[libvirt] [PATCH v2 13/29] conf: Merge virDomainStorageSourceFormat into virDomainDiskSourceFormat

Peter Krempa pkrempa at redhat.com
Fri Mar 22 18:00:49 UTC 2019


There was only one caller, remove the unnecessary wrapper.

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

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 89e2900df2..db02005f5b 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -23716,38 +23716,45 @@ virDomainDiskSourceFormatPrivateData(virBufferPtr buf,
 }


-static int
-virDomainStorageSourceFormat(virBufferPtr attrBuf,
-                             virBufferPtr childBuf,
-                             virStorageSourcePtr src,
-                             unsigned int flags)
+int
+virDomainDiskSourceFormat(virBufferPtr buf,
+                          virStorageSourcePtr src,
+                          int policy,
+                          bool attrIndex,
+                          unsigned int flags,
+                          virDomainXMLOptionPtr xmlopt)
 {
+    VIR_AUTOCLEAN(virBuffer) attrBuf = VIR_BUFFER_INITIALIZER;
+    VIR_AUTOCLEAN(virBuffer) childBuf = VIR_BUFFER_INITIALIZER;
+
+    virBufferSetChildIndent(&childBuf, buf);
+
     switch ((virStorageType)src->type) {
     case VIR_STORAGE_TYPE_FILE:
-        virBufferEscapeString(attrBuf, " file='%s'", src->path);
+        virBufferEscapeString(&attrBuf, " file='%s'", src->path);
         break;

     case VIR_STORAGE_TYPE_BLOCK:
-        virBufferEscapeString(attrBuf, " dev='%s'", src->path);
+        virBufferEscapeString(&attrBuf, " dev='%s'", src->path);
         break;

     case VIR_STORAGE_TYPE_DIR:
-        virBufferEscapeString(attrBuf, " dir='%s'", src->path);
+        virBufferEscapeString(&attrBuf, " dir='%s'", src->path);
         break;

     case VIR_STORAGE_TYPE_NETWORK:
-        if (virDomainDiskSourceFormatNetwork(attrBuf, childBuf,
+        if (virDomainDiskSourceFormatNetwork(&attrBuf, &childBuf,
                                              src, flags) < 0)
             return -1;
         break;

     case VIR_STORAGE_TYPE_VOLUME:
         if (src->srcpool) {
-            virBufferEscapeString(attrBuf, " pool='%s'", src->srcpool->pool);
-            virBufferEscapeString(attrBuf, " volume='%s'",
+            virBufferEscapeString(&attrBuf, " pool='%s'", src->srcpool->pool);
+            virBufferEscapeString(&attrBuf, " volume='%s'",
                                   src->srcpool->volume);
             if (src->srcpool->mode)
-                virBufferAsprintf(attrBuf, " mode='%s'",
+                virBufferAsprintf(&attrBuf, " mode='%s'",
                                   virStorageSourcePoolModeTypeToString(src->srcpool->mode));
         }

@@ -23761,7 +23768,7 @@ virDomainStorageSourceFormat(virBufferPtr attrBuf,
     }

     if (src->type != VIR_STORAGE_TYPE_NETWORK)
-        virDomainSourceDefFormatSeclabel(childBuf, src->nseclabels,
+        virDomainSourceDefFormatSeclabel(&childBuf, src->nseclabels,
                                          src->seclabels, flags);

     /* Storage Source formatting will not carry through the blunder
@@ -23771,38 +23778,17 @@ virDomainStorageSourceFormat(virBufferPtr attrBuf,
      * So avoid formatting it for volumes. */
     if (src->auth && src->authInherited &&
         src->type != VIR_STORAGE_TYPE_VOLUME)
-        virStorageAuthDefFormat(childBuf, src->auth);
+        virStorageAuthDefFormat(&childBuf, src->auth);

     /* If we found encryption as a child of <source>, then format it
      * as we found it. */
     if (src->encryption && src->encryptionInherited &&
-        virStorageEncryptionFormat(childBuf, src->encryption) < 0)
+        virStorageEncryptionFormat(&childBuf, src->encryption) < 0)
         return -1;

     if (src->pr)
-        virStoragePRDefFormat(childBuf, src->pr,
+        virStoragePRDefFormat(&childBuf, src->pr,
                               flags & VIR_DOMAIN_DEF_FORMAT_MIGRATABLE);
-
-    return 0;
-}
-
-
-int
-virDomainDiskSourceFormat(virBufferPtr buf,
-                          virStorageSourcePtr src,
-                          int policy,
-                          bool attrIndex,
-                          unsigned int flags,
-                          virDomainXMLOptionPtr xmlopt)
-{
-    VIR_AUTOCLEAN(virBuffer) attrBuf = VIR_BUFFER_INITIALIZER;
-    VIR_AUTOCLEAN(virBuffer) childBuf = VIR_BUFFER_INITIALIZER;
-
-    virBufferSetChildIndent(&childBuf, buf);
-
-    if (virDomainStorageSourceFormat(&attrBuf, &childBuf, src, flags) < 0)
-        return -1;
-
     if (policy && src->type != VIR_STORAGE_TYPE_NETWORK)
         virBufferEscapeString(&attrBuf, " startupPolicy='%s'",
                               virDomainStartupPolicyTypeToString(policy));
-- 
2.20.1




More information about the libvir-list mailing list