@@ -43,9 +43,9 @@ let connect_err name number =
43
43
44
44
(* Mirage implementation backing the target. *)
45
45
let backend_predicate = function
46
- | `Xen | `Qubes -> " mirage_xen"
47
- | `Virtio | `Ukvm -> " mirage_solo5"
48
- | `Unix | `MacOSX -> " mirage_unix"
46
+ | `Xen | `Qubes -> " mirage_xen"
47
+ | `Virtio | `Ukvm | `Muen -> " mirage_solo5"
48
+ | `Unix | `MacOSX -> " mirage_unix"
49
49
50
50
(* * {2 Devices} *)
51
51
let qrexec = job
@@ -232,7 +232,7 @@ let nocrypto = impl @@ object
232
232
| `Xen | `Qubes ->
233
233
[ package ~min:" 0.5 .4 " ~sublibs:[" mirage" ] " nocrypto" ;
234
234
package ~ocamlfind:[] " zarith- xen" ]
235
- | `Virtio | `Ukvm ->
235
+ | `Virtio | `Ukvm | `Muen ->
236
236
[ package ~min:" 0.5 .4 " ~sublibs:[" mirage" ] " nocrypto" ;
237
237
package ~ocamlfind:[] " zarith- freestanding" ]
238
238
| `Unix | `MacOSX ->
@@ -241,7 +241,7 @@ let nocrypto = impl @@ object
241
241
method! build _ = R.ok (enable_entropy ())
242
242
method! connect i _ _ =
243
243
match get_target i with
244
- | `Xen | `Qubes | `Virtio | `Ukvm -> " Nocrypto_entropy_mirage. initialize () "
244
+ | `Xen | `Qubes | `Virtio | `Ukvm | `Muen -> " Nocrypto_entropy_mirage. initialize () "
245
245
| `Unix | `MacOSX -> " Nocrypto_entropy_lwt. initialize () "
246
246
end
247
247
@@ -300,7 +300,8 @@ let custom_console str =
300
300
`Xen, console_xen str;
301
301
`Qubes, console_xen str;
302
302
`Virtio, console_solo5 str;
303
- `Ukvm, console_solo5 str
303
+ `Ukvm, console_solo5 str;
304
+ `Muen, console_solo5 str
304
305
] ~default:(console_unix str)
305
306
306
307
let default_console = custom_console " 0 "
@@ -349,7 +350,8 @@ let direct_kv_ro dirname =
349
350
`Xen , crunch dirname;
350
351
`Qubes , crunch dirname;
351
352
`Virtio , crunch dirname;
352
- `Ukvm , crunch dirname
353
+ `Ukvm , crunch dirname;
354
+ `Muen , crunch dirname
353
355
] ~default: (direct_kv_ro_conf dirname)
354
356
355
357
type block = BLOCK
@@ -415,7 +417,7 @@ class block_conf file =
415
417
method! packages =
416
418
Key. match_ Key. (value target) @@ function
417
419
| `Xen | `Qubes -> xen_block_packages
418
- | `Virtio | `Ukvm -> [ package ~min: " 0.2.1" " mirage-block-solo5" ]
420
+ | `Virtio | `Ukvm | `Muen -> [ package ~min: " 0.2.1" " mirage-block-solo5" ]
419
421
| `Unix | `MacOSX -> [ package ~min: " 2.5.0" " mirage-block-unix" ]
420
422
421
423
method! configure _ =
@@ -424,15 +426,18 @@ class block_conf file =
424
426
425
427
method private connect_name target root =
426
428
match target with
427
- | `Unix | `MacOSX | `Virtio | `Ukvm ->
429
+ | `Unix | `MacOSX | `Virtio | `Ukvm | `Muen ->
428
430
Fpath. (to_string (root / file)) (* open the file directly *)
429
431
| `Xen | `Qubes ->
430
432
let b = make_block_t file in
431
433
xenstore_id_of_index b.number |> string_of_int
432
434
433
435
method! connect i s _ =
434
- Fmt. strf " %s.connect %S" s
435
- (self#connect_name (get_target i) @@ Info. build_dir i)
436
+ match get_target i with
437
+ | `Muen -> failwith " Block devices not supported on Muen target."
438
+ | `Unix | `MacOSX | `Virtio | `Ukvm | `Xen | `Qubes ->
439
+ Fmt. strf " %s.connect %S" s
440
+ (self#connect_name (get_target i) @@ Info. build_dir i)
436
441
end
437
442
438
443
let block_of_file file = impl (new block_conf file)
@@ -600,7 +605,7 @@ let network_conf (intf : string Key.key) =
600
605
| `MacOSX -> [ package ~min: " 1.3.0" " mirage-net-macosx" ]
601
606
| `Xen -> [ package ~min: " 1.7.0" " mirage-net-xen" ]
602
607
| `Qubes -> [ package ~min: " 1.7.0" " mirage-net-xen" ; package ~min: " 0.4" " mirage-qubes" ]
603
- | `Virtio | `Ukvm -> [ package ~min: " 0.2.0" " mirage-net-solo5" ]
608
+ | `Virtio | `Ukvm | `Muen -> [ package ~min: " 0.2.0" " mirage-net-solo5" ]
604
609
method! connect _ modname _ =
605
610
Fmt. strf " %s.connect %a" modname Key. serialize_call key
606
611
method! configure i =
@@ -705,9 +710,9 @@ let (@??) x y = opt_map Key.abstract x @? y
705
710
(* convenience function for linking tcpip.unix or .xen for checksums *)
706
711
let right_tcpip_library ?min ?max ?ocamlfind ~sublibs pkg =
707
712
Key. match_ Key. (value target) @@ function
708
- | `MacOSX | `Unix -> [ package ?min ?max ?ocamlfind ~sublibs: (" unix" ::sublibs) pkg ]
709
- | `Qubes | `Xen -> [ package ?min ?max ?ocamlfind ~sublibs: (" xen" ::sublibs) pkg ]
710
- | `Virtio | `Ukvm -> [ package ?min ?max ?ocamlfind ~sublibs pkg ]
713
+ | `MacOSX | `Unix -> [ package ?min ?max ?ocamlfind ~sublibs: (" unix" ::sublibs) pkg ]
714
+ | `Qubes | `Xen -> [ package ?min ?max ?ocamlfind ~sublibs: (" xen" ::sublibs) pkg ]
715
+ | `Virtio | `Ukvm | `Muen -> [ package ?min ?max ?ocamlfind ~sublibs pkg ]
711
716
712
717
let ipv4_keyed_conf ?network ?gateway () = impl @@ object
713
718
inherit base_configurable
@@ -1343,7 +1348,8 @@ let default_argv =
1343
1348
`Xen , argv_xen;
1344
1349
`Qubes , argv_xen;
1345
1350
`Virtio , argv_solo5;
1346
- `Ukvm , argv_solo5
1351
+ `Ukvm , argv_solo5;
1352
+ `Muen , argv_solo5
1347
1353
] ~default: argv_unix
1348
1354
1349
1355
(* * Log reporting *)
@@ -1413,7 +1419,7 @@ let mprof_trace ~size () =
1413
1419
method! packages =
1414
1420
Key. match_ Key. (value target) @@ function
1415
1421
| `Xen | `Qubes -> [ package " mirage-profile" ; package " mirage-profile-xen" ]
1416
- | `Virtio | `Ukvm -> []
1422
+ | `Virtio | `Ukvm | `Muen -> []
1417
1423
| `Unix | `MacOSX -> [ package " mirage-profile" ; package " mirage-profile-unix" ]
1418
1424
method! build _ =
1419
1425
match query_ocamlfind [" lwt.tracing" ] with
@@ -1422,7 +1428,7 @@ let mprof_trace ~size () =
1422
1428
opam pin add lwt https://github.com/mirage/lwt.git#tracing"
1423
1429
| Ok _ -> Ok ()
1424
1430
method! connect i _ _ = match get_target i with
1425
- | `Virtio | `Ukvm -> failwith " tracing is not currently implemented for solo5 targets"
1431
+ | `Virtio | `Ukvm | `Muen -> failwith " tracing is not currently implemented for solo5 targets"
1426
1432
| `Unix | `MacOSX ->
1427
1433
Fmt. strf
1428
1434
" Lwt.return ())@.\
@@ -1858,12 +1864,12 @@ let compile libs warn_error target =
1858
1864
(if terminal () then [" color(always)" ] else [] )
1859
1865
and result = match target with
1860
1866
| `Unix | `MacOSX -> " main.native"
1861
- | `Xen | `Qubes | `Virtio | `Ukvm -> " main.native.o"
1867
+ | `Xen | `Qubes | `Virtio | `Ukvm | `Muen -> " main.native.o"
1862
1868
and cflags = [ " -g" ]
1863
1869
and lflags =
1864
1870
let dontlink =
1865
1871
match target with
1866
- | `Xen | `Qubes | `Virtio | `Ukvm -> [" unix" ; " str" ; " num" ; " threads" ]
1872
+ | `Xen | `Qubes | `Virtio | `Ukvm | `Muen -> [" unix" ; " str" ; " num" ; " threads" ]
1867
1873
| `Unix | `MacOSX -> []
1868
1874
in
1869
1875
let dont = List. map (fun k -> [ " -dontlink" ; k ]) dontlink in
@@ -1942,6 +1948,26 @@ let ldflags pkg = pkg_config pkg ["--variable=ldflags"]
1942
1948
1943
1949
let ldpostflags pkg = pkg_config pkg [" --variable=ldpostflags" ]
1944
1950
1951
+ let find_ld pkg =
1952
+ match pkg_config pkg [" --variable=ld" ] with
1953
+ | Ok (ld ::_ ) ->
1954
+ Log. warn (fun m -> m " using %s as ld (pkg-config %s --variable=ld)" ld pkg) ;
1955
+ ld
1956
+ | Ok [] ->
1957
+ Log. warn (fun m -> m " pkg-config %s --variable=ld returned nothing, using ld" pkg) ;
1958
+ " ld"
1959
+ | Error msg ->
1960
+ Log. warn (fun m -> m " error %a while pkg-config %s --variable=ld, using ld"
1961
+ Rresult.R. pp_msg msg pkg) ;
1962
+ " ld"
1963
+
1964
+ let solo5_pkg = function
1965
+ | `Virtio -> " solo5-kernel-virtio" , " .virtio"
1966
+ | `Muen -> " solo5-kernel-muen" , " .muen"
1967
+ | `Ukvm -> " solo5-kernel-ukvm" , " .ukvm"
1968
+ | `Unix | `MacOSX | `Xen | `Qubes ->
1969
+ invalid_arg " solo5_kernel only defined for solo5 targets"
1970
+
1945
1971
let link info name target target_debug =
1946
1972
let libs = Info. libraries info in
1947
1973
match target with
@@ -1976,46 +2002,37 @@ let link info name target target_debug =
1976
2002
Bos.OS.Cmd. run link >> = fun () ->
1977
2003
Ok out
1978
2004
end
1979
- | `Virtio ->
2005
+ | `Virtio | `Muen | `Ukvm ->
2006
+ let pkg, post = solo5_pkg target in
1980
2007
extra_c_artifacts " freestanding" libs >> = fun c_artifacts ->
1981
2008
static_libs " mirage-solo5" >> = fun static_libs ->
1982
- ldflags " solo5-kernel-virtio" >> = fun ldflags ->
1983
- ldpostflags " solo5-kernel-virtio" >> = fun ldpostflags ->
1984
- let out = name ^ " .virtio" in
2009
+ ldflags pkg >> = fun ldflags ->
2010
+ ldpostflags pkg >> = fun ldpostflags ->
2011
+ let out = name ^ post in
2012
+ let ld = find_ld pkg in
1985
2013
let linker =
1986
- Bos.Cmd. (v " ld " %% of_list ldflags % " _build/main.native.o" %%
2014
+ Bos.Cmd. (v ld %% of_list ldflags % " _build/main.native.o" %%
1987
2015
of_list c_artifacts %% of_list static_libs % " -o" % out
1988
2016
%% of_list ldpostflags)
1989
2017
in
1990
2018
Log. info (fun m -> m " linking with %a" Bos.Cmd. pp linker);
1991
2019
Bos.OS.Cmd. run linker >> = fun () ->
1992
- Ok out
1993
- | `Ukvm ->
1994
- extra_c_artifacts " freestanding" libs >> = fun c_artifacts ->
1995
- static_libs " mirage-solo5" >> = fun static_libs ->
1996
- ldflags " solo5-kernel-ukvm" >> = fun ldflags ->
1997
- ldpostflags " solo5-kernel-ukvm" >> = fun ldpostflags ->
1998
- let out = name ^ " .ukvm" in
1999
- let linker =
2000
- Bos.Cmd. (v " ld" %% of_list ldflags % " _build/main.native.o" %%
2001
- of_list c_artifacts %% of_list static_libs % " -o" % out
2002
- %% of_list ldpostflags)
2003
- in
2004
- let ukvm_mods =
2005
- List. fold_left (fun acc -> function
2006
- | "mirage-net-solo5" -> " net" :: acc
2007
- | "mirage-block-solo5" -> " blk" :: acc
2008
- | _ -> acc)
2009
- [] libs @ (if target_debug then [" gdb" ] else [] )
2010
- in
2011
- pkg_config " solo5-kernel-ukvm" [" --variable=libdir" ] >> = function
2012
- | [ libdir ] ->
2013
- Bos.OS.Cmd. run Bos.Cmd. (v " ukvm-configure" % (libdir ^ " /src/ukvm" ) %% of_list ukvm_mods) >> = fun () ->
2014
- Bos.OS.Cmd. run Bos.Cmd. (v " make" % " -f" % " Makefile.ukvm" % " ukvm-bin" ) >> = fun () ->
2015
- Log. info (fun m -> m " linking with %a" Bos.Cmd. pp linker);
2016
- Bos.OS.Cmd. run linker >> = fun () ->
2020
+ if target = `Ukvm then
2021
+ let ukvm_mods =
2022
+ List. fold_left (fun acc -> function
2023
+ | "mirage-net-solo5" -> " net" :: acc
2024
+ | "mirage-block-solo5" -> " blk" :: acc
2025
+ | _ -> acc)
2026
+ [] libs @ (if target_debug then [" gdb" ] else [] )
2027
+ in
2028
+ pkg_config pkg [" --variable=libdir" ] >> = function
2029
+ | [ libdir ] ->
2030
+ Bos.OS.Cmd. run Bos.Cmd. (v " ukvm-configure" % (libdir ^ " /src/ukvm" ) %% of_list ukvm_mods) >> = fun () ->
2031
+ Bos.OS.Cmd. run Bos.Cmd. (v " make" % " -f" % " Makefile.ukvm" % " ukvm-bin" ) >> = fun () ->
2032
+ Ok out
2033
+ | _ -> R. error_msg (" pkg-config " ^ pkg ^ " --variable=libdir failed" )
2034
+ else
2017
2035
Ok out
2018
- | _ -> R. error_msg " pkg-config solo5-kernel-ukvm --variable=libdir failed"
2019
2036
2020
2037
let build i =
2021
2038
let name = Info. name i in
@@ -2046,6 +2063,7 @@ let clean i =
2046
2063
Bos.OS.File. delete Fpath. (v name + " xen" ) >> = fun () ->
2047
2064
Bos.OS.File. delete Fpath. (v name + " elf" ) >> = fun () ->
2048
2065
Bos.OS.File. delete Fpath. (v name + " virtio" ) >> = fun () ->
2066
+ Bos.OS.File. delete Fpath. (v name + " muen" ) >> = fun () ->
2049
2067
Bos.OS.File. delete Fpath. (v name + " ukvm" ) >> = fun () ->
2050
2068
Bos.OS.File. delete Fpath. (v " Makefile.ukvm" ) >> = fun () ->
2051
2069
Bos.OS.Dir. delete ~recurse: true Fpath. (v " _build-ukvm" ) >> = fun () ->
@@ -2086,12 +2104,12 @@ module Project = struct
2086
2104
package ~build: true " ocamlbuild" ;
2087
2105
] in
2088
2106
Key. match_ Key. (value target) @@ function
2089
- | `Xen | `Qubes -> [ package ~min: " 3.0.4" " mirage-xen" ] @ common
2090
- | `Virtio -> [ package ~min: " 0.2.1" ~ocamlfind: [] " solo5-kernel-virtio" ;
2091
- package ~min: " 0.2.0" " mirage-solo5" ] @ common
2092
- | `Ukvm -> [ package ~min: " 0.2.1" ~ocamlfind: [] " solo5-kernel-ukvm" ;
2093
- package ~min: " 0.2.0" " mirage-solo5" ] @ common
2094
2107
| `Unix | `MacOSX -> [ package ~min: " 3.0.0" " mirage-unix" ] @ common
2108
+ | `Xen | `Qubes -> [ package ~min: " 3.0.4" " mirage-xen" ] @ common
2109
+ | `Virtio | `Ukvm | `Muen as tgt ->
2110
+ let pkg, _ = solo5_pkg tgt in
2111
+ [ package ~min: " 0.2.1" ~ocamlfind: [] pkg ;
2112
+ package ~min: " 0.2.0" " mirage-solo5" ] @ common
2095
2113
2096
2114
method! build = build
2097
2115
method! configure = configure
0 commit comments