From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id DB5B41FF16B for ; Tue, 29 Jul 2025 13:16:14 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 87619E8CD; Tue, 29 Jul 2025 13:16:34 +0200 (CEST) From: Wolfgang Bumiller To: pve-devel@lists.proxmox.com Date: Tue, 29 Jul 2025 13:15:23 +0200 Message-ID: <20250729111557.136012-11-w.bumiller@proxmox.com> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250729111557.136012-1-w.bumiller@proxmox.com> References: <20250729111557.136012-1-w.bumiller@proxmox.com> MIME-Version: 1.0 X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1753787749376 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.077 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: [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" - 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. 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) + | (? subvol) + | (? (?base)) + | (? (?basevol)) + ) + - + (?\d+) + - + (?