From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 026526A8F7 for ; Mon, 15 Mar 2021 12:58:04 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id E7A73206D1 for ; Mon, 15 Mar 2021 12:57:33 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [212.186.127.180]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 16558206BA for ; Mon, 15 Mar 2021 12:57:33 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 9FD9E45433 for ; Mon, 15 Mar 2021 12:57:32 +0100 (CET) From: Fabian Ebner To: pve-devel@lists.proxmox.com Date: Mon, 15 Mar 2021 12:57:27 +0100 Message-Id: <20210315115729.24381-1-f.ebner@proxmox.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.003 Adjusted score from AWL reputation of From: address KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pve-devel] [PATCH qemu-server 1/3] restore vma: fix applying storage-specific bandwidth limit X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 15 Mar 2021 11:58:04 -0000 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 --- PVE/QemuServer.pm | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm index 57cfe62..15100ed 100644 --- a/PVE/QemuServer.pm +++ b/PVE/QemuServer.pm @@ -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) { -- 2.20.1