]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: Add attempt to call qemuMonitorDriveDel for AttachSCSI failure path
authorJohn Ferlan <jferlan@redhat.com>
Mon, 18 Jul 2016 16:50:52 +0000 (12:50 -0400)
committerJohn Ferlan <jferlan@redhat.com>
Tue, 2 Aug 2016 14:11:11 +0000 (10:11 -0400)
Completion of fix for:
    https://bugzilla.redhat.com/show_bug.cgi?id=1336225

Similar to the other disk types, add the qemuMonitorDriveDel in the failure
to add/hotplug a SCSI disk.

src/qemu/qemu_hotplug.c

index fd915f4c299858ecf56cebfdf0ec3a938a04b008..8115ad741a66589811bcbf88af1e71e46ac0b674 100644 (file)
@@ -602,6 +602,7 @@ qemuDomainAttachSCSIDisk(virConnectPtr conn,
     char *devstr = NULL;
     bool driveAdded = false;
     bool encobjAdded = false;
+    char *drivealias = NULL;
     int ret = -1;
     int rv;
     virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
@@ -649,6 +650,9 @@ qemuDomainAttachSCSIDisk(virConnectPtr conn,
     if (!(drivestr = qemuBuildDriveStr(disk, false, priv->qemuCaps)))
         goto error;
 
+    if (!(drivealias = qemuAliasFromDisk(disk)))
+        goto error;
+
     if (VIR_REALLOC_N(vm->def->disks, vm->def->ndisks+1) < 0)
         goto error;
 
@@ -683,15 +687,16 @@ qemuDomainAttachSCSIDisk(virConnectPtr conn,
     qemuDomainSecretDiskDestroy(disk);
     VIR_FREE(devstr);
     VIR_FREE(drivestr);
+    VIR_FREE(drivealias);
     virObjectUnref(cfg);
     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, drivealias) < 0) {
+        VIR_WARN("Unable to remove drive %s (%s) after failed "
+                 "qemuMonitorAddDevice", drivealias, drivestr);
+    }
     if (encobjAdded)
         ignore_value(qemuMonitorDelObject(priv->mon, encinfo->s.aes.alias));
     if (orig_err) {