mirror of
https://git.proxmox.com/git/pve-guest-common
synced 2025-07-14 02:28:10 +00:00
abstract migrate: code-style cleanup get_bwlimit
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
parent
8d62b1e563
commit
ea022f01c3
@ -345,22 +345,19 @@ sub get_bwlimit {
|
|||||||
my $bwlimit = PVE::Storage::get_bandwidth_limit('migration', $local_sids, $self->{opts}->{bwlimit});
|
my $bwlimit = PVE::Storage::get_bandwidth_limit('migration', $local_sids, $self->{opts}->{bwlimit});
|
||||||
|
|
||||||
if ($self->{opts}->{remote}) {
|
if ($self->{opts}->{remote}) {
|
||||||
my $bwlimit_opts = {
|
my $bwlimit_reply = PVE::Tunnel::write_tunnel($self->{tunnel}, 10, 'bwlimit', {
|
||||||
operation => 'migration',
|
operation => 'migration',
|
||||||
storages => [$target],
|
storages => [$target],
|
||||||
bwlimit => $self->{opts}->{bwlimit},
|
bwlimit => $self->{opts}->{bwlimit},
|
||||||
};
|
});
|
||||||
|
|
||||||
my $bwlimit_reply = PVE::Tunnel::write_tunnel(
|
if ($bwlimit_reply && (my $remote_bwlimit_raw = $bwlimit_reply->{bwlimit})) {
|
||||||
$self->{tunnel}, 10, 'bwlimit', $bwlimit_opts);
|
|
||||||
|
|
||||||
if ($bwlimit_reply && $bwlimit_reply->{bwlimit}) {
|
|
||||||
# untaint
|
# untaint
|
||||||
my ($remote_bwlimit) = ($bwlimit_reply->{bwlimit} =~ m/^(\d+(.\d+)?)$/)
|
my ($remote_bwlimit) = ($remote_bwlimit_raw =~ m/^(\d+(?:.\d+)?)$/)
|
||||||
or die "invalid remote bandwidth limit: '$bwlimit_reply->{bwlimit}'\n";
|
or die "invalid remote bandwidth limit: '$bwlimit_reply->{bwlimit}'\n";
|
||||||
|
|
||||||
$bwlimit = $remote_bwlimit
|
# only allow lowering the effecting bandwidth limit.
|
||||||
if (!$bwlimit || $bwlimit > $remote_bwlimit);
|
$bwlimit = $remote_bwlimit if (!$bwlimit || $bwlimit > $remote_bwlimit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user