|
1 | 1 | { pkgs |
2 | 2 | , microvmConfig |
3 | | -, macvtapFds |
| 3 | +, ... |
4 | 4 | }: |
5 | 5 |
|
6 | 6 | let |
7 | 7 | inherit (pkgs) lib; |
8 | 8 | 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 |
12 | 12 | 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 | + |
13 | 24 | in { |
| 25 | + preStart = '' |
| 26 | + ${preStart} |
| 27 | + export HOME=$PWD |
| 28 | + ''; |
| 29 | + |
14 | 30 | command = |
15 | 31 | if user != null |
16 | 32 | 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" |
17 | 41 | else builtins.concatStringsSep " " ( |
18 | 42 | [ |
19 | 43 | "${pkgs.openvmm}/bin/openvmm" |
20 | | - "-m" "${toString mem}M" |
| 44 | + "--hv" |
| 45 | + "-m" "${toString mem}MB" |
21 | 46 | "-p" (toString vcpu) |
| 47 | + "--virtio-console" |
22 | 48 | "-k" (lib.escapeShellArg "${kernel.dev}/vmlinux") |
23 | 49 | "-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}") |
30 | 51 | ] |
31 | 52 | ++ |
32 | 53 | lib.optionals storeOnDisk [ |
33 | 54 | "--disk" (lib.escapeShellArg "file:${storeDisk},ro") |
34 | 55 | ] |
35 | 56 | ++ |
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 | + ] |
38 | 66 | ) volumes |
39 | 67 | ++ |
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" |
49 | 75 | ) shares |
50 | 76 | ++ |
51 | 77 | builtins.concatMap ({ type, id, mac, ... }: |
52 | 78 | if type == "tap" |
53 | 79 | then [ |
54 | 80 | "--virtio-net" "tap" |
55 | 81 | ] |
56 | | - # TODO: --nic |
57 | 82 | else throw "interface type ${type} is not supported by openvmm" |
58 | 83 | ) 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 | + # ] |
68 | 93 | ); |
69 | 94 |
|
70 | 95 | # TODO: |
|
0 commit comments