The copy on read functionality is done using a separate layer in the
backing chain. Add function to generate properties for it.
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
src/qemu/qemu_block.c | 22 ++++++++++++++++++++++
src/qemu/qemu_block.h | 2 ++
2 files changed, 24 insertions(+)
diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c
index ccdd334367..5321dda316 100644
--- a/src/qemu/qemu_block.c
+++ b/src/qemu/qemu_block.c
@@ -1745,3 +1745,25 @@ qemuBlockSnapshotAddLegacy(virJSONValuePtr actions,
VIR_FREE(source);
return ret;
}
+
+
+/**
+ * qemuBlockStorageGetCopyOnReadProps:
+ * @disk: disk with copy-on-read enabled
+ *
+ * Creates blockdev properties for a disk copy-on-read layer.
+ */
+virJSONValuePtr
+qemuBlockStorageGetCopyOnReadProps(virDomainDiskDefPtr disk)
+{
+ qemuDomainDiskPrivatePtr priv = QEMU_DOMAIN_DISK_PRIVATE(disk);
+ virJSONValuePtr ret = NULL;
+
+ ignore_value(virJSONValueObjectCreate(&ret,
+ "s:driver",
"copy-on-read",
+ "s:node-name",
priv->nodeCopyOnRead,
+ "s:file",
disk->src->nodeformat,
+ NULL));
+
+ return ret;
+}
diff --git a/src/qemu/qemu_block.h b/src/qemu/qemu_block.h
index fd8984e60b..62ed5027cb 100644
--- a/src/qemu/qemu_block.h
+++ b/src/qemu/qemu_block.h
@@ -67,6 +67,8 @@ qemuBlockStorageSourceGetURI(virStorageSourcePtr src);
virJSONValuePtr
qemuBlockStorageSourceGetBlockdevProps(virStorageSourcePtr src);
+virJSONValuePtr
+qemuBlockStorageGetCopyOnReadProps(virDomainDiskDefPtr disk);
typedef struct qemuBlockStorageSourceAttachData qemuBlockStorageSourceAttachData;
typedef qemuBlockStorageSourceAttachData *qemuBlockStorageSourceAttachDataPtr;
--
2.16.2