render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
99cbc7
From 648ffa72001e1bb6d26a71f4a0be38042bab9242 Mon Sep 17 00:00:00 2001
99cbc7
Message-Id: <648ffa72001e1bb6d26a71f4a0be38042bab9242@dist-git>
99cbc7
From: John Ferlan <jferlan@redhat.com>
99cbc7
Date: Wed, 3 Apr 2019 09:12:14 -0400
99cbc7
Subject: [PATCH] storage: Move FS backend mount creation command helper
99cbc7
MIME-Version: 1.0
99cbc7
Content-Type: text/plain; charset=UTF-8
99cbc7
Content-Transfer-Encoding: 8bit
99cbc7
99cbc7
https://bugzilla.redhat.com/show_bug.cgi?id=1584663
99cbc7
99cbc7
Move virStorageBackendFileSystemMountCmd to storage_util so that
99cbc7
it can be used by the test harness.
99cbc7
99cbc7
Signed-off-by: John Ferlan <jferlan@redhat.com>
99cbc7
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
99cbc7
(cherry picked from commit 728b9ed61abe3fea101dd4dddddeb9a530babc6a)
99cbc7
Message-Id: <20190403131219.16385-3-jferlan@redhat.com>
99cbc7
Reviewed-by: Ján Tomko <jtomko@redhat.com>
99cbc7
---
99cbc7
 src/storage/storage_backend_fs.c | 52 --------------------------------
99cbc7
 src/storage/storage_util.c       | 52 ++++++++++++++++++++++++++++++++
99cbc7
 src/storage/storage_util.h       |  4 +++
99cbc7
 3 files changed, 56 insertions(+), 52 deletions(-)
99cbc7
99cbc7
diff --git a/src/storage/storage_backend_fs.c b/src/storage/storage_backend_fs.c
99cbc7
index 4015271419..4acdb43e0d 100644
99cbc7
--- a/src/storage/storage_backend_fs.c
99cbc7
+++ b/src/storage/storage_backend_fs.c
99cbc7
@@ -334,58 +334,6 @@ virStorageBackendFileSystemIsMounted(virStoragePoolObjPtr pool)
99cbc7
 }
99cbc7
 
99cbc7
 
99cbc7
-static virCommandPtr
99cbc7
-virStorageBackendFileSystemMountCmd(virStoragePoolDefPtr def,
99cbc7
-                                    const char *src)
99cbc7
-{
99cbc7
-    /* 'mount -t auto' doesn't seem to auto determine nfs (or cifs),
99cbc7
-     *  while plain 'mount' does. We have to craft separate argvs to
99cbc7
-     *  accommodate this */
99cbc7
-    bool netauto = (def->type == VIR_STORAGE_POOL_NETFS &&
99cbc7
-                    def->source.format == VIR_STORAGE_POOL_NETFS_AUTO);
99cbc7
-    bool glusterfs = (def->type == VIR_STORAGE_POOL_NETFS &&
99cbc7
-                      def->source.format == VIR_STORAGE_POOL_NETFS_GLUSTERFS);
99cbc7
-    bool cifsfs = (def->type == VIR_STORAGE_POOL_NETFS &&
99cbc7
-                   def->source.format == VIR_STORAGE_POOL_NETFS_CIFS);
99cbc7
-    virCommandPtr cmd = NULL;
99cbc7
-
99cbc7
-    if (netauto)
99cbc7
-        cmd = virCommandNewArgList(MOUNT,
99cbc7
-                                   src,
99cbc7
-                                   def->target.path,
99cbc7
-                                   NULL);
99cbc7
-    else if (glusterfs)
99cbc7
-        cmd = virCommandNewArgList(MOUNT,
99cbc7
-                                   "-t",
99cbc7
-                                   virStoragePoolFormatFileSystemNetTypeToString(def->source.format),
99cbc7
-                                   src,
99cbc7
-                                   "-o",
99cbc7
-                                   "direct-io-mode=1",
99cbc7
-                                   def->target.path,
99cbc7
-                                   NULL);
99cbc7
-    else if (cifsfs)
99cbc7
-        cmd = virCommandNewArgList(MOUNT,
99cbc7
-                                   "-t",
99cbc7
-                                   virStoragePoolFormatFileSystemNetTypeToString(def->source.format),
99cbc7
-                                   src,
99cbc7
-                                   def->target.path,
99cbc7
-                                   "-o",
99cbc7
-                                   "guest",
99cbc7
-                                   NULL);
99cbc7
-    else
99cbc7
-        cmd = virCommandNewArgList(MOUNT,
99cbc7
-                                   "-t",
99cbc7
-                                   (def->type == VIR_STORAGE_POOL_FS ?
99cbc7
-                                    virStoragePoolFormatFileSystemTypeToString(def->source.format) :
99cbc7
-                                    virStoragePoolFormatFileSystemNetTypeToString(def->source.format)),
99cbc7
-                                   src,
99cbc7
-                                   def->target.path,
99cbc7
-                                   NULL);
99cbc7
-
99cbc7
-    return cmd;
99cbc7
-}
99cbc7
-
99cbc7
-
99cbc7
 /**
99cbc7
  * @pool storage pool to mount
99cbc7
  *
99cbc7
diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c
99cbc7
index 637b90fac1..327b500b6b 100644
99cbc7
--- a/src/storage/storage_util.c
99cbc7
+++ b/src/storage/storage_util.c
99cbc7
@@ -4210,3 +4210,55 @@ virStorageBackendZeroPartitionTable(const char *path,
99cbc7
     return storageBackendVolWipeLocalFile(path, VIR_STORAGE_VOL_WIPE_ALG_ZERO,
99cbc7
                                           size, true);
99cbc7
 }
99cbc7
+
99cbc7
+
99cbc7
+virCommandPtr
99cbc7
+virStorageBackendFileSystemMountCmd(virStoragePoolDefPtr def,
99cbc7
+                                    const char *src)
99cbc7
+{
99cbc7
+    /* 'mount -t auto' doesn't seem to auto determine nfs (or cifs),
99cbc7
+     *  while plain 'mount' does. We have to craft separate argvs to
99cbc7
+     *  accommodate this */
99cbc7
+    bool netauto = (def->type == VIR_STORAGE_POOL_NETFS &&
99cbc7
+                    def->source.format == VIR_STORAGE_POOL_NETFS_AUTO);
99cbc7
+    bool glusterfs = (def->type == VIR_STORAGE_POOL_NETFS &&
99cbc7
+                      def->source.format == VIR_STORAGE_POOL_NETFS_GLUSTERFS);
99cbc7
+    bool cifsfs = (def->type == VIR_STORAGE_POOL_NETFS &&
99cbc7
+                   def->source.format == VIR_STORAGE_POOL_NETFS_CIFS);
99cbc7
+    virCommandPtr cmd = NULL;
99cbc7
+
99cbc7
+    if (netauto)
99cbc7
+        cmd = virCommandNewArgList(MOUNT,
99cbc7
+                                   src,
99cbc7
+                                   def->target.path,
99cbc7
+                                   NULL);
99cbc7
+    else if (glusterfs)
99cbc7
+        cmd = virCommandNewArgList(MOUNT,
99cbc7
+                                   "-t",
99cbc7
+                                   virStoragePoolFormatFileSystemNetTypeToString(def->source.format),
99cbc7
+                                   src,
99cbc7
+                                   "-o",
99cbc7
+                                   "direct-io-mode=1",
99cbc7
+                                   def->target.path,
99cbc7
+                                   NULL);
99cbc7
+    else if (cifsfs)
99cbc7
+        cmd = virCommandNewArgList(MOUNT,
99cbc7
+                                   "-t",
99cbc7
+                                   virStoragePoolFormatFileSystemNetTypeToString(def->source.format),
99cbc7
+                                   src,
99cbc7
+                                   def->target.path,
99cbc7
+                                   "-o",
99cbc7
+                                   "guest",
99cbc7
+                                   NULL);
99cbc7
+    else
99cbc7
+        cmd = virCommandNewArgList(MOUNT,
99cbc7
+                                   "-t",
99cbc7
+                                   (def->type == VIR_STORAGE_POOL_FS ?
99cbc7
+                                    virStoragePoolFormatFileSystemTypeToString(def->source.format) :
99cbc7
+                                    virStoragePoolFormatFileSystemNetTypeToString(def->source.format)),
99cbc7
+                                   src,
99cbc7
+                                   def->target.path,
99cbc7
+                                   NULL);
99cbc7
+
99cbc7
+    return cmd;
99cbc7
+}
99cbc7
diff --git a/src/storage/storage_util.h b/src/storage/storage_util.h
99cbc7
index 58b991c772..5b0baf56c4 100644
99cbc7
--- a/src/storage/storage_util.h
99cbc7
+++ b/src/storage/storage_util.h
99cbc7
@@ -177,4 +177,8 @@ int
99cbc7
 virStorageBackendZeroPartitionTable(const char *path,
99cbc7
                                     unsigned long long size);
99cbc7
 
99cbc7
+virCommandPtr
99cbc7
+virStorageBackendFileSystemMountCmd(virStoragePoolDefPtr def,
99cbc7
+                                    const char *src);
99cbc7
+
99cbc7
 #endif /* __VIR_STORAGE_UTIL_H__ */
99cbc7
-- 
99cbc7
2.21.0
99cbc7