[pve-devel] [PATCH v2 container 1/2] fix #1451: add mountoptions to container config

Thomas Lamprecht t.lamprecht at proxmox.com
Tue May 21 11:15:27 CEST 2019


On 5/21/19 10:47 AM, Oguz Bektas wrote:
> adds a mountoptions parameter in container config, which allows
> passing arbitrary mount options for the mountpoints and the rootfs.
> 
> the format is such:
> mountoptions=option;option;option;...
> 
> for example:
> 
> mp0: local-lvm:vm-1500-disk-1,mp=/etc/test1,mountoptions=strictatime;noexec;nodev,quota=1,size=8G
> 
> Signed-off-by: Oguz Bektas <o.bektas at proxmox.com>
> ---
>  src/PVE/LXC.pm        | 12 ++++++++++--
>  src/PVE/LXC/Config.pm |  7 +++++++
>  2 files changed, 17 insertions(+), 2 deletions(-)
> 
> diff --git a/src/PVE/LXC.pm b/src/PVE/LXC.pm
> index 62b6b8c..3f4c533 100644
> --- a/src/PVE/LXC.pm
> +++ b/src/PVE/LXC.pm
> @@ -1415,11 +1415,19 @@ sub mountpoint_mount {
>  
>      die "unknown snapshot path for '$volid'" if !$storage && defined($snapname);
>  
> -    my $optstring = '';
> +    my @mountoptions= split(/;/, $mountpoint->{mountoptions});
> +    my $optlist = [];
> +    foreach my $opt (@mountoptions) {
> +	push @$optlist, $opt;
> +    }
> +
>      my $acl = $mountpoint->{acl};
>      if (defined($acl)) {
> -	$optstring .= ($acl ? 'acl' : 'noacl');
> +	push @$optlist, ($acl ? 'acl' : 'noacl');
>      }
> +
> +    my $optstring = '';
> +    $optstring = join(',', @$optlist);

can be:
my $optstring = join(',', @$optlist);


>      my $readonly = $mountpoint->{ro};
>  
>      my @extra_opts;
> diff --git a/src/PVE/LXC/Config.pm b/src/PVE/LXC/Config.pm
> index 8dcd73c..99efb54 100644
> --- a/src/PVE/LXC/Config.pm
> +++ b/src/PVE/LXC/Config.pm
> @@ -236,6 +236,13 @@ my $rootfs_desc = {
>  	description => 'Explicitly enable or disable ACL support.',
>  	optional => 1,
>      },
> +    mountoptions => {
> +	optional => 1,
> +	type => 'string',
> +	description => 'Extra mount options for rootfs/mps.',

"Extra mount options applied on this mount point"

Maybe add a verbose desc. that this does not gets checked against any 
conflicts, etc. from inside this, or with the ones set by us..

> +	format_description => 'opt;opt;...',
> +	pattern => qr/[a-zA-Z0-9; ]+/,

and we're sure about allowing all?? also there's no option
on any FS supported option which can include ';' ? 

> +    },
>      ro => {
>  	type => 'boolean',
>  	description => 'Read-only mount point',
> 





More information about the pve-devel mailing list