提交 513faf6c 编写于 作者: P Peter Krempa

qemu: hotplug: Use storage chain helpers in qemuDomainRemoveDiskDevice

Use the new helpers for removing the backing chain in case when
-blockdev is used. For -drive this function has a local implementation.
Signed-off-by: NPeter Krempa <pkrempa@redhat.com>
Reviewed-by: NJán Tomko <jtomko@redhat.com>
上级 407fd434
......@@ -4381,7 +4381,7 @@ qemuDomainRemoveDiskDevice(virQEMUDriverPtr driver,
virDomainDiskDefPtr disk)
{
qemuDomainDiskPrivatePtr diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk);
qemuHotplugDiskSourceDataPtr diskbackend = NULL;
VIR_AUTOPTR(qemuBlockStorageSourceChainData) diskBackend = NULL;
virDomainDeviceDef dev;
size_t i;
qemuDomainObjPrivatePtr priv = vm->privateData;
......@@ -4392,13 +4392,21 @@ qemuDomainRemoveDiskDevice(virQEMUDriverPtr driver,
VIR_DEBUG("Removing disk %s from domain %p %s",
disk->info.alias, vm, vm->def->name);
if (!(diskbackend = qemuHotplugDiskSourceRemovePrepare(disk, disk->src,
priv->qemuCaps)))
return -1;
if (blockdev) {
if (VIR_STRDUP(corAlias, diskPriv->nodeCopyOnRead) < 0)
goto cleanup;
if (!(diskBackend = qemuBlockStorageSourceChainDetachPrepareBlockdev(disk->src)))
goto cleanup;
} else {
char *driveAlias;
if (!(driveAlias = qemuAliasDiskDriveFromDisk(disk)))
goto cleanup;
if (!(diskBackend = qemuBlockStorageSourceChainDetachPrepareDrive(disk->src, driveAlias)))
goto cleanup;
}
for (i = 0; i < vm->def->ndisks; i++) {
......@@ -4413,7 +4421,7 @@ qemuDomainRemoveDiskDevice(virQEMUDriverPtr driver,
if (corAlias)
ignore_value(qemuMonitorDelObject(priv->mon, corAlias));
qemuHotplugDiskSourceRemove(priv->mon, diskbackend);
qemuBlockStorageSourceChainDetach(priv->mon, diskBackend);
if (qemuDomainObjExitMonitor(driver, vm) < 0)
goto cleanup;
......@@ -4435,7 +4443,6 @@ qemuDomainRemoveDiskDevice(virQEMUDriverPtr driver,
ret = 0;
cleanup:
qemuHotplugDiskSourceDataFree(diskbackend);
virDomainDiskDefFree(disk);
return ret;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册