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

Andrea Bolognani via Devel posted 31 patches 5 months, 3 weeks ago
There is a newer version of this series
[PATCH 19/31] qemu: Ensure USB controllers have a PCI address assigned
Posted by Andrea Bolognani via Devel 5 months, 3 weeks 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
Re: [PATCH 19/31] qemu: Ensure USB controllers have a PCI address assigned
Posted by Peter Krempa via Devel 4 months, 3 weeks ago
On Tue, Aug 19, 2025 at 18:22:23 +0200, Andrea Bolognani via Devel wrote:
> 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,

This surely is no internal error.

> +                       _("Missing PCI address for USB controller idx=%1$d"),

This ought to say something about the USB controller model %s requiring
PCI support and PCI address asigned to go with my comments on the
previous patch.

> +                       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
>