[pve-devel] [PATCH pve-storage 3/3 v2] lvmthin: Match snapshot remove regex to allowed names

Dominic Jäger d.jaeger at proxmox.com
Wed Oct 28 11:04:54 CET 2020


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 at proxmox.com>
Signed-off-by: Dominic Jäger <d.jaeger at 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





More information about the pve-devel mailing list