[libvirt] [PATCH] qemu: Don't delete USB device on failed qemuPrepareHostdevUSBDevices

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. --- src/qemu/qemu_hotplug.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 9b60816..dfca7e2 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -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); } -- 1.7.8.5

On 05/17/2012 08:34 PM, Michal Privoznik wrote:
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. --- src/qemu/qemu_hotplug.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 9b60816..dfca7e2 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -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); }
I wrote the original code, so I give my ACK here. Guannan Ren

On 17.05.2012 16:10, Guannan Ren wrote:
On 05/17/2012 08:34 PM, Michal Privoznik wrote:
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. --- src/qemu/qemu_hotplug.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 9b60816..dfca7e2 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -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); }
I wrote the original code, so I give my ACK here.
Guannan Ren
Thanks, pushed. Michal
participants (2)
-
Guannan Ren
-
Michal Privoznik