mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-23 20:02:21 +00:00
qemu: hotplug: Transfer ownership of backing chain to block job on disk unplug
When removing the disk fronted while any block job is still active we need to transfer the ownership of the backing chain to the job itself as the job still holds the reference to the chain members and thus attempts to remove them would fail. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
ae4b921f2a
commit
d524c9a893
@ -4228,8 +4228,15 @@ qemuDomainRemoveDiskDevice(virQEMUDriverPtr driver,
|
|||||||
if (VIR_STRDUP(corAlias, diskPriv->nodeCopyOnRead) < 0)
|
if (VIR_STRDUP(corAlias, diskPriv->nodeCopyOnRead) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (!(diskBackend = qemuBlockStorageSourceChainDetachPrepareBlockdev(disk->src)))
|
if (diskPriv->blockjob) {
|
||||||
goto cleanup;
|
/* the block job keeps reference to the disk chain */
|
||||||
|
diskPriv->blockjob->disk = NULL;
|
||||||
|
virObjectUnref(diskPriv->blockjob);
|
||||||
|
diskPriv->blockjob = NULL;
|
||||||
|
} else {
|
||||||
|
if (!(diskBackend = qemuBlockStorageSourceChainDetachPrepareBlockdev(disk->src)))
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
char *driveAlias;
|
char *driveAlias;
|
||||||
|
|
||||||
@ -4252,7 +4259,8 @@ qemuDomainRemoveDiskDevice(virQEMUDriverPtr driver,
|
|||||||
if (corAlias)
|
if (corAlias)
|
||||||
ignore_value(qemuMonitorDelObject(priv->mon, corAlias));
|
ignore_value(qemuMonitorDelObject(priv->mon, corAlias));
|
||||||
|
|
||||||
qemuBlockStorageSourceChainDetach(priv->mon, diskBackend);
|
if (diskBackend)
|
||||||
|
qemuBlockStorageSourceChainDetach(priv->mon, diskBackend);
|
||||||
|
|
||||||
if (qemuDomainObjExitMonitor(driver, vm) < 0)
|
if (qemuDomainObjExitMonitor(driver, vm) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -4262,7 +4270,8 @@ qemuDomainRemoveDiskDevice(virQEMUDriverPtr driver,
|
|||||||
qemuDomainReleaseDeviceAddress(vm, &disk->info);
|
qemuDomainReleaseDeviceAddress(vm, &disk->info);
|
||||||
|
|
||||||
/* tear down disk security access */
|
/* tear down disk security access */
|
||||||
qemuDomainStorageSourceChainAccessRevoke(driver, vm, disk->src);
|
if (diskBackend)
|
||||||
|
qemuDomainStorageSourceChainAccessRevoke(driver, vm, disk->src);
|
||||||
|
|
||||||
dev.type = VIR_DOMAIN_DEVICE_DISK;
|
dev.type = VIR_DOMAIN_DEVICE_DISK;
|
||||||
dev.data.disk = disk;
|
dev.data.disk = disk;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user