]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: move out legacy USB controller formatting
authorJán Tomko <jtomko@redhat.com>
Tue, 15 Jan 2019 14:33:10 +0000 (15:33 +0100)
committerJán Tomko <jtomko@redhat.com>
Fri, 25 Jan 2019 13:54:50 +0000 (14:54 +0100)
Move out the code formatting "-usb" on the QEMU command line.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Cole Robinson <crobinso@redhat.com>
src/qemu/qemu_command.c

index 9873c96c2d05f508d1ed2a7d597e5c959ba77abd..4ff526df3ee19f65ff03fc073283311614fe944f 100644 (file)
@@ -3049,6 +3049,26 @@ qemuBuildControllerDevStr(const virDomainDef *domainDef,
 }
 
 
+static int
+qemuBuildLegacyUSBControllerCommandLine(virCommandPtr cmd,
+                                        const virDomainDef *def,
+                                        int usbcontroller)
+{
+    if (usbcontroller == 0 &&
+        !qemuDomainIsQ35(def) &&
+        !qemuDomainIsARMVirt(def) &&
+        !qemuDomainIsRISCVVirt(def) &&
+        !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;
+}
+
+
 /**
  * qemuBuildSkipController:
  * @controller: Controller to check
@@ -3184,16 +3204,8 @@ qemuBuildControllerDevCommandLine(virCommandPtr cmd,
         }
     }
 
-    if (usbcontroller == 0 &&
-        !qemuDomainIsQ35(def) &&
-        !qemuDomainIsARMVirt(def) &&
-        !qemuDomainIsRISCVVirt(def) &&
-        !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");
-    }
+    if (qemuBuildLegacyUSBControllerCommandLine(cmd, def, usbcontroller) < 0)
+        goto cleanup;
 
     ret = 0;