[PATCH v5 4/9] storage: Add the nfsvers to the command line

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

 



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

Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx>
---
 src/storage/storage_util.c                    | 19 +++++++++++++------
 .../pool-netfs-protocol-ver-freebsd.argv      |  1 +
 .../pool-netfs-protocol-ver-linux.argv        |  2 ++
 .../pool-netfs-protocol-ver.argv              |  1 +
 tests/storagepoolxml2argvtest.c               |  3 +++
 5 files changed, 20 insertions(+), 6 deletions(-)
 create mode 100644 tests/storagepoolxml2argvdata/pool-netfs-protocol-ver-freebsd.argv
 create mode 100644 tests/storagepoolxml2argvdata/pool-netfs-protocol-ver-linux.argv
 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 d63237ce8f..a5cb47b4d0 100644
--- a/src/storage/storage_util.c
+++ b/src/storage/storage_util.c
@@ -4290,10 +4290,11 @@ virStorageBackendFileSystemMountAddOptions(virCommandPtr cmd,
 static void
 virStorageBackendFileSystemMountNFSArgs(virCommandPtr cmd,
                                         const char *src,
-                                        virStoragePoolDefPtr def)
+                                        virStoragePoolDefPtr def,
+                                        const char *nfsVers)
 {
     virCommandAddArgList(cmd, src, def->target.path, NULL);
-    virStorageBackendFileSystemMountAddOptions(cmd, NULL);
+    virStorageBackendFileSystemMountAddOptions(cmd, nfsVers);
 }
 
 
@@ -4326,7 +4327,8 @@ virStorageBackendFileSystemMountCIFSArgs(virCommandPtr cmd,
 static void
 virStorageBackendFileSystemMountDefaultArgs(virCommandPtr cmd,
                                             const char *src,
-                                            virStoragePoolDefPtr def)
+                                            virStoragePoolDefPtr def,
+                                            const char *nfsVers)
 {
     const char *fmt;
 
@@ -4335,7 +4337,7 @@ virStorageBackendFileSystemMountDefaultArgs(virCommandPtr cmd,
     else
         fmt = virStoragePoolFormatFileSystemNetTypeToString(def->source.format);
     virCommandAddArgList(cmd, "-t", fmt, src, def->target.path, NULL);
-    virStorageBackendFileSystemMountAddOptions(cmd, NULL);
+    virStorageBackendFileSystemMountAddOptions(cmd, nfsVers);
 }
 
 
@@ -4354,16 +4356,21 @@ virStorageBackendFileSystemMountCmd(const char *cmdstr,
     bool cifsfs = (def->type == VIR_STORAGE_POOL_NETFS &&
                    def->source.format == VIR_STORAGE_POOL_NETFS_CIFS);
     virCommandPtr cmd = NULL;
+    VIR_AUTOFREE(char *) nfsVers = NULL;
+
+    if (def->type == VIR_STORAGE_POOL_NETFS && def->source.protocolVer > 0 &&
+        virAsprintf(&nfsVers, "nfsvers=%u", def->source.protocolVer) < 0)
+        return NULL;
 
     cmd = virCommandNew(cmdstr);
     if (netauto)
-        virStorageBackendFileSystemMountNFSArgs(cmd, src, def);
+        virStorageBackendFileSystemMountNFSArgs(cmd, src, def, nfsVers);
     else if (glusterfs)
         virStorageBackendFileSystemMountGlusterArgs(cmd, src, def);
     else if (cifsfs)
         virStorageBackendFileSystemMountCIFSArgs(cmd, src, def);
     else
-        virStorageBackendFileSystemMountDefaultArgs(cmd, src, def);
+        virStorageBackendFileSystemMountDefaultArgs(cmd, src, def, nfsVers);
     return cmd;
 }
 
diff --git a/tests/storagepoolxml2argvdata/pool-netfs-protocol-ver-freebsd.argv b/tests/storagepoolxml2argvdata/pool-netfs-protocol-ver-freebsd.argv
new file mode 100644
index 0000000000..59d09d2e5d
--- /dev/null
+++ b/tests/storagepoolxml2argvdata/pool-netfs-protocol-ver-freebsd.argv
@@ -0,0 +1 @@
+mount -t nfs localhost:/var/lib/libvirt/images /mnt -o nosuid,noexec,nfsvers=3
diff --git a/tests/storagepoolxml2argvdata/pool-netfs-protocol-ver-linux.argv b/tests/storagepoolxml2argvdata/pool-netfs-protocol-ver-linux.argv
new file mode 100644
index 0000000000..c819a089d2
--- /dev/null
+++ b/tests/storagepoolxml2argvdata/pool-netfs-protocol-ver-linux.argv
@@ -0,0 +1,2 @@
+mount -t nfs localhost:/var/lib/libvirt/images /mnt -o nodev,nosuid,noexec,\
+nfsvers=3
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 0331d3497b..88059cbdfc 100644
--- a/tests/storagepoolxml2argvtest.c
+++ b/tests/storagepoolxml2argvtest.c
@@ -176,18 +176,21 @@ mymain(void)
     DO_TEST_LINUX("pool-fs");
     DO_TEST_LINUX("pool-netfs");
     DO_TEST_LINUX("pool-netfs-auto");
+    DO_TEST_LINUX("pool-netfs-protocol-ver");
     DO_TEST_LINUX("pool-netfs-gluster");
     DO_TEST_LINUX("pool-netfs-cifs");
 #elif defined(__FreeBSD__)
     DO_TEST_FREEBSD("pool-fs");
     DO_TEST_FREEBSD("pool-netfs");
     DO_TEST_FREEBSD("pool-netfs-auto");
+    DO_TEST_FREEBSD("pool-netfs-protocol-ver");
     DO_TEST_FREEBSD("pool-netfs-gluster");
     DO_TEST_FREEBSD("pool-netfs-cifs");
 #else
     DO_TEST("pool-fs");
     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");
 #endif
-- 
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