提交 b71cf872 编写于 作者: P Peter Krempa

qemu: hotplug: Fix handling of the 'copy-on-read' layer with blockdev

My original implementation was completely broken because it attempted to
use object-add/del instead of blockdev-add/del.

https://bugzilla.redhat.com/show_bug.cgi?id=1798366Signed-off-by: NPeter Krempa <pkrempa@redhat.com>
Reviewed-by: NJán Tomko <jtomko@redhat.com>
Reviewed-by: NDaniel Henrique Barboza <danielhb413@gmail.com>
上级 db57e9da
......@@ -680,6 +680,7 @@ qemuDomainAttachDiskGeneric(virQEMUDriverPtr driver,
g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver);
g_autoptr(virJSONValue) corProps = NULL;
g_autofree char *corAlias = NULL;
bool corAdded = false;
bool blockdev = virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV);
if (qemuDomainStorageSourceChainAccessAllow(driver, vm, disk->src) < 0)
......@@ -692,9 +693,12 @@ qemuDomainAttachDiskGeneric(virQEMUDriverPtr driver,
goto cleanup;
if (blockdev) {
if (disk->copy_on_read == VIR_TRISTATE_SWITCH_ON &&
!(corProps = qemuBlockStorageGetCopyOnReadProps(disk)))
goto cleanup;
if (disk->copy_on_read == VIR_TRISTATE_SWITCH_ON) {
if (!(corProps = qemuBlockStorageGetCopyOnReadProps(disk)))
goto cleanup;
corAlias = g_strdup(QEMU_DOMAIN_DISK_PRIVATE(disk)->nodeCopyOnRead);
}
if (!(data = qemuBuildStorageSourceChainAttachPrepareBlockdev(disk->src,
priv->qemuCaps)))
......@@ -719,9 +723,12 @@ qemuDomainAttachDiskGeneric(virQEMUDriverPtr driver,
if (qemuBlockStorageSourceChainAttach(priv->mon, data) < 0)
goto exit_monitor;
if (corProps &&
qemuMonitorAddObject(priv->mon, &corProps, &corAlias) < 0)
goto exit_monitor;
if (corProps) {
if (qemuMonitorBlockdevAdd(priv->mon, &corProps) < 0)
goto exit_monitor;
corAdded = true;
}
if (qemuDomainAttachExtensionDevice(priv->mon, &disk->info) < 0)
goto exit_monitor;
......@@ -763,8 +770,8 @@ qemuDomainAttachDiskGeneric(virQEMUDriverPtr driver,
return ret;
exit_monitor:
if (corAlias)
ignore_value(qemuMonitorDelObject(priv->mon, corAlias));
if (corAdded)
ignore_value(qemuMonitorBlockdevDel(priv->mon, corAlias));
qemuBlockStorageSourceChainDetach(priv->mon, data);
if (qemuDomainObjExitMonitor(driver, vm) < 0)
......@@ -4250,7 +4257,7 @@ qemuDomainRemoveDiskDevice(virQEMUDriverPtr driver,
qemuDomainObjEnterMonitor(driver, vm);
if (corAlias)
ignore_value(qemuMonitorDelObject(priv->mon, corAlias));
ignore_value(qemuMonitorBlockdevDel(priv->mon, corAlias));
if (diskBackend)
qemuBlockStorageSourceChainDetach(priv->mon, diskBackend);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册