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 E5E936C2ED for ; Fri, 29 Jan 2021 16:11:49 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id E381C11248 for ; Fri, 29 Jan 2021 16:11:49 +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 998381120A for ; Fri, 29 Jan 2021 16:11:47 +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 6623843B65 for ; Fri, 29 Jan 2021 16:11:47 +0100 (CET) From: Fabian Ebner To: pve-devel@lists.proxmox.com Date: Fri, 29 Jan 2021 16:11:35 +0100 Message-Id: <20210129151143.10014-6-f.ebner@proxmox.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210129151143.10014-1-f.ebner@proxmox.com> References: <20210129151143.10014-1-f.ebner@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.004 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 URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [qemumigrate.pm] Subject: [pve-devel] [PATCH v2 qemu-server 05/13] migration: fix calculation of bandwith limit for non-disk migration 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: Fri, 29 Jan 2021 15:11:49 -0000 The case with: 1. no generic 'migration' limit from the storage plugin 2. a migrate_speed limit in the VM config was broken. It would assign 0 to migrate_speed when picking the minimum value and then default to the default value. Fix it by checking if bwlimit is 0 before picking the minimum. Also, make it a bit more readable by avoiding the trick of //-assigning bwlimit before the units match up and relying on getting back the original bwlimit value as the minimum. Instead, only ||-assign after the units match up and don't rely on other things. Signed-off-by: Fabian Ebner --- New in v2 PVE/QemuMigrate.pm | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/PVE/QemuMigrate.pm b/PVE/QemuMigrate.pm index 455581c..0522208 100644 --- a/PVE/QemuMigrate.pm +++ b/PVE/QemuMigrate.pm @@ -961,11 +961,15 @@ sub phase2 { # migrate speed can be set via bwlimit (datacenter.cfg and API) and via the # migrate_speed parameter in qm.conf - take the lower of the two. my $bwlimit = PVE::Storage::get_bandwidth_limit('migration', undef, $opt_bwlimit) // 0; - my $migrate_speed = $conf->{migrate_speed} // $bwlimit; + my $migrate_speed = $conf->{migrate_speed} // 0; # migrate_speed is in MB/s, bwlimit in KB/s $migrate_speed *= 1024; - $migrate_speed = ($bwlimit < $migrate_speed) ? $bwlimit : $migrate_speed; + if ($bwlimit && $migrate_speed) { + $migrate_speed = ($bwlimit < $migrate_speed) ? $bwlimit : $migrate_speed; + } else { + $migrate_speed ||= $bwlimit; + } # always set migrate speed (overwrite kvm default of 32m) we set a very high # default of 8192m which is basically unlimited -- 2.20.1