|
|
99cbc7 |
From 2098b067ec805170011979646c52c8dbbda943c3 Mon Sep 17 00:00:00 2001
|
|
|
99cbc7 |
Message-Id: <2098b067ec805170011979646c52c8dbbda943c3@dist-git>
|
|
|
99cbc7 |
From: John Ferlan <jferlan@redhat.com>
|
|
|
99cbc7 |
Date: Wed, 3 Apr 2019 09:12:13 -0400
|
|
|
99cbc7 |
Subject: [PATCH] storage: Extract out mount command creation for FS Backend
|
|
|
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 |
Extract out the code that is used to create the MOUNT command
|
|
|
99cbc7 |
for starting the pool. We can use this for Storage Pool XML
|
|
|
99cbc7 |
to Argv testing to ensure code changes don't alter how a
|
|
|
99cbc7 |
storage pool is started.
|
|
|
99cbc7 |
|
|
|
99cbc7 |
Signed-off-by: John Ferlan <jferlan@redhat.com>
|
|
|
99cbc7 |
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
|
|
|
99cbc7 |
(cherry picked from commit 1bebb904fe2f8f51b29efe28bbe91d708f142ade)
|
|
|
99cbc7 |
Message-Id: <20190403131219.16385-2-jferlan@redhat.com>
|
|
|
99cbc7 |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
99cbc7 |
---
|
|
|
99cbc7 |
src/storage/storage_backend_fs.c | 70 +++++++++++++++++++-------------
|
|
|
99cbc7 |
1 file changed, 41 insertions(+), 29 deletions(-)
|
|
|
99cbc7 |
|
|
|
99cbc7 |
diff --git a/src/storage/storage_backend_fs.c b/src/storage/storage_backend_fs.c
|
|
|
99cbc7 |
index 8983738210..4015271419 100644
|
|
|
99cbc7 |
--- a/src/storage/storage_backend_fs.c
|
|
|
99cbc7 |
+++ b/src/storage/storage_backend_fs.c
|
|
|
99cbc7 |
@@ -333,19 +333,11 @@ virStorageBackendFileSystemIsMounted(virStoragePoolObjPtr pool)
|
|
|
99cbc7 |
return ret;
|
|
|
99cbc7 |
}
|
|
|
99cbc7 |
|
|
|
99cbc7 |
-/**
|
|
|
99cbc7 |
- * @pool storage pool to mount
|
|
|
99cbc7 |
- *
|
|
|
99cbc7 |
- * Ensure that a FS storage pool is mounted on its target location.
|
|
|
99cbc7 |
- * If already mounted, this is a no-op
|
|
|
99cbc7 |
- *
|
|
|
99cbc7 |
- * Returns 0 if successfully mounted, -1 on error
|
|
|
99cbc7 |
- */
|
|
|
99cbc7 |
-static int
|
|
|
99cbc7 |
-virStorageBackendFileSystemMount(virStoragePoolObjPtr pool)
|
|
|
99cbc7 |
+
|
|
|
99cbc7 |
+static virCommandPtr
|
|
|
99cbc7 |
+virStorageBackendFileSystemMountCmd(virStoragePoolDefPtr def,
|
|
|
99cbc7 |
+ const char *src)
|
|
|
99cbc7 |
{
|
|
|
99cbc7 |
- virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool);
|
|
|
99cbc7 |
- char *src = NULL;
|
|
|
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 |
@@ -356,23 +348,6 @@ virStorageBackendFileSystemMount(virStoragePoolObjPtr pool)
|
|
|
99cbc7 |
bool cifsfs = (def->type == VIR_STORAGE_POOL_NETFS &&
|
|
|
99cbc7 |
def->source.format == VIR_STORAGE_POOL_NETFS_CIFS);
|
|
|
99cbc7 |
virCommandPtr cmd = NULL;
|
|
|
99cbc7 |
- int ret = -1;
|
|
|
99cbc7 |
- int rc;
|
|
|
99cbc7 |
-
|
|
|
99cbc7 |
- if (virStorageBackendFileSystemIsValid(pool) < 0)
|
|
|
99cbc7 |
- return -1;
|
|
|
99cbc7 |
-
|
|
|
99cbc7 |
- if ((rc = virStorageBackendFileSystemIsMounted(pool)) < 0)
|
|
|
99cbc7 |
- return -1;
|
|
|
99cbc7 |
-
|
|
|
99cbc7 |
- /* Short-circuit if already mounted */
|
|
|
99cbc7 |
- if (rc == 1) {
|
|
|
99cbc7 |
- VIR_INFO("Target '%s' is already mounted", def->target.path);
|
|
|
99cbc7 |
- return 0;
|
|
|
99cbc7 |
- }
|
|
|
99cbc7 |
-
|
|
|
99cbc7 |
- if (!(src = virStorageBackendFileSystemGetPoolSource(pool)))
|
|
|
99cbc7 |
- return -1;
|
|
|
99cbc7 |
|
|
|
99cbc7 |
if (netauto)
|
|
|
99cbc7 |
cmd = virCommandNewArgList(MOUNT,
|
|
|
99cbc7 |
@@ -407,6 +382,43 @@ virStorageBackendFileSystemMount(virStoragePoolObjPtr pool)
|
|
|
99cbc7 |
def->target.path,
|
|
|
99cbc7 |
NULL);
|
|
|
99cbc7 |
|
|
|
99cbc7 |
+ return cmd;
|
|
|
99cbc7 |
+}
|
|
|
99cbc7 |
+
|
|
|
99cbc7 |
+
|
|
|
99cbc7 |
+/**
|
|
|
99cbc7 |
+ * @pool storage pool to mount
|
|
|
99cbc7 |
+ *
|
|
|
99cbc7 |
+ * Ensure that a FS storage pool is mounted on its target location.
|
|
|
99cbc7 |
+ * If already mounted, this is a no-op
|
|
|
99cbc7 |
+ *
|
|
|
99cbc7 |
+ * Returns 0 if successfully mounted, -1 on error
|
|
|
99cbc7 |
+ */
|
|
|
99cbc7 |
+static int
|
|
|
99cbc7 |
+virStorageBackendFileSystemMount(virStoragePoolObjPtr pool)
|
|
|
99cbc7 |
+{
|
|
|
99cbc7 |
+ virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool);
|
|
|
99cbc7 |
+ char *src = NULL;
|
|
|
99cbc7 |
+ virCommandPtr cmd = NULL;
|
|
|
99cbc7 |
+ int ret = -1;
|
|
|
99cbc7 |
+ int rc;
|
|
|
99cbc7 |
+
|
|
|
99cbc7 |
+ if (virStorageBackendFileSystemIsValid(pool) < 0)
|
|
|
99cbc7 |
+ return -1;
|
|
|
99cbc7 |
+
|
|
|
99cbc7 |
+ if ((rc = virStorageBackendFileSystemIsMounted(pool)) < 0)
|
|
|
99cbc7 |
+ return -1;
|
|
|
99cbc7 |
+
|
|
|
99cbc7 |
+ /* Short-circuit if already mounted */
|
|
|
99cbc7 |
+ if (rc == 1) {
|
|
|
99cbc7 |
+ VIR_INFO("Target '%s' is already mounted", def->target.path);
|
|
|
99cbc7 |
+ return 0;
|
|
|
99cbc7 |
+ }
|
|
|
99cbc7 |
+
|
|
|
99cbc7 |
+ if (!(src = virStorageBackendFileSystemGetPoolSource(pool)))
|
|
|
99cbc7 |
+ return -1;
|
|
|
99cbc7 |
+
|
|
|
99cbc7 |
+ cmd = virStorageBackendFileSystemMountCmd(def, src);
|
|
|
99cbc7 |
if (virCommandRun(cmd, NULL) < 0)
|
|
|
99cbc7 |
goto cleanup;
|
|
|
99cbc7 |
|
|
|
99cbc7 |
--
|
|
|
99cbc7 |
2.21.0
|
|
|
99cbc7 |
|