From d451575bb12b7696bba5b4c4bcbb7e6541996ebc Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Tue, 21 Aug 2018 14:45:57 +0200 Subject: [PATCH] qemu: domain: Add field for storing node name for copy-on-read MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Ján Tomko --- 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 4ea12c3fd7..2d78210770 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->qomName); + VIR_FREE(priv->nodeCopyOnRead); } static virClassPtr qemuDomainStorageSourcePrivateClass; @@ -2131,6 +2132,7 @@ qemuDomainDiskPrivateParse(xmlXPathContextPtr ctxt, qemuDomainDiskPrivatePtr priv = QEMU_DOMAIN_DISK_PRIVATE(disk); priv->qomName = virXPathString("string(./qom/@name)", ctxt); + priv->nodeCopyOnRead = virXPathString("string(./nodenames/nodename[@type='copyOnRead']/@name)", ctxt); return 0; } @@ -2144,6 +2146,15 @@ qemuDomainDiskPrivateFormat(virDomainDiskDefPtr disk, virBufferEscapeString(buf, "\n", priv->qomName); + if (priv->nodeCopyOnRead) { + virBufferAddLit(buf, "\n"); + virBufferAdjustIndent(buf, 2); + virBufferEscapeString(buf, "\n", + priv->nodeCopyOnRead); + virBufferAdjustIndent(buf, -2); + virBufferAddLit(buf, "\n"); + } + return 0; } diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index 2afc6b454a..2a3ef6ba3d 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 *qomName; /* QOM path of the disk (also refers to the 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 24e9fd9f6d..08f7f40761 100644 --- a/tests/qemustatusxml2xmldata/modern-in.xml +++ b/tests/qemustatusxml2xmldata/modern-in.xml @@ -335,6 +335,9 @@
+ + + -- GitLab