From: Alexandre Derumier via pve-devel <pve-devel@lists.proxmox.com>
To: pve-devel@lists.proxmox.com
Cc: Alexandre Derumier <alexandre.derumier@groupe-cyllene.com>
Subject: [pve-devel] [PATCH FOLLOW-UP storage 08/10] plugin: lvmplugin: add parse_snap_name
Date: Tue, 15 Jul 2025 07:26:41 +0200 [thread overview]
Message-ID: <mailman.1380.1752557217.395.pve-devel@lists.proxmox.com> (raw)
In-Reply-To: <20250715052643.1182073-1-alexandre.derumier@groupe-cyllene.com>
[-- Attachment #1: Type: message/rfc822, Size: 4948 bytes --]
From: Alexandre Derumier <alexandre.derumier@groupe-cyllene.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH FOLLOW-UP storage 08/10] plugin: lvmplugin: add parse_snap_name
Date: Tue, 15 Jul 2025 07:26:41 +0200
Message-ID: <20250715052643.1182073-8-alexandre.derumier@groupe-cyllene.com>
Signed-off-by: Alexandre Derumier <alexandre.derumier@groupe-cyllene.com>
---
src/PVE/Storage/LVMPlugin.pm | 17 ++++++++++++-----
src/PVE/Storage/Plugin.pm | 17 +++++++++++++----
2 files changed, 25 insertions(+), 9 deletions(-)
diff --git a/src/PVE/Storage/LVMPlugin.pm b/src/PVE/Storage/LVMPlugin.pm
index 0e2c38c..6e77eb3 100644
--- a/src/PVE/Storage/LVMPlugin.pm
+++ b/src/PVE/Storage/LVMPlugin.pm
@@ -458,6 +458,14 @@ my sub get_snap_name {
}
}
+my sub parse_snap_name {
+ my ($name) = @_;
+
+ if ($name =~ m/^snap_\S+_(.*)\.qcow2$/) {
+ return $1;
+ }
+}
+
sub filesystem_path {
my ($class, $scfg, $volname, $snapname) = @_;
@@ -773,11 +781,10 @@ sub volume_snapshot_info {
my $get_snapname_from_path = sub {
my ($volname, $path) = @_;
- my $basepath = basename($path);
- my $name = ($volname =~ s/\.[^.]+$//r);
- if ($basepath =~ m/^snap_${name}_(.*)\.qcow2$/) {
- return $1;
- } elsif ($basepath eq $volname) {
+ my $name = basename($path);
+ if (my $snapname = parse_snap_name($name)) {
+ return $snapname;
+ } elsif ($name eq $volname) {
return 'current';
}
return undef;
diff --git a/src/PVE/Storage/Plugin.pm b/src/PVE/Storage/Plugin.pm
index aafb13c..59ffa5e 100644
--- a/src/PVE/Storage/Plugin.pm
+++ b/src/PVE/Storage/Plugin.pm
@@ -779,6 +779,14 @@ my sub get_snap_name {
return $name;
}
+my sub parse_snap_name {
+ my ($name) = @_;
+
+ if ($name =~ m/^snap-(.*)-vm(.*)$/) {
+ return $1;
+ }
+}
+
sub filesystem_path {
my ($class, $scfg, $volname, $snapname) = @_;
@@ -1728,10 +1736,11 @@ sub volume_snapshot_info {
my $get_snapname_from_path = sub {
my ($volname, $path) = @_;
- my $basepath = basename($path);
- if ($basepath =~ m/^snap-(.*)-vm(.*)$/) {
- return $1;
- } elsif ($basepath eq basename($volname)) {
+ my $name = basename($path);
+
+ if (my $snapname = parse_snap_name($name)) {
+ return $snapname;
+ } elsif ($name eq basename($volname)) {
return 'current';
}
return undef;
--
2.39.5
[-- Attachment #2: Type: text/plain, Size: 160 bytes --]
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
next prev parent reply other threads:[~2025-07-15 5:26 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20250715052643.1182073-1-alexandre.derumier@groupe-cyllene.com>
2025-07-15 5:26 ` [pve-devel] [PATCH FOLLOW-UP storage 02/10] common: fix qemu_img_resize Alexandre Derumier via pve-devel
2025-07-15 5:26 ` [pve-devel] [PATCH FOLLOW-UP storage 03/10] plugin: volume_export: don't allow export of external snapshots Alexandre Derumier via pve-devel
2025-07-15 5:26 ` [pve-devel] [PATCH FOLLOW-UP storage 04/10] lvmplugin: alloc_snap_image: die if file_size_info return empty size Alexandre Derumier via pve-devel
2025-07-15 5:26 ` [pve-devel] [PATCH FOLLOW-UP storage 05/10] lvmplugin: snapshot: use relative path for backing image Alexandre Derumier via pve-devel
2025-07-15 5:26 ` [pve-devel] [PATCH FOLLOW-UP storage 06/10] plugin|lvmplugin: don't allow volume rename if external snapshots exist Alexandre Derumier via pve-devel
2025-07-15 5:26 ` [pve-devel] [PATCH FOLLOW-UP storage 07/10] lvmplugin: add volume_snapshot_info Alexandre Derumier via pve-devel
2025-07-15 5:26 ` Alexandre Derumier via pve-devel [this message]
2025-07-15 5:26 ` [pve-devel] [PATCH FOLLOW-UP storage 09/10] plugin : improve parse_namedir warning Alexandre Derumier via pve-devel
2025-07-15 5:26 ` [pve-devel] [PATCH FOLLOW-UP storage 10/10] lvmplugin: add external-snapshots option && forbid creation of qcow2 volumes without it Alexandre Derumier via pve-devel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=mailman.1380.1752557217.395.pve-devel@lists.proxmox.com \
--to=pve-devel@lists.proxmox.com \
--cc=alexandre.derumier@groupe-cyllene.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox