[PATCH 19/31] qemu: Ensure USB controllers have a PCI address assigned

Andrea Bolognani via Devel posted 31 patches 2 weeks, 5 days ago
[PATCH 19/31] qemu: Ensure USB controllers have a PCI address assigned
Posted by Andrea Bolognani via Devel 2 weeks, 5 days ago
If we have gotten this far into creating the QEMU command line,
either the user or some earlier code should have assigned a PCI
address to the USB controller. If one is not present, that must
mean there's a bug somewhere.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
---
 src/qemu/qemu_command.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index e8de386f30..f5a80f6955 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -2598,6 +2598,13 @@ qemuValidateDomainDeviceDefControllerUSB(const virDomainControllerDef *def,
         return -1;
     }
 
+    if (!virDeviceInfoPCIAddressIsPresent(&def->info)) {
+        virReportError(VIR_ERR_INTERNAL_ERROR,
+                       _("Missing PCI address for USB controller idx=%1$d"),
+                       def->idx);
+        return -1;
+    }
+
     if (!virQEMUCapsGet(qemuCaps, qemuControllerModelUSBToCaps(def->model))) {
         virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
                        _("USB controller model '%1$s' not supported in this QEMU binary"),
-- 
2.50.1