render / rpms / libvirt

Forked from rpms/libvirt 10 months ago
Clone
3e5111
From 657451fe2a5e8b55adbae643ac818b496c9cbc0c Mon Sep 17 00:00:00 2001
3e5111
Message-Id: <657451fe2a5e8b55adbae643ac818b496c9cbc0c@dist-git>
3e5111
From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
3e5111
Date: Tue, 16 May 2017 10:44:51 +0200
3e5111
Subject: [PATCH] qemu: refactor qemuBuildIOMMUCommandLine
3e5111
MIME-Version: 1.0
3e5111
Content-Type: text/plain; charset=UTF-8
3e5111
Content-Transfer-Encoding: 8bit
3e5111
3e5111
Introduce a separate buffer for options and use a helper
3e5111
variable for def->iommu.
3e5111
3e5111
(cherry picked from commit b595cc05e83288b743d48904964e4dcb547a2d26)
3e5111
Signed-off-by: Ján Tomko <jtomko@redhat.com>
3e5111
3e5111
https://bugzilla.redhat.com/show_bug.cgi?id=1427005
3e5111
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
3e5111
---
3e5111
 src/qemu/qemu_command.c | 21 +++++++++++++++------
3e5111
 1 file changed, 15 insertions(+), 6 deletions(-)
3e5111
3e5111
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
3e5111
index 4d3a3d8ca..b27b9f8ad 100644
3e5111
--- a/src/qemu/qemu_command.c
3e5111
+++ b/src/qemu/qemu_command.c
3e5111
@@ -6664,33 +6664,42 @@ qemuBuildIOMMUCommandLine(virCommandPtr cmd,
3e5111
                           const virDomainDef *def,
3e5111
                           virQEMUCapsPtr qemuCaps)
3e5111
 {
3e5111
-    if (!def->iommu)
3e5111
+    virBuffer opts = VIR_BUFFER_INITIALIZER;
3e5111
+    const virDomainIOMMUDef *iommu = def->iommu;
3e5111
+    int ret = -1;
3e5111
+
3e5111
+    if (!iommu)
3e5111
         return 0;
3e5111
 
3e5111
     if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_MACHINE_IOMMU))
3e5111
         return 0; /* Already handled via -machine */
3e5111
 
3e5111
-    switch (def->iommu->model) {
3e5111
+    switch (iommu->model) {
3e5111
     case VIR_DOMAIN_IOMMU_MODEL_INTEL:
3e5111
         if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_INTEL_IOMMU)) {
3e5111
             virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
3e5111
                            _("IOMMU device: '%s' is not supported with "
3e5111
                              "this QEMU binary"),
3e5111
-                           virDomainIOMMUModelTypeToString(def->iommu->model));
3e5111
+                           virDomainIOMMUModelTypeToString(iommu->model));
3e5111
             return -1;
3e5111
         }
3e5111
         if (!qemuDomainIsQ35(def)) {
3e5111
             virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
3e5111
                            _("IOMMU device: '%s' is only supported with "
3e5111
                              "Q35 machines"),
3e5111
-                           virDomainIOMMUModelTypeToString(def->iommu->model));
3e5111
+                           virDomainIOMMUModelTypeToString(iommu->model));
3e5111
             return -1;
3e5111
         }
3e5111
-        virCommandAddArgList(cmd, "-device", "intel-iommu", NULL);
3e5111
+        virBufferAddLit(&opts, "intel-iommu");
3e5111
     case VIR_DOMAIN_IOMMU_MODEL_LAST:
3e5111
         break;
3e5111
     }
3e5111
-    return 0;
3e5111
+    virCommandAddArg(cmd, "-device");
3e5111
+    virCommandAddArgBuffer(cmd, &opts);
3e5111
+
3e5111
+    ret = 0;
3e5111
+    virBufferFreeAndReset(&opts);
3e5111
+    return ret;
3e5111
 }
3e5111
 
3e5111
 
3e5111
-- 
3e5111
2.13.0
3e5111