Skip to content

Commit bcabdff

Browse files
vunnysoastro
authored andcommitted
qemu: add deviceExtraArgs option for devices
This option could be useful in case we may need to pass any extra arguments to pci device. For example: -device vfio-pci,host=x,multifunction=on,id=hostId,x-igd-opregion=on Signed-off-by: Vunny Sodhi <[email protected]>
1 parent abab3cf commit bcabdff

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

lib/runners/qemu.nix

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,9 +290,12 @@ lib.warnIf (mem == 2048) ''
290290
"-device" "qemu-xhci"
291291
]
292292
++
293-
builtins.concatMap ({ bus, path, ... }: {
293+
builtins.concatMap ({ bus, path, qemu,... }: {
294294
pci = [
295-
"-device" "vfio-pci,host=${path},multifunction=on"
295+
"-device" "vfio-pci,host=${path},multifunction=on${
296+
# Allow to pass additional arguments to pci device
297+
lib.optionalString (qemu.deviceExtraArgs != null) ",${qemu.deviceExtraArgs}"
298+
}"
296299
];
297300
usb = [
298301
"-device" "usb-host,${path}"

nixos-modules/microvm/options.nix

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,7 @@ in
352352
} {
353353
bus = "pci";
354354
path = "0000:01:01.0";
355+
deviceExtraArgs = "id=hostId,x-igd-opregion=on";
355356
} {
356357
# QEMU only
357358
bus = "usb";
@@ -372,6 +373,13 @@ in
372373
Identification of the device on its bus
373374
'';
374375
};
376+
qemu.deviceExtraArgs = mkOption {
377+
type = with types; nullOr str;
378+
default = null;
379+
description = ''
380+
Device additional arguments (optional)
381+
'';
382+
};
375383
};
376384
});
377385
};

0 commit comments

Comments
 (0)