From 6ed8ba564d2e3dcf3a2e0413f5074630ce3eeb56 Mon Sep 17 00:00:00 2001 Message-Id: <6ed8ba564d2e3dcf3a2e0413f5074630ce3eeb56.1386932210.git.jdenemar@redhat.com> From: Cole Robinson Date: Mon, 9 Dec 2013 20:12:45 +0100 Subject: [PATCH] qemu: hotplug: Fix adding USB devices to the driver list https://bugzilla.redhat.com/show_bug.cgi?id=1025108 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) Signed-off-by: Jiri Denemark --- 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 a253a74..24a2096 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -1374,9 +1374,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.5.1