]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: Don't delete USB device on failed qemuPrepareHostdevUSBDevices
authorMichal Privoznik <mprivozn@redhat.com>
Thu, 17 May 2012 11:40:52 +0000 (13:40 +0200)
committerCole Robinson <crobinso@redhat.com>
Thu, 14 Jun 2012 22:22:51 +0000 (18:22 -0400)
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.
(cherry picked from commit 9c484e3dc5464dfbb538744360b401a0bc59c1c6)

src/qemu/qemu_hotplug.c

index 409d28841daff6c4905c2c72769f6fa64f3c9501..a91c7095e6e143042230394f7d4cad4060d046a8 100644 (file)
@@ -1173,8 +1173,10 @@ int qemuDomainAttachHostDevice(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);
     }