qemuBlockStorageSourceChainData encapsulates the backend of the disk for
startup and hotplug operations. Add the handling for the copy-on-read
filter so that the hotplug code doesn't need to have separate cleanup.
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
src/qemu/qemu_block.c | 12 ++++++++++++
src/qemu/qemu_block.h | 4 ++++
2 files changed, 16 insertions(+)
diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c
index 89f20eb1d2..6627d044cd 100644
--- a/src/qemu/qemu_block.c
+++ b/src/qemu/qemu_block.c
@@ -1947,6 +1947,9 @@ qemuBlockStorageSourceChainDataFree(qemuBlockStorageSourceChainData
*data)
for (i = 0; i < data->nsrcdata; i++)
qemuBlockStorageSourceAttachDataFree(data->srcdata[i]);
+ virJSONValueFree(data->copyOnReadProps);
+ g_free(data->copyOnReadNodename);
+
g_free(data->srcdata);
g_free(data);
}
@@ -2054,6 +2057,11 @@ qemuBlockStorageSourceChainAttach(qemuMonitor *mon,
return -1;
}
+ if (data->copyOnReadProps) {
+ if (qemuMonitorBlockdevAdd(mon, &data->copyOnReadProps) < 0)
+ return -1;
+ }
+
return 0;
}
@@ -2072,6 +2080,10 @@ qemuBlockStorageSourceChainDetach(qemuMonitor *mon,
{
size_t i;
+ if (data->copyOnReadAttached)
+ ignore_value(qemuMonitorBlockdevDel(mon, data->copyOnReadNodename));
+
+
for (i = 0; i < data->nsrcdata; i++)
qemuBlockStorageSourceAttachRollback(mon, data->srcdata[i]);
}
diff --git a/src/qemu/qemu_block.h b/src/qemu/qemu_block.h
index 28ccca97a8..ff7048eb6c 100644
--- a/src/qemu/qemu_block.h
+++ b/src/qemu/qemu_block.h
@@ -150,6 +150,10 @@ qemuBlockStorageSourceDetachOneBlockdev(virQEMUDriver *driver,
struct _qemuBlockStorageSourceChainData {
qemuBlockStorageSourceAttachData **srcdata;
size_t nsrcdata;
+
+ virJSONValue *copyOnReadProps;
+ char *copyOnReadNodename;
+ bool copyOnReadAttached;
};
typedef struct _qemuBlockStorageSourceChainData qemuBlockStorageSourceChainData;
--
2.31.1