404507
From 996dfd6322782e72583384381ffebf91ef1d3e27 Mon Sep 17 00:00:00 2001
404507
Message-Id: <996dfd6322782e72583384381ffebf91ef1d3e27@dist-git>
404507
From: Peter Krempa <pkrempa@redhat.com>
404507
Date: Thu, 14 Dec 2017 14:31:51 +0100
404507
Subject: [PATCH] conf: Add infrastructure for disk source private data XML
404507
404507
VM drivers may need to store additional private data to the status XML
404507
so that it can be restored after libvirtd restart. Since not everything
404507
is needed add a callback infrastructure, where VM drivers can add only
404507
stuff they need.
404507
404507
Note that the private data is formatted as a <privateData> sub-element
404507
of the <disk> or <backingStore> <source> sub-element. This is done since
404507
storing it out of band (in the VM private data) would require a complex
404507
matching process to allow to put the data into correct place.
404507
404507
(cherry picked from commit aed3d038a6565f3b0e916bdb004ca90b302b200d)
404507
404507
 Conflicts:
404507
	tests/qemublocktest.c: This file does not exist downstream yet.
404507
404507
https://bugzilla.redhat.com/show_bug.cgi?id=1523261
404507
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
404507
---
404507
 src/conf/domain_conf.c      | 136 ++++++++++++++++++++++++++++++++++----------
404507
 src/conf/domain_conf.h      |  17 +++++-
404507
 src/conf/snapshot_conf.c    |  18 +++---
404507
 src/network/bridge_driver.c |   2 +-
404507
 src/qemu/qemu_domain.c      |   2 +-
404507
 tests/virstoragetest.c      |   2 +-
404507
 6 files changed, 134 insertions(+), 43 deletions(-)
404507
404507
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
404507
index 2d54037b71..ad9c16a1e0 100644
404507
--- a/src/conf/domain_conf.c
404507
+++ b/src/conf/domain_conf.c
404507
@@ -8550,11 +8550,43 @@ virDomainDiskSourceEncryptionParse(xmlNodePtr node,
404507
 }
404507
 
404507
 
404507
+static int
404507
+virDomainDiskSourcePrivateDataParse(xmlXPathContextPtr ctxt,
404507
+                                    virStorageSourcePtr src,
404507
+                                    unsigned int flags,
404507
+                                    virDomainXMLOptionPtr xmlopt)
404507
+{
404507
+    xmlNodePtr saveNode = ctxt->node;
404507
+    xmlNodePtr node;
404507
+    int ret = -1;
404507
+
404507
+    if (!(flags & VIR_DOMAIN_DEF_PARSE_STATUS) ||
404507
+        !xmlopt || !xmlopt->privateData.storageParse)
404507
+        return 0;
404507
+
404507
+    if (!(node = virXPathNode("./privateData", ctxt)))
404507
+        return 0;
404507
+
404507
+    ctxt->node = node;
404507
+
404507
+    if (xmlopt->privateData.storageParse(ctxt, src) < 0)
404507
+        goto cleanup;
404507
+
404507
+    ret = 0;
404507
+
404507
+ cleanup:
404507
+    ctxt->node = saveNode;
404507
+
404507
+    return ret;
404507
+}
404507
+
404507
+
404507
 int
404507
 virDomainDiskSourceParse(xmlNodePtr node,
404507
                          xmlXPathContextPtr ctxt,
404507
                          virStorageSourcePtr src,
404507
-                         unsigned int flags)
404507
+                         unsigned int flags,
404507
+                         virDomainXMLOptionPtr xmlopt)
404507
 {
404507
     int ret = -1;
404507
     xmlNodePtr saveNode = ctxt->node;
404507
@@ -8593,6 +8625,9 @@ virDomainDiskSourceParse(xmlNodePtr node,
404507
     if (virDomainDiskSourceEncryptionParse(node, &src->encryption) < 0)
404507
         goto cleanup;
404507
 
404507
+    if (virDomainDiskSourcePrivateDataParse(ctxt, src, flags, xmlopt) < 0)
404507
+        goto cleanup;
404507
+
404507
     /* People sometimes pass a bogus '' source path when they mean to omit the
404507
      * source element completely (e.g. CDROM without media). This is just a
404507
      * little compatibility check to help those broken apps */
404507
@@ -8610,7 +8645,8 @@ virDomainDiskSourceParse(xmlNodePtr node,
404507
 static int
404507
 virDomainDiskBackingStoreParse(xmlXPathContextPtr ctxt,
404507
                                virStorageSourcePtr src,
404507
-                               unsigned int flags)
404507
+                               unsigned int flags,
404507
+                               virDomainXMLOptionPtr xmlopt)
404507
 {
404507
     virStorageSourcePtr backingStore = NULL;
404507
     xmlNodePtr save_ctxt = ctxt->node;
404507
@@ -8668,8 +8704,8 @@ virDomainDiskBackingStoreParse(xmlXPathContextPtr ctxt,
404507
         goto cleanup;
404507
     }
404507
 
404507
-    if (virDomainDiskSourceParse(source, ctxt, backingStore, flags) < 0 ||
404507
-        virDomainDiskBackingStoreParse(ctxt, backingStore, flags) < 0)
404507
+    if (virDomainDiskSourceParse(source, ctxt, backingStore, flags, xmlopt) < 0 ||
404507
+        virDomainDiskBackingStoreParse(ctxt, backingStore, flags, xmlopt) < 0)
404507
         goto cleanup;
404507
 
404507
     VIR_STEAL_PTR(src->backingStore, backingStore);
404507
@@ -8771,7 +8807,8 @@ static int
404507
 virDomainDiskDefMirrorParse(virDomainDiskDefPtr def,
404507
                             xmlNodePtr cur,
404507
                             xmlXPathContextPtr ctxt,
404507
-                            unsigned int flags)
404507
+                            unsigned int flags,
404507
+                            virDomainXMLOptionPtr xmlopt)
404507
 {
404507
     xmlNodePtr mirrorNode;
404507
     char *mirrorFormat = NULL;
404507
@@ -8809,7 +8846,8 @@ virDomainDiskDefMirrorParse(virDomainDiskDefPtr def,
404507
             goto cleanup;
404507
         }
404507
 
404507
-        if (virDomainDiskSourceParse(mirrorNode, ctxt, def->mirror, flags) < 0)
404507
+        if (virDomainDiskSourceParse(mirrorNode, ctxt, def->mirror,
404507
+                                     flags, xmlopt) < 0)
404507
             goto cleanup;
404507
     } else {
404507
         /* For back-compat reasons, we handle a file name
404507
@@ -9235,7 +9273,7 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
404507
         if (!source && virXMLNodeNameEqual(cur, "source")) {
404507
             sourceNode = cur;
404507
 
404507
-            if (virDomainDiskSourceParse(cur, ctxt, def->src, flags) < 0)
404507
+            if (virDomainDiskSourceParse(cur, ctxt, def->src, flags, xmlopt) < 0)
404507
                 goto error;
404507
 
404507
             /* If we've already found an <auth> as a child of <disk> and
404507
@@ -9316,7 +9354,7 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
404507
         } else if (!def->mirror &&
404507
                    virXMLNodeNameEqual(cur, "mirror") &&
404507
                    !(flags & VIR_DOMAIN_DEF_PARSE_INACTIVE)) {
404507
-            if (virDomainDiskDefMirrorParse(def, cur, ctxt, flags) < 0)
404507
+            if (virDomainDiskDefMirrorParse(def, cur, ctxt, flags, xmlopt) < 0)
404507
                 goto error;
404507
         } else if (!authdef &&
404507
                    virXMLNodeNameEqual(cur, "auth")) {
404507
@@ -9587,7 +9625,7 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
404507
     product = NULL;
404507
 
404507
     if (!(flags & VIR_DOMAIN_DEF_PARSE_DISK_SOURCE)) {
404507
-        if (virDomainDiskBackingStoreParse(ctxt, def->src, flags) < 0)
404507
+        if (virDomainDiskBackingStoreParse(ctxt, def->src, flags, xmlopt) < 0)
404507
             goto error;
404507
     }
404507
 
404507
@@ -22349,12 +22387,43 @@ virDomainDiskSourceFormatNetwork(virBufferPtr attrBuf,
404507
 }
404507
 
404507
 
404507
+static int
404507
+virDomainDiskSourceFormatPrivateData(virBufferPtr buf,
404507
+                                     virStorageSourcePtr src,
404507
+                                     unsigned int flags,
404507
+                                     virDomainXMLOptionPtr xmlopt)
404507
+{
404507
+    virBuffer childBuf = VIR_BUFFER_INITIALIZER;
404507
+    int ret = -1;
404507
+
404507
+    if (!(flags & VIR_DOMAIN_DEF_FORMAT_STATUS) ||
404507
+        !xmlopt || !xmlopt->privateData.storageFormat)
404507
+        return 0;
404507
+
404507
+    virBufferSetChildIndent(&childBuf, buf);
404507
+
404507
+    if (xmlopt->privateData.storageFormat(src, &childBuf) < 0)
404507
+        goto cleanup;
404507
+
404507
+    if (virXMLFormatElement(buf, "privateData", NULL, &childBuf) < 0)
404507
+        goto cleanup;
404507
+
404507
+    ret = 0;
404507
+
404507
+ cleanup:
404507
+    virBufferFreeAndReset(&childBuf);
404507
+
404507
+    return ret;
404507
+}
404507
+
404507
+
404507
 static int
404507
 virDomainDiskSourceFormatInternal(virBufferPtr buf,
404507
                                   virStorageSourcePtr src,
404507
                                   int policy,
404507
                                   unsigned int flags,
404507
-                                  bool skipSeclabels)
404507
+                                  bool skipSeclabels,
404507
+                                  virDomainXMLOptionPtr xmlopt)
404507
 {
404507
     const char *startupPolicy = NULL;
404507
     virBuffer attrBuf = VIR_BUFFER_INITIALIZER;
404507
@@ -22436,6 +22505,9 @@ virDomainDiskSourceFormatInternal(virBufferPtr buf,
404507
             virStorageEncryptionFormat(&childBuf, src->encryption) < 0)
404507
             return -1;
404507
 
404507
+        if (virDomainDiskSourceFormatPrivateData(&childBuf, src, flags, xmlopt) < 0)
404507
+            return -1;
404507
+
404507
         if (virXMLFormatElement(buf, "source", &attrBuf, &childBuf) < 0)
404507
             goto error;
404507
     }
404507
@@ -22453,15 +22525,18 @@ int
404507
 virDomainDiskSourceFormat(virBufferPtr buf,
404507
                           virStorageSourcePtr src,
404507
                           int policy,
404507
-                          unsigned int flags)
404507
+                          unsigned int flags,
404507
+                          virDomainXMLOptionPtr xmlopt)
404507
 {
404507
-    return virDomainDiskSourceFormatInternal(buf, src, policy, flags, false);
404507
+    return virDomainDiskSourceFormatInternal(buf, src, policy, flags, false, xmlopt);
404507
 }
404507
 
404507
 
404507
 static int
404507
 virDomainDiskBackingStoreFormat(virBufferPtr buf,
404507
-                                virStorageSourcePtr backingStore)
404507
+                                virStorageSourcePtr backingStore,
404507
+                                virDomainXMLOptionPtr xmlopt,
404507
+                                unsigned int flags)
404507
 {
404507
     const char *format;
404507
 
404507
@@ -22490,9 +22565,9 @@ virDomainDiskBackingStoreFormat(virBufferPtr buf,
404507
 
404507
     virBufferAsprintf(buf, "<format type='%s'/>\n", format);
404507
     /* We currently don't output seclabels for backing chain element */
404507
-    if (virDomainDiskSourceFormatInternal(buf, backingStore, 0, 0, true) < 0 ||
404507
-        virDomainDiskBackingStoreFormat(buf,
404507
-                                        backingStore->backingStore) < 0)
404507
+    if (virDomainDiskSourceFormatInternal(buf, backingStore, 0, flags, true, xmlopt) < 0 ||
404507
+        virDomainDiskBackingStoreFormat(buf, backingStore->backingStore,
404507
+                                        xmlopt, flags) < 0)
404507
         return -1;
404507
 
404507
     virBufferAdjustIndent(buf, -2);
404507
@@ -22510,7 +22585,8 @@ virDomainDiskBackingStoreFormat(virBufferPtr buf,
404507
 static int
404507
 virDomainDiskDefFormat(virBufferPtr buf,
404507
                        virDomainDiskDefPtr def,
404507
-                       unsigned int flags)
404507
+                       unsigned int flags,
404507
+                       virDomainXMLOptionPtr xmlopt)
404507
 {
404507
     const char *type = virStorageTypeToString(def->src->type);
404507
     const char *device = virDomainDiskDeviceTypeToString(def->device);
404507
@@ -22623,13 +22699,14 @@ virDomainDiskDefFormat(virBufferPtr buf,
404507
     }
404507
 
404507
     if (virDomainDiskSourceFormat(buf, def->src, def->startupPolicy,
404507
-                                  flags) < 0)
404507
+                                  flags, xmlopt) < 0)
404507
         return -1;
404507
 
404507
     /* Don't format backingStore to inactive XMLs until the code for
404507
      * persistent storage of backing chains is ready. */
404507
     if (!(flags & VIR_DOMAIN_DEF_FORMAT_INACTIVE) &&
404507
-        virDomainDiskBackingStoreFormat(buf, def->src->backingStore) < 0)
404507
+        virDomainDiskBackingStoreFormat(buf, def->src->backingStore,
404507
+                                        xmlopt, flags) < 0)
404507
         return -1;
404507
 
404507
     virBufferEscapeString(buf, "<backenddomain name='%s'/>\n", def->domain_name);
404507
@@ -22666,7 +22743,7 @@ virDomainDiskDefFormat(virBufferPtr buf,
404507
         virBufferAddLit(buf, ">\n");
404507
         virBufferAdjustIndent(buf, 2);
404507
         virBufferEscapeString(buf, "<format type='%s'/>\n", formatStr);
404507
-        if (virDomainDiskSourceFormat(buf, def->mirror, 0, 0) < 0)
404507
+        if (virDomainDiskSourceFormat(buf, def->mirror, 0, 0, xmlopt) < 0)
404507
             return -1;
404507
         virBufferAdjustIndent(buf, -2);
404507
         virBufferAddLit(buf, "</mirror>\n");
404507
@@ -25897,7 +25974,8 @@ int
404507
 virDomainDefFormatInternal(virDomainDefPtr def,
404507
                            virCapsPtr caps,
404507
                            unsigned int flags,
404507
-                           virBufferPtr buf)
404507
+                           virBufferPtr buf,
404507
+                           virDomainXMLOptionPtr xmlopt)
404507
 {
404507
     unsigned char *uuid;
404507
     char uuidstr[VIR_UUID_STRING_BUFLEN];
404507
@@ -25952,10 +26030,10 @@ virDomainDefFormatInternal(virDomainDefPtr def,
404507
          * but no leading indentation before the starting element.
404507
          * Thankfully, libxml maps what looks like globals into
404507
          * thread-local uses, so we are thread-safe.  */
404507
-        xmlIndentTreeOutput = 1;
404507
-        xmlbuf = xmlBufferCreate();
404507
-        if (xmlNodeDump(xmlbuf, def->metadata->doc, def->metadata,
404507
-                        virBufferGetIndent(buf, false) / 2, 1) < 0) {
404507
+            xmlIndentTreeOutput = 1;
404507
+            xmlbuf = xmlBufferCreate();
404507
+            if (xmlNodeDump(xmlbuf, def->metadata->doc, def->metadata,
404507
+                            virBufferGetIndent(buf, false) / 2, 1) < 0) {
404507
             xmlBufferFree(xmlbuf);
404507
             xmlIndentTreeOutput = oldIndentTreeOutput;
404507
             goto error;
404507
@@ -26528,7 +26606,7 @@ virDomainDefFormatInternal(virDomainDefPtr def,
404507
                           def->emulator);
404507
 
404507
     for (n = 0; n < def->ndisks; n++)
404507
-        if (virDomainDiskDefFormat(buf, def->disks[n], flags) < 0)
404507
+        if (virDomainDiskDefFormat(buf, def->disks[n], flags, xmlopt) < 0)
404507
             goto error;
404507
 
404507
     for (n = 0; n < def->ncontrollers; n++)
404507
@@ -26715,7 +26793,7 @@ virDomainDefFormat(virDomainDefPtr def, virCapsPtr caps, unsigned int flags)
404507
     virBuffer buf = VIR_BUFFER_INITIALIZER;
404507
 
404507
     virCheckFlags(VIR_DOMAIN_DEF_FORMAT_COMMON_FLAGS, NULL);
404507
-    if (virDomainDefFormatInternal(def, caps, flags, &buf) < 0)
404507
+    if (virDomainDefFormatInternal(def, caps, flags, &buf, NULL) < 0)
404507
         return NULL;
404507
 
404507
     return virBufferContentAndReset(&buf;;
404507
@@ -26750,7 +26828,7 @@ virDomainObjFormat(virDomainXMLOptionPtr xmlopt,
404507
         xmlopt->privateData.format(&buf, obj) < 0)
404507
         goto error;
404507
 
404507
-    if (virDomainDefFormatInternal(obj->def, caps, flags, &buf) < 0)
404507
+    if (virDomainDefFormatInternal(obj->def, caps, flags, &buf, xmlopt) < 0)
404507
         goto error;
404507
 
404507
     virBufferAdjustIndent(&buf, -2);
404507
@@ -27704,7 +27782,7 @@ virDomainDeviceDefCopy(virDomainDeviceDefPtr src,
404507
 
404507
     switch ((virDomainDeviceType) src->type) {
404507
     case VIR_DOMAIN_DEVICE_DISK:
404507
-        rc = virDomainDiskDefFormat(&buf, src->data.disk, flags);
404507
+        rc = virDomainDiskDefFormat(&buf, src->data.disk, flags, xmlopt);
404507
         break;
404507
     case VIR_DOMAIN_DEVICE_LEASE:
404507
         rc = virDomainLeaseDefFormat(&buf, src->data.lease);
404507
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
404507
index 698d3280fe..5e67c9a9c1 100644
404507
--- a/src/conf/domain_conf.h
404507
+++ b/src/conf/domain_conf.h
404507
@@ -2626,6 +2626,12 @@ typedef int (*virDomainXMLPrivateDataParseFunc)(xmlXPathContextPtr,
404507
                                                 virDomainObjPtr,
404507
                                                 virDomainDefParserConfigPtr);
404507
 
404507
+typedef int (*virDomainXMLPrivateDataStorageSourceParseFunc)(xmlXPathContextPtr ctxt,
404507
+                                                             virStorageSourcePtr src);
404507
+typedef int (*virDomainXMLPrivateDataStorageSourceFormatFunc)(virStorageSourcePtr src,
404507
+                                                              virBufferPtr buf);
404507
+
404507
+
404507
 typedef struct _virDomainXMLPrivateDataCallbacks virDomainXMLPrivateDataCallbacks;
404507
 typedef virDomainXMLPrivateDataCallbacks *virDomainXMLPrivateDataCallbacksPtr;
404507
 struct _virDomainXMLPrivateDataCallbacks {
404507
@@ -2639,6 +2645,8 @@ struct _virDomainXMLPrivateDataCallbacks {
404507
     virDomainXMLPrivateDataNewFunc    chrSourceNew;
404507
     virDomainXMLPrivateDataFormatFunc format;
404507
     virDomainXMLPrivateDataParseFunc  parse;
404507
+    virDomainXMLPrivateDataStorageSourceParseFunc storageParse;
404507
+    virDomainXMLPrivateDataStorageSourceFormatFunc storageFormat;
404507
 };
404507
 
404507
 typedef bool (*virDomainABIStabilityDomain)(const virDomainDef *src,
404507
@@ -2963,12 +2971,14 @@ char *virDomainObjFormat(virDomainXMLOptionPtr xmlopt,
404507
 int virDomainDefFormatInternal(virDomainDefPtr def,
404507
                                virCapsPtr caps,
404507
                                unsigned int flags,
404507
-                               virBufferPtr buf);
404507
+                               virBufferPtr buf,
404507
+                               virDomainXMLOptionPtr xmlopt);
404507
 
404507
 int virDomainDiskSourceFormat(virBufferPtr buf,
404507
                               virStorageSourcePtr src,
404507
                               int policy,
404507
-                              unsigned int flags);
404507
+                              unsigned int flags,
404507
+                              virDomainXMLOptionPtr xmlopt);
404507
 
404507
 int virDomainNetDefFormat(virBufferPtr buf,
404507
                           virDomainNetDefPtr def,
404507
@@ -3017,7 +3027,8 @@ virDomainDiskRemoveByName(virDomainDefPtr def, const char *name);
404507
 int virDomainDiskSourceParse(xmlNodePtr node,
404507
                              xmlXPathContextPtr ctxt,
404507
                              virStorageSourcePtr src,
404507
-                             unsigned int flags);
404507
+                             unsigned int flags,
404507
+                             virDomainXMLOptionPtr xmlopt);
404507
 
404507
 int virDomainNetFindIdx(virDomainDefPtr def, virDomainNetDefPtr net);
404507
 virDomainNetDefPtr virDomainNetFind(virDomainDefPtr def, const char *device);
404507
diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c
404507
index f0e852c92b..d7b086242b 100644
404507
--- a/src/conf/snapshot_conf.c
404507
+++ b/src/conf/snapshot_conf.c
404507
@@ -110,7 +110,8 @@ static int
404507
 virDomainSnapshotDiskDefParseXML(xmlNodePtr node,
404507
                                  xmlXPathContextPtr ctxt,
404507
                                  virDomainSnapshotDiskDefPtr def,
404507
-                                 unsigned int flags)
404507
+                                 unsigned int flags,
404507
+                                 virDomainXMLOptionPtr xmlopt)
404507
 {
404507
     int ret = -1;
404507
     char *snapshot = NULL;
404507
@@ -155,7 +156,7 @@ virDomainSnapshotDiskDefParseXML(xmlNodePtr node,
404507
     }
404507
 
404507
     if ((cur = virXPathNode("./source", ctxt)) &&
404507
-        virDomainDiskSourceParse(cur, ctxt, def->src, flags) < 0)
404507
+        virDomainDiskSourceParse(cur, ctxt, def->src, flags, xmlopt) < 0)
404507
         goto cleanup;
404507
 
404507
     if ((driver = virXPathString("string(./driver/@type)", ctxt))) {
404507
@@ -348,8 +349,8 @@ virDomainSnapshotDefParse(xmlXPathContextPtr ctxt,
404507
             goto cleanup;
404507
         def->ndisks = n;
404507
         for (i = 0; i < def->ndisks; i++) {
404507
-            if (virDomainSnapshotDiskDefParseXML(nodes[i], ctxt,
404507
-                                                 &def->disks[i], flags) < 0)
404507
+            if (virDomainSnapshotDiskDefParseXML(nodes[i], ctxt, &def->disks[i],
404507
+                                                 flags, xmlopt) < 0)
404507
                 goto cleanup;
404507
         }
404507
         VIR_FREE(nodes);
404507
@@ -663,7 +664,8 @@ virDomainSnapshotAlignDisks(virDomainSnapshotDefPtr def,
404507
 
404507
 static void
404507
 virDomainSnapshotDiskDefFormat(virBufferPtr buf,
404507
-                               virDomainSnapshotDiskDefPtr disk)
404507
+                               virDomainSnapshotDiskDefPtr disk,
404507
+                               virDomainXMLOptionPtr xmlopt)
404507
 {
404507
     int type = disk->src->type;
404507
 
404507
@@ -686,7 +688,7 @@ virDomainSnapshotDiskDefFormat(virBufferPtr buf,
404507
     if (disk->src->format > 0)
404507
         virBufferEscapeString(buf, "<driver type='%s'/>\n",
404507
                               virStorageFileFormatTypeToString(disk->src->format));
404507
-    virDomainDiskSourceFormat(buf, disk->src, 0, 0);
404507
+    virDomainDiskSourceFormat(buf, disk->src, 0, 0, xmlopt);
404507
 
404507
     virBufferAdjustIndent(buf, -2);
404507
     virBufferAddLit(buf, "</disk>\n");
404507
@@ -740,13 +742,13 @@ virDomainSnapshotDefFormat(const char *domain_uuid,
404507
         virBufferAddLit(&buf, "<disks>\n");
404507
         virBufferAdjustIndent(&buf, 2);
404507
         for (i = 0; i < def->ndisks; i++)
404507
-            virDomainSnapshotDiskDefFormat(&buf, &def->disks[i]);
404507
+            virDomainSnapshotDiskDefFormat(&buf, &def->disks[i], xmlopt);
404507
         virBufferAdjustIndent(&buf, -2);
404507
         virBufferAddLit(&buf, "</disks>\n");
404507
     }
404507
 
404507
     if (def->dom) {
404507
-        if (virDomainDefFormatInternal(def->dom, caps, flags, &buf) < 0)
404507
+        if (virDomainDefFormatInternal(def->dom, caps, flags, &buf, xmlopt) < 0)
404507
             goto error;
404507
     } else if (domain_uuid) {
404507
         virBufferAddLit(&buf, "<domain>\n");
404507
diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
404507
index fcaa66df91..334da7a85d 100644
404507
--- a/src/network/bridge_driver.c
404507
+++ b/src/network/bridge_driver.c
404507
@@ -233,7 +233,7 @@ networkRunHook(virNetworkObjPtr obj,
404507
             goto cleanup;
404507
         if (virNetworkDefFormatBuf(&buf, def, 0) < 0)
404507
             goto cleanup;
404507
-        if (dom && virDomainDefFormatInternal(dom, NULL, 0, &buf) < 0)
404507
+        if (dom && virDomainDefFormatInternal(dom, NULL, 0, &buf, NULL) < 0)
404507
             goto cleanup;
404507
 
404507
         virBufferAdjustIndent(&buf, -2);
404507
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
404507
index 9dd9db049b..625bcb20d5 100644
404507
--- a/src/qemu/qemu_domain.c
404507
+++ b/src/qemu/qemu_domain.c
404507
@@ -5245,7 +5245,7 @@ qemuDomainDefFormatBufInternal(virQEMUDriverPtr driver,
404507
  format:
404507
     ret = virDomainDefFormatInternal(def, caps,
404507
                                      virDomainDefFormatConvertXMLFlags(flags),
404507
-                                     buf);
404507
+                                     buf, driver->xmlopt);
404507
 
404507
  cleanup:
404507
     virDomainDefFree(copy);
404507
diff --git a/tests/virstoragetest.c b/tests/virstoragetest.c
404507
index e1d8751728..bdd0829c21 100644
404507
--- a/tests/virstoragetest.c
404507
+++ b/tests/virstoragetest.c
404507
@@ -693,7 +693,7 @@ testBackingParse(const void *args)
404507
         goto cleanup;
404507
     }
404507
 
404507
-    if (virDomainDiskSourceFormat(&buf, src, 0, 0) < 0 ||
404507
+    if (virDomainDiskSourceFormat(&buf, src, 0, 0, NULL) < 0 ||
404507
         !(xml = virBufferContentAndReset(&buf))) {
404507
         fprintf(stderr, "failed to format disk source xml\n");
404507
         goto cleanup;
404507
-- 
404507
2.15.1
404507