Skip to content

Commit 4b867d6

Browse files
committed
lib/runners/openvmm: init
1 parent 63b914d commit 4b867d6

File tree

3 files changed

+77
-1
lines changed

3 files changed

+77
-1
lines changed

flake.nix

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,8 @@
9999
crosvm-example
100100
kvmtool-example
101101
stratovirt-example
102-
# alioth-example
102+
alioth-example
103+
openvmm-example
103104
virtiofsd
104105
];
105106
pathsToLink = [ "/" ];
@@ -159,6 +160,8 @@
159160
"qemu"
160161
# currently broken:
161162
# "crosvm"
163+
# not implemented:
164+
# "openvmm"
162165
];
163166
hypervisorsWithUserNet = [ "qemu" "kvmtool" ];
164167
makeExample = { system, hypervisor, config ? {} }:

lib/default.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ rec {
88
"kvmtool"
99
"stratovirt"
1010
"alioth"
11+
"openvmm"
1112
];
1213

1314
hypervisorsWithNetwork = hypervisors;

lib/runners/openvmm.nix

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
{ pkgs
2+
, microvmConfig
3+
, macvtapFds
4+
}:
5+
6+
let
7+
inherit (pkgs) lib;
8+
inherit (microvmConfig)
9+
user
10+
vcpu mem interfaces volumes shares devices vsock
11+
kernel initrdPath
12+
storeDisk storeOnDisk;
13+
in {
14+
command =
15+
if user != null
16+
then throw "openvmm will not change user"
17+
else builtins.concatStringsSep " " (
18+
[
19+
"${pkgs.openvmm}/bin/openvmm"
20+
"-m" "${toString mem}M"
21+
"-p" (toString vcpu)
22+
"-k" (lib.escapeShellArg "${kernel.dev}/vmlinux")
23+
"-r" initrdPath
24+
"-c" (lib.escapeShellArg "console=ttyS0 reboot=k panic=1 verbose ${toString microvmConfig.kernelParams}")
25+
# "--vmbus-redirect"
26+
"--hv"
27+
# "--virtio-console"
28+
"--virtio-serial" "stderr"
29+
"--guest-watchdog"
30+
]
31+
++
32+
lib.optionals storeOnDisk [
33+
"--disk" (lib.escapeShellArg "file:${storeDisk},ro")
34+
]
35+
++
36+
builtins.concatMap ({ image, ... }:
37+
[ "--disk" (lib.escapeShellArg "file:${image},uh") ]
38+
) volumes
39+
++
40+
builtins.concatMap ({ proto, source, tag, ... }:
41+
{
42+
virtiofs = [
43+
"--virtio-fs" (lib.escapeShellArg "${tag}:${source}")
44+
];
45+
"9p" = [
46+
"--virtio-9p" (lib.escapeShellArg "${tag}:${source}")
47+
];
48+
}.${proto}
49+
) shares
50+
++
51+
builtins.concatMap ({ type, id, mac, ... }:
52+
if type == "tap"
53+
then [
54+
"--virtio-net" "tap"
55+
]
56+
# TODO: --nic
57+
else throw "interface type ${type} is not supported by openvmm"
58+
) interfaces
59+
++
60+
map ({ ... }:
61+
throw "PCI/USB passthrough is not supported on openvmm"
62+
) devices
63+
++ (
64+
if vsock.cid != null
65+
then throw "Host-native AF_VSOCK is not supported by openvmm"
66+
else []
67+
)
68+
);
69+
70+
# TODO:
71+
canShutdown = false;
72+
}

0 commit comments

Comments
 (0)