The copy-on-read feature is expressed by adding a new node layer in
qemu when using -blockdev. Since we will keep these per-disk (as opposed
to per storage source) we need to store the appropriate node names in
the disk definition.
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
src/qemu/qemu_domain.c | 11 +++++++++++
src/qemu/qemu_domain.h | 1 +
tests/qemustatusxml2xmldata/modern-in.xml | 3 +++
3 files changed, 15 insertions(+)
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 9c1a2c6053..c98be208f1 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -1066,6 +1066,7 @@ qemuDomainDiskPrivateDispose(void *obj)
VIR_FREE(priv->blockJobError);
virStorageSourceFree(priv->migrSource);
VIR_FREE(priv->backendQomName);
+ VIR_FREE(priv->nodeCopyOnRead);
}
static virClassPtr qemuDomainStorageSourcePrivateClass;
@@ -2131,6 +2132,7 @@ qemuDomainDiskPrivateParse(xmlXPathContextPtr ctxt,
qemuDomainDiskPrivatePtr priv = QEMU_DOMAIN_DISK_PRIVATE(disk);
priv->backendQomName = virXPathString("string(./qom/@backend)", ctxt);
+ priv->nodeCopyOnRead =
virXPathString("string(./nodenames/nodename[@type='copyOnRead']/@name)",
ctxt);
return 0;
}
@@ -2144,6 +2146,15 @@ qemuDomainDiskPrivateFormat(virDomainDiskDefPtr disk,
virBufferEscapeString(buf, "<qom backend='%s'/>\n",
priv->backendQomName);
+ if (priv->nodeCopyOnRead) {
+ virBufferAddLit(buf, "<nodenames>\n");
+ virBufferAdjustIndent(buf, 2);
+ virBufferEscapeString(buf, "<nodename type='copyOnRead'
name='%s'/>\n",
+ priv->nodeCopyOnRead);
+ virBufferAdjustIndent(buf, -2);
+ virBufferAddLit(buf, "</nodenames>\n");
+ }
+
return 0;
}
diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
index 20208f56f5..758ffc0bb9 100644
--- a/src/qemu/qemu_domain.h
+++ b/src/qemu/qemu_domain.h
@@ -398,6 +398,7 @@ struct _qemuDomainDiskPrivate {
bool removable; /* device media can be removed/changed */
char *backendQomName; /* QOM path to the eligible block backend */
+ char *nodeCopyOnRead; /* nodename of the disk-wide copy-on-read blockdev layer */
};
# define QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(src) \
diff --git a/tests/qemustatusxml2xmldata/modern-in.xml
b/tests/qemustatusxml2xmldata/modern-in.xml
index 21d4faca66..612090786a 100644
--- a/tests/qemustatusxml2xmldata/modern-in.xml
+++ b/tests/qemustatusxml2xmldata/modern-in.xml
@@ -333,6 +333,9 @@
<address type='pci' domain='0x0000' bus='0x00'
slot='0x0b' function='0x0'/>
<privateData>
<qom backend='virtio-disk1/virtio-backend'/>
+ <nodenames>
+ <nodename type='copyOnRead' name='cor-node'/>
+ </nodenames>
</privateData>
</disk>
<disk type='file' device='cdrom'>
--
2.16.2