[pve-devel] [PATCH] [FEATURE] Apply the options of lxc.rootfs.options on rootfs.
Gerrit Venema
gmoniker at gmail.com
Sat Jan 9 16:27:45 CET 2016
This option is allowed inside the configuration file for a container.
But it didn't get applied. This may be used to turn off posix ACL for
a container or use external journals etc.
This commit only allows setting the options on a loopback mount and
plain devices. The options on a bind mount influence the host system
and there is no history for the original settings.
Signed-off-by: Gerrit Venema <gmoniker at gmail.com>
---
src/PVE/LXC.pm | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/src/PVE/LXC.pm b/src/PVE/LXC.pm
index 6023334..832b8ab 100644
--- a/src/PVE/LXC.pm
+++ b/src/PVE/LXC.pm
@@ -1983,6 +1983,10 @@ sub sanitize_mountpoint {
sub foreach_mountpoint_full {
my ($conf, $reverse, $func) = @_;
+ my $lxc_root_options = '';
+ foreach my $item (@{$conf->{lxc}}) {
+ $lxc_root_options = @{$item}[1] if @{$item}[0] eq 'lxc.rootfs.options';
+ }
foreach my $key (mountpoint_names($reverse)) {
my $value = $conf->{$key};
@@ -1992,6 +1996,7 @@ sub foreach_mountpoint_full {
# just to be sure: rootfs is /
my $path = $key eq 'rootfs' ? '/' : $mountpoint->{mp};
+ $mountpoint->{options} = $lxc_root_options if $key eq 'rootfs' && $lxc_root_options;
$mountpoint->{mp} = sanitize_mountpoint($path);
$path = $mountpoint->{volume};
@@ -2158,6 +2163,11 @@ sub mountpoint_mount {
die "unknown snapshot path for '$volid'" if !$storage && defined($snapname);
+ my @extra_opts = ();
+ if ($mountpoint->{options}) {
+ push @extra_opts, '-o', $mountpoint->{options};
+ }
+
if ($storage) {
my $scfg = PVE::Storage::storage_config($storage_cfg, $storage);
@@ -2185,7 +2195,6 @@ sub mountpoint_mount {
return wantarray ? ($path, 0) : $path;
} elsif ($format eq 'raw' || $format eq 'iso') {
my $use_loopdev = 0;
- my @extra_opts;
if ($scfg->{path}) {
push @extra_opts, '-o', 'loop';
$use_loopdev = 1;
@@ -2208,7 +2217,7 @@ sub mountpoint_mount {
die "unsupported image format '$format'\n";
}
} elsif ($type eq 'device') {
- PVE::Tools::run_command(['mount', $volid, $mount_path]) if $mount_path;
+ PVE::Tools::run_command(['mount', @extra_opts, $volid, $mount_path]) if $mount_path;
return wantarray ? ($volid, 0) : $volid;
} elsif ($type eq 'bind' && -d $volid) {
&$check_mount_path($volid);
--
2.1.4
More information about the pve-devel
mailing list