mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-23 06:05:27 +00:00
qemu: hotplug: Don't leak 'disk' if VM crashes during unplug finishing
qemuDomainRemoveDiskDevice would leak the disk to be removed if the VM
crashed since it was removed from the definition but not freed.
Broken in commit 105bcdde76
which moved the removal from the definition
earlier.
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
d3f9dda2c9
commit
ee46360b43
@ -3864,6 +3864,7 @@ qemuDomainRemoveDiskDevice(virQEMUDriverPtr driver,
|
||||
bool prUsed = false;
|
||||
const char *authAlias = NULL;
|
||||
const char *encAlias = NULL;
|
||||
int ret = -1;
|
||||
|
||||
VIR_DEBUG("Removing disk %s from domain %p %s",
|
||||
disk->info.alias, vm, vm->def->name);
|
||||
@ -3918,7 +3919,7 @@ qemuDomainRemoveDiskDevice(virQEMUDriverPtr driver,
|
||||
ignore_value(qemuMonitorDelObject(priv->mon, qemuDomainGetManagedPRAlias()));
|
||||
|
||||
if (qemuDomainObjExitMonitor(driver, vm) < 0)
|
||||
return -1;
|
||||
goto cleanup;
|
||||
|
||||
virDomainAuditDisk(vm, disk->src, NULL, "detach", true);
|
||||
|
||||
@ -3938,8 +3939,11 @@ qemuDomainRemoveDiskDevice(virQEMUDriverPtr driver,
|
||||
ignore_value(qemuRemoveSharedDevice(driver, &dev, vm->def->name));
|
||||
virDomainUSBAddressRelease(priv->usbaddrs, &disk->info);
|
||||
|
||||
ret = 0;
|
||||
|
||||
cleanup:
|
||||
virDomainDiskDefFree(disk);
|
||||
return 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user