Skip to content

Commit 5792bc1

Browse files
committed
stratovirt: fix pci device addrs
1 parent 0ab757d commit 5792bc1

File tree

1 file changed

+25
-6
lines changed

1 file changed

+25
-6
lines changed

lib/runners/stratovirt.nix

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ let
4848
(builtins.head xs // { index = n; })
4949
] ++ (enumerate (n + 1) (builtins.tail xs));
5050

51+
virtioblkOffset = 4;
52+
virtiofsOffset = virtioblkOffset + builtins.length microvmConfig.volumes;
53+
5154
forwardPortsOptions =
5255
let
5356
forwardingOptions = lib.flip lib.concatMapStrings forwardPorts
@@ -89,17 +92,33 @@ in {
8992
"-device" "virtio-blk-${devType 2},drive=store,id=blk_store"
9093
] ++
9194
lib.optionals (socket != null) [ "-qmp" "unix:${socket},server,nowait" ] ++
92-
builtins.concatMap ({ image, letter, serial, direct, ... }: [
93-
"-drive" "id=vd${letter},format=raw,file=${image},aio=io_uring,direct=${if direct then "on" else "off"}"
94-
"-device" "virtio-blk-${devType 4},drive=vd${letter},id=blk_vd${letter}${
95+
builtins.concatMap ({ index, image, letter, serial, direct, ... }: [
96+
"-drive"
97+
"id=vd${
98+
letter
99+
},format=raw,if=none,aio=io_uring,file=${
100+
image
101+
},direct=${
102+
if direct then "on" else "off"
103+
}"
104+
"-device"
105+
"virtio-blk-${
106+
devType (virtioblkOffset + index)
107+
},drive=vd${
108+
letter
109+
},id=blk_vd${
110+
letter
111+
}${
95112
lib.optionalString (serial != null) ",serial=${serial}"
96113
}"
97-
]) volumes ++
114+
]) (enumerate 0 volumes) ++
98115
lib.optionals (shares != []) (
99116
builtins.concatMap ({ proto, index, socket, source, tag, ... }: {
100117
"virtiofs" = [
101-
"-chardev" "socket,id=fs${toString index},path=${socket}"
102-
"-device" "vhost-user-fs-${devType (5 + index)},chardev=fs${toString index},tag=${tag},id=fs${toString index}"
118+
"-chardev"
119+
"socket,id=fs${toString index},path=${socket}"
120+
"-device"
121+
"vhost-user-fs-${devType (virtiofsOffset + index)},chardev=fs${toString index},tag=${tag},id=fs${toString index}"
103122
];
104123
}.${proto}) (enumerate 0 shares)
105124
)

0 commit comments

Comments
 (0)