From: Michal Privoznik <[email protected]>
Resolves: https://issues.redhat.com/browse/RHEL-76269
Signed-off-by: Michal Privoznik <[email protected]>
---
src/qemu/qemu_command.c | 10 ++++++++++
.../virtio-iommu-aarch64.aarch64-latest.args | 2 +-
.../virtio-iommu-x86_64.x86_64-latest.args | 2 +-
3 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 953156ce2a..b271f48dbf 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -6285,6 +6285,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:
@@ -6306,10 +6307,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 \
--
2.52.0