|
|
0a7476 |
From e6545c2acc9a3626572cbf937c1d7eba62362e3b Mon Sep 17 00:00:00 2001
|
|
|
0a7476 |
Message-Id: <e6545c2acc9a3626572cbf937c1d7eba62362e3b@dist-git>
|
|
|
0a7476 |
From: John Ferlan <jferlan@redhat.com>
|
|
|
0a7476 |
Date: Wed, 3 Apr 2019 09:12:18 -0400
|
|
|
0a7476 |
Subject: [PATCH] storage: Rework virStorageBackendFileSystemMountCmd
|
|
|
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 |
Let's create helpers for each style of command line created. This
|
|
|
0a7476 |
primarily is easier on the eyes rather than the large multi line
|
|
|
0a7476 |
if-then-else-else clause used, but may also be useful if in the
|
|
|
0a7476 |
future any particular pool needs to add to the command line based
|
|
|
0a7476 |
on pool xml format.
|
|
|
0a7476 |
|
|
|
0a7476 |
Signed-off-by: John Ferlan <jferlan@redhat.com>
|
|
|
0a7476 |
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
|
|
|
0a7476 |
(cherry picked from commit b663d4329ca844b1bdb536acaa2ae338bf435f74)
|
|
|
0a7476 |
Message-Id: <20190403131219.16385-7-jferlan@redhat.com>
|
|
|
0a7476 |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
0a7476 |
---
|
|
|
0a7476 |
src/storage/storage_util.c | 84 +++++++++++++++++++++++++-------------
|
|
|
0a7476 |
1 file changed, 55 insertions(+), 29 deletions(-)
|
|
|
0a7476 |
|
|
|
0a7476 |
diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c
|
|
|
0a7476 |
index ccbc2c925c..70ce600581 100644
|
|
|
0a7476 |
--- a/src/storage/storage_util.c
|
|
|
0a7476 |
+++ b/src/storage/storage_util.c
|
|
|
0a7476 |
@@ -4245,6 +4245,56 @@ virStorageBackendFileSystemGetPoolSource(virStoragePoolObjPtr pool)
|
|
|
0a7476 |
}
|
|
|
0a7476 |
|
|
|
0a7476 |
|
|
|
0a7476 |
+static void
|
|
|
0a7476 |
+virStorageBackendFileSystemMountNFSArgs(virCommandPtr cmd,
|
|
|
0a7476 |
+ const char *src,
|
|
|
0a7476 |
+ virStoragePoolDefPtr def)
|
|
|
0a7476 |
+{
|
|
|
0a7476 |
+ virCommandAddArgList(cmd, src, def->target.path, NULL);
|
|
|
0a7476 |
+}
|
|
|
0a7476 |
+
|
|
|
0a7476 |
+
|
|
|
0a7476 |
+static void
|
|
|
0a7476 |
+virStorageBackendFileSystemMountGlusterArgs(virCommandPtr cmd,
|
|
|
0a7476 |
+ const char *src,
|
|
|
0a7476 |
+ virStoragePoolDefPtr def)
|
|
|
0a7476 |
+{
|
|
|
0a7476 |
+ const char *fmt;
|
|
|
0a7476 |
+
|
|
|
0a7476 |
+ fmt = virStoragePoolFormatFileSystemNetTypeToString(def->source.format);
|
|
|
0a7476 |
+ virCommandAddArgList(cmd, "-t", fmt, src, "-o", "direct-io-mode=1",
|
|
|
0a7476 |
+ def->target.path, NULL);
|
|
|
0a7476 |
+}
|
|
|
0a7476 |
+
|
|
|
0a7476 |
+
|
|
|
0a7476 |
+static void
|
|
|
0a7476 |
+virStorageBackendFileSystemMountCIFSArgs(virCommandPtr cmd,
|
|
|
0a7476 |
+ const char *src,
|
|
|
0a7476 |
+ virStoragePoolDefPtr def)
|
|
|
0a7476 |
+{
|
|
|
0a7476 |
+ const char *fmt;
|
|
|
0a7476 |
+
|
|
|
0a7476 |
+ fmt = virStoragePoolFormatFileSystemNetTypeToString(def->source.format);
|
|
|
0a7476 |
+ virCommandAddArgList(cmd, "-t", fmt, src, def->target.path,
|
|
|
0a7476 |
+ "-o", "guest", NULL);
|
|
|
0a7476 |
+}
|
|
|
0a7476 |
+
|
|
|
0a7476 |
+
|
|
|
0a7476 |
+static void
|
|
|
0a7476 |
+virStorageBackendFileSystemMountDefaultArgs(virCommandPtr cmd,
|
|
|
0a7476 |
+ const char *src,
|
|
|
0a7476 |
+ virStoragePoolDefPtr def)
|
|
|
0a7476 |
+{
|
|
|
0a7476 |
+ const char *fmt;
|
|
|
0a7476 |
+
|
|
|
0a7476 |
+ if (def->type == VIR_STORAGE_POOL_FS)
|
|
|
0a7476 |
+ fmt = virStoragePoolFormatFileSystemTypeToString(def->source.format);
|
|
|
0a7476 |
+ else
|
|
|
0a7476 |
+ fmt = virStoragePoolFormatFileSystemNetTypeToString(def->source.format);
|
|
|
0a7476 |
+ virCommandAddArgList(cmd, "-t", fmt, src, def->target.path, NULL);
|
|
|
0a7476 |
+}
|
|
|
0a7476 |
+
|
|
|
0a7476 |
+
|
|
|
0a7476 |
virCommandPtr
|
|
|
0a7476 |
virStorageBackendFileSystemMountCmd(virStoragePoolDefPtr def,
|
|
|
0a7476 |
const char *src)
|
|
|
0a7476 |
@@ -4260,38 +4310,14 @@ virStorageBackendFileSystemMountCmd(virStoragePoolDefPtr def,
|
|
|
0a7476 |
def->source.format == VIR_STORAGE_POOL_NETFS_CIFS);
|
|
|
0a7476 |
virCommandPtr cmd = NULL;
|
|
|
0a7476 |
|
|
|
0a7476 |
+ cmd = virCommandNew(MOUNT);
|
|
|
0a7476 |
if (netauto)
|
|
|
0a7476 |
- cmd = virCommandNewArgList(MOUNT,
|
|
|
0a7476 |
- src,
|
|
|
0a7476 |
- def->target.path,
|
|
|
0a7476 |
- NULL);
|
|
|
0a7476 |
+ virStorageBackendFileSystemMountNFSArgs(cmd, src, def);
|
|
|
0a7476 |
else if (glusterfs)
|
|
|
0a7476 |
- cmd = virCommandNewArgList(MOUNT,
|
|
|
0a7476 |
- "-t",
|
|
|
0a7476 |
- virStoragePoolFormatFileSystemNetTypeToString(def->source.format),
|
|
|
0a7476 |
- src,
|
|
|
0a7476 |
- "-o",
|
|
|
0a7476 |
- "direct-io-mode=1",
|
|
|
0a7476 |
- def->target.path,
|
|
|
0a7476 |
- NULL);
|
|
|
0a7476 |
+ virStorageBackendFileSystemMountGlusterArgs(cmd, src, def);
|
|
|
0a7476 |
else if (cifsfs)
|
|
|
0a7476 |
- cmd = virCommandNewArgList(MOUNT,
|
|
|
0a7476 |
- "-t",
|
|
|
0a7476 |
- virStoragePoolFormatFileSystemNetTypeToString(def->source.format),
|
|
|
0a7476 |
- src,
|
|
|
0a7476 |
- def->target.path,
|
|
|
0a7476 |
- "-o",
|
|
|
0a7476 |
- "guest",
|
|
|
0a7476 |
- NULL);
|
|
|
0a7476 |
+ virStorageBackendFileSystemMountCIFSArgs(cmd, src, def);
|
|
|
0a7476 |
else
|
|
|
0a7476 |
- cmd = virCommandNewArgList(MOUNT,
|
|
|
0a7476 |
- "-t",
|
|
|
0a7476 |
- (def->type == VIR_STORAGE_POOL_FS ?
|
|
|
0a7476 |
- virStoragePoolFormatFileSystemTypeToString(def->source.format) :
|
|
|
0a7476 |
- virStoragePoolFormatFileSystemNetTypeToString(def->source.format)),
|
|
|
0a7476 |
- src,
|
|
|
0a7476 |
- def->target.path,
|
|
|
0a7476 |
- NULL);
|
|
|
0a7476 |
-
|
|
|
0a7476 |
+ virStorageBackendFileSystemMountDefaultArgs(cmd, src, def);
|
|
|
0a7476 |
return cmd;
|
|
|
0a7476 |
}
|
|
|
0a7476 |
--
|
|
|
0a7476 |
2.21.0
|
|
|
0a7476 |
|