[pve-devel] applied: [PATCH container] move_volume: call deactivate volume for the old volid in any case

Wolfgang Bumiller w.bumiller at proxmox.com
Tue Jun 14 11:43:56 CEST 2022


applied, thanks

On Wed, May 04, 2022 at 10:15:02AM +0200, Dominik Csapak wrote:
> not only when we want to remove it. Otherwise, if the old volume is
> mapped (e.g. ceph krbd), we don't unmap it when we're finished.
> 
> We have to save if we deactivated successfully before attempting to
> remove it. If it was not removed (either because we could not
> deactivate, or the remove failed), we add it back as unused.
> 
> Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
> ---
>  src/PVE/API2/LXC.pm | 22 ++++++++++++++++------
>  1 file changed, 16 insertions(+), 6 deletions(-)
> 
> diff --git a/src/PVE/API2/LXC.pm b/src/PVE/API2/LXC.pm
> index 64724cb..e909cb0 100644
> --- a/src/PVE/API2/LXC.pm
> +++ b/src/PVE/API2/LXC.pm
> @@ -2043,13 +2043,23 @@ __PACKAGE__->register_method({
>  		    die $err;
>  		}
>  
> +		my $deactivated = 0;
> +		eval {
> +		    PVE::Storage::deactivate_volumes($storage_cfg, [ $old_volid ]);
> +		    $deactivated = 1;
> +		};
> +		warn $@ if $@;
> +
>  		if ($param->{delete}) {
> -		    eval {
> -			PVE::Storage::deactivate_volumes($storage_cfg, [ $old_volid ]);
> -			PVE::Storage::vdisk_free($storage_cfg, $old_volid);
> -		    };
> -		    if (my $err = $@) {
> -			warn $err;
> +		    my $removed = 0;
> +		    if ($deactivated) {
> +			eval {
> +			    PVE::Storage::vdisk_free($storage_cfg, $old_volid);
> +			    $removed = 1;
> +			};
> +			warn $@ if $@;
> +		    }
> +		    if (!$removed) {
>  			PVE::LXC::Config->lock_config($vmid, sub {
>  			    my $conf = PVE::LXC::Config->load_config($vmid);
>  			    PVE::LXC::Config->add_unused_volume($conf, $old_volid);
> -- 
> 2.30.2




More information about the pve-devel mailing list