[libvirt PATCH 19/21] qemu: Generate command line for virtio-iommu

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

Signed-off-by: Andrea Bolognani <abologna@xxxxxxxxxx>
---
 src/qemu/qemu_command.c                         | 17 ++++++++++++++---
 .../virtio-iommu-aarch64.aarch64-latest.args    |  1 +
 .../virtio-iommu-x86_64.x86_64-latest.args      |  1 +
 3 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index ef5ebe6413..9941e2a10b 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -6204,10 +6204,11 @@ qemuBuildBootCommandLine(virCommand *cmd,
 
 static int
 qemuBuildIOMMUCommandLine(virCommand *cmd,
-                          const virDomainDef *def)
+                          const virDomainDef *def,
+                          virQEMUCaps *qemuCaps)
 {
     g_auto(virBuffer) opts = VIR_BUFFER_INITIALIZER;
-    const virDomainIOMMUDef *iommu = def->iommu;
+    virDomainIOMMUDef *iommu = def->iommu;
 
     if (!iommu)
         return 0;
@@ -6239,6 +6240,16 @@ qemuBuildIOMMUCommandLine(virCommand *cmd,
         break;
 
     case VIR_DOMAIN_IOMMU_MODEL_VIRTIO:
+        if (qemuBuildVirtioDevStr(&opts, "virtio-iommu", qemuCaps,
+                                  VIR_DOMAIN_DEVICE_IOMMU, iommu) < 0) {
+            return -1;
+        }
+
+        if (qemuBuildDeviceAddressStr(&opts, def, &iommu->info) < 0)
+            return -1;
+
+        virCommandAddArg(cmd, "-device");
+        virCommandAddArgBuffer(cmd, &opts);
         break;
 
     case VIR_DOMAIN_IOMMU_MODEL_SMMUV3:
@@ -10493,7 +10504,7 @@ qemuBuildCommandLine(virQEMUDriver *driver,
     if (qemuBuildBootCommandLine(cmd, def) < 0)
         return NULL;
 
-    if (qemuBuildIOMMUCommandLine(cmd, def) < 0)
+    if (qemuBuildIOMMUCommandLine(cmd, def, qemuCaps) < 0)
         return NULL;
 
     if (qemuBuildGlobalControllerCommandLine(cmd, def) < 0)
diff --git a/tests/qemuxml2argvdata/virtio-iommu-aarch64.aarch64-latest.args b/tests/qemuxml2argvdata/virtio-iommu-aarch64.aarch64-latest.args
index 0363b0370d..3f33abd696 100644
--- a/tests/qemuxml2argvdata/virtio-iommu-aarch64.aarch64-latest.args
+++ b/tests/qemuxml2argvdata/virtio-iommu-aarch64.aarch64-latest.args
@@ -29,6 +29,7 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-guest/.config \
 -rtc base=utc \
 -no-shutdown \
 -boot strict=on \
+-device virtio-iommu-pci,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 8a1413d33d..7249d29b93 100644
--- a/tests/qemuxml2argvdata/virtio-iommu-x86_64.x86_64-latest.args
+++ b/tests/qemuxml2argvdata/virtio-iommu-x86_64.x86_64-latest.args
@@ -25,6 +25,7 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \
 -rtc base=utc \
 -no-shutdown \
 -boot strict=on \
+-device virtio-iommu-pci,bus=pcie.0,addr=0x1 \
 -audiodev id=audio1,driver=none \
 -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \
 -msg timestamp=on
-- 
2.31.1




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux