]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
conf: Use virXMLFormatElement in virDomainDiskBackingStoreFormat
authorPeter Krempa <pkrempa@redhat.com>
Thu, 7 Mar 2019 17:00:03 +0000 (18:00 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 3 Apr 2019 09:58:09 +0000 (11:58 +0200)
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/conf/domain_conf.c

index 940ef5aee71a145680d88287a12de36721e52054..6a2d46b3e9826b02df84fea0b3aa441723b87744 100644 (file)
@@ -23826,8 +23826,12 @@ virDomainDiskBackingStoreFormat(virBufferPtr buf,
                                 virDomainXMLOptionPtr xmlopt,
                                 unsigned int flags)
 {
+    VIR_AUTOCLEAN(virBuffer) attrBuf = VIR_BUFFER_INITIALIZER;
+    VIR_AUTOCLEAN(virBuffer) childBuf = VIR_BUFFER_INITIALIZER;
     bool inactive = flags & VIR_DOMAIN_DEF_FORMAT_INACTIVE;
 
+    virBufferSetChildIndent(&childBuf, buf);
+
     if (!backingStore)
         return 0;
 
@@ -23847,22 +23851,23 @@ virDomainDiskBackingStoreFormat(virBufferPtr buf,
         return -1;
     }
 
-    virBufferAsprintf(buf, "<backingStore type='%s'",
+    virBufferAsprintf(&attrBuf, " type='%s'",
                       virStorageTypeToString(backingStore->type));
     if (backingStore->id != 0)
-        virBufferAsprintf(buf, " index='%u'", backingStore->id);
-    virBufferAddLit(buf, ">\n");
-    virBufferAdjustIndent(buf, 2);
+        virBufferAsprintf(&attrBuf, " index='%u'", backingStore->id);
 
-    virBufferAsprintf(buf, "<format type='%s'/>\n",
+    virBufferAsprintf(&childBuf, "<format type='%s'/>\n",
                       virStorageFileFormatTypeToString(backingStore->format));
-    if (virDomainDiskSourceFormat(buf, backingStore, 0, false, flags, xmlopt) < 0 ||
-        virDomainDiskBackingStoreFormat(buf, backingStore->backingStore,
+    if (virDomainDiskSourceFormat(&childBuf, backingStore, 0, false, flags, xmlopt) < 0)
+        return -1;
+
+    if (virDomainDiskBackingStoreFormat(&childBuf, backingStore->backingStore,
                                         xmlopt, flags) < 0)
         return -1;
 
-    virBufferAdjustIndent(buf, -2);
-    virBufferAddLit(buf, "</backingStore>\n");
+    if (virXMLFormatElement(buf, "backingStore", &attrBuf, &childBuf) < 0)
+        return -1;
+
     return 0;
 }