From ea022f01c331e37296847bcd24cbf794e8f0837f Mon Sep 17 00:00:00 2001 From: Thomas Lamprecht Date: Mon, 10 Feb 2025 16:48:36 +0100 Subject: [PATCH] abstract migrate: code-style cleanup get_bwlimit Signed-off-by: Thomas Lamprecht --- src/PVE/AbstractMigrate.pm | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/PVE/AbstractMigrate.pm b/src/PVE/AbstractMigrate.pm index 54f7956..a2a47bf 100644 --- a/src/PVE/AbstractMigrate.pm +++ b/src/PVE/AbstractMigrate.pm @@ -345,22 +345,19 @@ sub get_bwlimit { my $bwlimit = PVE::Storage::get_bandwidth_limit('migration', $local_sids, $self->{opts}->{bwlimit}); if ($self->{opts}->{remote}) { - my $bwlimit_opts = { + my $bwlimit_reply = PVE::Tunnel::write_tunnel($self->{tunnel}, 10, 'bwlimit', { operation => 'migration', storages => [$target], bwlimit => $self->{opts}->{bwlimit}, - }; + }); - my $bwlimit_reply = PVE::Tunnel::write_tunnel( - $self->{tunnel}, 10, 'bwlimit', $bwlimit_opts); - - if ($bwlimit_reply && $bwlimit_reply->{bwlimit}) { + if ($bwlimit_reply && (my $remote_bwlimit_raw = $bwlimit_reply->{bwlimit})) { # 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"; - $bwlimit = $remote_bwlimit - if (!$bwlimit || $bwlimit > $remote_bwlimit); + # only allow lowering the effecting bandwidth limit. + $bwlimit = $remote_bwlimit if (!$bwlimit || $bwlimit > $remote_bwlimit); } }