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

Dominic Jäger d.jaeger at proxmox.com
Tue Oct 27 11:12:07 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>
---
Something like m/^snap_${volname}_${configidre}$/ would maybe be nicer, but I
didn't see how to get that RE from JSONSchema in a shorter way than that single
function call.

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

diff --git a/PVE/Storage/LvmThinPlugin.pm b/PVE/Storage/LvmThinPlugin.pm
index d1c5b1f..4af57be 100644
--- a/PVE/Storage/LvmThinPlugin.pm
+++ b/PVE/Storage/LvmThinPlugin.pm
@@ -117,7 +117,8 @@ 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}_(.+)$/;
+	    next if !PVE::JSONSchema::pve_verify_configid($1, 1);
 	    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