mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
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.
This commit is contained in:
parent
98be861b4d
commit
8125113cdb
@ -252,10 +252,16 @@ int qemuDomainAttachPciDiskDevice(virConnectPtr conn,
|
|||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
ret = qemuMonitorAddDevice(priv->mon, devstr);
|
ret = qemuMonitorAddDevice(priv->mon, devstr);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
VIR_WARN("qemuMonitorAddDevice failed on %s (%s)",
|
virErrorPtr orig_err = virSaveLastError();
|
||||||
drivestr, devstr);
|
if (qemuMonitorDriveDel(priv->mon, drivestr) < 0) {
|
||||||
/* XXX should call 'drive_del' on error but this does not
|
VIR_WARN("Unable to remove drive %s (%s) after failed "
|
||||||
exist yet */
|
"qemuMonitorAddDevice",
|
||||||
|
drivestr, devstr);
|
||||||
|
}
|
||||||
|
if (orig_err) {
|
||||||
|
virSetError(orig_err);
|
||||||
|
virFreeError(orig_err);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user