]> git.proxmox.com Git - pve-storage.git/commitdiff
fix: check connection for nfs v4 only server
authorAlwin Antreich <a.antreich@proxmox.com>
Wed, 16 Dec 2020 11:59:04 +0000 (12:59 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Tue, 26 Jan 2021 18:15:17 +0000 (19:15 +0100)
the check_connection is done by querying the exports of the nfs server
in question. With nfs v4 those exports aren't listed anymore since nfs
v4 employs a pseudo-filesystem starting from root (/).

rpcinfo allows to query the existence of an nfs v4 service.

Signed-off-by: Alwin Antreich <a.antreich@proxmox.com>
PVE/Storage/NFSPlugin.pm

index e8e27c090ff4992d3b7253e0135ea202efedcd4f..72e06c2ec2599979454280f0e41a477c1f335e94 100644 (file)
@@ -160,8 +160,16 @@ sub check_connection {
     my ($class, $storeid, $scfg) = @_;
 
     my $server = $scfg->{server};
-
-    my $cmd = ['/sbin/showmount', '--no-headers', '--exports', $server];
+    my $opts = $scfg->{options};
+
+    my $cmd;
+    if (defined($opts) && $opts =~ /vers=4.*/) {
+       # nfsv4 uses a pseudo-filesystem always beginning with /
+       # no exports are listed
+       $cmd = ['/usr/sbin/rpcinfo', '-t', $server, 'nfs', '4'];
+    } else {
+       $cmd = ['/sbin/showmount', '--no-headers', '--exports', $server];
+    }
 
     eval { run_command($cmd, timeout => 10, outfunc => sub {}, errfunc => sub {}) };
     if (my $err = $@) {