On Mon, Jan 26, 2026 at 10:50:19 +0100, Michal Privoznik via Devel wrote:
From: Michal Privoznik <mprivozn@redhat.com>
In PCI assignment scenario the virtio-iommu needs to know the guest page size also known as granule. Expose it as an attribute to the <driver/> element of a virtio-iommu.
This is possibly interesting only for aarch64 since it supports virtio-iommu and also supports running guests with different page size than the host.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- docs/formatdomain.rst | 38 ++++++++- src/conf/domain_conf.c | 77 ++++++++++++++++++- src/conf/domain_conf.h | 1 + src/conf/domain_validate.c | 9 ++- src/conf/schemas/domaincommon.rng | 22 ++++++ src/qemu/qemu_validate.c | 11 +++ .../virtio-iommu-aarch64.aarch64-latest.xml | 4 +- .../qemuxmlconfdata/virtio-iommu-aarch64.xml | 4 +- .../virtio-iommu-x86_64.x86_64-latest.xml | 3 + tests/qemuxmlconfdata/virtio-iommu-x86_64.xml | 6 +- 10 files changed, 166 insertions(+), 9 deletions(-)
[..]
@@ -14522,6 +14539,41 @@ virDomainIOMMUDefParseXML(virDomainXMLOption *xmlopt, if (virXMLPropInt(driver, "pciBus", 10, VIR_XML_PROP_NONE, &iommu->pci_bus, -1) < 0) return NULL; + + if ((granule = virXPathNode("./driver/granule", ctxt))) { + g_autofree char *mode = virXMLPropString(granule, "mode"); + unsigned long long size; + int rc; + + rc = virDomainParseMemory("./driver/granule/@size", + "./driver/granule/@unit", + ctxt, &size, false, false); + if (rc < 0) { + return NULL; + } else if (rc > 0) { + if (mode) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("'mode' and 'size' can't be specified at the same time for 'granule'")); + return NULL; + } + + if (size != (int) size) {
Consider using VIR_ASSIGN_IS_OVERFLOW
+ virReportError(VIR_ERR_OVERFLOW, "%s", _("size value too large")); + return NULL; + } + + iommu->granule = (int)size; + } else { + if (STREQ_NULLABLE(mode, "host")) { + iommu->granule = -1; + } else if (mode) { + virReportError(VIR_ERR_XML_ERROR, + _("Invalid value for attribute '%1$s' in element '%2$s': '%3$s'."), + "mode", "granule", mode); + return NULL; + } + } + } }
if (virDomainDeviceInfoParseXML(xmlopt, node, ctxt,
Reviewed-by: Peter Krempa <pkrempa@redhat.com>