Am 03.02.22 um 13:41 schrieb Fabian Grünbichler:
> @@ -251,22 +311,30 @@ sub scan_local_volumes {
>           next if @{$dl->{$storeid}} == 0;
>  
>           my $targetsid = 
> PVE::QemuServer::map_id($self->{opts}->{storagemap}, $storeid);
> -         # check if storage is available on target node
> -         my $target_scfg = PVE::Storage::storage_check_enabled(
> -             $storecfg,
> -             $targetsid,
> -             $self->{node},
> -         );
> -
> -         die "content type 'images' is not available on storage 
> '$targetsid'\n"
> -             if !$target_scfg->{content}->{images};
> +         my $remote_bwlimit;

Nit: unused variable

> +         my $bwlimit_sids = [$storeid];
> +         if (!$self->{opts}->{remote}) {
> +             # check if storage is available on target node
> +             my $target_scfg = PVE::Storage::storage_check_enabled(
> +                 $storecfg,
> +                 $targetsid,
> +                 $self->{node},
> +             );
> +
> +             die "content type 'images' is not available on storage 
> '$targetsid'\n"
> +                 if !$target_scfg->{content}->{images};
> +
> +             push @$bwlimit_sids, $targetsid;
> +         }
>  
>           my $bwlimit = PVE::Storage::get_bandwidth_limit(
>               'migration',
> -             [$targetsid, $storeid],
> +             $bwlimit_sids,
>               $self->{opts}->{bwlimit},
>           );
>  
> +         $bwlimit = $self->merge_bwlimits($bwlimit, [$targetsid]);
> +
>

----8<----

>  
> +# merges local limit '$bwlimit' and a possible remote limit
> +sub merge_bwlimits {
> +    my ($self, $bwlimit, $storages) = @_;
> +

Since both callers of this call PVE::Storage::get_bandwith_limit() right
before, it could be moved in here, and $bwlimit dropped from our parameters?

> +    if ($self->{opts}->{remote}) {
> +     # get remote bwlimit
> +     my $bwlimit_opts = {
> +         operation => 'migration',
> +         storages => $storages,
> +         bwlimit => $self->{opts}->{bwlimit},

I was confused for a bit here why it's not $bwlimit, but of course we
want to re-do the (admittedly edge-case heavy) calculation on the remote
side. Might be worth a comment, but no big deal.

> +     };
> +     my $remote_bwlimit = PVE::Tunnel::write_tunnel($self->{tunnel}, 10, 
> 'bwlimit', $bwlimit_opts);
> +     if ($remote_bwlimit && $remote_bwlimit->{bwlimit}) {
> +         $remote_bwlimit = $remote_bwlimit->{bwlimit};
> +
> +         $bwlimit = $remote_bwlimit
> +             if (!$bwlimit || $bwlimit > $remote_bwlimit);

Style nit: unnecessary parentheses

> +     }
> +    }
> +
> +    return $bwlimit;
> +}
> +
>  1;


_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to