If protocolVer present, add the -o nfsvers=# to the command
line for the NFS Storage Pool
Signed-off-by: John Ferlan <jferlan(a)redhat.com>
---
src/storage/storage_util.c | 20 +++++++++++++++----
.../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, 23 insertions(+), 4 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 44a95d9fab..b82bef2904 100644
--- a/src/storage/storage_util.c
+++ b/src/storage/storage_util.c
@@ -4267,10 +4267,22 @@ virStorageBackendFileSystemGetPoolSource(virStoragePoolObjPtr
pool)
static void
-virStorageBackendFileSystemMountNFSAddOptions(virCommandPtr cmd)
+virStorageBackendFileSystemMountNFSAddOptions(virCommandPtr cmd,
+ virStoragePoolDefPtr def)
{
+ VIR_AUTOFREE(char *) mountOpts = NULL;
+ virBuffer buf = VIR_BUFFER_INITIALIZER;
+
+ if (def->source.protocolVer > 0)
+ virBufferAsprintf(&buf, "nfsvers=%u,",
def->source.protocolVer);
+
if (*default_nfs_mount_opts != '\0')
- virCommandAddArgList(cmd, "-o", default_nfs_mount_opts, NULL);
+ virBufferAddLit(&buf, default_nfs_mount_opts);
+
+ virBufferTrim(&buf, ",", -1);
+ mountOpts = virBufferContentAndReset(&buf);
+ if (mountOpts)
+ virCommandAddArgList(cmd, "-o", mountOpts, NULL);
}
@@ -4280,7 +4292,7 @@ virStorageBackendFileSystemMountNFSArgs(virCommandPtr cmd,
virStoragePoolDefPtr def)
{
virCommandAddArgList(cmd, src, def->target.path, NULL);
- virStorageBackendFileSystemMountNFSAddOptions(cmd);
+ virStorageBackendFileSystemMountNFSAddOptions(cmd, def);
}
@@ -4323,7 +4335,7 @@ virStorageBackendFileSystemMountDefaultArgs(virCommandPtr cmd,
fmt = virStoragePoolFormatFileSystemNetTypeToString(def->source.format);
virCommandAddArgList(cmd, "-t", fmt, src, def->target.path, NULL);
if (def->type == VIR_STORAGE_POOL_NETFS)
- virStorageBackendFileSystemMountNFSAddOptions(cmd);
+ virStorageBackendFileSystemMountNFSAddOptions(cmd, def);
}
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..3384a8a8dd
--- /dev/null
+++ b/tests/storagepoolxml2argvdata/pool-netfs-protocol-ver-freebsd.argv
@@ -0,0 +1 @@
+mount -t nfs localhost:/var/lib/libvirt/images /mnt -o nfsvers=3,nosuid,noexec
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..7508046340
--- /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 nfsvers=3,nodev,nosuid,\
+noexec
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 c114fecbcf..b6a46280cd 100644
--- a/tests/storagepoolxml2argvtest.c
+++ b/tests/storagepoolxml2argvtest.c
@@ -176,12 +176,15 @@ mymain(void)
#ifdef __linux__
DO_TEST_LINUX("pool-netfs");
DO_TEST_LINUX("pool-netfs-auto");
+ DO_TEST_LINUX("pool-netfs-protocol-ver");
#elif defined(__FreeBSD__)
DO_TEST_FREEBSD("pool-netfs");
DO_TEST_FREEBSD("pool-netfs-auto");
+ DO_TEST_FREEBSD("pool-netfs-protocol-ver");
#else
DO_TEST("pool-netfs");
DO_TEST("pool-netfs-auto");
+ DO_TEST("pool-netfs-protocol-ver");
#endif
DO_TEST("pool-netfs-gluster");
DO_TEST("pool-netfs-cifs");
--
2.20.1