]> git.proxmox.com Git - qemu-server.git/commitdiff
restore vma: fix applying storage-specific bandwidth limit
authorFabian Ebner <f.ebner@proxmox.com>
Mon, 15 Mar 2021 11:57:27 +0000 (12:57 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Mon, 15 Mar 2021 12:22:58 +0000 (13:22 +0100)
At this stage, there are no keys in %storage_limits to iterate over. The
refactoring in commit 9f3d73bc353c79f84498122b779764184f504005 broke the logic
by accident.

Also explicitly set zero if there is no limit to avoid repeating the
get_bandwith_limit call for the same storage. When accessing the value later,
zero is already correctly handled as 'no limit'.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
PVE/QemuServer.pm

index 57cfe627eb24e74db75d5c2b0de3b0e2722cdd50..15100ed40e18400620839902c434ca930e671619 100644 (file)
@@ -6400,11 +6400,13 @@ sub restore_vma_archive {
 
        my $virtdev_hash = $parse_backup_hints->($rpcenv, $user, $cfg, $fh, $devinfo, $opts);
 
-       foreach my $key (keys %storage_limits) {
-           my $limit = PVE::Storage::get_bandwidth_limit('restore', [$key], $bwlimit);
-           next if !$limit;
-           print STDERR "rate limit for storage $key: $limit KiB/s\n";
-           $storage_limits{$key} = $limit * 1024;
+       foreach my $info (values %{$virtdev_hash}) {
+           my $storeid = $info->{storeid};
+           next if defined($storage_limits{$storeid});
+
+           my $limit = PVE::Storage::get_bandwidth_limit('restore', [$storeid], $bwlimit) // 0;
+           print STDERR "rate limit for storage $storeid: $limit KiB/s\n" if $limit;
+           $storage_limits{$storeid} = $limit * 1024;
        }
 
        foreach my $devname (keys %$devinfo) {