[PATCH 3/3] qemu: format intel-iommu on the command line

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

 



<devices>
  <iommu model='intel-iommu'/>
</devices>

results in:

-device intel-iommu

https://bugzilla.redhat.com/show_bug.cgi?id=1235580
---
 src/qemu/qemu_command.c                            | 30 ++++++++++++++++++++++
 .../qemuxml2argvdata/qemuxml2argv-intel-iommu.args | 22 ++++++++++++++++
 tests/qemuxml2argvtest.c                           |  2 ++
 3 files changed, 54 insertions(+)
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-intel-iommu.args

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 6944129..9f1d447 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -6171,6 +6171,33 @@ qemuBuildBootCommandLine(virCommandPtr cmd,
 
 
 static int
+qemuBuildIOMMUCommandLine(virCommandPtr cmd,
+                          const virDomainDef *def,
+                          virQEMUCapsPtr qemuCaps)
+{
+    if (!def->iommu)
+        return 0;
+
+    switch (def->iommu->model) {
+    case VIR_DOMAIN_IOMMU_MODEL_INTEL:
+        if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_INTEL_IOMMU)) {
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                           _("IOMMU device: '%s' is not supported with "
+                             "this QEMU binary"),
+                           virDomainIOMMUModelTypeToString(def->iommu->model));
+            return -1;
+        }
+        virCommandAddArgList(cmd, "-device",
+                             virDomainIOMMUModelTypeToString(def->iommu->model),
+                             NULL);
+    case VIR_DOMAIN_IOMMU_MODEL_LAST:
+        break;
+    }
+    return 0;
+}
+
+
+static int
 qemuBuildGlobalControllerCommandLine(virCommandPtr cmd,
                                      const virDomainDef *def,
                                      virQEMUCapsPtr qemuCaps)
@@ -9254,6 +9281,9 @@ qemuBuildCommandLine(virQEMUDriverPtr driver,
     if (qemuBuildBootCommandLine(cmd, def, qemuCaps, &emitBootindex) < 0)
         goto error;
 
+    if (qemuBuildIOMMUCommandLine(cmd, def, qemuCaps) < 0)
+        goto error;
+
     if (qemuBuildGlobalControllerCommandLine(cmd, def, qemuCaps) < 0)
         goto error;
 
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-intel-iommu.args b/tests/qemuxml2argvdata/qemuxml2argv-intel-iommu.args
new file mode 100644
index 0000000..69e4490
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-intel-iommu.args
@@ -0,0 +1,22 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/home/test \
+USER=test \
+LOGNAME=test \
+QEMU_AUDIO_DRV=none \
+/usr/bin/qemu \
+-name QEMUGuest1 \
+-S \
+-M q35 \
+-m 214 \
+-smp 1 \
+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
+-nographic \
+-nodefaults \
+-monitor unix:/tmp/lib/domain--1-QEMUGuest1/monitor.sock,server,nowait \
+-no-acpi \
+-boot c \
+-device intel-iommu \
+-device i82801b11-bridge,id=pci.1,bus=pcie.0,addr=0x1e \
+-device pci-bridge,chassis_nr=2,id=pci.2,bus=pci.1,addr=0x0 \
+-device virtio-balloon-pci,id=balloon0,bus=pci.2,addr=0x1
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index a4b8bf4..59fa420 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -2023,6 +2023,8 @@ mymain(void)
                               QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_USB_HUB);
 
     DO_TEST("acpi-table", NONE);
+    DO_TEST("intel-iommu", QEMU_CAPS_DEVICE_PCI_BRIDGE,
+            QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE, QEMU_CAPS_DEVICE_INTEL_IOMMU);
 
     qemuTestDriverFree(&driver);
 
-- 
2.7.3

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[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]