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 986587058C for ; Tue, 21 Jun 2022 17:21:29 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 8EED47238 for ; Tue, 21 Jun 2022 17:20:59 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (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 384D47220 for ; Tue, 21 Jun 2022 17:20:56 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 0E7CA43C40 for ; Tue, 21 Jun 2022 17:20:56 +0200 (CEST) From: Daniel Tschlatscher To: pve-devel@lists.proxmox.com Date: Tue, 21 Jun 2022 17:20:24 +0200 Message-Id: <20220621152026.496514-1-d.tschlatscher@proxmox.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.112 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record T_SCC_BODY_TEXT_LINE -0.01 - URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [qemu.pm, helpers.pm, qemuserver.pm] Subject: [pve-devel] [PATCH qemu-server 1/2] fix #3502: VM start timeout config parameter 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: Tue, 21 Jun 2022 15:21:29 -0000 It was already possible to set the timeout parameter for the VM config via the API. However, the value was not considered when the function config_aware_timeout() was called. Now, if the timeout parameter is set, it will override the heuristic calculation of the VM start timeout. During testing I found a problem where really big values (10^20)+ would be converted to scientific notation, which means they no longer pass the integer type check. To get around this, I set the maximum value for the timeout to 2,680,000 seconds, which is around 31 days. This I'd wager, is an upper limit in which nobody should realistically run into. Signed-off-by: Daniel Tschlatscher --- PVE/API2/Qemu.pm | 1 + PVE/QemuServer.pm | 7 +++++++ PVE/QemuServer/Helpers.pm | 3 +++ 3 files changed, 11 insertions(+) diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm index a824657..d0a4eaa 100644 --- a/PVE/API2/Qemu.pm +++ b/PVE/API2/Qemu.pm @@ -2494,6 +2494,7 @@ __PACKAGE__->register_method({ description => "Wait maximal timeout seconds.", type => 'integer', minimum => 0, + maximum => 2680000, default => 'max(30, vm memory in GiB)', optional => 1, }, diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm index e9aa248..81a7f6d 100644 --- a/PVE/QemuServer.pm +++ b/PVE/QemuServer.pm @@ -713,6 +713,13 @@ EODESCR description => "Some (read-only) meta-information about this guest.", optional => 1, }, + timeout => { + optional => 1, + type => 'integer', + description => 'The maximum timeout to wait for a VM to start', + minimum => 0, + maximum => 2680000, + } }; my $cicustom_fmt = { diff --git a/PVE/QemuServer/Helpers.pm b/PVE/QemuServer/Helpers.pm index c10d842..c26d0dc 100644 --- a/PVE/QemuServer/Helpers.pm +++ b/PVE/QemuServer/Helpers.pm @@ -142,6 +142,9 @@ sub version_cmp { sub config_aware_timeout { my ($config, $is_suspended) = @_; + + return $config->{timeout} if defined($config->{timeout}); + my $memory = $config->{memory}; my $timeout = 30; -- 2.30.2