[libvirt PATCH] qemu: make qemuBuildDeviceAddressPCIGetBus more generic

Ján Tomko via Devel posted 1 patch 18 hours ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/fbea1624cb02b0ab6c47785a664b4b95c5ae48d6.1763650574.git.jtomko@redhat.com
src/qemu/qemu_command.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
[libvirt PATCH] qemu: make qemuBuildDeviceAddressPCIGetBus more generic
Posted by Ján Tomko via Devel 18 hours ago
From: Ján Tomko <jtomko@redhat.com>

Operate on a virPCIDeviceAddress, not virDomainDeviceInfo
so that this can be reused to look for buses that are not
stored in the device info.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
---
A prerequisite for the SMMUv3 series


 src/qemu/qemu_command.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index c56c321a6e..d5a4201e12 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -332,7 +332,7 @@ qemuBuildMasterKeyCommandLine(virCommand *cmd,
 
 static char *
 qemuBuildDeviceAddressPCIGetBus(const virDomainDef *domainDef,
-                                const virDomainDeviceInfo *info)
+                                const virPCIDeviceAddress *pci)
 {
     g_autofree char *devStr = NULL;
     const char *contAlias = NULL;
@@ -340,14 +340,14 @@ qemuBuildDeviceAddressPCIGetBus(const virDomainDef *domainDef,
     int contTargetIndex = 0;
     size_t i;
 
-    if (!(devStr = virPCIDeviceAddressAsString(&info->addr.pci)))
+    if (!(devStr = virPCIDeviceAddressAsString(pci)))
         return NULL;
 
     for (i = 0; i < domainDef->ncontrollers; i++) {
         virDomainControllerDef *cont = domainDef->controllers[i];
 
         if (cont->type == VIR_DOMAIN_CONTROLLER_TYPE_PCI &&
-            cont->idx == info->addr.pci.bus) {
+            cont->idx == pci->bus) {
             contAlias = cont->info.alias;
             contIsPHB = virDomainControllerIsPSeriesPHB(cont);
             contTargetIndex = cont->opts.pciopts.targetIndex;
@@ -355,7 +355,7 @@ qemuBuildDeviceAddressPCIGetBus(const virDomainDef *domainDef,
             if (!contAlias) {
                 virReportError(VIR_ERR_INTERNAL_ERROR,
                                _("Device alias was not set for PCI controller with index '%1$u' required for device at address '%2$s'"),
-                               info->addr.pci.bus, devStr);
+                               pci->bus, devStr);
                 return NULL;
             }
 
@@ -397,7 +397,7 @@ qemuBuildDeviceAddressPCIGetBus(const virDomainDef *domainDef,
     if (!contAlias) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
                        _("Could not find PCI controller with index '%1$u' required for device at address '%2$s'"),
-                       info->addr.pci.bus, devStr);
+                       pci->bus, devStr);
         return NULL;
     }
 
@@ -584,7 +584,7 @@ qemuBuildDeviceAddressProps(virJSONValue *props,
     switch (info->type) {
     case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI: {
         g_autofree char *pciaddr = NULL;
-        g_autofree char *bus = qemuBuildDeviceAddressPCIGetBus(domainDef, info);
+        g_autofree char *bus = qemuBuildDeviceAddressPCIGetBus(domainDef, &info->addr.pci);
 
         if (!bus)
             return -1;
-- 
2.51.1

Re: [libvirt PATCH] qemu: make qemuBuildDeviceAddressPCIGetBus more generic
Posted by Peter Krempa via Devel 17 hours ago
On Thu, Nov 20, 2025 at 15:56:14 +0100, Ján Tomko via Devel wrote:
> From: Ján Tomko <jtomko@redhat.com>
> 
> Operate on a virPCIDeviceAddress, not virDomainDeviceInfo
> so that this can be reused to look for buses that are not
> stored in the device info.
> 
> Signed-off-by: Ján Tomko <jtomko@redhat.com>
> ---
> A prerequisite for the SMMUv3 series

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