[PATCH pve-container 1/1] Adding new mount point type named 'zfs' to let configure a ZFS dataset as mount point for LXC container

Konstantin Filippov frank030366 at hotmail.com
Wed May 10 02:08:30 CEST 2023


Signed-off-by: Konstantin Filippov <frank030366 at hotmail.com>
---
 src/PVE/LXC.pm        | 4 ++++
 src/PVE/LXC/Config.pm | 3 ++-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/PVE/LXC.pm b/src/PVE/LXC.pm
index d138161..30cf48d 100644
--- a/src/PVE/LXC.pm
+++ b/src/PVE/LXC.pm
@@ -1839,6 +1839,10 @@ sub __mountpoint_mount {
 	my ($devpath) = (Cwd::realpath($volid) =~ /^(.*)$/s); # realpath() taints
 	PVE::Tools::run_command(['mount', @extra_opts, $volid, $mount_path]) if $mount_path;
 	return wantarray ? ($volid, 0, $devpath) : $volid;
+    } elsif ($type eq 'zfs') {
+	push @extra_opts, '-o', 'ro' if $readonly;
+	PVE::Tools::run_command(['mount.zfs', @extra_opts, $volid, $mount_path]) if $mount_path;
+	return wantarray ? ($volid, 0, undef) : $volid
     } elsif ($type eq 'bind') {
 	die "directory '$volid' does not exist\n" if ! -d $volid;
 	bindmount($volid, $parentfd, $last_dir//$rootdir, $mount_path, $readonly, @extra_opts) if $mount_path;
diff --git a/src/PVE/LXC/Config.pm b/src/PVE/LXC/Config.pm
index ac9db94..056ec98 100644
--- a/src/PVE/LXC/Config.pm
+++ b/src/PVE/LXC/Config.pm
@@ -1557,7 +1557,8 @@ sub classify_mountpoint {
 	return 'device' if $vol =~ m!^/dev/!;
 	return 'bind';
     }
-    return 'volume';
+    return 'volume' if $vol =~ m!:.*(vm|subvol)-[0-9]*-disk-[0-9]*!;
+    return 'zfs';
 }
 
 my $__is_volume_in_use = sub {
-- 
2.30.2





More information about the pve-devel mailing list