From: Filip Schauer <f.schauer@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH container] fix #5907: ignore conflicting mount options for read-only mounts
Date: Mon, 25 Nov 2024 14:09:08 +0100 [thread overview]
Message-ID: <20241125130908.22076-1-f.schauer@proxmox.com> (raw)
When mounting volumes as read-only, certain mount options like
"discard", "lazytime", and "noatime" are either ignored or can cause the
mount to fail. For example, attempting to mount with "-t zfs" and
"-o ro,discard" leads to an error: filesystem cannot be mounted due to
invalid option 'discard'.
This commit ensures that only valid mount options, such as "nodev",
"noexec", and "nosuid", are applied to read-only mounts, avoiding
potential mount failures.
Signed-off-by: Filip Schauer <f.schauer@proxmox.com>
---
src/PVE/LXC.pm | 8 ++++++--
src/PVE/LXC/Config.pm | 6 ++++++
2 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/src/PVE/LXC.pm b/src/PVE/LXC.pm
index e78e365..d01fafc 100644
--- a/src/PVE/LXC.pm
+++ b/src/PVE/LXC.pm
@@ -1865,11 +1865,16 @@ sub __mountpoint_mount {
die "unknown snapshot path for '$volid'" if !$storage && defined($snapname);
+ my $readonly = $mountpoint->{ro};
my $optlist = [];
if (my $mountopts = $mountpoint->{mountoptions}) {
my @opts = split(/;/, $mountpoint->{mountoptions});
- push @$optlist, grep { PVE::LXC::Config::is_valid_mount_option($_) } @opts;
+ if ($readonly || defined($snapname)) {
+ push @$optlist, grep { PVE::LXC::Config::is_valid_ro_mount_option($_) } @opts;
+ } else {
+ push @$optlist, grep { PVE::LXC::Config::is_valid_mount_option($_) } @opts;
+ }
}
my $acl = $mountpoint->{acl};
@@ -1880,7 +1885,6 @@ sub __mountpoint_mount {
}
my $optstring = join(',', @$optlist);
- my $readonly = $mountpoint->{ro};
my @extra_opts;
@extra_opts = ('-o', $optstring) if $optstring;
diff --git a/src/PVE/LXC/Config.pm b/src/PVE/LXC/Config.pm
index 5cc37f7..0740e8c 100644
--- a/src/PVE/LXC/Config.pm
+++ b/src/PVE/LXC/Config.pm
@@ -312,12 +312,18 @@ cfs_register_file('/lxc/', \&parse_pct_config, \&write_pct_config);
my $valid_mount_option_re = qr/(discard|lazytime|noatime|nodev|noexec|nosuid)/;
+my $valid_ro_mount_option_re = qr/(nodev|noexec|nosuid)/;
sub is_valid_mount_option {
my ($option) = @_;
return $option =~ $valid_mount_option_re;
}
+sub is_valid_ro_mount_option {
+ my ($option) = @_;
+ return $option =~ $valid_ro_mount_option_re;
+}
+
my $rootfs_desc = {
volume => {
type => 'string',
--
2.39.5
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
reply other threads:[~2024-11-25 13:09 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241125130908.22076-1-f.schauer@proxmox.com \
--to=f.schauer@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox