[PATCH 5/6] qemu_validate: Check whether granule of virtio-iommu is supported

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

Just like with other features, check whether QEMU supports them
based on capabilities. Now, instead of inventing a new QEMU
capability, an existing one can be used:
QEMU_CAPS_VIRTIO_IOMMU_AW_BITS.

This is because the aw-bits and granule attributes were
introduced into QEMU in close succession (v9.0.0-rc0~9^2~7
v9.0.0-rc0~9^2~11), neither can be disabled at compile time and
backporting just one without the other makes almost no sense.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
---
 src/qemu/qemu_validate.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c
index ab8a1938c1..f5072941c5 100644
--- a/src/qemu/qemu_validate.c
+++ b/src/qemu/qemu_validate.c
@@ -5684,6 +5684,12 @@ qemuValidateDomainDeviceDefIOMMU(const virDomainIOMMUDef *iommu,
                        _("iommu: updating dma translation is not supported with this QEMU binary"));
         return -1;
     }
+    if (iommu->granule_mode != VIR_DOMAIN_IOMMU_GRANULE_MODE_NONE &&
+        !virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_IOMMU_AW_BITS)) {
+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                       _("iommu: page granule is not supported with this QEMU binary"));
+        return -1;
+    }
 
     return 0;
 }
-- 
2.52.0
Re: [PATCH 5/6] qemu_validate: Check whether granule of virtio-iommu is supported
Posted by Peter Krempa via Devel 1 week, 4 days ago
On Wed, Jan 21, 2026 at 17:27:21 +0100, Michal Privoznik via Devel wrote:
> From: Michal Privoznik <mprivozn@redhat.com>
> 
> Just like with other features, check whether QEMU supports them
> based on capabilities. Now, instead of inventing a new QEMU
> capability, an existing one can be used:
> QEMU_CAPS_VIRTIO_IOMMU_AW_BITS.
> 
> This is because the aw-bits and granule attributes were
> introduced into QEMU in close succession (v9.0.0-rc0~9^2~7
> v9.0.0-rc0~9^2~11), neither can be disabled at compile time and
> backporting just one without the other makes almost no sense.

A similar justification, possibly a bit more condensed ...


> 
> Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
> ---
>  src/qemu/qemu_validate.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c
> index ab8a1938c1..f5072941c5 100644
> --- a/src/qemu/qemu_validate.c
> +++ b/src/qemu/qemu_validate.c
> @@ -5684,6 +5684,12 @@ qemuValidateDomainDeviceDefIOMMU(const virDomainIOMMUDef *iommu,
>                         _("iommu: updating dma translation is not supported with this QEMU binary"));
>          return -1;
>      }

... needs to be put into a comment somewhere here.


> +    if (iommu->granule_mode != VIR_DOMAIN_IOMMU_GRANULE_MODE_NONE &&
> +        !virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_IOMMU_AW_BITS)) {
> +        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
> +                       _("iommu: page granule is not supported with this QEMU binary"));
> +        return -1;
> +    }
>  
>      return 0;
>  }
> -- 
> 2.52.0
>