[pve-devel] [PATCH v4 pve-storage 5/5] lvm: add lvremove helper

Fabian Grünbichler f.gruenbichler at proxmox.com
Tue Apr 1 15:50:49 CEST 2025


> Alexandre Derumier via pve-devel <pve-devel at lists.proxmox.com> hat am 11.03.2025 11:28 CET geschrieben:
> 
>  
> _______________________________________________
> pve-devel mailing list
> pve-devel at lists.proxmox.com
> https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
> Signed-off-by: Alexandre Derumier <alexandre.derumier at groupe-cyllene.com>
> ---
>  src/PVE/Storage/LVMPlugin.pm | 15 ++++++++++-----
>  1 file changed, 10 insertions(+), 5 deletions(-)
> 
> diff --git a/src/PVE/Storage/LVMPlugin.pm b/src/PVE/Storage/LVMPlugin.pm
> index 2431fcd..ab3563b 100644
> --- a/src/PVE/Storage/LVMPlugin.pm
> +++ b/src/PVE/Storage/LVMPlugin.pm
> @@ -373,6 +373,14 @@ sub lvrename {
>      );
>  }
>  
> +sub lvremove {
> +   my ($name, $vg) = @_;
> +
> +   my $path = $vg ? "$vg/$name" : $name;

why? it's only called twice below and both have a volume group set?

the call in qemu-server is forbidden - you must never call directly into plugin code like that..

> +   my $cmd = ['/sbin/lvremove', '-f', $path];
> +   run_command($cmd, errmsg => "lvremove '$path' error");
> +}
> +
>  sub alloc_image {
>      my ($class, $storeid, $scfg, $vmid, $fmt, $name, $size, $backing) = @_;
>  
> @@ -453,8 +461,7 @@ sub free_image {
>  	warn $@ if $@;
>  
>  	$class->cluster_lock_storage($storeid, $scfg->{shared}, undef, sub {
> -	    my $cmd = ['/sbin/lvremove', '-f', "$vg/del-$volname"];
> -	    run_command($cmd, errmsg => "lvremove '$vg/del-$volname' error");
> +	    lvremove("del-$volname", $vg);
>  	});
>  	print "successfully removed volume $volname ($vg/del-$volname)\n";
>      };
> @@ -470,9 +477,7 @@ sub free_image {
>  	run_command($cmd, errmsg => "lvrename '$vg/$volname' error");
>  	return $zero_out_worker;
>      } else {
> -	my $tmpvg = $scfg->{vgname};
> -	$cmd = ['/sbin/lvremove', '-f', "$tmpvg/$volname"];
> -	run_command($cmd, errmsg => "lvremove '$tmpvg/$volname' error");
> +	lvremove($volname, $scfg->{vgname});
>      }
>  
>      return undef;
> -- 
> 2.39.5




More information about the pve-devel mailing list