mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-31 17:05:16 +00:00
qemu: Format rom.enabled attribute for PCI devices
The attribute can be used to disable ROM loading completely for a device. This might be needed because, even when the guest is configured such that the PCI ROM will not be loaded in the PCI BAR, some hypervisors (eg. QEMU) might still make it available to the guest in a form (eg. fw_cfg) that some firmwares (eg. SeaBIOS) will consume, thus not achieving the desired result. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1425058 Signed-off-by: Andrea Bolognani <abologna@redhat.com>
This commit is contained in:
parent
c4466179f4
commit
4d11d9a292
@ -442,13 +442,20 @@ static int
|
|||||||
qemuBuildRomStr(virBufferPtr buf,
|
qemuBuildRomStr(virBufferPtr buf,
|
||||||
virDomainDeviceInfoPtr info)
|
virDomainDeviceInfoPtr info)
|
||||||
{
|
{
|
||||||
if (info->rombar || info->romfile) {
|
if (info->romenabled || info->rombar || info->romfile) {
|
||||||
if (info->type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) {
|
if (info->type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) {
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
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;
|
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) {
|
switch (info->rombar) {
|
||||||
case VIR_TRISTATE_SWITCH_OFF:
|
case VIR_TRISTATE_SWITCH_OFF:
|
||||||
virBufferAddLit(buf, ",rombar=0");
|
virBufferAddLit(buf, ",rombar=0");
|
||||||
@ -464,6 +471,7 @@ qemuBuildRomStr(virBufferPtr buf,
|
|||||||
virQEMUBuildBufferEscapeComma(buf, info->romfile);
|
virQEMUBuildBufferEscapeComma(buf, info->romfile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
26
tests/qemuxml2argvdata/pci-rom-disabled.args
Normal file
26
tests/qemuxml2argvdata/pci-rom-disabled.args
Normal file
@ -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=
|
20
tests/qemuxml2argvdata/pci-rom-disabled.xml
Normal file
20
tests/qemuxml2argvdata/pci-rom-disabled.xml
Normal file
@ -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>
|
@ -1554,6 +1554,7 @@ mymain(void)
|
|||||||
DO_TEST_PARSE_ERROR("hostdev-mdev-invalid-target-address",
|
DO_TEST_PARSE_ERROR("hostdev-mdev-invalid-target-address",
|
||||||
QEMU_CAPS_DEVICE_VFIO_PCI);
|
QEMU_CAPS_DEVICE_VFIO_PCI);
|
||||||
DO_TEST("pci-rom", NONE);
|
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", "exec:cat", 7, 0, 0, GIC_NONE, NONE);
|
||||||
DO_TEST_FULL("restore-v2-fd", "stdio", 7, 0, 0, GIC_NONE, NONE);
|
DO_TEST_FULL("restore-v2-fd", "stdio", 7, 0, 0, GIC_NONE, NONE);
|
||||||
|
29
tests/qemuxml2xmloutdata/pci-rom-disabled.xml
Normal file
29
tests/qemuxml2xmloutdata/pci-rom-disabled.xml
Normal file
@ -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>
|
@ -474,6 +474,7 @@ mymain(void)
|
|||||||
DO_TEST("hostdev-vfio", NONE);
|
DO_TEST("hostdev-vfio", NONE);
|
||||||
DO_TEST("hostdev-mdev-precreated", NONE);
|
DO_TEST("hostdev-mdev-precreated", NONE);
|
||||||
DO_TEST("pci-rom", NONE);
|
DO_TEST("pci-rom", NONE);
|
||||||
|
DO_TEST("pci-rom-disabled", NONE);
|
||||||
DO_TEST("pci-serial-dev-chardev", NONE);
|
DO_TEST("pci-serial-dev-chardev", NONE);
|
||||||
|
|
||||||
DO_TEST("encrypted-disk", NONE);
|
DO_TEST("encrypted-disk", NONE);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user