diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index b666f3715f..418729b988 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -442,13 +442,20 @@ static int
qemuBuildRomStr(virBufferPtr buf,
virDomainDeviceInfoPtr info)
{
- if (info->rombar || info->romfile) {
+ if (info->romenabled || info->rombar || info->romfile) {
if (info->type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
- "%s", _("rombar and romfile are supported only for PCI devices"));
+ "%s", _("ROM tuning is only supported for PCI devices"));
return -1;
}
+ /* Passing an empty romfile= tells QEMU to disable ROM entirely for
+ * this device, and makes other settings irrelevant */
+ if (info->romenabled == VIR_TRISTATE_BOOL_NO) {
+ virBufferAddLit(buf, ",romfile=");
+ return 0;
+ }
+
switch (info->rombar) {
case VIR_TRISTATE_SWITCH_OFF:
virBufferAddLit(buf, ",rombar=0");
@@ -464,6 +471,7 @@ qemuBuildRomStr(virBufferPtr buf,
virQEMUBuildBufferEscapeComma(buf, info->romfile);
}
}
+
return 0;
}
diff --git a/tests/qemuxml2argvdata/pci-rom-disabled.args b/tests/qemuxml2argvdata/pci-rom-disabled.args
new file mode 100644
index 0000000000..8c9dc2fb80
--- /dev/null
+++ b/tests/qemuxml2argvdata/pci-rom-disabled.args
@@ -0,0 +1,26 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/home/test \
+USER=test \
+LOGNAME=test \
+QEMU_AUDIO_DRV=none \
+/usr/bin/qemu-system-x86_64 \
+-name guest \
+-S \
+-machine pc,accel=tcg,usb=off,dump-guest-core=off \
+-m 214 \
+-smp 1,sockets=1,cores=1,threads=1 \
+-uuid c7a5fdbd-edaf-9466-926a-d65c16db1809 \
+-display none \
+-no-user-config \
+-nodefaults \
+-chardev socket,id=charmonitor,path=/tmp/lib/domain--1-guest/monitor.sock,\
+server,nowait \
+-mon chardev=charmonitor,id=monitor,mode=control \
+-rtc base=utc \
+-no-shutdown \
+-no-acpi \
+-boot c \
+-netdev user,id=hostnet0 \
+-device virtio-net-pci,netdev=hostnet0,id=net0,mac=52:54:00:24:a5:9f,bus=pci.0,\
+addr=0x3,romfile=
diff --git a/tests/qemuxml2argvdata/pci-rom-disabled.xml b/tests/qemuxml2argvdata/pci-rom-disabled.xml
new file mode 100644
index 0000000000..1c12052382
--- /dev/null
+++ b/tests/qemuxml2argvdata/pci-rom-disabled.xml
@@ -0,0 +1,20 @@
+
+ guest
+ c7a5fdbd-edaf-9466-926a-d65c16db1809
+ 219100
+ 1
+
+ hvm
+
+
+ /usr/bin/qemu-system-x86_64
+
+
+
+
+
+
+
+
+
+
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 74d930ebe2..ae9893a84e 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -1554,6 +1554,7 @@ mymain(void)
DO_TEST_PARSE_ERROR("hostdev-mdev-invalid-target-address",
QEMU_CAPS_DEVICE_VFIO_PCI);
DO_TEST("pci-rom", NONE);
+ DO_TEST("pci-rom-disabled", NONE);
DO_TEST_FULL("restore-v2", "exec:cat", 7, 0, 0, GIC_NONE, NONE);
DO_TEST_FULL("restore-v2-fd", "stdio", 7, 0, 0, GIC_NONE, NONE);
diff --git a/tests/qemuxml2xmloutdata/pci-rom-disabled.xml b/tests/qemuxml2xmloutdata/pci-rom-disabled.xml
new file mode 100644
index 0000000000..6a95064ebf
--- /dev/null
+++ b/tests/qemuxml2xmloutdata/pci-rom-disabled.xml
@@ -0,0 +1,29 @@
+
+ guest
+ c7a5fdbd-edaf-9466-926a-d65c16db1809
+ 219100
+ 219100
+ 1
+
+ hvm
+
+
+
+ destroy
+ restart
+ destroy
+
+ /usr/bin/qemu-system-x86_64
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index 9e77b9fb13..6c1f0b0fa6 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -474,6 +474,7 @@ mymain(void)
DO_TEST("hostdev-vfio", NONE);
DO_TEST("hostdev-mdev-precreated", NONE);
DO_TEST("pci-rom", NONE);
+ DO_TEST("pci-rom-disabled", NONE);
DO_TEST("pci-serial-dev-chardev", NONE);
DO_TEST("encrypted-disk", NONE);