]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
qemu: command: Always execute memory device formatter
authorPeter Krempa <pkrempa@redhat.com>
Wed, 7 Oct 2015 13:40:58 +0000 (15:40 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 18 Nov 2015 09:32:18 +0000 (10:32 +0100)
Since we already make sure before that the domain configuration is
valid we may execute it always at the cost of doing 0 iterations of the
for loop.

This patch will simplify later refactor as it will avoid whitespace
changes.

src/qemu/qemu_command.c

index 5e1e04effd925579a2d3c3a1f03fb22eecae16ac..c0b361b771d53d686fde2f8703028ed54579bb9a 100644 (file)
@@ -9401,38 +9401,37 @@ qemuBuildCommandLine(virConnectPtr conn,
         }
     }
 
-    if (virDomainNumaGetNodeCount(def->numa)) {
-        if (qemuBuildNumaArgStr(cfg, def, cmd, qemuCaps, nodeset) < 0)
+    if (virDomainNumaGetNodeCount(def->numa) &&
+        qemuBuildNumaArgStr(cfg, def, cmd, qemuCaps, nodeset) < 0)
             goto error;
 
-        /* memory hotplug requires NUMA to be enabled - we already checked
-         * that memory devices are present only when NUMA is */
+    /* memory hotplug requires NUMA to be enabled - we already checked
+     * that memory devices are present only when NUMA is */
 
-        if (def->nmems > def->mem.memory_slots) {
-            virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-                           _("memory device count '%zu' exceeds slots count '%u'"),
-                           def->nmems, def->mem.memory_slots);
-            goto error;
-        }
-
-        for (i = 0; i < def->nmems; i++) {
-            char *backStr;
-            char *dimmStr;
-
-            if (!(backStr = qemuBuildMemoryDimmBackendStr(def->mems[i], def,
-                                                          qemuCaps, cfg)))
-                goto error;
+    if (def->nmems > def->mem.memory_slots) {
+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                       _("memory device count '%zu' exceeds slots count '%u'"),
+                       def->nmems, def->mem.memory_slots);
+        goto error;
+    }
 
-            if (!(dimmStr = qemuBuildMemoryDeviceStr(def->mems[i], def, qemuCaps))) {
-                VIR_FREE(backStr);
-                goto error;
-            }
+    for (i = 0; i < def->nmems; i++) {
+        char *backStr;
+        char *dimmStr;
 
-            virCommandAddArgList(cmd, "-object", backStr, "-device", dimmStr, NULL);
+        if (!(backStr = qemuBuildMemoryDimmBackendStr(def->mems[i], def,
+                                                      qemuCaps, cfg)))
+            goto error;
 
+        if (!(dimmStr = qemuBuildMemoryDeviceStr(def->mems[i], def, qemuCaps))) {
             VIR_FREE(backStr);
-            VIR_FREE(dimmStr);
+            goto error;
         }
+
+        virCommandAddArgList(cmd, "-object", backStr, "-device", dimmStr, NULL);
+
+        VIR_FREE(backStr);
+        VIR_FREE(dimmStr);
     }
 
     virCommandAddArgList(cmd, "-uuid", uuid, NULL);