From: Michal Privoznik Date: Wed, 21 Jan 2026 11:54:17 +0000 (+0100) Subject: qemu_validate: Check whether granule of virtio-iommu is supported X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2eea8e3829931e531c87102409f94d46e92cd842;p=thirdparty%2Flibvirt.git qemu_validate: Check whether granule of virtio-iommu is supported 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 Reviewed-by: Peter Krempa --- diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c index 94a34b6efa..0bad299996 100644 --- a/src/qemu/qemu_validate.c +++ b/src/qemu/qemu_validate.c @@ -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;