This change catches an invalid use of the option in our
test suite.
Signed-off-by: Andrea Bolognani <abologna(a)redhat.com>
---
src/qemu/qemu_domain.c | 31 ++++++++++++++++++++++++++
tests/qemuxml2argvdata/pcie-expander-bus.xml | 2 +-
tests/qemuxml2xmloutdata/pcie-expander-bus.xml | 2 +-
3 files changed, 33 insertions(+), 2 deletions(-)
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index b4dd7a7e8..81f347ce4 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -4488,6 +4488,37 @@ qemuDomainDeviceDefValidateControllerPCI(const
virDomainControllerDef *controlle
break;
}
+ /* busNr */
+ switch ((virDomainControllerModelPCI) controller->model) {
+ case VIR_DOMAIN_CONTROLLER_MODEL_PCI_EXPANDER_BUS:
+ case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_EXPANDER_BUS:
+ if (pciopts->busNr == -1) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Option '%s' not set for '%s'
controller"),
+ "busNr", model);
+ return -1;
+ }
+ break;
+
+ case VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT:
+ 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_PCIE_ROOT:
+ if (pciopts->busNr != -1) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("Option '%s' is not valid for '%s'
controller"),
+ "busNr", model);
+ return -1;
+ }
+ break;
+
+ case VIR_DOMAIN_CONTROLLER_MODEL_PCI_LAST:
+ break;
+ }
+
return 0;
}
diff --git a/tests/qemuxml2argvdata/pcie-expander-bus.xml
b/tests/qemuxml2argvdata/pcie-expander-bus.xml
index ac01c26cc..237430a1e 100644
--- a/tests/qemuxml2argvdata/pcie-expander-bus.xml
+++ b/tests/qemuxml2argvdata/pcie-expander-bus.xml
@@ -35,7 +35,7 @@
<address type='pci' bus='0x00' slot='4'/>
</controller>
<controller type='pci' index='2'
model='pcie-root-port'>
- <target busNr='220'>
+ <target>
<node>1</node>
</target>
<address type='pci' bus='0x01'/>
diff --git a/tests/qemuxml2xmloutdata/pcie-expander-bus.xml
b/tests/qemuxml2xmloutdata/pcie-expander-bus.xml
index aaac423ca..d5e741b80 100644
--- a/tests/qemuxml2xmloutdata/pcie-expander-bus.xml
+++ b/tests/qemuxml2xmloutdata/pcie-expander-bus.xml
@@ -36,7 +36,7 @@
</controller>
<controller type='pci' index='2'
model='pcie-root-port'>
<model name='ioh3420'/>
- <target chassis='2' port='0x0' busNr='220'>
+ <target chassis='2' port='0x0'>
<node>1</node>
</target>
<address type='pci' domain='0x0000' bus='0x01'
slot='0x00' function='0x0'/>
--
2.14.3