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

[libvirt] [PATCH v3 05/11] storage: Add the nfsvers to the command line



If protocolVer present, add the -o nfsvers=# to the command
line for the NFS Storage Pool

Signed-off-by: John Ferlan <jferlan redhat com>
---
 src/storage/storage_util.c                                 | 6 +++++-
 tests/storagepoolxml2argvdata/pool-netfs-protocol-ver.argv | 1 +
 tests/storagepoolxml2argvtest.c                            | 1 +
 3 files changed, 7 insertions(+), 1 deletion(-)
 create mode 100644 tests/storagepoolxml2argvdata/pool-netfs-protocol-ver.argv

diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c
index 8fe6139682..0c52b797fc 100644
--- a/src/storage/storage_util.c
+++ b/src/storage/storage_util.c
@@ -4337,11 +4337,15 @@ virStorageBackendFileSystemMountCmd(const char *cmdstr,
     else
         virStorageBackendFileSystemMountDefaultArgs(cmd, src, def);
 
-    if (def->type == VIR_STORAGE_POOL_NETFS && def->source.mountOpts) {
+    if (def->type == VIR_STORAGE_POOL_NETFS &&
+        (def->source.mountOpts || (def->source.protocolVer > 0))) {
         size_t i;
         virBuffer buf = VIR_BUFFER_INITIALIZER;
         VIR_AUTOFREE(char *) mountOpts = NULL;
 
+        if (def->source.protocolVer > 0)
+            virBufferAsprintf(&buf, "nfsvers=%u,", def->source.protocolVer);
+
         for (i = 0; i < def->source.nmountOpts; i++)
             virBufferAsprintf(&buf, "%s,", def->source.mountOpts[i]);
 
diff --git a/tests/storagepoolxml2argvdata/pool-netfs-protocol-ver.argv b/tests/storagepoolxml2argvdata/pool-netfs-protocol-ver.argv
new file mode 100644
index 0000000000..f26656d5b8
--- /dev/null
+++ b/tests/storagepoolxml2argvdata/pool-netfs-protocol-ver.argv
@@ -0,0 +1 @@
+mount -t nfs localhost:/var/lib/libvirt/images /mnt -o nfsvers=3
diff --git a/tests/storagepoolxml2argvtest.c b/tests/storagepoolxml2argvtest.c
index 0df97fb390..e8bae9fb8c 100644
--- a/tests/storagepoolxml2argvtest.c
+++ b/tests/storagepoolxml2argvtest.c
@@ -157,6 +157,7 @@ mymain(void)
     DO_TEST_FAIL("pool-iscsi-auth");
     DO_TEST("pool-netfs");
     DO_TEST("pool-netfs-auto");
+    DO_TEST("pool-netfs-protocol-ver");
     DO_TEST("pool-netfs-gluster");
     DO_TEST("pool-netfs-cifs");
     DO_TEST("pool-netfs-mountopts");
-- 
2.20.1


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