How to deploy MirageOS example to AWS

796 Views Asked by At

Note: I looks like this is an outstanding issue: http://lists.xenproject.org/archives/html/mirageos-devel/2016-02/msg00076.html and https://github.com/mirage/mirage-bootvar-xen/issues/17

I'm trying to get the "hello" example from mirage-skeleton running in AWS. I'm using the "ec2.sh" script from the mirage repository, and I'm getting an error when it runs.

I configure, build, then deploy and run, the example like this:

> cd ../mirage-skeleton/hello/
> mirage configure --xen
> gmake
> ec2.sh -k mir-console.xen
> ec2-run-instances --region us-west-1 ami-dc96e5bc

In the system log in the EC2 console, after the boot messages, I get this error:

Xen Minimal OS!
Initialising timer interface
Initialising console ... done.
getenv(OCAMLRUNPARAM) -> null
getenv(CAMLRUNPARAM) -> null
getenv(PATH) -> null
Unsupported function lseek called in Mini-OS kernel
Unsupported function lseek called in Mini-OS kernel
Unsupported function lseek called in Mini-OS kernel
getenv(OCAMLRUNPARAM) -> null
getenv(CAMLRUNPARAM) -> null
getenv(TMPDIR) -> null
getenv(TEMP) -> null
Fatal error: exception Failure("Malformed boot parameter \"ro\"")
Raised at file "src/core/lwt.ml", line 789, characters 22-23
Called from file "lib/main.ml", line 58, characters 10-20
Called from file "main.ml", line 52, characters 5-10
Mirage exiting with status 2
Do_exit called!

These are the versions of the mirage libraries I have installed:

mirage                         2.7.0  The MirageOS library operating system
mirage-bootvar-xen             0.3.1  Library for reading MirageOS unikernel boo
mirage-clock-xen                 1.1  A Mirage-compatible Clock library for Xen
mirage-conduit                 2.2.0  Virtual package for the MirageOS Conduit t
mirage-console                 2.1.3  A Mirage-compatible Console library for Xe
mirage-dns                     2.5.0  Virtual package for the MirageOS DNS trans
mirage-entropy-xen             0.3.0  MirageOS entropy device
mirage-http                    2.5.1  MirageOS HTTP client and server driver
mirage-net-xen                 1.5.0  Ethernet network device driver for MirageO
mirage-profile                 0.6.1  Collect profiling information
mirage-types                   2.6.0  Module type definitions for Mirage-compati
mirage-types-lwt               2.6.0  Lwt module type definitions for Mirage-com
mirage-vnetif                  0.1.0  Virtual network interface and software swi
mirage-xen                     2.3.3  MirageOS library for Xen
mirage-xen-minios              0.8.0  Xen MiniOS guest operating system library
mirage-xen-ocaml               2.3.4  MirageOS headers for the OCaml runtime
mirage-xen-posix               2.3.4  MirageOS library for posix headers

For reference, for the "hello" example, the config.ml file is:

open Mirage

let key =
let doc = Key.Arg.info ~doc:"How to say hello." ["hello"] in
Key.(create "hello" Arg.(opt string "Hello World!" doc))

let main =
foreign
    ~keys:[Key.abstract key]
    "Unikernel.Main" (console @-> job)

let () =
register "console" [main $ default_console]

and unikernel.ml is

open Lwt

module Main (C: V1_LWT.CONSOLE) = struct

let start c =
    for_lwt i = 0 to 4 do
    C.log c (Key_gen.hello ()) ;
    lwt () = OS.Time.sleep 1.0 in
    return ()
    done

end

I read something about boot/kernel parameters being a new feature in the most recent version of MirageOS. Is there something I need to change in the config.ml to account for this?

I should add, this example does work locally in Xen:

> sudo xl create -c console.xl
Xen Minimal OS!
Initialising timer interface
Initialising console ... done.
getenv(OCAMLRUNPARAM) -> null
getenv(CAMLRUNPARAM) -> null
getenv(PATH) -> null
Unsupported function lseek called in Mini-OS kernel
Unsupported function lseek called in Mini-OS kernel
Unsupported function lseek called in Mini-OS kernel
getenv(OCAMLRUNPARAM) -> null
getenv(CAMLRUNPARAM) -> null
getenv(TMPDIR) -> null
getenv(TEMP) -> null
Hello World!
Hello World!
Hello World!
Hello World!
Hello World!
Parsing config from console.xl
1

There are 1 best solutions below

0
On

As I mentioned, this seems to be an open issue. What worked for me was following the advice at the bottom of the page here https://github.com/mirage/mirage/issues/493 which is to pin opam to the branch of mirage-bootvar-xen here https://github.com/talex5/mirage-bootvar-xen/tree/qubes.

I had some issues just trying to clone and checkout the qubes branch, so I ended up downloading the zip and using that.

> opam pin add mirage-bootvar-xen <location of unzipped repository>