Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: mirage/mirage
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: ee6b6d96ad43
Choose a base ref
...
head repository: mirage/mirage
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 0332db0a2c67
Choose a head ref
  • 2 commits
  • 11 files changed
  • 2 contributors

Commits on Nov 8, 2018

  1. Native Genode target

    Support for a "genode" target that uses Solo5 to run as a native Genode
    component.
    ehmry committed Nov 8, 2018
    Copy the full SHA
    0e8b07e View commit details
  2. Merge pull request #942 from ehmry/genode

    Native Genode target
    hannesm authored Nov 8, 2018
    Copy the full SHA
    0332db0 View commit details
21 changes: 13 additions & 8 deletions lib/mirage.ml
Original file line number Diff line number Diff line change
@@ -32,9 +32,9 @@ include Functoria

(* Mirage implementation backing the target. *)
let backend_predicate = function
| `Xen | `Qubes -> "mirage_xen"
| `Virtio | `Hvt | `Muen -> "mirage_solo5"
| `Unix | `MacOSX -> "mirage_unix"
| `Xen | `Qubes -> "mirage_xen"
| `Virtio | `Hvt | `Muen | `Genode -> "mirage_solo5"
| `Unix | `MacOSX -> "mirage_unix"

(** {2 Devices} *)

@@ -606,12 +606,13 @@ let compile ignore_dirs libs warn_error target =
(if terminal () then ["color(always)"] else [])
and result = match target with
| `Unix | `MacOSX -> "main.native"
| `Xen | `Qubes | `Virtio | `Hvt | `Muen -> "main.native.o"
| `Xen | `Qubes | `Virtio | `Hvt | `Muen | `Genode -> "main.native.o"
and cflags = [ "-g" ]
and lflags =
let dontlink =
match target with
| `Xen | `Qubes | `Virtio | `Hvt | `Muen -> ["unix"; "str"; "num"; "threads"]
| `Xen | `Qubes | `Virtio | `Hvt | `Muen | `Genode ->
["unix"; "str"; "num"; "threads"]
| `Unix | `MacOSX -> []
in
let dont = List.map (fun k -> [ "-dontlink" ; k ]) dontlink in
@@ -688,7 +689,8 @@ let extra_c_artifacts target pkgs =
in
R.ok r

let static_libs pkg_config_deps = pkg_config pkg_config_deps [ "--static" ; "--libs" ]
let static_libs pkg_config_deps =
pkg_config pkg_config_deps [ "--static" ; "--libs" ]

let ldflags pkg = pkg_config pkg ["--variable=ldflags"]

@@ -711,6 +713,7 @@ let solo5_pkg = function
| `Virtio -> "solo5-bindings-virtio", ".virtio"
| `Muen -> "solo5-bindings-muen", ".muen"
| `Hvt -> "solo5-bindings-hvt", ".hvt"
| `Genode -> "solo5-bindings-genode", ".genode"
| `Unix | `MacOSX | `Xen | `Qubes ->
invalid_arg "solo5_kernel only defined for solo5 targets"

@@ -748,7 +751,7 @@ let link info name target target_debug =
Bos.OS.Cmd.run link >>= fun () ->
Ok out
end
| `Virtio | `Muen | `Hvt ->
| `Virtio | `Muen | `Hvt | `Genode ->
let pkg, post = solo5_pkg target in
extra_c_artifacts "freestanding" libs >>= fun c_artifacts ->
static_libs "mirage-solo5" >>= fun static_libs ->
@@ -819,6 +822,7 @@ let clean i =
Bos.OS.File.delete (opam_file (unikernel_opam_name name `Qubes)) >>= fun () ->
Bos.OS.File.delete (opam_file (unikernel_opam_name name `Muen)) >>= fun () ->
Bos.OS.File.delete (opam_file (unikernel_opam_name name `MacOSX)) >>= fun () ->
Bos.OS.File.delete (opam_file (unikernel_opam_name name `Genode)) >>= fun () ->
Bos.OS.File.delete Fpath.(v "main.native.o") >>= fun () ->
Bos.OS.File.delete Fpath.(v "main.native") >>= fun () ->
Bos.OS.File.delete Fpath.(v name) >>= fun () ->
@@ -827,6 +831,7 @@ let clean i =
Bos.OS.File.delete Fpath.(v name + "virtio") >>= fun () ->
Bos.OS.File.delete Fpath.(v name + "muen") >>= fun () ->
Bos.OS.File.delete Fpath.(v name + "hvt") >>= fun () ->
Bos.OS.File.delete Fpath.(v name + "genode") >>= fun () ->
Bos.OS.File.delete Fpath.(v "Makefile.solo5-hvt") >>= fun () ->
Bos.OS.Dir.delete ~recurse:true Fpath.(v "_build-solo5-hvt") >>= fun () ->
Bos.OS.File.delete Fpath.(v "solo5-hvt") >>= fun () ->
@@ -876,7 +881,7 @@ module Project = struct
Key.match_ Key.(value target) @@ function
| `Unix | `MacOSX -> [ package ~min:"3.0.0" "mirage-unix" ] @ common
| `Xen | `Qubes -> [ package ~min:"3.0.4" "mirage-xen" ] @ common
| `Virtio | `Hvt | `Muen as tgt ->
| `Virtio | `Hvt | `Muen | `Genode as tgt ->
let pkg, _ = solo5_pkg tgt in
[ package ~min:"0.4.0" ~ocamlfind:[] pkg ;
package ~min:"0.4.0" "mirage-solo5" ] @ common
3 changes: 2 additions & 1 deletion lib/mirage_impl_argv.ml
Original file line number Diff line number Diff line change
@@ -47,5 +47,6 @@ let default_argv =
`Qubes, argv_xen;
`Virtio, argv_solo5;
`Hvt, argv_solo5;
`Muen, argv_solo5
`Muen, argv_solo5;
`Genode, argv_solo5
] ~default:argv_unix
7 changes: 4 additions & 3 deletions lib/mirage_impl_block.ml
Original file line number Diff line number Diff line change
@@ -68,7 +68,8 @@ class block_conf file =
method! packages =
Key.match_ Key.(value target) @@ function
| `Xen | `Qubes -> xen_block_packages
| `Virtio | `Hvt | `Muen -> [ package ~min:"0.3.0" "mirage-block-solo5" ]
| `Virtio | `Hvt | `Muen | `Genode ->
[ package ~min:"0.3.0" "mirage-block-solo5" ]
| `Unix | `MacOSX -> [ package ~min:"2.5.0" "mirage-block-unix" ]

method! configure _ =
@@ -77,7 +78,7 @@ class block_conf file =

method private connect_name target root =
match target with
| `Unix | `MacOSX | `Virtio | `Hvt | `Muen ->
| `Unix | `MacOSX | `Virtio | `Hvt | `Muen | `Genode ->
Fpath.(to_string (root / file)) (* open the file directly *)
| `Xen | `Qubes ->
let b = make_block_t file in
@@ -86,7 +87,7 @@ class block_conf file =
method! connect i s _ =
match get_target i with
| `Muen -> failwith "Block devices not supported on Muen target."
| `Unix | `MacOSX | `Virtio | `Hvt | `Xen | `Qubes ->
| `Unix | `MacOSX | `Virtio | `Hvt | `Xen | `Qubes | `Genode ->
Fmt.strf "%s.connect %S" s
(self#connect_name (get_target i) @@ Info.build_dir i)
end
3 changes: 2 additions & 1 deletion lib/mirage_impl_console.ml
Original file line number Diff line number Diff line change
@@ -41,7 +41,8 @@ let custom_console str =
`Qubes, console_xen str;
`Virtio, console_solo5 str;
`Hvt, console_solo5 str;
`Muen, console_solo5 str
`Muen, console_solo5 str;
`Genode, console_solo5 str
] ~default:(console_unix str)

let default_console = custom_console "0"
6 changes: 3 additions & 3 deletions lib/mirage_impl_ip.ml
Original file line number Diff line number Diff line change
@@ -34,9 +34,9 @@ let (@??) x y = opt_map Key.abstract x @? y
(* convenience function for linking tcpip.unix or .xen for checksums *)
let right_tcpip_library ?min ?max ?ocamlfind ~sublibs pkg =
Key.match_ Key.(value target) @@ function
|`MacOSX | `Unix -> [ package ?min ?max ?ocamlfind ~sublibs:("unix"::sublibs) pkg ]
|`Qubes | `Xen -> [ package ?min ?max ?ocamlfind ~sublibs:("xen"::sublibs) pkg ]
|`Virtio | `Hvt | `Muen -> [ package ?min ?max ?ocamlfind ~sublibs pkg ]
|`MacOSX | `Unix -> [ package ?min ?max ?ocamlfind ~sublibs:("unix"::sublibs) pkg ]
|`Qubes | `Xen -> [ package ?min ?max ?ocamlfind ~sublibs:("xen"::sublibs) pkg ]
|`Virtio | `Hvt | `Muen | `Genode -> [ package ?min ?max ?ocamlfind ~sublibs pkg ]

let ipv4_keyed_conf ?network ?gateway () = impl @@ object
inherit base_configurable
3 changes: 2 additions & 1 deletion lib/mirage_impl_kv_ro.ml
Original file line number Diff line number Diff line change
@@ -49,5 +49,6 @@ let direct_kv_ro dirname =
`Qubes, crunch dirname;
`Virtio, crunch dirname;
`Hvt, crunch dirname;
`Muen, crunch dirname
`Muen, crunch dirname;
`Genode, crunch dirname
] ~default:(direct_kv_ro_conf dirname)
2 changes: 1 addition & 1 deletion lib/mirage_impl_network.ml
Original file line number Diff line number Diff line change
@@ -21,7 +21,7 @@ let network_conf (intf : string Key.key) =
| `MacOSX -> [ package ~min:"1.3.0" "mirage-net-macosx" ]
| `Xen -> [ package ~min:"1.7.0" "mirage-net-xen"]
| `Qubes -> [ package ~min:"1.7.0" "mirage-net-xen" ; package ~min:"0.4" "mirage-qubes" ]
| `Virtio | `Hvt | `Muen -> [ package ~min:"0.3.0" "mirage-net-solo5" ]
| `Virtio | `Hvt | `Muen | `Genode -> [ package ~min:"0.3.0" "mirage-net-solo5" ]
method! connect _ modname _ =
Fmt.strf "%s.connect %a" modname Key.serialize_call key
method! configure i =
4 changes: 2 additions & 2 deletions lib/mirage_impl_random.ml
Original file line number Diff line number Diff line change
@@ -32,7 +32,7 @@ let nocrypto = impl @@ object
| `Xen | `Qubes ->
[ package ~min:"0.5.4" ~sublibs:["mirage"] "nocrypto";
package ~ocamlfind:[] "zarith-xen" ]
| `Virtio | `Hvt | `Muen ->
| `Virtio | `Hvt | `Muen | `Genode ->
[ package ~min:"0.5.4" ~sublibs:["mirage"] "nocrypto";
package ~ocamlfind:[] "zarith-freestanding" ]
| `Unix | `MacOSX ->
@@ -41,7 +41,7 @@ let nocrypto = impl @@ object
method! build _ = Rresult.R.ok (enable_entropy ())
method! connect i _ _ =
match Mirage_impl_misc.get_target i with
| `Xen | `Qubes | `Virtio | `Hvt | `Muen -> "Nocrypto_entropy_mirage.initialize ()"
| `Xen | `Qubes | `Virtio | `Hvt | `Muen | `Genode -> "Nocrypto_entropy_mirage.initialize ()"
| `Unix | `MacOSX -> "Nocrypto_entropy_lwt.initialize ()"
end

4 changes: 2 additions & 2 deletions lib/mirage_impl_tracing.ml
Original file line number Diff line number Diff line change
@@ -18,7 +18,7 @@ let mprof_trace ~size () =
method! packages =
Key.match_ Key.(value target) @@ function
| `Xen | `Qubes -> [ package "mirage-profile"; package "mirage-profile-xen" ]
| `Virtio | `Hvt | `Muen -> []
| `Virtio | `Hvt | `Muen | `Genode -> []
| `Unix | `MacOSX -> [ package "mirage-profile"; package "mirage-profile-unix" ]
method! build _ =
match query_ocamlfind ["lwt.tracing"] with
@@ -27,7 +27,7 @@ let mprof_trace ~size () =
opam pin add lwt https://github.com/mirage/lwt.git#tracing"
| Ok _ -> Ok ()
method! connect i _ _ = match get_target i with
| `Virtio | `Hvt | `Muen -> failwith "tracing is not currently implemented for solo5 targets"
| `Virtio | `Hvt | `Muen | `Genode -> failwith "tracing is not currently implemented for solo5 targets"
| `Unix | `MacOSX ->
Fmt.strf
"Lwt.return ())@.\
7 changes: 5 additions & 2 deletions lib/mirage_key.ml
Original file line number Diff line number Diff line change
@@ -89,6 +89,7 @@ type mode = [
| `Muen
| `MacOSX
| `Qubes
| `Genode
]

let first_ukvm_mention = ref true
@@ -106,6 +107,7 @@ let target_conv: mode Cmdliner.Arg.converter =
"hvt" , `Hvt;
"muen" , `Muen;
"qubes" , `Qubes;
"genode" , `Genode;
]
in
let filter_ukvm s =
@@ -136,7 +138,7 @@ let default_unix = lazy (
let target =
let doc =
"Target platform to compile the unikernel for. Valid values are: \
$(i,xen), $(i,qubes), $(i,unix), $(i,macosx), $(i,virtio), $(i,hvt), $(i,muen)."
$(i,xen), $(i,qubes), $(i,unix), $(i,macosx), $(i,virtio), $(i,hvt), $(i,muen), $(i,genode)."
in
let serialize ppf = function
| `Unix -> Fmt.pf ppf "`Unix"
@@ -146,6 +148,7 @@ let target =
| `Muen -> Fmt.pf ppf "`Muen"
| `MacOSX -> Fmt.pf ppf "`MacOSX"
| `Qubes -> Fmt.pf ppf "`Qubes"
| `Genode -> Fmt.pf ppf "`Genode"
in
let conv = Arg.conv ~conv:target_conv ~runtime_conv:"target" ~serialize in
let doc =
@@ -158,7 +161,7 @@ let target =
let is_unix =
Key.match_ Key.(value target) @@ function
| `Unix | `MacOSX -> true
| `Qubes | `Xen | `Virtio | `Hvt | `Muen -> false
| `Qubes | `Xen | `Virtio | `Hvt | `Muen | `Genode -> false

let warn_error =
let doc = "Enable -warn-error when compiling OCaml sources." in
6 changes: 3 additions & 3 deletions lib/mirage_key.mli
Original file line number Diff line number Diff line change
@@ -30,14 +30,14 @@ end

include Functoria.KEY with module Arg := Arg

type mode = [ `Unix | `Xen | `Qubes | `MacOSX | `Virtio | `Hvt | `Muen ]
type mode = [ `Unix | `Xen | `Qubes | `MacOSX | `Virtio | `Hvt | `Muen | `Genode ]

(** {2 Mirage keys} *)

val target: mode key
(** [-t TARGET]: Key setting the configuration mode for the current project.
Is one of ["unix"], ["macosx"], ["xen"], ["qubes"], ["virtio"], ["hvt"]
or ["muen"].
Is one of ["unix"], ["macosx"], ["xen"], ["qubes"], ["virtio"], ["hvt"], ["muen"]
or ["genode"].
*)

val pp_target: mode Fmt.t