MirageOS - Unable to build unikernel for XEN

I wrote a simple MirageOS-based Unikernel to make a basic HTTP GET call. Although it works without problems when I run it as Unix binary, the moment I mirage configure --xen it for XEN ( mirage configure --xen ) and run the make , I get the following error:

 ocamlbuild -use-ocamlfind -pkgs lwt.syntax,cohttp.lwt,cohttp.lwt-core,mirage-console.xen,mirage-http,mirage-types.lwt -tags "syntax(camlp4o),annot,bin_annot,strict_sequence,principal" -tag-line "<static*.*>: -syntax(camlp4o)" -cflag -g -lflags -g,-linkpkg,-dontlink,unix main.native.o + ocamlfind ocamlopt -g -linkpkg -dontlink unix -output-obj -package mirage-types.lwt -package mirage-http -package mirage-console.xen -package cohttp.lwt-core -package cohttp.lwt -package lwt.syntax -syntax camlp4o unikernel.cmx main.cmx -o main.native.o File "_none_", line 1: Error: No implementations provided for the following modules: Unix referenced from /home/mirage/.opam/system/lib/lwt/lwt-unix.cmxa(Lwt_engine), /home/mirage/.opam/system/lib/lwt/lwt-unix.cmxa(Lwt_unix), /home/mirage/.opam/system/lib/lwt/lwt-unix.cmxa(Lwt_io), /home/mirage/.opam/system/lib/lwt/lwt-unix.cmxa(Lwt_log), /home/mirage/.opam/system/lib/ipaddr/ipaddr_unix.cmxa(Ipaddr_unix), /home/mirage/.opam/system/lib/xenstore_transport/xenstore_transport_lwt_unix.cmxa(Xs_transport_lwt_unix_client), /home/mirage/.opam/system/lib/conduit/conduit-lwt-unix.cmxa(Conduit_lwt_unix), /home/mirage/.opam/system/lib/cohttp/cohttp_lwt_unix.cmxa(Cohttp_lwt_unix_debug), /home/mirage/.opam/system/lib/cohttp/cohttp_lwt_unix.cmxa(Cohttp_lwt_unix) Command exited with code 2. Compilation unsuccessful after building 7 targets (0 cached) in 00:00:03. make: *** [main.native.o] Error 10 

I just started working with MirageOS and OCaml, so that might be a dumb question, but right now I really don't know what to do.

+5
source share
2 answers

You cannot use Cohttp_lwt_unix . As the name suggests, it runs on unix, not xen. If you want an example web server, which is xen-proof, you can look at this skeleton or code used by mirage compression .

+5
source

As @Drup says, you need to avoid any "unix" packages if you want to be portable. Use the Mirage adapter for cohttp instead. This should work:

https://github.com/mirage/mirage-http

+3
source

Source: https://habr.com/ru/post/1242706/


All Articles