]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: Clean up qemuBuildControllerDevCommandLine()
authorAndrea Bolognani <abologna@redhat.com>
Mon, 4 Sep 2017 16:05:43 +0000 (18:05 +0200)
committerAndrea Bolognani <abologna@redhat.com>
Thu, 7 Sep 2017 12:13:40 +0000 (14:13 +0200)
Add a 'cleanup' label and improve the readability of one of the
checks by making it conform to our formatting standard and moving
the corresponding comment.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Laine Stump <laine@laine.org>
src/qemu/qemu_command.c

index ed8cb6e2bf1ea1612a1de7c7ab44746284909c5c..e57a3278e09b9feaa680c26eb16fdc6fa5118041 100644 (file)
@@ -3125,6 +3125,7 @@ qemuBuildControllerDevCommandLine(virCommandPtr cmd,
         VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL,
         VIR_DOMAIN_CONTROLLER_TYPE_CCID,
     };
+    int ret = -1;
 
     for (j = 0; j < ARRAY_CARDINALITY(contOrder); j++) {
         for (i = 0; i < def->ncontrollers; i++) {
@@ -3186,7 +3187,7 @@ qemuBuildControllerDevCommandLine(virCommandPtr cmd,
                     virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
                                    _("Multiple legacy USB controllers are "
                                      "not supported"));
-                    return -1;
+                    goto cleanup;
                 }
                 usblegacy = true;
                 continue;
@@ -3194,7 +3195,7 @@ qemuBuildControllerDevCommandLine(virCommandPtr cmd,
 
             if (qemuBuildControllerDevStr(def, cont, qemuCaps,
                                           &devstr, &usbcontroller) < 0)
-                return -1;
+                goto cleanup;
 
             if (devstr) {
                 virCommandAddArg(cmd, "-device");
@@ -3204,16 +3205,20 @@ qemuBuildControllerDevCommandLine(virCommandPtr cmd,
         }
     }
 
-    /* We haven't added any USB controller yet, but we haven't been asked
-     * not to add one either. Add a legacy USB controller, unless we're
-     * creating a kind of guest we want to keep legacy-free */
     if (usbcontroller == 0 &&
         !qemuDomainIsQ35(def) &&
         !qemuDomainIsVirt(def) &&
-        !ARCH_IS_S390(def->os.arch))
+        !ARCH_IS_S390(def->os.arch)) {
+        /* We haven't added any USB controller yet, but we haven't been asked
+         * not to add one either. Add a legacy USB controller, unless we're
+         * creating a kind of guest we want to keep legacy-free */
         virCommandAddArg(cmd, "-usb");
+    }
 
-    return 0;
+    ret = 0;
+
+ cleanup:
+    return ret;
 }