]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu_validate: Check whether granule of virtio-iommu is supported
authorMichal Privoznik <mprivozn@redhat.com>
Wed, 21 Jan 2026 11:54:17 +0000 (12:54 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Fri, 6 Feb 2026 15:13:42 +0000 (16:13 +0100)
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>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
src/qemu/qemu_validate.c

index 94a34b6efabb7658885f821e92e4f49b97f1e043..0bad2999962457d84c55554775c98bfba0aa503b 100644 (file)
@@ -5696,6 +5696,17 @@ qemuValidateDomainDeviceDefIOMMU(const virDomainIOMMUDef *iommu,
                            _("iommu: unsupported granule size. Supported values are 4, 8, 16 and 64 KiB"));
             return -1;
         }
+
+        /* While the QEMU_CAPS_VIRTIO_IOMMU_AW_BITS tracks .aw-bits attribute of
+         * virtio-iommu it is also a good indicator of .granule attribute as both
+         * attributes were introduced in neighboring commits, in the same release,
+         * neither can be disabled at compile time and backporting one without the
+         * other makes no sense. */
+        if (!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;