From 2d41980768d85a6536dfc34e210ff5f95493434c Mon Sep 17 00:00:00 2001 From: Michal Privoznik <mprivozn@redhat.com> Date: Thu, 12 Jul 2012 00:35:12 +0800 Subject: [PATCH] qemu: Don't delete USB device on failed qemuPrepareHostdevUSBDevices To: libvir-list@redhat.com (cherry picked from commit 9c484e3dc5464dfbb538744360b401a0bc59c1c6) Resolve BZ:https://bugzilla.redhat.com/show_bug.cgi?id=816601 If qemuPrepareHostdevUSBDevices fail it will roll back devices added to the driver list of used devices. However, if it may fail because the device is being used already. But then again - with roll back. Therefore don't try to remove a usb device manually if the function fail. Although, we want to remove the device if any operation performed afterwards fail. Conflicts: src/qemu/qemu_hotplug.c Signed-off-by: Daniel Veillard <veillard@redhat.com> --- src/qemu/qemu_driver.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 0889c7e..14cb41d 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -8367,8 +8367,10 @@ static int qemudDomainAttachHostDevice(struct qemud_driver *driver, goto cleanup; } - if (qemuPrepareHostdevUSBDevices(driver, vm->def->name, list) < 0) + if (qemuPrepareHostdevUSBDevices(driver, vm->def->name, list) < 0) { + usb = NULL; goto cleanup; + } usbDeviceListSteal(list, usb); } -- 1.7.7.6