[PATCH v3 10/11] storage: Add NFS storage pool namespace options to command line

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



If the NetFS Storage Pool Namespace XML data exists, format the
mount options on the MOUNT command line.

When the pool is started, the options will be generated on the
command line along with the options already defined.

To view the options of the running pool, use either 'nfsstat -m'
or 'grep $POOLNAME /proc/mounts' for the added Flags/options.

Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx>
---
 src/storage/storage_util.c                             | 10 +++++++++-
 .../pool-netfs-ns-mountopts.argv                       |  2 ++
 tests/storagepoolxml2argvtest.c                        |  4 ++++
 3 files changed, 15 insertions(+), 1 deletion(-)
 create mode 100644 tests/storagepoolxml2argvdata/pool-netfs-ns-mountopts.argv

diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c
index 1c0a8ee5cf..8edcd23e2f 100644
--- a/src/storage/storage_util.c
+++ b/src/storage/storage_util.c
@@ -4354,7 +4354,8 @@ virStorageBackendFileSystemMountCmd(const char *cmdstr,
         virStorageBackendFileSystemMountDefaultArgs(cmd, src, def);
 
     if (def->type == VIR_STORAGE_POOL_NETFS &&
-        (def->source.mountOpts || (def->source.protocolVer > 0))) {
+        (def->source.mountOpts || (def->source.protocolVer > 0) ||
+         def->namespaceData)) {
         size_t i;
         virBuffer buf = VIR_BUFFER_INITIALIZER;
         VIR_AUTOFREE(char *) mountOpts = NULL;
@@ -4365,6 +4366,13 @@ virStorageBackendFileSystemMountCmd(const char *cmdstr,
         for (i = 0; i < def->source.nmountOpts; i++)
             virBufferAsprintf(&buf, "%s,", def->source.mountOpts[i]);
 
+        if (def->namespaceData) {
+            virStoragePoolNetFSMountOptionsDefPtr opts = def->namespaceData;
+
+            for (i = 0; i < opts->noptions; i++)
+                virBufferAsprintf(&buf, "%s,", opts->options[i]);
+        }
+
         virBufferTrim(&buf, ",", -1);
 
         if (virBufferCheckError(&buf) < 0)
diff --git a/tests/storagepoolxml2argvdata/pool-netfs-ns-mountopts.argv b/tests/storagepoolxml2argvdata/pool-netfs-ns-mountopts.argv
new file mode 100644
index 0000000000..87c5c83c47
--- /dev/null
+++ b/tests/storagepoolxml2argvdata/pool-netfs-ns-mountopts.argv
@@ -0,0 +1,2 @@
+mount -t nfs localhost:/var/lib/libvirt/images /mnt -o nfsvers=3,nodev,nosuid,\
+sync,lazytime
diff --git a/tests/storagepoolxml2argvtest.c b/tests/storagepoolxml2argvtest.c
index e8bae9fb8c..84a9075c78 100644
--- a/tests/storagepoolxml2argvtest.c
+++ b/tests/storagepoolxml2argvtest.c
@@ -144,6 +144,9 @@ mymain(void)
 #define DO_TEST_FAIL(pool, ...) \
     DO_TEST_FULL(true, pool)
 
+    if (storageRegisterAll() < 0)
+       return EXIT_FAILURE;
+
     DO_TEST_FAIL("pool-dir");
     DO_TEST_FAIL("pool-dir-naming");
     DO_TEST("pool-fs");
@@ -161,6 +164,7 @@ mymain(void)
     DO_TEST("pool-netfs-gluster");
     DO_TEST("pool-netfs-cifs");
     DO_TEST("pool-netfs-mountopts");
+    DO_TEST("pool-netfs-ns-mountopts");
     DO_TEST_FAIL("pool-scsi");
     DO_TEST_FAIL("pool-scsi-type-scsi-host");
     DO_TEST_FAIL("pool-scsi-type-fc-host");
-- 
2.20.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux