[libvirt] [PATCH 1/2] qemu: attempt to delete disk when SCSI attach failed

Guido Günther agx at sigxcpu.org
Fri Jul 22 10:08:45 UTC 2016


We have a qemuMonitorDriveDel now so use it
---
 src/qemu/qemu_hotplug.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index e8a30d5..6232a0e 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -678,11 +678,12 @@ qemuDomainAttachSCSIDisk(virConnectPtr conn,
     return ret;
 
  exit_monitor:
-    /* XXX should call 'drive_del' on error but this does not exist yet */
-    if (driveAdded)
-        VIR_WARN("qemuMonitorAddDevice failed on %s (%s)", drivestr, devstr);
-
     orig_err = virSaveLastError();
+    if (driveAdded && qemuMonitorDriveDel(priv->mon, drivestr) < 0) {
+        VIR_WARN("Unable to remove drive %s (%s) after failed "
+                 "qemuMonitorAddDevice",
+                 drivestr, devstr);
+    }
     if (encobjAdded)
         ignore_value(qemuMonitorDelObject(priv->mon, encinfo->s.aes.alias));
     if (orig_err) {
-- 
2.8.1




More information about the libvir-list mailing list