]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virStorageSourceGetBackingStoreStr: Move the function earlier
authorPeter Krempa <pkrempa@redhat.com>
Fri, 22 Jan 2021 14:15:01 +0000 (15:15 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 27 Jan 2021 06:49:57 +0000 (07:49 +0100)
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@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
src/storage_file/storage_source.c

index 85734d9275d95dc42193e0cb5be8709e3e2c910e..430e3214c48f982eac8350221407bb6851d040b2 100644 (file)
@@ -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;
-}