]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: hotplug: Fix adding USB devices to the driver list
authorCole Robinson <crobinso@redhat.com>
Thu, 5 Dec 2013 19:59:05 +0000 (14:59 -0500)
committerCole Robinson <crobinso@redhat.com>
Mon, 9 Dec 2013 18:43:48 +0000 (13:43 -0500)
We were unconditionally removing the device from the host list, when it
should only be done on error.

This fixes USB collision detection when hotplugging the same device to
two guests.

src/qemu/qemu_hotplug.c

index b7512a71dcd849ae84a1c08700fd37c0684cd21d..16b990d9cc714e7b30366b98b6bed85529abe894 100644 (file)
@@ -1515,9 +1515,9 @@ cleanup:
             virSecurityManagerRestoreHostdevLabel(driver->securityManager,
                                                   vm->def, hostdev, NULL) < 0)
             VIR_WARN("Unable to restore host device labelling on hotplug fail");
+        if (added)
+            virUSBDeviceListSteal(driver->activeUsbHostdevs, usb);
     }
-    if (added)
-        virUSBDeviceListSteal(driver->activeUsbHostdevs, usb);
     if (list && usb &&
         !virUSBDeviceListFind(list, usb) &&
         !virUSBDeviceListFind(driver->activeUsbHostdevs, usb))