[libvirt] [PATCH 09/10] qemu: Reorganize IOThread -object arguments

John Ferlan jferlan at redhat.com
Wed Feb 17 00:44:19 UTC 2016


Reorganize the module to put all the IOThread argument processing code
together after the -smp to form a logical order of processing for
qemuBuildCommandLine working top down in the module.

Signed-off-by: John Ferlan <jferlan at redhat.com>
---
 src/qemu/qemu_command.c | 56 +++++++++++++++++++++++++++++++++----------------
 1 file changed, 38 insertions(+), 18 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index c90650f..3000e8f 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -1035,6 +1035,42 @@ qemuBuildSmpCommandLine(virCommandPtr cmd,
 }
 
 
+/** Start IOThread -object arguments */
+static int
+qemuBuildIOThreadCommandLine(virCommandPtr cmd,
+                             const virDomainDef *def,
+                             virQEMUCapsPtr qemuCaps)
+{
+    size_t i;
+
+    if (def->niothreadids == 0)
+        return 0;
+
+    if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_IOTHREAD)) {
+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                       _("IOThreads not supported for this QEMU"));
+        goto error;
+    }
+
+    /* Create iothread objects using the defined iothreadids list
+     * and the defined id and name from the list. These may be used
+     * by a disk definition which will associate to an iothread by
+     * supplying a value of an id from the list
+     */
+    for (i = 0; i < def->niothreadids; i++) {
+        virCommandAddArg(cmd, "-object");
+        virCommandAddArgFormat(cmd, "iothread,id=iothread%u",
+                               def->iothreadids[i]->iothread_id);
+    }
+
+    return 0;
+
+ error:
+    return -1;
+
+}
+
+
 static int
 qemuBuildObjectCommandLinePropsInternal(const char *key,
                                         const virJSONValue *value,
@@ -6924,24 +6960,8 @@ qemuBuildCommandLine(virConnectPtr conn,
     if (qemuBuildSmpCommandLine(cmd, def, qemuCaps) < 0)
         goto error;
 
-    if (def->niothreadids) {
-        if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_IOTHREAD)) {
-            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                           _("IOThreads not supported for this QEMU"));
-            goto error;
-        }
-
-        /* Create iothread objects using the defined iothreadids list
-         * and the defined id and name from the list. These may be used
-         * by a disk definition which will associate to an iothread by
-         * supplying a value of an id from the list
-         */
-        for (i = 0; i < def->niothreadids; i++) {
-            virCommandAddArg(cmd, "-object");
-            virCommandAddArgFormat(cmd, "iothread,id=iothread%u",
-                                   def->iothreadids[i]->iothread_id);
-        }
-    }
+    if (qemuBuildIOThreadCommandLine(cmd, def, qemuCaps) < 0)
+        goto error;
 
     if (virDomainNumaGetNodeCount(def->numa) &&
         qemuBuildNumaArgStr(cfg, def, cmd, qemuCaps, nodeset) < 0)
-- 
2.5.0




More information about the libvir-list mailing list