[pve-devel] [PATCH] add property 'nfsversion' to storage
Frank Brendel
frank.brendel at eurolog.com
Thu May 3 09:35:27 CEST 2012
Signed-off-by: Frank Brendel <frank.brendel at eurolog.com>
---
PVE/API2/Storage/Config.pm | 8 ++++++++
PVE/Storage.pm | 16 ++++++++++++++--
2 files changed, 22 insertions(+), 2 deletions(-)
diff --git a/PVE/API2/Storage/Config.pm b/PVE/API2/Storage/Config.pm
index 4461ddd..2b9ee99 100755
--- a/PVE/API2/Storage/Config.pm
+++ b/PVE/API2/Storage/Config.pm
@@ -173,6 +173,10 @@ __PACKAGE__->register_method ({
optional => 1,
minimum => 0,
},
+ nfsversion => {
+ type => 'integer',
+ optional => 1,
+ },
shared => {
type => 'boolean',
optional => 1,
@@ -280,6 +284,10 @@ __PACKAGE__->register_method ({
optional => 1,
minimum => 0,
},
+ nfsversion => {
+ type => 'integer',
+ optional => 1,
+ },
digest => {
type => 'string',
description => 'Prevent changes if current configuration file has different SHA1 digest. This can be used to prevent concurrent modifications.',
diff --git a/PVE/Storage.pm b/PVE/Storage.pm
index cd74a3a..21fa53c 100755
--- a/PVE/Storage.pm
+++ b/PVE/Storage.pm
@@ -120,6 +120,7 @@ my $confvars = {
nodes => 'nodes',
options => 'options',
maxfiles => 'natural',
+ nfsversion => 'nfsversion',
};
my $required_config = {
@@ -131,7 +132,7 @@ my $required_config = {
my $fixed_config = {
dir => ['path'],
- nfs => ['path', 'server', 'export'],
+ nfs => ['path', 'server', 'export', 'nfsversion'],
lvm => ['vgname', 'base'],
iscsi => ['portal', 'target'],
};
@@ -159,6 +160,7 @@ my $default_config = {
content => [ { images => 1, rootdir => 1, vztmpl => 1, iso => 1, backup => 1},
{ images => 1 }],
format => [ { raw => 1, qcow2 => 1, vmdk => 1 } , 'raw' ],
+ nfsversion => 0,
},
lvm => {
@@ -334,6 +336,10 @@ sub check_type {
return int($value) if $value =~ m/^\d+$/;
return undef if $noerr;
die "type check ('natural') failed - got '$value'\n";
+ } elsif ($ct eq 'nfsversion') {
+ return int($value) if ($value && ($value eq 3 || $value eq 4));
+ return undef if $noerr;
+ die "NFS version '$value' not supported\n";
} elsif ($ct eq 'nodes') {
my $res = {};
@@ -1825,6 +1831,7 @@ sub __activate_storage_full {
if ($type eq 'nfs') {
my $server = $scfg->{server};
my $export = $scfg->{export};
+ my $options = $scfg->{options};
if (!nfs_is_mounted ($server, $export, $path, $mountdata)) {
@@ -1836,7 +1843,12 @@ sub __activate_storage_full {
die "unable to activate storage '$storeid' - " .
"directory '$path' does not exist\n" if ! -d $path;
- nfs_mount ($server, $export, $path, $scfg->{options});
+ # set nfs version but do not overwride explicit set options
+ if ($scfg->{nfsversion} && $options !~ '/vers=[3,4]/') {
+ $options .= "vers=" . $scfg->{nfsversion};
+ }
+
+ nfs_mount ($server, $export, $path, $options);
}
} else {
--
1.7.0.4
More information about the pve-devel
mailing list