[PATCH 6/6] qemu_command: Generate granule prop for virtio-iommu

Michal Privoznik via Devel posted 6 patches 1 week, 4 days ago
There is a newer version of this series
[PATCH 6/6] qemu_command: Generate granule prop for virtio-iommu
Posted by Michal Privoznik via Devel 1 week, 4 days ago
From: Michal Privoznik <mprivozn@redhat.com>

Resolves: https://issues.redhat.com/browse/RHEL-76269
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
---
 src/qemu/qemu_command.c                                     | 6 ++++++
 .../virtio-iommu-aarch64.aarch64-latest.args                | 2 +-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 6a01d647b9..0fde2eb659 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -6285,6 +6285,7 @@ qemuBuildIOMMUCommandLine(virCommand *cmd,
         virDomainIOMMUDef *iommu = def->iommus[i];
         g_autoptr(virJSONValue) props = NULL;
         g_autoptr(virJSONValue) wrapperProps = NULL;
+        const char *granule_mode = NULL;
 
         switch (iommu->model) {
         case VIR_DOMAIN_IOMMU_MODEL_INTEL:
@@ -6306,10 +6307,15 @@ qemuBuildIOMMUCommandLine(virCommand *cmd,
             break;
 
         case VIR_DOMAIN_IOMMU_MODEL_VIRTIO:
+            if (iommu->granule_mode != VIR_DOMAIN_IOMMU_GRANULE_MODE_NONE) {
+                granule_mode = virDomainIOMMUGranuleModeTypeToString(iommu->granule_mode);
+            }
+
             if (virJSONValueObjectAdd(&props,
                                       "s:driver", "virtio-iommu",
                                       "s:id", iommu->info.alias,
                                       "z:aw-bits", iommu->aw_bits,
+                                      "S:granule", granule_mode,
                                       NULL) < 0) {
                 return -1;
             }
diff --git a/tests/qemuxmlconfdata/virtio-iommu-aarch64.aarch64-latest.args b/tests/qemuxmlconfdata/virtio-iommu-aarch64.aarch64-latest.args
index 071bc00b34..85160f3ca4 100644
--- a/tests/qemuxmlconfdata/virtio-iommu-aarch64.aarch64-latest.args
+++ b/tests/qemuxmlconfdata/virtio-iommu-aarch64.aarch64-latest.args
@@ -28,7 +28,7 @@ XDG_CONFIG_HOME=/var/lib/libvirt/qemu/domain--1-guest/.config \
 -rtc base=utc \
 -no-shutdown \
 -boot strict=on \
--device '{"driver":"virtio-iommu","id":"iommu0","aw-bits":48,"bus":"pcie.0","addr":"0x1"}' \
+-device '{"driver":"virtio-iommu","id":"iommu0","aw-bits":48,"granule":"64K","bus":"pcie.0","addr":"0x1"}' \
 -audiodev '{"id":"audio1","driver":"none"}' \
 -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \
 -msg timestamp=on
-- 
2.52.0
Re: [PATCH 6/6] qemu_command: Generate granule prop for virtio-iommu
Posted by Peter Krempa via Devel 1 week, 4 days ago
On Wed, Jan 21, 2026 at 17:27:22 +0100, Michal Privoznik via Devel wrote:
> From: Michal Privoznik <mprivozn@redhat.com>
> 
> Resolves: https://issues.redhat.com/browse/RHEL-76269
> Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
> ---
>  src/qemu/qemu_command.c                                     | 6 ++++++
>  .../virtio-iommu-aarch64.aarch64-latest.args                | 2 +-
>  2 files changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
> index 6a01d647b9..0fde2eb659 100644
> --- a/src/qemu/qemu_command.c
> +++ b/src/qemu/qemu_command.c
> @@ -6285,6 +6285,7 @@ qemuBuildIOMMUCommandLine(virCommand *cmd,
>          virDomainIOMMUDef *iommu = def->iommus[i];
>          g_autoptr(virJSONValue) props = NULL;
>          g_autoptr(virJSONValue) wrapperProps = NULL;
> +        const char *granule_mode = NULL;
>  
>          switch (iommu->model) {
>          case VIR_DOMAIN_IOMMU_MODEL_INTEL:
> @@ -6306,10 +6307,15 @@ qemuBuildIOMMUCommandLine(virCommand *cmd,
>              break;
>  
>          case VIR_DOMAIN_IOMMU_MODEL_VIRTIO:
> +            if (iommu->granule_mode != VIR_DOMAIN_IOMMU_GRANULE_MODE_NONE) {
> +                granule_mode = virDomainIOMMUGranuleModeTypeToString(iommu->granule_mode);
> +            }
> +
>              if (virJSONValueObjectAdd(&props,
>                                        "s:driver", "virtio-iommu",
>                                        "s:id", iommu->info.alias,
>                                        "z:aw-bits", iommu->aw_bits,
> +                                      "S:granule", granule_mode,

okay so you are doing a 1:1 mapping to qemu values, but I still wonder
what the intention behind the specific values is. If it's supposed to
mean the number we IMO should use proper unit. (which will require a
different enum convertor for use here).