[PATCH 01/12] virStorageSourceGetBackingStoreStr: Move the function earlier

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Move it together with virStorageSourceGetRelativeBackingPath which is
the main reason why it exists. Upcoming patch will modify the comment
and arguments refering to virStorageSourceGetRelativeBackingPath so it's
better if they are together.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/storage_file/storage_source.c | 100 +++++++++++++++---------------
 1 file changed, 50 insertions(+), 50 deletions(-)

diff --git a/src/storage_file/storage_source.c b/src/storage_file/storage_source.c
index 85734d9275..430e3214c4 100644
--- a/src/storage_file/storage_source.c
+++ b/src/storage_file/storage_source.c
@@ -1880,6 +1880,56 @@ virStorageSourceGetRelativeBackingPath(virStorageSourcePtr top,
 }


+/**
+ * virStorageSourceGetBackingStoreStr:
+ * @src: storage object
+ *
+ * Extracts the backing store string as stored in the storage volume described
+ * by @src and returns it to the user. Caller is responsible for freeing it.
+ * In case when the string can't be retrieved or does not exist NULL is
+ * returned.
+ */
+int
+virStorageSourceGetBackingStoreStr(virStorageSourcePtr src,
+                                   char **backing)
+{
+    ssize_t headerLen;
+    int rv;
+    g_autofree char *buf = NULL;
+    g_autoptr(virStorageSource) tmp = NULL;
+
+    *backing = NULL;
+
+    /* exit if we can't load information about the current image */
+    if (!virStorageSourceSupportsBackingChainTraversal(src))
+        return 0;
+
+    rv = virStorageSourceAccess(src, F_OK);
+    if (rv == -2)
+        return 0;
+    if (rv < 0) {
+        virStorageSourceReportBrokenChain(errno, src, src);
+        return -1;
+    }
+
+    if ((headerLen = virStorageSourceRead(src, 0, VIR_STORAGE_MAX_HEADER,
+                                          &buf)) < 0) {
+        if (headerLen == -2)
+            return 0;
+        return -1;
+    }
+
+    if (!(tmp = virStorageSourceCopy(src, false)))
+        return -1;
+
+    if (virStorageFileProbeGetMetadata(tmp, buf, headerLen) < 0)
+        return -1;
+
+    *backing = g_steal_pointer(&tmp->backingStoreRaw);
+    return 0;
+}
+
+
 static bool
 virStorageSourceIsInitialized(const virStorageSource *src)
 {
@@ -2562,53 +2612,3 @@ virStorageSourceGetMetadata(virStorageSourcePtr src,
     virHashFree(cycle);
     return ret;
 }
-
-
-/**
- * virStorageSourceGetBackingStoreStr:
- * @src: storage object
- *
- * Extracts the backing store string as stored in the storage volume described
- * by @src and returns it to the user. Caller is responsible for freeing it.
- * In case when the string can't be retrieved or does not exist NULL is
- * returned.
- */
-int
-virStorageSourceGetBackingStoreStr(virStorageSourcePtr src,
-                                   char **backing)
-{
-    ssize_t headerLen;
-    int rv;
-    g_autofree char *buf = NULL;
-    g_autoptr(virStorageSource) tmp = NULL;
-
-    *backing = NULL;
-
-    /* exit if we can't load information about the current image */
-    if (!virStorageSourceSupportsBackingChainTraversal(src))
-        return 0;
-
-    rv = virStorageSourceAccess(src, F_OK);
-    if (rv == -2)
-        return 0;
-    if (rv < 0) {
-        virStorageSourceReportBrokenChain(errno, src, src);
-        return -1;
-    }
-
-    if ((headerLen = virStorageSourceRead(src, 0, VIR_STORAGE_MAX_HEADER,
-                                          &buf)) < 0) {
-        if (headerLen == -2)
-            return 0;
-        return -1;
-    }
-
-    if (!(tmp = virStorageSourceCopy(src, false)))
-        return -1;
-
-    if (virStorageFileProbeGetMetadata(tmp, buf, headerLen) < 0)
-        return -1;
-
-    *backing = g_steal_pointer(&tmp->backingStoreRaw);
-    return 0;
-}
-- 
2.29.2




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux