summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJiri Denemark <jdenemar@redhat.com>2012-09-20 22:28:35 +0200
committerJiri Denemark <jdenemar@redhat.com>2012-09-21 12:23:01 +0200
commit8125113cdb61bb4352af8e80e66573282be9cf83 (patch)
tree124ac8d3dd8f9c7e8f6aa7050190a1cca8e2e822
parentlocking: Remove README file in favor of internals/locking.html (diff)
downloadlibvirt-8125113cdb61bb4352af8e80e66573282be9cf83.tar.gz
libvirt-8125113cdb61bb4352af8e80e66573282be9cf83.tar.bz2
libvirt-8125113cdb61bb4352af8e80e66573282be9cf83.zip
qemu: Fix failure path in disk hotplug
Disk hotplug is a two phase action: qemuMonitorAddDrive followed by qemuMonitorAddDevice. When the first part succeeds but the second one fails, we need to rollback the drive addition.
-rw-r--r--src/qemu/qemu_hotplug.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 4cd83fdf3..bcf3081a0 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -252,10 +252,16 @@ int qemuDomainAttachPciDiskDevice(virConnectPtr conn,
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 */
+ virErrorPtr 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);
+ }
}
}
} else {