]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: exit early if USB_CONTROLLER_MODEL_NONE is present
authorJán Tomko <jtomko@redhat.com>
Tue, 15 Jan 2019 14:46:39 +0000 (15:46 +0100)
committerJán Tomko <jtomko@redhat.com>
Fri, 25 Jan 2019 13:54:50 +0000 (14:54 +0100)
This removes the need to mark it in the 'usbcontroller' variable.

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

index 4ff526df3ee19f65ff03fc073283311614fe944f..e108ad1e862e3e24bd6a7f60ca3ea4645bda8e23 100644 (file)
@@ -3054,6 +3054,19 @@ qemuBuildLegacyUSBControllerCommandLine(virCommandPtr cmd,
                                         const virDomainDef *def,
                                         int usbcontroller)
 {
+    size_t i;
+
+    for (i = 0; i < def->ncontrollers; i++) {
+        virDomainControllerDefPtr cont = def->controllers[i];
+
+        if (cont->type != VIR_DOMAIN_CONTROLLER_TYPE_USB)
+            continue;
+
+        /* If we have mode='none', there are no other USB controllers */
+        if (cont->model == VIR_DOMAIN_CONTROLLER_MODEL_USB_NONE)
+            return 0;
+    }
+
     if (usbcontroller == 0 &&
         !qemuDomainIsQ35(def) &&
         !qemuDomainIsARMVirt(def) &&
@@ -3155,7 +3168,6 @@ qemuBuildControllerDevCommandLine(virCommandPtr cmd,
             /* skip USB controllers with type none.*/
             if (cont->type == VIR_DOMAIN_CONTROLLER_TYPE_USB &&
                 cont->model == VIR_DOMAIN_CONTROLLER_MODEL_USB_NONE) {
-                usbcontroller = -1; /* mark we don't want a controller */
                 continue;
             }