From 3ceee38d6d4b86bf9c80ce3a15c671f8fbf797cd Mon Sep 17 00:00:00 2001 From: Fabian Ebner Date: Tue, 18 Feb 2020 12:31:22 +0100 Subject: [PATCH 1/1] Fix mounting ZFS snapshots whose dataset is not mounted below '/' Trying to back up a container with a ZFS dataset with non-standard mount would fail, see [0]. This also removes the near-dead code $name .= "\@$snapname"; when snapname is false-y, but defined and turns the check for $snapname into one for definedness. [0]: https://forum.proxmox.com/threads/lxc-backup-fails-unable-to-open-the-dataset-vzdump.64944/ Signed-off-by: Fabian Ebner --- src/PVE/LXC.pm | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/PVE/LXC.pm b/src/PVE/LXC.pm index 34ca2a3..21bc9c6 100644 --- a/src/PVE/LXC.pm +++ b/src/PVE/LXC.pm @@ -1647,19 +1647,17 @@ sub __mountpoint_mount { if ($format eq 'subvol') { if ($mount_path) { - if ($snapname) { + my (undef, $name) = PVE::Storage::parse_volname($storage_cfg, $volid); + if (defined($snapname)) { + $name .= "\@$snapname"; if ($scfg->{type} eq 'zfspool') { - my $path_arg = $path; - $path_arg =~ s!^/+!!; - PVE::Tools::run_command(['mount', '-o', 'ro', @extra_opts, '-t', 'zfs', $path_arg, $mount_path]); + PVE::Tools::run_command(['mount', '-o', 'ro', @extra_opts, '-t', 'zfs', "$scfg->{pool}/$name", $mount_path]); } else { die "cannot mount subvol snapshots for storage type '$scfg->{type}'\n"; } } else { if (defined($acl) && $scfg->{type} eq 'zfspool') { my $acltype = ($acl ? 'acltype=posixacl' : 'acltype=noacl'); - my (undef, $name) = PVE::Storage::parse_volname($storage_cfg, $volid); - $name .= "\@$snapname" if defined($snapname); PVE::Tools::run_command(['zfs', 'set', $acltype, "$scfg->{pool}/$name"]); } bindmount($path, $parentfd, $last_dir//$rootdir, $mount_path, $readonly, @extra_opts); -- 2.39.2