[pve-devel] [PATCH storage 22/26] zfs: update 'path' method for new naming scheme
Wolfgang Bumiller
w.bumiller at proxmox.com
Tue Jul 29 13:15:35 CEST 2025
Signed-off-by: Wolfgang Bumiller <w.bumiller at proxmox.com>
---
src/PVE/Storage/ZFSPoolPlugin.pm | 25 ++++++++++++++++---------
1 file changed, 16 insertions(+), 9 deletions(-)
diff --git a/src/PVE/Storage/ZFSPoolPlugin.pm b/src/PVE/Storage/ZFSPoolPlugin.pm
index 2cae090..83cb9fb 100644
--- a/src/PVE/Storage/ZFSPoolPlugin.pm
+++ b/src/PVE/Storage/ZFSPoolPlugin.pm
@@ -123,7 +123,15 @@ sub zfs_parse_zvol_list {
return $list;
}
-my sub image_vtype_from_name : prototype($) {
+my sub volname_is_subvol : prototype($) {
+ my ($volname) = @_;
+ return 1 if $volname =~ /^(?:base-)?subvol-ct-/;
+ return 1 if $volname =~ /^subvol-/;
+ return 1 if $volname =~ /^basevol-/;
+ return 0;
+}
+
+my sub volume_type_from_name : prototype($) {
my ($name) = @_;
return 'ct-vol' if $name =~ /^(base-)?subvol(-ct)?-/;
@@ -194,16 +202,15 @@ sub path {
my $path = '';
my $mountpoint = $scfg->{mountpoint} // "/$scfg->{pool}";
- if ($vtype eq "images") {
- if ($name =~ m/^subvol-/ || $name =~ m/^basevol-/) {
- $path = "$mountpoint/$name";
- } else {
- $path = "/dev/zvol/$scfg->{pool}/$name";
- }
- $path .= "\@$snapname" if defined($snapname);
+ die "$vtype is not allowed in ZFSPool!"
+ if $vtype ne 'vm-vol' && $vtype ne 'ct-vol' && $vtype ne 'images';
+
+ if (volname_is_subvol($name)) {
+ $path = "$mountpoint/$name";
} else {
- die "$vtype is not allowed in ZFSPool!";
+ $path = "/dev/zvol/$scfg->{pool}/$name";
}
+ $path .= "\@$snapname" if defined($snapname);
return ($path, $vmid, $vtype);
}
--
2.47.2
More information about the pve-devel
mailing list