all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: "Dominic Jäger" <d.jaeger@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH pve-storage 3/3 v2] lvmthin: Match snapshot remove regex to allowed names
Date: Wed, 28 Oct 2020 11:04:54 +0100	[thread overview]
Message-ID: <20201028100454.313122-3-d.jaeger@proxmox.com> (raw)
In-Reply-To: <20201028100454.313122-1-d.jaeger@proxmox.com>

We allow snapshot names that match pve-configid but during qm destroy we have
not removed all snapshots that match pve-configid so far. For example, the name
x-y was allowed but the resulting snap_vm-105-disk-0_x-y was not removed.

Reported-by: Hannes Laimer <h.laimer@proxmox.com>
Signed-off-by: Dominic Jäger <d.jaeger@proxmox.com>
---
Requires the pve-common patches

v1->v2: Use the now public regex instead of the verify function

The "use constant" variant requires a backslash
${\PVE::JSONSchema::CONFIGID_RE} for each usage and the getter/method variant
requires postponed regular subexpressions m/^(??{get_configid_re()})$/), so
"our" looked the most simple to me.

 PVE/Storage/LvmThinPlugin.pm | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/PVE/Storage/LvmThinPlugin.pm b/PVE/Storage/LvmThinPlugin.pm
index d1c5b1f..c9e127c 100644
--- a/PVE/Storage/LvmThinPlugin.pm
+++ b/PVE/Storage/LvmThinPlugin.pm
@@ -117,7 +117,7 @@ sub free_image {
 
 	# remove all volume snapshots first
 	foreach my $lv (keys %$dat) {
-	    next if $lv !~ m/^snap_${volname}_(\w+)$/;
+	    next if $lv !~ m/^snap_${volname}_${PVE::JSONSchema::CONFIGID_RE}$/;
 	    my $cmd = ['/sbin/lvremove', '-f', "$vg/$lv"];
 	    run_command($cmd, errmsg => "lvremove snapshot '$vg/$lv' error");
 	}
-- 
2.20.1




  parent reply	other threads:[~2020-10-28 10:05 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-28 10:04 [pve-devel] [PATCH pve-common 1/3 v2] Add tests for verify_configid Dominic Jäger
2020-10-28 10:04 ` [pve-devel] [PATCH pve-common 2/3 v2] Make configid regex public Dominic Jäger
2020-10-29 18:15   ` [pve-devel] applied: " Thomas Lamprecht
2020-10-28 10:04 ` Dominic Jäger [this message]
2020-11-16 17:26   ` [pve-devel] applied: [PATCH pve-storage 3/3 v2] lvmthin: Match snapshot remove regex to allowed names Thomas Lamprecht
2020-10-29 18:15 ` [pve-devel] applied: [PATCH pve-common 1/3 v2] Add tests for verify_configid Thomas Lamprecht

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=20201028100454.313122-3-d.jaeger@proxmox.com \
    --to=d.jaeger@proxmox.com \
    --cc=pve-devel@lists.proxmox.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal