Unify the handling of the copy-on-read filter by changing the handling
to use qemuBlockStorageSourceChainData.
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
src/qemu/qemu_hotplug.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 31dc9a43b2..86b2027be7 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -4288,7 +4288,6 @@ qemuDomainRemoveDiskDevice(virQEMUDriver *driver,
virDomainDeviceDef dev;
size_t i;
qemuDomainObjPrivate *priv = vm->privateData;
- g_autofree char *corAlias = NULL;
bool blockdev = virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV);
int ret = -1;
@@ -4301,10 +4300,7 @@ qemuDomainRemoveDiskDevice(virQEMUDriver *driver,
if (!(diskBackend =
qemuBlockStorageSourceChainDetachPrepareChardev(chardevAlias)))
goto cleanup;
- } else if (blockdev &&
- !qemuDiskBusIsSD(disk->bus)) {
- corAlias = g_strdup(diskPriv->nodeCopyOnRead);
-
+ } else if (blockdev && !qemuDiskBusIsSD(disk->bus)) {
if (diskPriv->blockjob) {
/* the block job keeps reference to the disk chain */
diskPriv->blockjob->disk = NULL;
@@ -4314,6 +4310,13 @@ qemuDomainRemoveDiskDevice(virQEMUDriver *driver,
if (!(diskBackend =
qemuBlockStorageSourceChainDetachPrepareBlockdev(disk->src)))
goto cleanup;
}
+
+ if (diskPriv->nodeCopyOnRead) {
+ if (!diskBackend)
+ diskBackend = g_new0(qemuBlockStorageSourceChainData, 1);
+ diskBackend->copyOnReadNodename = g_strdup(diskPriv->nodeCopyOnRead);
+ diskBackend->copyOnReadAttached = true;
+ }
} else {
char *driveAlias;
@@ -4333,9 +4336,6 @@ qemuDomainRemoveDiskDevice(virQEMUDriver *driver,
qemuDomainObjEnterMonitor(driver, vm);
- if (corAlias)
- ignore_value(qemuMonitorBlockdevDel(priv->mon, corAlias));
-
if (diskBackend)
qemuBlockStorageSourceChainDetach(priv->mon, diskBackend);
--
2.31.1