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