The attribute can be used to disable ROM loading completely
for a device.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1425058
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
---
src/qemu/qemu_command.c | 13 ++++++++++--
tests/qemuxml2argvdata/pci-rom-disabled.args | 26 ++++++++++++++++++++++++
tests/qemuxml2argvdata/pci-rom-disabled.xml | 20 ++++++++++++++++++
tests/qemuxml2argvtest.c | 1 +
tests/qemuxml2xmloutdata/pci-rom-disabled.xml | 29 +++++++++++++++++++++++++++
tests/qemuxml2xmltest.c | 1 +
6 files changed, 88 insertions(+), 2 deletions(-)
create mode 100644 tests/qemuxml2argvdata/pci-rom-disabled.args
create mode 100644 tests/qemuxml2argvdata/pci-rom-disabled.xml
create mode 100644 tests/qemuxml2xmloutdata/pci-rom-disabled.xml
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index b666f3715f..84c4e1e350 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=");
+ goto done;
+ }
+
switch (info->rombar) {
case VIR_TRISTATE_SWITCH_OFF:
virBufferAddLit(buf, ",rombar=0");
@@ -464,6 +471,8 @@ qemuBuildRomStr(virBufferPtr buf,
virQEMUBuildBufferEscapeComma(buf, info->romfile);
}
}
+
+ done:
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 @@
+<domain type='qemu'>
+ <name>guest</name>
+ <uuid>c7a5fdbd-edaf-9466-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>219100</memory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='x86_64' machine='pc'>hvm</type>
+ </os>
+ <devices>
+ <emulator>/usr/bin/qemu-system-x86_64</emulator>
+ <controller type='pci' model='pci-root'/>
+ <controller type='usb' model='none'/>
+ <interface type='user'>
+ <mac address='52:54:00:24:a5:9f'/>
+ <model type='virtio'/>
+ <rom enabled='no'/>
+ </interface>
+ <memballoon model='none'/>
+ </devices>
+</domain>
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 @@
+<domain type='qemu'>
+ <name>guest</name>
+ <uuid>c7a5fdbd-edaf-9466-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>219100</memory>
+ <currentMemory unit='KiB'>219100</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='x86_64' machine='pc'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu-system-x86_64</emulator>
+ <controller type='pci' index='0' model='pci-root'/>
+ <controller type='usb' index='0' model='none'/>
+ <interface type='user'>
+ <mac address='52:54:00:24:a5:9f'/>
+ <model type='virtio'/>
+ <rom enabled='no'/>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
+ </interface>
+ <input type='mouse' bus='ps2'/>
+ <input type='keyboard' bus='ps2'/>
+ <memballoon model='none'/>
+ </devices>
+</domain>
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);
--
2.14.3
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
On Fri, Apr 20, 2018 at 17:44:30 +0200, Andrea Bolognani wrote:
> The attribute can be used to disable ROM loading completely
> for a device.
You could mention that this is necessary because even if you turn the
ROM BAR off, some firmware might still load it.
>
> Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1425058
> Signed-off-by: Andrea Bolognani <abologna@redhat.com>
> ---
> src/qemu/qemu_command.c | 13 ++++++++++--
> tests/qemuxml2argvdata/pci-rom-disabled.args | 26 ++++++++++++++++++++++++
> tests/qemuxml2argvdata/pci-rom-disabled.xml | 20 ++++++++++++++++++
> tests/qemuxml2argvtest.c | 1 +
> tests/qemuxml2xmloutdata/pci-rom-disabled.xml | 29 +++++++++++++++++++++++++++
> tests/qemuxml2xmltest.c | 1 +
> 6 files changed, 88 insertions(+), 2 deletions(-)
> create mode 100644 tests/qemuxml2argvdata/pci-rom-disabled.args
> create mode 100644 tests/qemuxml2argvdata/pci-rom-disabled.xml
> create mode 100644 tests/qemuxml2xmloutdata/pci-rom-disabled.xml
>
> diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
> index b666f3715f..84c4e1e350 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=");
> + goto done;
You can return early rather than having to jump. This function needs to
be refactored anyways, so no need to be nice to others comming after
you.
> + }
> +
> switch (info->rombar) {
> case VIR_TRISTATE_SWITCH_OFF:
> virBufferAddLit(buf, ",rombar=0");
> @@ -464,6 +471,8 @@ qemuBuildRomStr(virBufferPtr buf,
> virQEMUBuildBufferEscapeComma(buf, info->romfile);
> }
> }
> +
> + done:
> return 0;
> }
[...]
> 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 @@
> +<domain type='qemu'>
> + <name>guest</name>
> + <uuid>c7a5fdbd-edaf-9466-926a-d65c16db1809</uuid>
> + <memory unit='KiB'>219100</memory>
> + <vcpu placement='static'>1</vcpu>
> + <os>
> + <type arch='x86_64' machine='pc'>hvm</type>
> + </os>
> + <devices>
> + <emulator>/usr/bin/qemu-system-x86_64</emulator>
> + <controller type='pci' model='pci-root'/>
> + <controller type='usb' model='none'/>
> + <interface type='user'>
> + <mac address='52:54:00:24:a5:9f'/>
> + <model type='virtio'/>
> + <rom enabled='no'/>
If we are going to explicitly keep around the quirk with the empty file
I think we should add a test case for it. It will not be fun though
since such XML is invalid.
> + </interface>
> + <memballoon model='none'/>
> + </devices>
> +</domain>
ACK if you get rid of that jump.
The test case will need to be added separately anyways.
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
On Mon, 2018-04-23 at 08:58 +0200, Peter Krempa wrote: > The test case will need to be added separately anyways. Here it is: https://www.redhat.com/archives/libvir-list/2018-April/msg02122.html -- Andrea Bolognani / Red Hat / Virtualization -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
© 2016 - 2025 Red Hat, Inc.