Skip to content

Commit e4a33cf

Browse files
committed
openvmm: rewrite
1 parent 4b867d6 commit e4a33cf

File tree

1 file changed

+57
-32
lines changed

1 file changed

+57
-32
lines changed

lib/runners/openvmm.nix

Lines changed: 57 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,95 @@
11
{ pkgs
22
, microvmConfig
3-
, macvtapFds
3+
, ...
44
}:
55

66
let
77
inherit (pkgs) lib;
88
inherit (microvmConfig)
9-
user
10-
vcpu mem interfaces volumes shares devices vsock
11-
kernel initrdPath
9+
hostName preStart user
10+
vcpu mem balloon initialBalloonMem hotplugMem hotpluggedMem interfaces volumes shares devices vsock
11+
kernel initrdPath credentialFiles
1212
storeDisk storeOnDisk;
13+
14+
muMsvm = pkgs.stdenv.mkDerivation {
15+
pname = "mu-msvm";
16+
version = "25.1.4";
17+
src = pkgs.fetchurl {
18+
url = "https://github.com/microsoft/mu_msvm/releases/download/v25.1.4/RELEASE-X64-artifacts.zip";
19+
hash = "0dm6cv84lhwzxva7qsdphdi1fm853lb37b0x658bdrcy82xx2gik";
20+
};
21+
22+
};
23+
1324
in {
25+
preStart = ''
26+
${preStart}
27+
export HOME=$PWD
28+
'';
29+
1430
command =
1531
if user != null
1632
then throw "openvmm will not change user"
33+
else if initialBalloonMem != 0
34+
then throw "openvmm does not support initialBalloonMem"
35+
else if hotplugMem != 0
36+
then throw "openvmm does not support hotplugMem"
37+
else if hotpluggedMem != 0
38+
then throw "openvmm does not support hotpluggedMem"
39+
else if credentialFiles != {}
40+
then throw "openvmm does not support credentialFiles"
1741
else builtins.concatStringsSep " " (
1842
[
1943
"${pkgs.openvmm}/bin/openvmm"
20-
"-m" "${toString mem}M"
44+
"--hv"
45+
"-m" "${toString mem}MB"
2146
"-p" (toString vcpu)
47+
"--virtio-console"
2248
"-k" (lib.escapeShellArg "${kernel.dev}/vmlinux")
2349
"-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"
50+
"-c" (lib.escapeShellArg "console=hvc0 verbose reboot=k panic=1 ${toString microvmConfig.kernelParams}")
3051
]
3152
++
3253
lib.optionals storeOnDisk [
3354
"--disk" (lib.escapeShellArg "file:${storeDisk},ro")
3455
]
3556
++
36-
builtins.concatMap ({ image, ... }:
37-
[ "--disk" (lib.escapeShellArg "file:${image},uh") ]
57+
builtins.concatMap ({ serial, image, readOnly, ... }:
58+
lib.warnIf (serial != null) ''
59+
Volume serial is not supported for openvmm
60+
''
61+
[ "--disk"
62+
(lib.escapeShellArg "${image}${
63+
lib.optionalString readOnly ",ro"
64+
}")
65+
]
3866
) volumes
3967
++
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}
68+
builtins.concatMap ({ proto, source, tag, readOnly, ... }:
69+
if proto == "9p"
70+
then if readOnly then
71+
throw "openvmm does not support readonly 9p share"
72+
else [
73+
"--virtio-9p" (lib.escapeShellArg "${source},${tag}")
74+
] else throw "virtiofs shares not implemented for openvmm"
4975
) shares
5076
++
5177
builtins.concatMap ({ type, id, mac, ... }:
5278
if type == "tap"
5379
then [
5480
"--virtio-net" "tap"
5581
]
56-
# TODO: --nic
5782
else throw "interface type ${type} is not supported by openvmm"
5883
) 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-
)
84+
# ++
85+
# map ({ bus, path }: {
86+
# pci = lib.escapeShellArg "--vfio-pci=${path}";
87+
# usb = throw "USB passthrough is not supported on openvmm";
88+
# }.${bus}) devices
89+
# ++
90+
# lib.optionals (vsock.cid != null) [
91+
# "--vsock" (toString vsock.cid)
92+
# ]
6893
);
6994

7095
# TODO:

0 commit comments

Comments
 (0)