[pve-devel] [PATCH container v2 01/11] migration: prepare: factor out common read-only variables

Fiona Ebner f.ebner at proxmox.com
Thu Feb 20 10:20:02 CET 2025


Am 11.02.25 um 17:08 schrieb Daniel Kral:
> Factor out the common read-only variables to allow the second call to
> `storage_check_enabled` to be below 100 characters.
> 

Just wanted to say in general, there is nothing wrong with using
$self->{node} either, especially if it's only used a single time,
because having an additional variable is more overhead then.

Still, can be fine in this case. But there are other usages of
$self->{node} further below in the branch for remote migration. And the
readability there would benefit more noticeably, because the variable is
used inside a string. So I'd rather go all the way, have the $node
variable be defined at the top level and used throughout the function.

> Signed-off-by: Daniel Kral <d.kral at proxmox.com>
> ---
> changes since v1:
> - new!
> 
>  src/PVE/LXC/Migrate.pm | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/src/PVE/LXC/Migrate.pm b/src/PVE/LXC/Migrate.pm
> index e1e6cab..f06a10a 100644
> --- a/src/PVE/LXC/Migrate.pm
> +++ b/src/PVE/LXC/Migrate.pm
> @@ -71,7 +71,8 @@ sub prepare {
>  	die "can't determine assigned storage for mount point '$ms'\n" if !$storage;
>  
>  	# check if storage is available on both nodes
> -	my $scfg = PVE::Storage::storage_check_enabled($self->{storecfg}, $storage);
> +	my ($storecfg, $node) = $self->@{qw(storecfg node)};
> +	my $scfg = PVE::Storage::storage_check_enabled($storecfg, $storage);
>  
>  	my $targetsid = $storage;
>  
> @@ -92,7 +93,7 @@ sub prepare {
>  	}
>  
>  	if (!$remote) {
> -	    my $target_scfg = PVE::Storage::storage_check_enabled($self->{storecfg}, $targetsid, $self->{node});
> +	    my $target_scfg = PVE::Storage::storage_check_enabled($storecfg, $targetsid, $node);
>  
>  	    die "$volid: content type 'rootdir' is not available on storage '$targetsid'\n"
>  		if !$target_scfg->{content}->{rootdir};





More information about the pve-devel mailing list