We have a qemuMonitorDriveDel now so use it --- src/qemu/qemu_hotplug.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 6232a0e..87c208b 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -707,6 +707,7 @@ qemuDomainAttachUSBMassStorageDevice(virQEMUDriverPtr driver, virDomainDiskDefPtr disk) { qemuDomainObjPrivatePtr priv = vm->privateData; + virErrorPtr orig_err; int ret = -1; char *drivestr = NULL; char *devstr = NULL; @@ -745,10 +746,16 @@ qemuDomainAttachUSBMassStorageDevice(virQEMUDriverPtr driver, if (ret == 0) { ret = qemuMonitorAddDevice(priv->mon, devstr); if (ret < 0) { - VIR_WARN("qemuMonitorAddDevice failed on %s (%s)", - drivestr, devstr); - /* XXX should call 'drive_del' on error but this does not - exist yet */ + orig_err = virSaveLastError(); + if (qemuMonitorDriveDel(priv->mon, drivestr) < 0) { + VIR_WARN("Unable to remove drive %s (%s) after failed " + "qemuMonitorAddDevice", + drivestr, devstr); + } + if (orig_err) { + virSetError(orig_err); + virFreeError(orig_err); + } } } if (qemuDomainObjExitMonitor(driver, vm) < 0) { -- 2.8.1 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list