[PATCH v4 09/10] 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-freebsd.argv               |  2 ++
 .../pool-netfs-ns-mountopts-linux.argv                 |  2 ++
 .../pool-netfs-ns-mountopts.argv                       |  1 +
 tests/storagepoolxml2argvtest.c                        |  6 ++++++
 5 files changed, 20 insertions(+), 1 deletion(-)
 create mode 100644 tests/storagepoolxml2argvdata/pool-netfs-ns-mountopts-freebsd.argv
 create mode 100644 tests/storagepoolxml2argvdata/pool-netfs-ns-mountopts-linux.argv
 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 2e753f4501..1fdaf54059 100644
--- a/src/storage/storage_util.c
+++ b/src/storage/storage_util.c
@@ -4293,7 +4293,15 @@ virStorageBackendFileSystemMountNFSAddOptions(virCommandPtr cmd,
         virBufferAsprintf(&buf, "nfsvers=%u,", def->source.protocolVer);
 
     if (*default_nfs_mount_opts != '\0')
-        virBufferAddLit(&buf, default_nfs_mount_opts);
+        virBufferAsprintf(&buf, "%s,", default_nfs_mount_opts);
+
+    if (def->namespaceData) {
+        size_t i;
+        virStoragePoolNetFSMountOptionsDefPtr opts = def->namespaceData;
+
+        for (i = 0; i < opts->noptions; i++)
+            virBufferAsprintf(&buf, "%s,", opts->options[i]);
+    }
 
     virBufferTrim(&buf, ",", -1);
     mountOpts = virBufferContentAndReset(&buf);
diff --git a/tests/storagepoolxml2argvdata/pool-netfs-ns-mountopts-freebsd.argv b/tests/storagepoolxml2argvdata/pool-netfs-ns-mountopts-freebsd.argv
new file mode 100644
index 0000000000..d8bd7e378e
--- /dev/null
+++ b/tests/storagepoolxml2argvdata/pool-netfs-ns-mountopts-freebsd.argv
@@ -0,0 +1,2 @@
+mount -t nfs localhost:/var/lib/libvirt/images /mnt -o nfsvers=3,nosuid,noexec,\
+sync,lazytime
diff --git a/tests/storagepoolxml2argvdata/pool-netfs-ns-mountopts-linux.argv b/tests/storagepoolxml2argvdata/pool-netfs-ns-mountopts-linux.argv
new file mode 100644
index 0000000000..486b2183b7
--- /dev/null
+++ b/tests/storagepoolxml2argvdata/pool-netfs-ns-mountopts-linux.argv
@@ -0,0 +1,2 @@
+mount -t nfs localhost:/var/lib/libvirt/images /mnt -o nfsvers=3,nodev,nosuid,\
+noexec,sync,lazytime
diff --git a/tests/storagepoolxml2argvdata/pool-netfs-ns-mountopts.argv b/tests/storagepoolxml2argvdata/pool-netfs-ns-mountopts.argv
new file mode 100644
index 0000000000..a63d6da456
--- /dev/null
+++ b/tests/storagepoolxml2argvdata/pool-netfs-ns-mountopts.argv
@@ -0,0 +1 @@
+mount -t nfs localhost:/var/lib/libvirt/images /mnt -o nfsvers=3,sync,lazytime
diff --git a/tests/storagepoolxml2argvtest.c b/tests/storagepoolxml2argvtest.c
index b6a46280cd..b6bc838f7b 100644
--- a/tests/storagepoolxml2argvtest.c
+++ b/tests/storagepoolxml2argvtest.c
@@ -162,6 +162,9 @@ mymain(void)
 #define DO_TEST_FREEBSD(pool, ...) \
     DO_TEST_FULL(false, pool, false, true)
 
+    if (storageRegisterAll() < 0)
+       return EXIT_FAILURE;
+
     DO_TEST_FAIL("pool-dir");
     DO_TEST_FAIL("pool-dir-naming");
     DO_TEST("pool-fs");
@@ -177,14 +180,17 @@ mymain(void)
     DO_TEST_LINUX("pool-netfs");
     DO_TEST_LINUX("pool-netfs-auto");
     DO_TEST_LINUX("pool-netfs-protocol-ver");
+    DO_TEST_LINUX("pool-netfs-ns-mountopts");
 #elif defined(__FreeBSD__)
     DO_TEST_FREEBSD("pool-netfs");
     DO_TEST_FREEBSD("pool-netfs-auto");
     DO_TEST_FREEBSD("pool-netfs-protocol-ver");
+    DO_TEST_FREEBSD("pool-netfs-ns-mountopts");
 #else
     DO_TEST("pool-netfs");
     DO_TEST("pool-netfs-auto");
     DO_TEST("pool-netfs-protocol-ver");
+    DO_TEST("pool-netfs-ns-mountopts");
 #endif
     DO_TEST("pool-netfs-gluster");
     DO_TEST("pool-netfs-cifs");
-- 
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