[libvirt] [RFC PATCH 02/30] qemu: domain: Format storage source node names into private data

Peter Krempa pkrempa at redhat.com
Thu Apr 19 15:24:59 UTC 2018


Save and restore node names if we know them in the status XML so that we
don't need to recalculate them or don't lose them in some cases.

Signed-off-by: Peter Krempa <pkrempa at redhat.com>
---
 src/qemu/qemu_domain.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index e2a8450e2e..224b3b0478 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -1934,6 +1934,9 @@ static int
 qemuStorageSourcePrivateDataParse(xmlXPathContextPtr ctxt,
                                   virStorageSourcePtr src)
 {
+    src->nodestorage = virXPathString("string(./nodename/@storage)", ctxt);
+    src->nodeformat = virXPathString("string(./nodename/@format)", ctxt);
+
     if (virStorageSourcePrivateDataParseRelPath(ctxt, src) < 0)
         return -1;

@@ -1945,6 +1948,15 @@ static int
 qemuStorageSourcePrivateDataFormat(virStorageSourcePtr src,
                                    virBufferPtr buf)
 {
+    if (src->nodestorage || src->nodeformat) {
+        virBufferAddLit(buf, "<nodename");
+        if (src->nodestorage)
+            virBufferAsprintf(buf, " storage='%s'", src->nodestorage);
+        if (src->nodeformat)
+            virBufferAsprintf(buf, " format='%s'", src->nodeformat);
+        virBufferAddLit(buf, "/>\n");
+    }
+
     if (virStorageSourcePrivateDataFormatRelPath(src, buf) < 0)
         return -1;

-- 
2.14.3




More information about the libvir-list mailing list