mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 21:55:25 +00:00
qemu: hotplug: Adjust error path for attach scsi disk
Adjust error path logic to make it clearer how to undo the failed add. Signed-off-by: John Ferlan <jferlan@redhat.com>
This commit is contained in:
parent
db5b47fd4a
commit
b0e002fcfd
@ -590,29 +590,22 @@ qemuDomainAttachSCSIDisk(virConnectPtr conn,
|
||||
if (VIR_REALLOC_N(vm->def->disks, vm->def->ndisks+1) < 0)
|
||||
goto error;
|
||||
|
||||
/* Attach the device - 2 step process */
|
||||
qemuDomainObjEnterMonitor(driver, vm);
|
||||
|
||||
ret = qemuMonitorAddDrive(priv->mon, drivestr);
|
||||
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 */
|
||||
}
|
||||
}
|
||||
if (qemuMonitorAddDrive(priv->mon, drivestr) < 0)
|
||||
goto failadddrive;
|
||||
|
||||
if (qemuDomainObjExitMonitor(driver, vm) < 0) {
|
||||
ret = -1;
|
||||
goto error;
|
||||
}
|
||||
if (qemuMonitorAddDevice(priv->mon, devstr) < 0)
|
||||
goto failadddevice;
|
||||
|
||||
virDomainAuditDisk(vm, NULL, disk->src, "attach", ret >= 0);
|
||||
if (qemuDomainObjExitMonitor(driver, vm) < 0)
|
||||
goto failexitmonitor;
|
||||
|
||||
if (ret < 0)
|
||||
goto error;
|
||||
virDomainAuditDisk(vm, NULL, disk->src, "attach", true);
|
||||
|
||||
virDomainDiskInsertPreAlloced(vm->def, disk);
|
||||
ret = 0;
|
||||
|
||||
cleanup:
|
||||
qemuDomainSecretDiskDestroy(disk);
|
||||
@ -621,6 +614,16 @@ qemuDomainAttachSCSIDisk(virConnectPtr conn,
|
||||
virObjectUnref(cfg);
|
||||
return ret;
|
||||
|
||||
failadddevice:
|
||||
/* XXX should call 'drive_del' on error but this does not exist yet */
|
||||
VIR_WARN("qemuMonitorAddDevice failed on %s (%s)", drivestr, devstr);
|
||||
|
||||
failadddrive:
|
||||
ignore_value(qemuDomainObjExitMonitor(driver, vm));
|
||||
|
||||
failexitmonitor:
|
||||
virDomainAuditDisk(vm, NULL, disk->src, "attach", false);
|
||||
|
||||
error:
|
||||
ignore_value(qemuDomainPrepareDisk(driver, vm, disk, NULL, true));
|
||||
goto cleanup;
|
||||
|
Loading…
Reference in New Issue
Block a user