]> xenbits.xensource.com Git - libvirt.git/commitdiff
storage: Move FS backend mount creation command helper
authorJohn Ferlan <jferlan@redhat.com>
Tue, 4 Dec 2018 11:34:58 +0000 (06:34 -0500)
committerJohn Ferlan <jferlan@redhat.com>
Thu, 13 Dec 2018 12:09:42 +0000 (07:09 -0500)
Move virStorageBackendFileSystemMountCmd to storage_util so that
it can be used by the test harness.

Signed-off-by: John Ferlan <jferlan@redhat.com>
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
src/storage/storage_backend_fs.c
src/storage/storage_util.c
src/storage/storage_util.h

index 4bf411b330a84adccdb1c3c5cf1607485b26ea67..b341ba84fabc7c57458a1691ba97289771e312ed 100644 (file)
@@ -331,58 +331,6 @@ virStorageBackendFileSystemIsMounted(virStoragePoolObjPtr pool)
 }
 
 
-static virCommandPtr
-virStorageBackendFileSystemMountCmd(virStoragePoolDefPtr def,
-                                    const char *src)
-{
-    /* 'mount -t auto' doesn't seem to auto determine nfs (or cifs),
-     *  while plain 'mount' does. We have to craft separate argvs to
-     *  accommodate this */
-    bool netauto = (def->type == VIR_STORAGE_POOL_NETFS &&
-                    def->source.format == VIR_STORAGE_POOL_NETFS_AUTO);
-    bool glusterfs = (def->type == VIR_STORAGE_POOL_NETFS &&
-                      def->source.format == VIR_STORAGE_POOL_NETFS_GLUSTERFS);
-    bool cifsfs = (def->type == VIR_STORAGE_POOL_NETFS &&
-                   def->source.format == VIR_STORAGE_POOL_NETFS_CIFS);
-    virCommandPtr cmd = NULL;
-
-    if (netauto)
-        cmd = virCommandNewArgList(MOUNT,
-                                   src,
-                                   def->target.path,
-                                   NULL);
-    else if (glusterfs)
-        cmd = virCommandNewArgList(MOUNT,
-                                   "-t",
-                                   virStoragePoolFormatFileSystemNetTypeToString(def->source.format),
-                                   src,
-                                   "-o",
-                                   "direct-io-mode=1",
-                                   def->target.path,
-                                   NULL);
-    else if (cifsfs)
-        cmd = virCommandNewArgList(MOUNT,
-                                   "-t",
-                                   virStoragePoolFormatFileSystemNetTypeToString(def->source.format),
-                                   src,
-                                   def->target.path,
-                                   "-o",
-                                   "guest",
-                                   NULL);
-    else
-        cmd = virCommandNewArgList(MOUNT,
-                                   "-t",
-                                   (def->type == VIR_STORAGE_POOL_FS ?
-                                    virStoragePoolFormatFileSystemTypeToString(def->source.format) :
-                                    virStoragePoolFormatFileSystemNetTypeToString(def->source.format)),
-                                   src,
-                                   def->target.path,
-                                   NULL);
-
-    return cmd;
-}
-
-
 /**
  * @pool storage pool to mount
  *
index 318a55665627d0a1cfd36b08ede7e297955db0a0..180d7b1fa3c3ed54a39bcecc6db3f660163d65dc 100644 (file)
@@ -4226,3 +4226,55 @@ virStorageBackendZeroPartitionTable(const char *path,
     return storageBackendVolWipeLocalFile(path, VIR_STORAGE_VOL_WIPE_ALG_ZERO,
                                           size, true);
 }
+
+
+virCommandPtr
+virStorageBackendFileSystemMountCmd(virStoragePoolDefPtr def,
+                                    const char *src)
+{
+    /* 'mount -t auto' doesn't seem to auto determine nfs (or cifs),
+     *  while plain 'mount' does. We have to craft separate argvs to
+     *  accommodate this */
+    bool netauto = (def->type == VIR_STORAGE_POOL_NETFS &&
+                    def->source.format == VIR_STORAGE_POOL_NETFS_AUTO);
+    bool glusterfs = (def->type == VIR_STORAGE_POOL_NETFS &&
+                      def->source.format == VIR_STORAGE_POOL_NETFS_GLUSTERFS);
+    bool cifsfs = (def->type == VIR_STORAGE_POOL_NETFS &&
+                   def->source.format == VIR_STORAGE_POOL_NETFS_CIFS);
+    virCommandPtr cmd = NULL;
+
+    if (netauto)
+        cmd = virCommandNewArgList(MOUNT,
+                                   src,
+                                   def->target.path,
+                                   NULL);
+    else if (glusterfs)
+        cmd = virCommandNewArgList(MOUNT,
+                                   "-t",
+                                   virStoragePoolFormatFileSystemNetTypeToString(def->source.format),
+                                   src,
+                                   "-o",
+                                   "direct-io-mode=1",
+                                   def->target.path,
+                                   NULL);
+    else if (cifsfs)
+        cmd = virCommandNewArgList(MOUNT,
+                                   "-t",
+                                   virStoragePoolFormatFileSystemNetTypeToString(def->source.format),
+                                   src,
+                                   def->target.path,
+                                   "-o",
+                                   "guest",
+                                   NULL);
+    else
+        cmd = virCommandNewArgList(MOUNT,
+                                   "-t",
+                                   (def->type == VIR_STORAGE_POOL_FS ?
+                                    virStoragePoolFormatFileSystemTypeToString(def->source.format) :
+                                    virStoragePoolFormatFileSystemNetTypeToString(def->source.format)),
+                                   src,
+                                   def->target.path,
+                                   NULL);
+
+    return cmd;
+}
index 58b991c772d0345621bc2c7eb2420e79f05a8663..5b0baf56c462faa0e1c162232e1c5fdfc8c8bf4c 100644 (file)
@@ -177,4 +177,8 @@ int
 virStorageBackendZeroPartitionTable(const char *path,
                                     unsigned long long size);
 
+virCommandPtr
+virStorageBackendFileSystemMountCmd(virStoragePoolDefPtr def,
+                                    const char *src);
+
 #endif /* __VIR_STORAGE_UTIL_H__ */