]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
util: virstoragefile: Move virStorageIs[File|Relative] to storage_source
authorPeter Krempa <pkrempa@redhat.com>
Fri, 22 Jan 2021 14:34:33 +0000 (15:34 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 27 Jan 2021 06:49:57 +0000 (07:49 +0100)
There are no other files using it. Move it and make the functions
static.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
src/libvirt_private.syms
src/storage_file/storage_source.c
src/util/virstoragefile.c
src/util/virstoragefile.h

index c03b769c3729c01aa07430bce52dd1f62ebecc62..0a2a54dfdf14614e7e5f64bad7ebc9a32fd4981e 100644 (file)
@@ -3218,8 +3218,6 @@ virStorageFileGetNPIVKey;
 virStorageFileGetSCSIKey;
 virStorageFileParseBackingStoreStr;
 virStorageFileParseChainIndex;
-virStorageIsFile;
-virStorageIsRelative;
 
 
 # util/virstring.h
index 23d36507ea985e3eb1130d3dda5b1a77117acb6a..df9fb6c05515adee757546958dd18934a1caa06a 100644 (file)
 VIR_LOG_INIT("storage_source");
 
 
+static bool
+virStorageSourceBackinStoreStringIsFile(const char *backing)
+{
+    char *colon;
+    char *slash;
+
+    if (!backing)
+        return false;
+
+    colon = strchr(backing, ':');
+    slash = strchr(backing, '/');
+
+    /* Reject anything that looks like a protocol (such as nbd: or
+     * rbd:); if someone really does want a relative file name that
+     * includes ':', they can always prefix './'.  */
+    if (colon && (!slash || colon < slash))
+        return false;
+    return true;
+}
+
+
+static bool
+virStorageSourceBackinStoreStringIsRelative(const char *backing)
+{
+    if (backing[0] == '/')
+        return false;
+
+    if (!virStorageSourceBackinStoreStringIsFile(backing))
+        return false;
+
+    return true;
+}
+
+
 static virStorageSourcePtr
 virStorageSourceMetadataNew(const char *path,
                             int format)
@@ -185,7 +219,7 @@ virStorageSourceChainLookup(virStorageSourcePtr chain,
 {
     virStorageSourcePtr prev;
     const char *start = chain->path;
-    bool nameIsFile = virStorageIsFile(name);
+    bool nameIsFile = virStorageSourceBackinStoreStringIsFile(name);
 
     if (!parent)
         parent = &prev;
@@ -1532,7 +1566,7 @@ virStorageSourceNewFromBackingAbsolute(const char *path,
 
     *src = NULL;
 
-    if (virStorageIsFile(path)) {
+    if (virStorageSourceBackinStoreStringIsFile(path)) {
         def->type = VIR_STORAGE_TYPE_FILE;
 
         def->path = g_strdup(path);
@@ -1604,7 +1638,7 @@ virStorageSourceNewFromChild(virStorageSourcePtr parent,
 
     *child = NULL;
 
-    if (virStorageIsRelative(parentRaw)) {
+    if (virStorageSourceBackinStoreStringIsRelative(parentRaw)) {
         if (!(def = virStorageSourceNewFromBackingRelative(parent, parentRaw)))
             return -1;
     } else {
@@ -1927,7 +1961,7 @@ virStorageSourceFetchRelativeBackingPath(virStorageSourcePtr src,
     if (virStorageFileProbeGetMetadata(tmp, buf, headerLen) < 0)
         return -1;
 
-    if (virStorageIsRelative(tmp->backingStoreRaw))
+    if (virStorageSourceBackinStoreStringIsRelative(tmp->backingStoreRaw))
         *relPath = g_steal_pointer(&tmp->backingStoreRaw);
 
     return 0;
index 85ccd9f52c9a3bfe540ed240fb0b8b989f2a7cc1..d1e56db7086a89b2e0094a15e69548b69137cf99 100644 (file)
 VIR_LOG_INIT("util.storagefile");
 
 
-bool
-virStorageIsFile(const char *backing)
-{
-    char *colon;
-    char *slash;
-
-    if (!backing)
-        return false;
-
-    colon = strchr(backing, ':');
-    slash = strchr(backing, '/');
-
-    /* Reject anything that looks like a protocol (such as nbd: or
-     * rbd:); if someone really does want a relative file name that
-     * includes ':', they can always prefix './'.  */
-    if (colon && (!slash || colon < slash))
-        return false;
-    return true;
-}
-
-
-bool
-virStorageIsRelative(const char *backing)
-{
-    if (backing[0] == '/')
-        return false;
-
-    if (!virStorageIsFile(backing))
-        return false;
-
-    return true;
-}
-
-
 #ifdef WITH_UDEV
 /* virStorageFileGetSCSIKey
  * @path: Path to the SCSI device
index 2c1a250f201043c0a9f57203a69f071adcfc7776..455a978a8df1ed5ee7413bf18bd6838efb79efa7 100644 (file)
@@ -33,9 +33,6 @@ int virStorageFileParseBackingStoreStr(const char *str,
                                        unsigned int *chainIndex)
     ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(3);
 
-bool virStorageIsFile(const char *path);
-bool virStorageIsRelative(const char *backing);
-
 int virStorageFileGetSCSIKey(const char *path,
                              char **key,
                              bool ignoreError);