public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] [PATCH storage] lvmthin: Match snapshot remove regex to allowed names
@ 2020-10-27 10:12 Dominic Jäger
  2020-10-27 12:18 ` Thomas Lamprecht
  0 siblings, 1 reply; 2+ messages in thread
From: Dominic Jäger @ 2020-10-27 10:12 UTC (permalink / raw)
  To: pve-devel

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>
---
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




^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [pve-devel] [PATCH storage] lvmthin: Match snapshot remove regex to allowed names
  2020-10-27 10:12 [pve-devel] [PATCH storage] lvmthin: Match snapshot remove regex to allowed names Dominic Jäger
@ 2020-10-27 12:18 ` Thomas Lamprecht
  0 siblings, 0 replies; 2+ messages in thread
From: Thomas Lamprecht @ 2020-10-27 12:18 UTC (permalink / raw)
  To: Proxmox VE development discussion, Dominic Jäger

On 27.10.20 11:12, Dominic Jäger wrote:
> 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>
> ---
> 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.
> 

hmm, I'd either:

* move that regex to an `our $PROXMOX_CONFID_RE = ...` variable (or a method which
  returns it

* copy over that regex to here, could be just fine here

but I'd like to avoid using a capture group just to pass it a method which then
regex checks it again.

>  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");
>  	}
> 






^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-10-27 12:18 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-27 10:12 [pve-devel] [PATCH storage] lvmthin: Match snapshot remove regex to allowed names Dominic Jäger
2020-10-27 12:18 ` Thomas Lamprecht

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal