]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: domain: Add field for storing node name for copy-on-read
authorPeter Krempa <pkrempa@redhat.com>
Tue, 21 Aug 2018 12:45:57 +0000 (14:45 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 21 Aug 2018 13:46:06 +0000 (15:46 +0200)
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@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/qemu/qemu_domain.c
src/qemu/qemu_domain.h
tests/qemustatusxml2xmldata/modern-in.xml

index 4ea12c3fd7eb3d995e91417d21e3a3d299545104..2d78210770c5aabc0f2befe1c3179a181a16411f 100644 (file)
@@ -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, "<qom name='%s'/>\n", priv->qomName);
 
+    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;
 }
 
index 2afc6b454a76444091b4182323a77e9fff374d40..2a3ef6ba3d92c089f4be2746b56cb815f8a8840b 100644 (file)
@@ -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) \
index 24e9fd9f6dacb1c9e75a48ac8ec647ea66314a33..08f7f40761d8b1926be2dfcf1c969bce22e7893e 100644 (file)
         <address type='pci' domain='0x0000' bus='0x00' slot='0x0b' function='0x0'/>
         <privateData>
           <qom name='virtio-disk1/virtio-backend'/>
+          <nodenames>
+            <nodename type='copyOnRead' name='cor-node'/>
+          </nodenames>
         </privateData>
       </disk>
       <disk type='file' device='cdrom'>