[libvirt] [PATCH 06/34] conf: domain: Merge virDomainDiskSourceFormatInternal into the wrapper

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


virDomainDiskSourceFormat would call virDomainDiskSourceFormatInternal
with a limited set of parameters. Remove the 'Internal' variant by
squishing into virDomainDiskSourceFormat and fix the callers.

Signed-off-by: Peter Krempa <pkrempa at redhat.com>
---
 src/conf/domain_conf.c   | 38 +++++++++++++-------------------------
 src/conf/domain_conf.h   |  2 ++
 src/conf/snapshot_conf.c |  2 +-
 tests/qemublocktest.c    |  2 +-
 tests/virstoragetest.c   |  2 +-
 5 files changed, 18 insertions(+), 28 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 32f6d88596..79e15c9886 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -23896,14 +23896,14 @@ virDomainStorageSourceFormatFull(virBufferPtr buf,
 }


-static int
-virDomainDiskSourceFormatInternal(virBufferPtr buf,
-                                  virStorageSourcePtr src,
-                                  int policy,
-                                  unsigned int flags,
-                                  bool seclabels,
-                                  bool attrIndex,
-                                  virDomainXMLOptionPtr xmlopt)
+int
+virDomainDiskSourceFormat(virBufferPtr buf,
+                          virStorageSourcePtr src,
+                          int policy,
+                          unsigned int flags,
+                          bool seclabels,
+                          bool attrIndex,
+                          virDomainXMLOptionPtr xmlopt)
 {
     VIR_AUTOCLEAN(virBuffer) attrBuf = VIR_BUFFER_INITIALIZER;
     VIR_AUTOCLEAN(virBuffer) childBuf = VIR_BUFFER_INITIALIZER;
@@ -23925,18 +23925,6 @@ virDomainDiskSourceFormatInternal(virBufferPtr buf,
 }


-int
-virDomainDiskSourceFormat(virBufferPtr buf,
-                          virStorageSourcePtr src,
-                          int policy,
-                          unsigned int flags,
-                          virDomainXMLOptionPtr xmlopt)
-{
-    return virDomainDiskSourceFormatInternal(buf, src, policy, flags, true,
-                                             false, xmlopt);
-}
-
-
 static int
 virDomainDiskBackingStoreFormat(virBufferPtr buf,
                                 virStorageSourcePtr backingStore,
@@ -23975,8 +23963,8 @@ virDomainDiskBackingStoreFormat(virBufferPtr buf,

     virBufferAsprintf(buf, "<format type='%s'/>\n", format);
     /* We currently don't output seclabels for backing chain element */
-    if (virDomainDiskSourceFormatInternal(buf, backingStore, 0, flags, false,
-                                          false, xmlopt) < 0 ||
+    if (virDomainDiskSourceFormat(buf, backingStore, 0, flags, false,
+                                  false, xmlopt) < 0 ||
         virDomainDiskBackingStoreFormat(buf, backingStore->backingStore,
                                         xmlopt, flags) < 0)
         return -1;
@@ -24137,7 +24125,7 @@ virDomainDiskDefFormatMirror(virBufferPtr buf,
     virBufferAddLit(buf, ">\n");
     virBufferAdjustIndent(buf, 2);
     virBufferEscapeString(buf, "<format type='%s'/>\n", formatStr);
-    if (virDomainDiskSourceFormat(buf, disk->mirror, 0, 0, xmlopt) < 0)
+    if (virDomainDiskSourceFormat(buf, disk->mirror, 0, 0, true, false, xmlopt) < 0)
         return -1;
     virBufferAdjustIndent(buf, -2);
     virBufferAddLit(buf, "</mirror>\n");
@@ -24233,8 +24221,8 @@ virDomainDiskDefFormat(virBufferPtr buf,
     if (def->src->auth && !def->src->authInherited)
         virStorageAuthDefFormat(buf, def->src->auth);

-    if (virDomainDiskSourceFormatInternal(buf, def->src, def->startupPolicy,
-                                          flags, true, true, xmlopt) < 0)
+    if (virDomainDiskSourceFormat(buf, def->src, def->startupPolicy,
+                                  flags, true, true, xmlopt) < 0)
         return -1;

     /* Don't format backingStore to inactive XMLs until the code for
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 51e0757f5c..7ea9822fe4 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -3016,6 +3016,8 @@ int virDomainDiskSourceFormat(virBufferPtr buf,
                               virStorageSourcePtr src,
                               int policy,
                               unsigned int flags,
+                              bool seclabels,
+                              bool attrIndex,
                               virDomainXMLOptionPtr xmlopt);

 int virDomainNetDefFormat(virBufferPtr buf,
diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c
index ffb1313c89..a849a58da3 100644
--- a/src/conf/snapshot_conf.c
+++ b/src/conf/snapshot_conf.c
@@ -768,7 +768,7 @@ virDomainSnapshotDiskDefFormat(virBufferPtr buf,
     if (disk->src->format > 0)
         virBufferEscapeString(buf, "<driver type='%s'/>\n",
                               virStorageFileFormatTypeToString(disk->src->format));
-    if (virDomainDiskSourceFormat(buf, disk->src, 0, 0, xmlopt) < 0)
+    if (virDomainDiskSourceFormat(buf, disk->src, 0, 0, true, false, xmlopt) < 0)
         return -1;

     virBufferAdjustIndent(buf, -2);
diff --git a/tests/qemublocktest.c b/tests/qemublocktest.c
index 4cd15a1dff..6b5571b7cb 100644
--- a/tests/qemublocktest.c
+++ b/tests/qemublocktest.c
@@ -87,7 +87,7 @@ testBackingXMLjsonXML(const void *args)
         goto cleanup;
     }

-    if (virDomainDiskSourceFormat(&buf, jsonsrc, 0, 0, NULL) < 0 ||
+    if (virDomainDiskSourceFormat(&buf, jsonsrc, 0, 0, true, false, NULL) < 0 ||
         !(actualxml = virBufferContentAndReset(&buf))) {
         fprintf(stderr, "failed to format disk source xml\n");
         goto cleanup;
diff --git a/tests/virstoragetest.c b/tests/virstoragetest.c
index fb98903f02..75c60da537 100644
--- a/tests/virstoragetest.c
+++ b/tests/virstoragetest.c
@@ -657,7 +657,7 @@ testBackingParse(const void *args)
         goto cleanup;
     }

-    if (virDomainDiskSourceFormat(&buf, src, 0, 0, NULL) < 0 ||
+    if (virDomainDiskSourceFormat(&buf, src, 0, 0, true, false, NULL) < 0 ||
         !(xml = virBufferContentAndReset(&buf))) {
         fprintf(stderr, "failed to format disk source xml\n");
         goto cleanup;
-- 
2.20.1




More information about the libvir-list mailing list