[libvirt] [PATCH 3/3] qemu: hotplug: Fix adding USB devices to the driver list

Cole Robinson crobinso at redhat.com
Thu Dec 5 20:40:28 UTC 2013


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 | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index b7512a7..16b990d 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -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))
-- 
1.8.4.2




More information about the libvir-list mailing list