Some test cases that were specifically set up to exploit the
lack of checks on PCI controller options start failing with
these changes, so they are marked as such.
Signed-off-by: Andrea Bolognani <abologna(a)redhat.com>
---
src/qemu/qemu_domain.c | 43 ++++++++++++
.../i440fx-controllers-pciopts.args | 24 -------
.../pseries-controllers-pciopts.args | 22 -------
.../qemuxml2argvdata/q35-controllers-pciopts.args | 28 --------
tests/qemuxml2argvtest.c | 19 +-----
.../i440fx-controllers-pciopts.xml | 45 -------------
.../pseries-controllers-pciopts.xml | 43 ------------
.../qemuxml2xmloutdata/q35-controllers-pciopts.xml | 76 ----------------------
tests/qemuxml2xmltest.c | 17 -----
9 files changed, 46 insertions(+), 271 deletions(-)
delete mode 100644 tests/qemuxml2argvdata/i440fx-controllers-pciopts.args
delete mode 100644 tests/qemuxml2argvdata/pseries-controllers-pciopts.args
delete mode 100644 tests/qemuxml2argvdata/q35-controllers-pciopts.args
delete mode 100644 tests/qemuxml2xmloutdata/i440fx-controllers-pciopts.xml
delete mode 100644 tests/qemuxml2xmloutdata/pseries-controllers-pciopts.xml
delete mode 100644 tests/qemuxml2xmloutdata/q35-controllers-pciopts.xml
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 2f76464df..52c76b515 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -4408,6 +4408,49 @@ qemuDomainDeviceDefValidateControllerPCI(const
virDomainControllerDef *controlle
break;
}
+ /* targetIndex */
+ switch ((virDomainControllerModelPCI) controller->model) {
+ case VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT:
+ /* PHBs for pSeries guests are stored as pci-root controllers and
+ * must have been assigned a targetIndex */
+ if (pciopts->targetIndex == -1 &&
+ qemuDomainIsPSeries(def)) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Option '%s' not set for '%s'
controller"),
+ "targetIndex", model);
+ return -1;
+ }
+ /* targetIndex only applies to pSeries guests, so for any other
+ * guest type it being present is an error */
+ if (pciopts->targetIndex != -1 &&
+ !qemuDomainIsPSeries(def)) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("Option '%s' is not valid for '%s'
controller"),
+ "targetIndex", model);
+ return -1;
+ }
+ break;
+
+ case VIR_DOMAIN_CONTROLLER_MODEL_PCI_BRIDGE:
+ case VIR_DOMAIN_CONTROLLER_MODEL_DMI_TO_PCI_BRIDGE:
+ case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT_PORT:
+ case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_SWITCH_UPSTREAM_PORT:
+ case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_SWITCH_DOWNSTREAM_PORT:
+ case VIR_DOMAIN_CONTROLLER_MODEL_PCI_EXPANDER_BUS:
+ case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_EXPANDER_BUS:
+ case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT:
+ if (pciopts->targetIndex != -1) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("Option '%s' is not valid for '%s'
controller"),
+ "targetIndex", model);
+ return -1;
+ }
+ break;
+
+ case VIR_DOMAIN_CONTROLLER_MODEL_PCI_LAST:
+ break;
+ }
+
return 0;
}
diff --git a/tests/qemuxml2argvdata/i440fx-controllers-pciopts.args
b/tests/qemuxml2argvdata/i440fx-controllers-pciopts.args
deleted file mode 100644
index d85fae5c9..000000000
--- a/tests/qemuxml2argvdata/i440fx-controllers-pciopts.args
+++ /dev/null
@@ -1,24 +0,0 @@
-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 \
--M pc \
--m 1024 \
--smp 1,sockets=1,cores=1,threads=1 \
--numa node,nodeid=0,cpus=0,mem=1024 \
--uuid 496d7ea8-9739-544b-4ebd-ef08be936e8b \
--nographic \
--nodefaults \
--chardev socket,id=charmonitor,path=/tmp/lib/domain--1-guest/monitor.sock,\
-server,nowait \
--mon chardev=charmonitor,id=monitor,mode=readline \
--no-acpi \
--boot c \
--global i440FX-pcihost.pci-hole64-size=1024K \
--device pci-bridge,chassis_nr=2,id=pci.1,bus=pci.0,addr=0x3 \
--device pxb,bus_nr=3,id=pci.2,numa_node=0,bus=pci.0,addr=0x4
diff --git a/tests/qemuxml2argvdata/pseries-controllers-pciopts.args
b/tests/qemuxml2argvdata/pseries-controllers-pciopts.args
deleted file mode 100644
index 5f1edfc83..000000000
--- a/tests/qemuxml2argvdata/pseries-controllers-pciopts.args
+++ /dev/null
@@ -1,22 +0,0 @@
-LC_ALL=C \
-PATH=/bin \
-HOME=/home/test \
-USER=test \
-LOGNAME=test \
-QEMU_AUDIO_DRV=none \
-/usr/bin/qemu-system-ppc64 \
--name guest \
--S \
--M pseries \
--m 1024 \
--smp 1,sockets=1,cores=1,threads=1 \
--numa node,nodeid=0,cpus=0,mem=1024 \
--uuid 496d7ea8-9739-544b-4ebd-ef08be936e8b \
--nographic \
--nodefaults \
--chardev socket,id=charmonitor,path=/tmp/lib/domain--1-guest/monitor.sock,\
-server,nowait \
--mon chardev=charmonitor,id=monitor,mode=readline \
--boot c \
--device spapr-pci-host-bridge,index=1,id=pci.1,numa_node=0 \
--device pci-bridge,chassis_nr=3,id=pci.2,bus=pci.0,addr=0x1
diff --git a/tests/qemuxml2argvdata/q35-controllers-pciopts.args
b/tests/qemuxml2argvdata/q35-controllers-pciopts.args
deleted file mode 100644
index 44259f502..000000000
--- a/tests/qemuxml2argvdata/q35-controllers-pciopts.args
+++ /dev/null
@@ -1,28 +0,0 @@
-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 \
--M q35 \
--m 1024 \
--smp 1,sockets=1,cores=1,threads=1 \
--numa node,nodeid=0,cpus=0,mem=1024 \
--uuid 496d7ea8-9739-544b-4ebd-ef08be936e8b \
--nographic \
--nodefaults \
--chardev socket,id=charmonitor,path=/tmp/lib/domain--1-guest/monitor.sock,\
-server,nowait \
--mon chardev=charmonitor,id=monitor,mode=readline \
--no-acpi \
--boot c \
--global q35-pcihost.pci-hole64-size=1024K \
--device i82801b11-bridge,id=pci.1,bus=pcie.0,addr=0x1e \
--device pci-bridge,chassis_nr=3,id=pci.2,bus=pci.1,addr=0x0 \
--device pxb-pcie,bus_nr=4,id=pci.3,numa_node=0,bus=pcie.0,addr=0x2 \
--device pcie-root-port,port=0x5,chassis=5,id=pci.4,bus=pcie.0,addr=0x3 \
--device x3130-upstream,id=pci.5,bus=pci.4,addr=0x0 \
--device xio3130-downstream,port=0x7,chassis=7,id=pci.6,bus=pci.5,addr=0x0
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 4154663da..525042e95 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -2435,22 +2435,9 @@ mymain(void)
QEMU_CAPS_DEVICE_IOH3420,
QEMU_CAPS_DEVICE_PXB_PCIE);
- DO_TEST("i440fx-controllers-pciopts",
- QEMU_CAPS_I440FX_PCI_HOLE64_SIZE,
- QEMU_CAPS_DEVICE_PCI_BRIDGE,
- QEMU_CAPS_DEVICE_PXB);
- DO_TEST("q35-controllers-pciopts",
- QEMU_CAPS_Q35_PCI_HOLE64_SIZE,
- QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
- QEMU_CAPS_DEVICE_PCI_BRIDGE,
- QEMU_CAPS_DEVICE_PXB_PCIE,
- QEMU_CAPS_DEVICE_PCIE_ROOT_PORT,
- QEMU_CAPS_DEVICE_X3130_UPSTREAM,
- QEMU_CAPS_DEVICE_XIO3130_DOWNSTREAM);
- DO_TEST("pseries-controllers-pciopts",
- QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
- QEMU_CAPS_SPAPR_PCI_HOST_BRIDGE_NUMA_NODE,
- QEMU_CAPS_DEVICE_PCI_BRIDGE);
+ DO_TEST_PARSE_ERROR("i440fx-controllers-pciopts", NONE);
+ DO_TEST_PARSE_ERROR("q35-controllers-pciopts", NONE);
+ DO_TEST_PARSE_ERROR("pseries-controllers-pciopts", NONE);
DO_TEST("hostdev-scsi-lsi",
QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_SCSI_LSI,
diff --git a/tests/qemuxml2xmloutdata/i440fx-controllers-pciopts.xml
b/tests/qemuxml2xmloutdata/i440fx-controllers-pciopts.xml
deleted file mode 100644
index d171d1370..000000000
--- a/tests/qemuxml2xmloutdata/i440fx-controllers-pciopts.xml
+++ /dev/null
@@ -1,45 +0,0 @@
-<domain type='qemu'>
- <name>guest</name>
- <uuid>496d7ea8-9739-544b-4ebd-ef08be936e8b</uuid>
- <memory unit='KiB'>1048576</memory>
- <currentMemory unit='KiB'>1048576</currentMemory>
- <vcpu placement='static'>1</vcpu>
- <os>
- <type arch='x86_64' machine='pc'>hvm</type>
- <boot dev='hd'/>
- </os>
- <cpu>
- <numa>
- <cell id='0' cpus='0' memory='1048576'
unit='KiB'/>
- </numa>
- </cpu>
- <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'>
- <target chassisNr='1' chassis='1' port='0x1'
busNr='1' index='0'/>
- <pcihole64 unit='KiB'>1024</pcihole64>
- </controller>
- <controller type='pci' index='1' model='pci-bridge'>
- <model name='pci-bridge'/>
- <target chassisNr='2' chassis='2' port='0x2'
busNr='2' index='2'>
- <node>0</node>
- </target>
- <address type='pci' domain='0x0000' bus='0x00'
slot='0x03' function='0x0'/>
- </controller>
- <controller type='pci' index='2'
model='pci-expander-bus'>
- <model name='pxb'/>
- <target chassisNr='3' chassis='3' port='0x3'
busNr='3' index='3'>
- <node>0</node>
- </target>
- <address type='pci' domain='0x0000' bus='0x00'
slot='0x04' function='0x0'/>
- </controller>
- <controller type='usb' index='0' model='none'/>
- <input type='mouse' bus='ps2'/>
- <input type='keyboard' bus='ps2'/>
- <memballoon model='none'/>
- </devices>
-</domain>
diff --git a/tests/qemuxml2xmloutdata/pseries-controllers-pciopts.xml
b/tests/qemuxml2xmloutdata/pseries-controllers-pciopts.xml
deleted file mode 100644
index bbe360e25..000000000
--- a/tests/qemuxml2xmloutdata/pseries-controllers-pciopts.xml
+++ /dev/null
@@ -1,43 +0,0 @@
-<domain type='qemu'>
- <name>guest</name>
- <uuid>496d7ea8-9739-544b-4ebd-ef08be936e8b</uuid>
- <memory unit='KiB'>1048576</memory>
- <currentMemory unit='KiB'>1048576</currentMemory>
- <vcpu placement='static'>1</vcpu>
- <os>
- <type arch='ppc64' machine='pseries'>hvm</type>
- <boot dev='hd'/>
- </os>
- <cpu>
- <numa>
- <cell id='0' cpus='0' memory='1048576'
unit='KiB'/>
- </numa>
- </cpu>
- <clock offset='utc'/>
- <on_poweroff>destroy</on_poweroff>
- <on_reboot>restart</on_reboot>
- <on_crash>destroy</on_crash>
- <devices>
- <emulator>/usr/bin/qemu-system-ppc64</emulator>
- <controller type='pci' index='0' model='pci-root'>
- <model name='spapr-pci-host-bridge'/>
- <target chassisNr='1' chassis='1' port='0x1'
busNr='1' index='0'/>
- </controller>
- <controller type='pci' index='1' model='pci-root'>
- <model name='spapr-pci-host-bridge'/>
- <target chassisNr='2' chassis='2' port='0x2'
busNr='2' index='1'>
- <node>0</node>
- </target>
- </controller>
- <controller type='pci' index='2' model='pci-bridge'>
- <model name='pci-bridge'/>
- <target chassisNr='3' chassis='3' port='0x3'
busNr='3' index='3'>
- <node>0</node>
- </target>
- <address type='pci' domain='0x0000' bus='0x00'
slot='0x01' function='0x0'/>
- </controller>
- <controller type='usb' index='0' model='none'/>
- <memballoon model='none'/>
- <panic model='pseries'/>
- </devices>
-</domain>
diff --git a/tests/qemuxml2xmloutdata/q35-controllers-pciopts.xml
b/tests/qemuxml2xmloutdata/q35-controllers-pciopts.xml
deleted file mode 100644
index 5ef7aa564..000000000
--- a/tests/qemuxml2xmloutdata/q35-controllers-pciopts.xml
+++ /dev/null
@@ -1,76 +0,0 @@
-<domain type='qemu'>
- <name>guest</name>
- <uuid>496d7ea8-9739-544b-4ebd-ef08be936e8b</uuid>
- <memory unit='KiB'>1048576</memory>
- <currentMemory unit='KiB'>1048576</currentMemory>
- <vcpu placement='static'>1</vcpu>
- <os>
- <type arch='x86_64' machine='q35'>hvm</type>
- <boot dev='hd'/>
- </os>
- <cpu>
- <numa>
- <cell id='0' cpus='0' memory='1048576'
unit='KiB'/>
- </numa>
- </cpu>
- <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='pcie-root'>
- <target chassisNr='1' chassis='1' port='0x1'
busNr='1' index='0'/>
- <pcihole64 unit='KiB'>1024</pcihole64>
- </controller>
- <controller type='pci' index='1'
model='dmi-to-pci-bridge'>
- <model name='i82801b11-bridge'/>
- <target chassisNr='2' chassis='2' port='0x2'
busNr='2' index='2'>
- <node>0</node>
- </target>
- <address type='pci' domain='0x0000' bus='0x00'
slot='0x1e' function='0x0'/>
- </controller>
- <controller type='pci' index='2' model='pci-bridge'>
- <model name='pci-bridge'/>
- <target chassisNr='3' chassis='3' port='0x3'
busNr='3' index='3'>
- <node>0</node>
- </target>
- <address type='pci' domain='0x0000' bus='0x01'
slot='0x00' function='0x0'/>
- </controller>
- <controller type='pci' index='3'
model='pcie-expander-bus'>
- <model name='pxb-pcie'/>
- <target chassisNr='4' chassis='4' port='0x4'
busNr='4' index='4'>
- <node>0</node>
- </target>
- <address type='pci' domain='0x0000' bus='0x00'
slot='0x02' function='0x0'/>
- </controller>
- <controller type='pci' index='4'
model='pcie-root-port'>
- <model name='pcie-root-port'/>
- <target chassisNr='5' chassis='5' port='0x5'
busNr='5' index='5'>
- <node>0</node>
- </target>
- <address type='pci' domain='0x0000' bus='0x00'
slot='0x03' function='0x0'/>
- </controller>
- <controller type='pci' index='5'
model='pcie-switch-upstream-port'>
- <model name='x3130-upstream'/>
- <target chassisNr='6' chassis='6' port='0x6'
busNr='6' index='6'>
- <node>0</node>
- </target>
- <address type='pci' domain='0x0000' bus='0x04'
slot='0x00' function='0x0'/>
- </controller>
- <controller type='pci' index='6'
model='pcie-switch-downstream-port'>
- <model name='xio3130-downstream'/>
- <target chassisNr='7' chassis='7' port='0x7'
busNr='7' index='7'>
- <node>0</node>
- </target>
- <address type='pci' domain='0x0000' bus='0x05'
slot='0x00' function='0x0'/>
- </controller>
- <controller type='usb' index='0' model='none'/>
- <controller type='sata' index='0'>
- <address type='pci' domain='0x0000' bus='0x00'
slot='0x1f' function='0x2'/>
- </controller>
- <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 7b8a16078..0eb9e6c77 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -1102,23 +1102,6 @@ mymain(void)
QEMU_CAPS_DEVICE_IOH3420,
QEMU_CAPS_HDA_DUPLEX);
- DO_TEST("i440fx-controllers-pciopts",
- QEMU_CAPS_I440FX_PCI_HOLE64_SIZE,
- QEMU_CAPS_DEVICE_PCI_BRIDGE,
- QEMU_CAPS_DEVICE_PXB);
- DO_TEST("q35-controllers-pciopts",
- QEMU_CAPS_Q35_PCI_HOLE64_SIZE,
- QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
- QEMU_CAPS_DEVICE_PCI_BRIDGE,
- QEMU_CAPS_DEVICE_PXB_PCIE,
- QEMU_CAPS_DEVICE_PCIE_ROOT_PORT,
- QEMU_CAPS_DEVICE_X3130_UPSTREAM,
- QEMU_CAPS_DEVICE_XIO3130_DOWNSTREAM);
- DO_TEST("pseries-controllers-pciopts",
- QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
- QEMU_CAPS_SPAPR_PCI_HOST_BRIDGE_NUMA_NODE,
- QEMU_CAPS_DEVICE_PCI_BRIDGE);
-
DO_TEST("hostdev-scsi-vhost-scsi-ccw",
QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_DEVICE_VHOST_SCSI,
QEMU_CAPS_DEVICE_SCSI_GENERIC, QEMU_CAPS_VIRTIO_CCW);
--
2.14.3