[PATCH 16/31] qemu: Validate presence of PCI support

Andrea Bolognani via Devel posted 31 patches 5 months, 3 weeks ago
There is a newer version of this series
[PATCH 16/31] qemu: Validate presence of PCI support
Posted by Andrea Bolognani via Devel 5 months, 3 weeks ago
The qemuValidateDomainDeviceDefControllerPCI() function is
called if PCI controllers are present in the domain
configuration, which shouldn't happen if the machine type
doesn't support PCI. If we somehow find ourselves in that
scenario, reporting an error would be the right thing to do.

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

diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c
index adba3e4a89..ebcc9b8e8e 100644
--- a/src/qemu/qemu_validate.c
+++ b/src/qemu/qemu_validate.c
@@ -3975,6 +3975,13 @@ qemuValidateDomainDeviceDefControllerPCI(const virDomainControllerDef *cont,
         return -1;
     }
 
+    if (!qemuDomainSupportsPCI(def)) {
+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                       _("Machine type '%1$s' does not support PCI"),
+                       def->os.machine);
+        return -1;
+    }
+
     /* modelName */
     switch ((virDomainControllerModelPCI) cont->model) {
     case VIR_DOMAIN_CONTROLLER_MODEL_PCI_BRIDGE:
-- 
2.50.1
Re: [PATCH 16/31] qemu: Validate presence of PCI support
Posted by Peter Krempa via Devel 4 months, 3 weeks ago
On Tue, Aug 19, 2025 at 18:22:20 +0200, Andrea Bolognani via Devel wrote:
> The qemuValidateDomainDeviceDefControllerPCI() function is
> called if PCI controllers are present in the domain
> configuration, which shouldn't happen if the machine type
> doesn't support PCI. If we somehow find ourselves in that
> scenario, reporting an error would be the right thing to do.
> 
> Signed-off-by: Andrea Bolognani <abologna@redhat.com>
> ---
>  src/qemu/qemu_validate.c | 7 +++++++
>  1 file changed, 7 insertions(+)

Reviewed-by: Peter Krempa <pkrempa@redhat.com>