[libvirt PATCH 3/3] qemu: Add IOMMU device alias to command line

Andrea Bolognani abologna at redhat.com
Thu Jul 21 09:32:29 UTC 2022


Note that we can only do this for intel-iommu and virtio-iommu,
which are configured using -device; smmuv3 is configured using
a machine type property, so there's no room on the command line
for an alias in that case.

https://bugzilla.redhat.com/show_bug.cgi?id=2108483

Signed-off-by: Andrea Bolognani <abologna at redhat.com>
---
 src/qemu/qemu_command.c                                         | 2 ++
 tests/qemuxml2argvdata/intel-iommu-aw-bits.x86_64-latest.args   | 2 +-
 .../intel-iommu-caching-mode.x86_64-latest.args                 | 2 +-
 .../intel-iommu-device-iotlb.x86_64-latest.args                 | 2 +-
 tests/qemuxml2argvdata/intel-iommu-eim.x86_64-latest.args       | 2 +-
 tests/qemuxml2argvdata/intel-iommu.x86_64-latest.args           | 2 +-
 tests/qemuxml2argvdata/virtio-iommu-aarch64.aarch64-latest.args | 2 +-
 tests/qemuxml2argvdata/virtio-iommu-x86_64.x86_64-latest.args   | 2 +-
 8 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 262fffe5fe..30c9bbbf2e 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -6441,6 +6441,7 @@ qemuBuildIOMMUCommandLine(virCommand *cmd,
     case VIR_DOMAIN_IOMMU_MODEL_INTEL:
         if (virJSONValueObjectAdd(&props,
                                   "s:driver", "intel-iommu",
+                                  "s:id", iommu->info.alias,
                                   "S:intremap", qemuOnOffAuto(iommu->intremap),
                                   "T:caching-mode", iommu->caching_mode,
                                   "S:eim", qemuOnOffAuto(iommu->eim),
@@ -6457,6 +6458,7 @@ qemuBuildIOMMUCommandLine(virCommand *cmd,
     case VIR_DOMAIN_IOMMU_MODEL_VIRTIO:
         if (virJSONValueObjectAdd(&props,
                                   "s:driver", "virtio-iommu",
+                                  "s:id", iommu->info.alias,
                                   NULL) < 0) {
             return -1;
         }
diff --git a/tests/qemuxml2argvdata/intel-iommu-aw-bits.x86_64-latest.args b/tests/qemuxml2argvdata/intel-iommu-aw-bits.x86_64-latest.args
index f61ff3f8ff..df11e3ddab 100644
--- a/tests/qemuxml2argvdata/intel-iommu-aw-bits.x86_64-latest.args
+++ b/tests/qemuxml2argvdata/intel-iommu-aw-bits.x86_64-latest.args
@@ -27,7 +27,7 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \
 -no-shutdown \
 -no-acpi \
 -boot strict=on \
--device '{"driver":"intel-iommu","intremap":"on","aw-bits":48}' \
+-device '{"driver":"intel-iommu","id":"iommu0","intremap":"on","aw-bits":48}' \
 -audiodev '{"id":"audio1","driver":"none"}' \
 -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \
 -msg timestamp=on
diff --git a/tests/qemuxml2argvdata/intel-iommu-caching-mode.x86_64-latest.args b/tests/qemuxml2argvdata/intel-iommu-caching-mode.x86_64-latest.args
index 083c6bfe4b..47976fa6a7 100644
--- a/tests/qemuxml2argvdata/intel-iommu-caching-mode.x86_64-latest.args
+++ b/tests/qemuxml2argvdata/intel-iommu-caching-mode.x86_64-latest.args
@@ -27,7 +27,7 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \
 -no-shutdown \
 -no-acpi \
 -boot strict=on \
--device '{"driver":"intel-iommu","intremap":"on","caching-mode":true}' \
+-device '{"driver":"intel-iommu","id":"iommu0","intremap":"on","caching-mode":true}' \
 -audiodev '{"id":"audio1","driver":"none"}' \
 -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \
 -msg timestamp=on
diff --git a/tests/qemuxml2argvdata/intel-iommu-device-iotlb.x86_64-latest.args b/tests/qemuxml2argvdata/intel-iommu-device-iotlb.x86_64-latest.args
index fc06e15191..af36c45292 100644
--- a/tests/qemuxml2argvdata/intel-iommu-device-iotlb.x86_64-latest.args
+++ b/tests/qemuxml2argvdata/intel-iommu-device-iotlb.x86_64-latest.args
@@ -27,7 +27,7 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \
 -no-shutdown \
 -no-acpi \
 -boot strict=on \
--device '{"driver":"intel-iommu","intremap":"on","device-iotlb":true}' \
+-device '{"driver":"intel-iommu","id":"iommu0","intremap":"on","device-iotlb":true}' \
 -audiodev '{"id":"audio1","driver":"none"}' \
 -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \
 -msg timestamp=on
diff --git a/tests/qemuxml2argvdata/intel-iommu-eim.x86_64-latest.args b/tests/qemuxml2argvdata/intel-iommu-eim.x86_64-latest.args
index c8dd31c5fe..8e2b54d1f9 100644
--- a/tests/qemuxml2argvdata/intel-iommu-eim.x86_64-latest.args
+++ b/tests/qemuxml2argvdata/intel-iommu-eim.x86_64-latest.args
@@ -27,7 +27,7 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \
 -no-shutdown \
 -no-acpi \
 -boot strict=on \
--device '{"driver":"intel-iommu","intremap":"on","eim":"on"}' \
+-device '{"driver":"intel-iommu","id":"iommu0","intremap":"on","eim":"on"}' \
 -audiodev '{"id":"audio1","driver":"none"}' \
 -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \
 -msg timestamp=on
diff --git a/tests/qemuxml2argvdata/intel-iommu.x86_64-latest.args b/tests/qemuxml2argvdata/intel-iommu.x86_64-latest.args
index db69543298..c99efd229b 100644
--- a/tests/qemuxml2argvdata/intel-iommu.x86_64-latest.args
+++ b/tests/qemuxml2argvdata/intel-iommu.x86_64-latest.args
@@ -27,7 +27,7 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \
 -no-shutdown \
 -no-acpi \
 -boot strict=on \
--device '{"driver":"intel-iommu"}' \
+-device '{"driver":"intel-iommu","id":"iommu0"}' \
 -audiodev '{"id":"audio1","driver":"none"}' \
 -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \
 -msg timestamp=on
diff --git a/tests/qemuxml2argvdata/virtio-iommu-aarch64.aarch64-latest.args b/tests/qemuxml2argvdata/virtio-iommu-aarch64.aarch64-latest.args
index 9c1de8ae9b..54f069c350 100644
--- a/tests/qemuxml2argvdata/virtio-iommu-aarch64.aarch64-latest.args
+++ b/tests/qemuxml2argvdata/virtio-iommu-aarch64.aarch64-latest.args
@@ -30,7 +30,7 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-guest/.config \
 -rtc base=utc \
 -no-shutdown \
 -boot strict=on \
--device '{"driver":"virtio-iommu","bus":"pcie.0","addr":"0x1"}' \
+-device '{"driver":"virtio-iommu","id":"iommu0","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/qemuxml2argvdata/virtio-iommu-x86_64.x86_64-latest.args b/tests/qemuxml2argvdata/virtio-iommu-x86_64.x86_64-latest.args
index 7e0aa7192d..744367c6c0 100644
--- a/tests/qemuxml2argvdata/virtio-iommu-x86_64.x86_64-latest.args
+++ b/tests/qemuxml2argvdata/virtio-iommu-x86_64.x86_64-latest.args
@@ -26,7 +26,7 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \
 -rtc base=utc \
 -no-shutdown \
 -boot strict=on \
--device '{"driver":"virtio-iommu","bus":"pcie.0","addr":"0x1"}' \
+-device '{"driver":"virtio-iommu","id":"iommu0","bus":"pcie.0","addr":"0x1"}' \
 -audiodev '{"id":"audio1","driver":"none"}' \
 -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \
 -msg timestamp=on
-- 
2.35.3



More information about the libvir-list mailing list