Hi Jano,

On 11/20/2025 8:00 AM, Ján Tomko wrote:
Introduce support for "pciBus" driver attribute for
"smmuv3" IOMMU model. The "pciBus" attribute indicates
the index of the controller that a smmuv3 IOMMU device
is attached to, and differentiates the device-pluggable
arm-smmuv3 model from the virt-machine-associated smmuv3
model.

Signed-off-by: Nathan Chen <[email protected]>
---
docs/formatdomain.rst             |  4 +++
src/conf/domain_conf.c            | 16 +++++++++
src/conf/domain_conf.h            |  1 +
src/conf/domain_validate.c        | 28 +++++++++++++--
src/conf/schemas/domaincommon.rng |  5 +++
src/qemu/qemu_command.c           | 58 +++++++++++++++++++++++++++++--
6 files changed, 106 insertions(+), 6 deletions(-)


Reviewed-by: Ján Tomko <[email protected]>

I will squash in the following:

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index cb8bdebf62..5a834ef842 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -6241,42 +6241,24 @@ qemuBuildBootCommandLine(virCommand *cmd,

  static virJSONValue *
  qemuBuildPCINestedSmmuv3DevProps(const virDomainDef *def,
-                                 const virDomainIOMMUDef *iommu,
-                                 size_t id)
+                                 const virDomainIOMMUDef *iommu)
  {
      g_autoptr(virJSONValue) props = NULL;
      g_autofree char *bus = NULL;
-    g_autofree char *smmuv3_id = NULL;
-    size_t i;
+    virPCIDeviceAddress addr = { .bus = iommu->pci_bus };

-    for (i = 0; i < def->ncontrollers; i++) {
-        virDomainControllerDef *cont = def->controllers[i];
-        if (cont->idx == iommu->pci_bus) {
-            if (cont->type == VIR_DOMAIN_CONTROLLER_TYPE_PCI) {
-                const char *alias = cont->info.alias;
-
-                if (!alias) {
-                    return NULL;
-                } else {
-                    bus = g_strdup(alias);
-                }
-                break;
-            }
-        }
-    }
+    bus = qemuBuildDeviceAddressPCIGetBus(def, &addr);

      if (!bus) {
          virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-                        _("Could not find a suitable controller for smmuv3.")); +                        _("Could not find a suitable controller for smmuv3"));
          return NULL;
      }

-    smmuv3_id = g_strdup_printf("smmuv3.%zu", id);
-
      if (virJSONValueObjectAdd(&props,
                                "s:driver", "arm-smmuv3",
                                "s:primary-bus", bus,
-                              "s:id", smmuv3_id,
+                              "s:id", iommu->info.alias,
                                NULL) < 0)
          return NULL;

@@ -6361,7 +6343,7 @@ qemuBuildIOMMUCommandLine(virCommand *cmd,

          case VIR_DOMAIN_IOMMU_MODEL_SMMUV3:
              if (iommu->pci_bus >= 0) {
-                if (!(props = qemuBuildPCINestedSmmuv3DevProps(def, iommu, i))) +                if (!(props = qemuBuildPCINestedSmmuv3DevProps(def, iommu)))
                      return -1;
                 if (qemuBuildDeviceCommandlineFromJSON(cmd, props, def, qemuCaps) < 0)
                      return -1;

Thank you for your review - I tried applying this proposed squash locally and I'm seeing a compilation error where qemuBuildDeviceAddressPCIGetBus() expects a virDomainDeviceInfo * for the second input argument instead of the virPCIDeviceAddress * passed to it. Would you agree with revising it to the following changes?

Change these lines:
    virPCIDeviceAddress addr = { .bus = iommu->pci_bus };
    bus = qemuBuildDeviceAddressPCIGetBus(def, &addr);

Into something like:
    virDomainDeviceInfo tempInfo = { 0 };
    tempInfo.addr.pci.bus = iommu->pci_bus;
    bus = qemuBuildDeviceAddressPCIGetBus(def, &tempInfo);

In addition, the tests/qemuxmlconfdata/iommu-smmuv3-pci-bus.aarch64-latest.args in the later qemuxmlconftest commit needs to change the nested smmuv3's id value to be "iommu0" and "iommu1" instead of "smmuv3.0" and "smmuv3.1" after we base it on iommu->info.alias in this squash.

-Nathan

Reply via email to