From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id BE1121FF183 for ; Wed, 30 Jul 2025 10:36:38 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 9036636793; Wed, 30 Jul 2025 10:38:04 +0200 (CEST) Date: Wed, 30 Jul 2025 10:37:27 +0200 From: Fabian =?iso-8859-1?q?Gr=FCnbichler?= To: Proxmox VE development discussion References: <20250729111557.136012-1-w.bumiller@proxmox.com> <20250729111557.136012-11-w.bumiller@proxmox.com> In-Reply-To: <20250729111557.136012-11-w.bumiller@proxmox.com> MIME-Version: 1.0 User-Agent: astroid/0.16.0 (https://github.com/astroidmail/astroid) Message-Id: <1753861192.t7ef8q26xn.astroid@yuna.none> X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1753864640247 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.046 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: Re: [pve-devel] [PATCH storage 10/26] plugins: update volname parsing for new naming convention X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox VE development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pve-devel-bounces@lists.proxmox.com Sender: "pve-devel" On July 29, 2025 1:15 pm, Wolfgang Bumiller wrote: > - ESXi, ISCSIDirect, ISCSI: > Volumes are always vm volumes. > - LVM: > New volumes use a `vol-vm-` or `vol-ct-` prefix. > - Dir based, LvmThin, RBD: > Like LVM, but for base images a `base-` prefix is added > *additionally*, instead of *replacing* the `vm-` portion like we > used to. > - ZFS: > VMs: `vol-vm-` prefix. > Containers: `subvol-ct-` prefix. we could get rid of this historic anomaly while we're at it, and make the new vtype just encoded as vol-ct for consistency - that those are always filesystem datasets, and the vol-vm ones always zvols is an implementation detail then? > Both also get an optional additional `base-` prefix for base > volumes. > > Note: all new base- prefix come in front of the `(sub)vol-*` prefixes. > > Signed-off-by: Wolfgang Bumiller > --- > src/PVE/Storage/ESXiPlugin.pm | 2 +- > src/PVE/Storage/ISCSIDirectPlugin.pm | 2 +- > src/PVE/Storage/ISCSIPlugin.pm | 2 +- > src/PVE/Storage/LVMPlugin.pm | 19 ++++++++--- > src/PVE/Storage/LvmThinPlugin.pm | 13 ++++++++ > src/PVE/Storage/Plugin.pm | 48 +++++++++++++++++++++------- > src/PVE/Storage/RBDPlugin.pm | 45 ++++++++++++++++++++++++-- > src/PVE/Storage/ZFSPoolPlugin.pm | 34 ++++++++++++++++---- > 8 files changed, 138 insertions(+), 27 deletions(-) > > diff --git a/src/PVE/Storage/ESXiPlugin.pm b/src/PVE/Storage/ESXiPlugin.pm > index eeb6a48..ea2f8f9 100644 > --- a/src/PVE/Storage/ESXiPlugin.pm > +++ b/src/PVE/Storage/ESXiPlugin.pm > @@ -421,7 +421,7 @@ sub parse_volname { > > my $format = 'raw'; > $format = 'vmdk' if $volname =~ /\.vmdk$/; > - return ('images', $volname, 0, undef, undef, undef, $format); > + return ('vm-vol', $volname, 0, undef, undef, undef, $format); > } > > sub list_images { > diff --git a/src/PVE/Storage/ISCSIDirectPlugin.pm b/src/PVE/Storage/ISCSIDirectPlugin.pm > index 069a41f..f5b466e 100644 > --- a/src/PVE/Storage/ISCSIDirectPlugin.pm > +++ b/src/PVE/Storage/ISCSIDirectPlugin.pm > @@ -87,7 +87,7 @@ sub parse_volname { > my ($class, $volname) = @_; > > if ($volname =~ m/^lun(\d+)$/) { > - return ('images', $1, undef, undef, undef, undef, 'raw'); > + return ('vm-vol', $1, undef, undef, undef, undef, 'raw'); > } > > die "unable to parse iscsi volume name '$volname'\n"; > diff --git a/src/PVE/Storage/ISCSIPlugin.pm b/src/PVE/Storage/ISCSIPlugin.pm > index 7b30955..4875a1f 100644 > --- a/src/PVE/Storage/ISCSIPlugin.pm > +++ b/src/PVE/Storage/ISCSIPlugin.pm > @@ -371,7 +371,7 @@ sub parse_volname { > my ($class, $volname) = @_; > > if ($volname =~ m!^\d+\.\d+\.\d+\.([^/\s]+)$!) { > - return ('images', $1, undef, undef, undef, undef, 'raw'); > + return ('vm-vol', $1, undef, undef, undef, undef, 'raw'); > } > > die "unable to parse iscsi volume name '$volname'\n"; > diff --git a/src/PVE/Storage/LVMPlugin.pm b/src/PVE/Storage/LVMPlugin.pm > index 6694cf2..9b88c6a 100644 > --- a/src/PVE/Storage/LVMPlugin.pm > +++ b/src/PVE/Storage/LVMPlugin.pm > @@ -452,11 +452,22 @@ sub parse_volname { > > PVE::Storage::Plugin::parse_lvm_name($volname); > > - if ($volname =~ m/^(vm-(\d+)-\S+)$/) { > - my $name = $1; > - my $vmid = $2; > + if ( > + $volname =~ m!^(? > + ( > + # New style volumes have a vtype: > + vol-(?vm|ct) > + > + # Old style: > + | vm > + ) > + -(?\d+)-\S+ > + )$!xn > + ) { > + my ($name, $vmid, $vtype) = @+{qw(name vmid vtype)}; > + $vtype = $vtype ? "$vtype-vol" : 'images'; > my $format = $volname =~ m/\.qcow2$/ ? 'qcow2' : 'raw'; > - return ('images', $name, $vmid, undef, undef, undef, $format); > + return ($vtype, $name, $vmid, undef, undef, undef, $format); > } > > die "unable to parse lvm volume name '$volname'\n"; > diff --git a/src/PVE/Storage/LvmThinPlugin.pm b/src/PVE/Storage/LvmThinPlugin.pm > index cdf0fd0..751bd7b 100644 > --- a/src/PVE/Storage/LvmThinPlugin.pm > +++ b/src/PVE/Storage/LvmThinPlugin.pm > @@ -77,6 +77,19 @@ sub parse_volname { > > PVE::Storage::Plugin::parse_lvm_name($volname); > > + # New naming convention: > + if ( > + $volname =~ m/^(? > + (?base-)? > + (?:vol-(? vm|ct))- > + (?\d+)- > + \S+)$/xn > + ) { > + my ($name, $vmid, $vtype, $isbase) = @+{qw(name vmid vtype isbase)}; > + return ($vtype . '-vol', $name, $vmid, undef, undef, !!$isbase, 'raw'); > + } > + > + # Old naming convention: > if ($volname =~ m/^((vm|base)-(\d+)-\S+)$/) { > return ('images', $1, $3, undef, undef, $2 eq 'base', 'raw'); > } > diff --git a/src/PVE/Storage/Plugin.pm b/src/PVE/Storage/Plugin.pm > index ae9d673..77bcfc7 100644 > --- a/src/PVE/Storage/Plugin.pm > +++ b/src/PVE/Storage/Plugin.pm > @@ -711,19 +711,46 @@ sub cluster_lock_storage { > my sub parse_snap_name { > my ($name) = @_; > > + if ($name =~ m/^snap-(.*)-vol-(?:vm|ct)(.*)$/) { > + return $1; > + } > + > if ($name =~ m/^snap-(.*)-vm(.*)$/) { > return $1; > } > + > + return; > } > > +our $DISK_NAME_REGEX = qr! > + (? > + ( > + # New convention: 'base-' prefix, 'vol-vm' and 'subvol-ct'. > + (? (?base-)? vol- (? vm|ct)) > + | (? (?base-)? subvol- (? ct)) > + > + # Old convention: "vm" vs "base" and "subvol" vs "basevol" > + | (? vm) `israw` is a weird identifier here. it's also not used anywhere, so maybe we could drop it for now and think of a better name if we ever need it? > + | (? subvol) > + | (? (?base)) > + | (? (?basevol)) the old convention was actually a lot more loose, see below.. we probably should add a warning to pve8to9 for volumes on builtin storage types that don't match this strict scheme at least? > + ) > + - > + (?\d+) > + - > + (?