[libvirt] [PATCH 10/34] conf: Move virDomainDiskBackingStoreFormat up to avoid forward declarations

Peter Krempa pkrempa at redhat.com
Mon Mar 18 15:54:59 UTC 2019


Upcoming commits will reorganize control flow leading to calling the
function to virDomainDiskSourceFormat thus it needs to be moved slightly
up.

Signed-off-by: Peter Krempa <pkrempa at redhat.com>
---
 src/conf/domain_conf.c | 102 ++++++++++++++++++++---------------------
 1 file changed, 51 insertions(+), 51 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 2b6a2b7ee8..9d738f06cd 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -23857,6 +23857,57 @@ virDomainStorageSourceFormat(virBufferPtr attrBuf,
 }


+static int
+virDomainDiskBackingStoreFormat(virBufferPtr buf,
+                                virStorageSourcePtr backingStore,
+                                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;
+
+    /* don't write detected backing chain members to inactive xml */
+    if (inactive && backingStore->detected)
+        return 0;
+
+    if (backingStore->type == VIR_STORAGE_TYPE_NONE) {
+        virBufferAddLit(buf, "<backingStore/>\n");
+        return 0;
+    }
+
+    if (backingStore->format <= 0 || backingStore->format >= VIR_STORAGE_FILE_LAST) {
+        virReportError(VIR_ERR_INTERNAL_ERROR,
+                       _("unexpected disk backing store format %d"),
+                       backingStore->format);
+        return -1;
+    }
+
+    virBufferAsprintf(&attrBuf, " type='%s'",
+                      virStorageTypeToString(backingStore->type));
+    if (backingStore->id != 0)
+        virBufferAsprintf(&attrBuf, " index='%u'", backingStore->id);
+
+    virBufferAsprintf(&childBuf, "<format type='%s'/>\n",
+                      virStorageFileFormatTypeToString(backingStore->format));
+    /* We currently don't output seclabels for backing chain element */
+    if (virDomainDiskSourceFormat(&childBuf, backingStore, 0, flags, false,
+                                  false, xmlopt) < 0)
+        return -1;
+
+    if (virDomainDiskBackingStoreFormat(&childBuf, backingStore->backingStore,
+                                        xmlopt, flags) < 0)
+        return -1;
+
+    return virXMLFormatElement(buf, "backingStore", &attrBuf, &childBuf);
+}
+
+
 /**
  * virDomainStorageSourceFormatFull:
  * @buf: output buffer
@@ -23918,57 +23969,6 @@ virDomainDiskSourceFormat(virBufferPtr buf,
 }


-static int
-virDomainDiskBackingStoreFormat(virBufferPtr buf,
-                                virStorageSourcePtr backingStore,
-                                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;
-
-    /* don't write detected backing chain members to inactive xml */
-    if (inactive && backingStore->detected)
-        return 0;
-
-    if (backingStore->type == VIR_STORAGE_TYPE_NONE) {
-        virBufferAddLit(buf, "<backingStore/>\n");
-        return 0;
-    }
-
-    if (backingStore->format <= 0 || backingStore->format >= VIR_STORAGE_FILE_LAST) {
-        virReportError(VIR_ERR_INTERNAL_ERROR,
-                       _("unexpected disk backing store format %d"),
-                       backingStore->format);
-        return -1;
-    }
-
-    virBufferAsprintf(&attrBuf, " type='%s'",
-                      virStorageTypeToString(backingStore->type));
-    if (backingStore->id != 0)
-        virBufferAsprintf(&attrBuf, " index='%u'", backingStore->id);
-
-    virBufferAsprintf(&childBuf, "<format type='%s'/>\n",
-                      virStorageFileFormatTypeToString(backingStore->format));
-    /* We currently don't output seclabels for backing chain element */
-    if (virDomainDiskSourceFormat(&childBuf, backingStore, 0, flags, false,
-                                  false, xmlopt) < 0)
-        return -1;
-
-    if (virDomainDiskBackingStoreFormat(&childBuf, backingStore->backingStore,
-                                        xmlopt, flags) < 0)
-        return -1;
-
-    return virXMLFormatElement(buf, "backingStore", &attrBuf, &childBuf);
-}
-
-
 #define FORMAT_IOTUNE(val) \
         if (disk->blkdeviotune.val) { \
             virBufferAsprintf(&childBuf, "<" #val ">%llu</" #val ">\n", \
-- 
2.20.1




More information about the libvir-list mailing list