From: Michal Privoznik Date: Wed, 21 Jan 2026 12:00:39 +0000 (+0100) Subject: qemu_command: Generate granule prop for virtio-iommu X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9373d8da6aca6a23c0cf17cddc07aac940d28994;p=thirdparty%2Flibvirt.git qemu_command: Generate granule prop for virtio-iommu Resolves: https://issues.redhat.com/browse/RHEL-76269 Signed-off-by: Michal Privoznik Reviewed-by: Peter Krempa --- diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 85f24c6307..069211e139 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -6358,6 +6358,7 @@ qemuBuildIOMMUCommandLine(virCommand *cmd, virDomainIOMMUDef *iommu = def->iommus[i]; g_autoptr(virJSONValue) props = NULL; g_autoptr(virJSONValue) wrapperProps = NULL; + g_autofree char *granule_mode = NULL; switch (iommu->model) { case VIR_DOMAIN_IOMMU_MODEL_INTEL: @@ -6379,10 +6380,19 @@ qemuBuildIOMMUCommandLine(virCommand *cmd, break; case VIR_DOMAIN_IOMMU_MODEL_VIRTIO: + if (iommu->granule != 0) { + if (iommu->granule == -1) { + granule_mode = g_strdup("host"); + } else { + granule_mode = g_strdup_printf("%dk", iommu->granule); + } + } + if (virJSONValueObjectAdd(&props, "s:driver", "virtio-iommu", "s:id", iommu->info.alias, "p: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..3c9cc0e9d1 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 diff --git a/tests/qemuxmlconfdata/virtio-iommu-x86_64.x86_64-latest.args b/tests/qemuxmlconfdata/virtio-iommu-x86_64.x86_64-latest.args index c2dbfd25ad..0d49128149 100644 --- a/tests/qemuxmlconfdata/virtio-iommu-x86_64.x86_64-latest.args +++ b/tests/qemuxmlconfdata/virtio-iommu-x86_64.x86_64-latest.args @@ -26,7 +26,7 @@ XDG_CONFIG_HOME=/var/lib/libvirt/qemu/domain--1-QEMUGuest1/.config \ -rtc base=utc \ -no-shutdown \ -boot strict=on \ --device '{"driver":"virtio-iommu","id":"iommu0","bus":"pcie.0","addr":"0x1"}' \ +-device '{"driver":"virtio-iommu","id":"iommu0","granule":"host","bus":"pcie.0","addr":"0x1"}' \ -audiodev '{"id":"audio1","driver":"none"}' \ -global ICH9-LPC.noreboot=off \ -watchdog-action reset \