]> 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 22:25:18 +0000 (17:25 -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.

(cherry picked from commit 586b0ed81828a443717b018989f2bced1bcfac01)

src/qemu/qemu_hotplug.c

index 96033ac54c37b8732a8c7db7671bef693c0f3c55..a483b4de60cf4231a7df52688a906ee5b0403ba1 100644 (file)
@@ -1498,9 +1498,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))