]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
conf: Add parameter to virDomainDiskSourceFormat
authorEric Blake <eblake@redhat.com>
Thu, 4 Apr 2019 20:32:05 +0000 (15:32 -0500)
committerEric Blake <eblake@redhat.com>
Mon, 6 May 2019 23:05:17 +0000 (18:05 -0500)
Commits 4bc42986 and 218c81ea removed virDomainStorageSourceFormat on
the grounds that there were no external callers; however, the upcoming
backup code wants to output a <target> (push mode) or <scratch> (pull
mode) element that is in all other respects identical to a domain's
<source> element, where the previous virDomainStorageSourceFormat fit
the bill nicely. But rather than reverting the commits, it's easier to
just add an additional parameter for the element name to use, and
update all callers.

Signed-off-by: Eric Blake <eblake@redhat.com>
src/conf/domain_conf.c
src/conf/domain_conf.h
src/conf/snapshot_conf.c
src/qemu/qemu_domain.c
tests/qemublocktest.c
tests/virstoragetest.c

index b4fb6cf981e30e226b147d2280ae932e3cca12d3..a3a514136b58458f290e9a4c3813b83bb800bb07 100644 (file)
@@ -23929,6 +23929,7 @@ virDomainDiskSourceFormatPrivateData(virBufferPtr buf,
  * virDomainDiskSourceFormat:
  * @buf: output buffer
  * @src: storage source definition to format
+ * @element: name to use for the top-level element (often "source")
  * @policy: startup policy attribute value, if necessary
  * @attrIndex: the 'index' attribute of <source> is formatted if true
  * @flags: XML formatter flags
@@ -23940,6 +23941,7 @@ virDomainDiskSourceFormatPrivateData(virBufferPtr buf,
 int
 virDomainDiskSourceFormat(virBufferPtr buf,
                           virStorageSourcePtr src,
+                          const char *element,
                           int policy,
                           bool attrIndex,
                           unsigned int flags,
@@ -24020,7 +24022,7 @@ virDomainDiskSourceFormat(virBufferPtr buf,
     if (virDomainDiskSourceFormatPrivateData(&childBuf, src, flags, xmlopt) < 0)
         return -1;
 
-    if (virXMLFormatElement(buf, "source", &attrBuf, &childBuf) < 0)
+    if (virXMLFormatElement(buf, element, &attrBuf, &childBuf) < 0)
         return -1;
 
     return 0;
@@ -24066,7 +24068,8 @@ virDomainDiskBackingStoreFormat(virBufferPtr buf,
 
     virBufferAsprintf(&childBuf, "<format type='%s'/>\n",
                       virStorageFileFormatTypeToString(backingStore->format));
-    if (virDomainDiskSourceFormat(&childBuf, backingStore, 0, false, flags, xmlopt) < 0)
+    if (virDomainDiskSourceFormat(&childBuf, backingStore, "source", 0, false,
+                                  flags, xmlopt) < 0)
         return -1;
 
     if (virDomainDiskBackingStoreFormat(&childBuf, backingStore, xmlopt, flags) < 0)
@@ -24229,7 +24232,8 @@ virDomainDiskDefFormatMirror(virBufferPtr buf,
                               virDomainDiskMirrorStateTypeToString(disk->mirrorState));
 
     virBufferEscapeString(&childBuf, "<format type='%s'/>\n", formatStr);
-    if (virDomainDiskSourceFormat(&childBuf, disk->mirror, 0, true, flags, xmlopt) < 0)
+    if (virDomainDiskSourceFormat(&childBuf, disk->mirror, "source", 0, true,
+                                  flags, xmlopt) < 0)
         return -1;
 
     if (virDomainDiskBackingStoreFormat(&childBuf, disk->mirror, xmlopt, flags) < 0)
@@ -24329,8 +24333,8 @@ virDomainDiskDefFormat(virBufferPtr buf,
     if (def->src->auth && !def->src->authInherited)
         virStorageAuthDefFormat(buf, def->src->auth);
 
-    if (virDomainDiskSourceFormat(buf, def->src, def->startupPolicy, true,
-                                  flags, xmlopt) < 0)
+    if (virDomainDiskSourceFormat(buf, def->src, "source", def->startupPolicy,
+                                  true, flags, xmlopt) < 0)
         return -1;
 
     /* Don't format backingStore to inactive XMLs until the code for
index 01c22d8cc3d72cb0c5aae750c71285754754dfbb..fa0756b6340b7d6674443e42ac3ca22b42cd14db 100644 (file)
@@ -3061,6 +3061,7 @@ int virDomainDefFormatInternal(virDomainDefPtr def,
 
 int virDomainDiskSourceFormat(virBufferPtr buf,
                               virStorageSourcePtr src,
+                              const char *element,
                               int policy,
                               bool attrIndex,
                               unsigned int flags,
index 36c328f6926f3f44538158b7d8169feade32eb6f..eaa9b3c5e6fd1f5f3e196777ab6b960773750a96 100644 (file)
@@ -772,7 +772,8 @@ virDomainSnapshotDiskDefFormat(virBufferPtr buf,
     if (disk->src->format > 0)
         virBufferEscapeString(buf, "<driver type='%s'/>\n",
                               virStorageFileFormatTypeToString(disk->src->format));
-    if (virDomainDiskSourceFormat(buf, disk->src, 0, false, 0, xmlopt) < 0)
+    if (virDomainDiskSourceFormat(buf, disk->src, "source", 0, false, 0,
+                                  xmlopt) < 0)
         return -1;
 
     virBufferAdjustIndent(buf, -2);
index 960aaff3c7ad5aa3762ad04d33b4da44b1d04896..db67fe219336cde46b08e23ba1069f9e12c114fb 100644 (file)
@@ -2360,7 +2360,7 @@ qemuDomainObjPrivateXMLFormatNBDMigrationSource(virBufferPtr buf,
                       virStorageTypeToString(src->type),
                       virStorageFileFormatTypeToString(src->format));
 
-    if (virDomainDiskSourceFormat(&childBuf, src, 0, false,
+    if (virDomainDiskSourceFormat(&childBuf, src, "source", 0, false,
                                   VIR_DOMAIN_DEF_FORMAT_STATUS, xmlopt) < 0)
         goto cleanup;
 
index c221b8af3079e3e08626a83c922edba455b3c0f5..21db3e4881f07b7d407ffe9d25e51f5513c2a3a7 100644 (file)
@@ -86,7 +86,8 @@ testBackingXMLjsonXML(const void *args)
         return -1;
     }
 
-    if (virDomainDiskSourceFormat(&buf, jsonsrc, 0, false, 0, NULL) < 0 ||
+    if (virDomainDiskSourceFormat(&buf, jsonsrc, "source", 0, false, 0,
+                                  NULL) < 0 ||
         !(actualxml = virBufferContentAndReset(&buf))) {
         fprintf(stderr, "failed to format disk source xml\n");
         return -1;
index 4f235112400347e00f3d2708174a3771a14b3269..ef16b3c6e06beefb5d4295844d567590d6f9f08f 100644 (file)
@@ -627,7 +627,7 @@ testBackingParse(const void *args)
         goto cleanup;
     }
 
-    if (virDomainDiskSourceFormat(&buf, src, 0, false, 0, NULL) < 0 ||
+    if (virDomainDiskSourceFormat(&buf, src, "source", 0, false, 0, NULL) < 0 ||
         !(xml = virBufferContentAndReset(&buf))) {
         fprintf(stderr, "failed to format disk source xml\n");
         goto cleanup;