From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [IPv6:2a0f:8001:1:32::40]) by lore.proxmox.com (Postfix) with ESMTPS id DADC91FF0B2 for ; Thu, 20 Aug 2026 11:06:17 +0200 (CEST) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 8A00221601; Thu, 20 Aug 2026 11:05:55 +0200 (CEST) From: Christian Ebner To: pve-devel@lists.proxmox.com Subject: [PATCH v3 qemu-server 2/6] helpers: never cache `unknown` on failed kvm binary version check Date: Thu, 20 Aug 2026 11:05:24 +0200 Message-ID: <20260820090528.117853-3-c.ebner@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260820090528.117853-1-c.ebner@proxmox.com> References: <20260820090528.117853-1-c.ebner@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1787216718229 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.779 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) 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 Message-ID-Hash: 2423GS2BMPJTAKLTEGPKZKNULCQFZ53Y X-Message-ID-Hash: 2423GS2BMPJTAKLTEGPKZKNULCQFZ53Y X-MailFrom: c.ebner@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Rather than init and cache the version as `unknown` in case the version check fails, which it would remain until the modified timestamp of the binary changes, only return unknown for this call and allow to reattempt. While at it, improve code by explicitley checking for the hash value being defined. Signed-off-by: Christian Ebner --- changes since version 2: - new in this version src/PVE/QemuServer/Helpers.pm | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/PVE/QemuServer/Helpers.pm b/src/PVE/QemuServer/Helpers.pm index dd17eef5..ebb1a874 100644 --- a/src/PVE/QemuServer/Helpers.pm +++ b/src/PVE/QemuServer/Helpers.pm @@ -60,10 +60,9 @@ sub kvm_user_version { my $cachedmtime = $kvm_mtime->{$binary} // -1; return $kvm_user_version->{$binary} - if $kvm_user_version->{$binary} + if defined($kvm_user_version->{$binary}) && $cachedmtime == $st->mtime; - $kvm_user_version->{$binary} = 'unknown'; $kvm_mtime->{$binary} = $st->mtime; my $code = sub { @@ -76,7 +75,7 @@ sub kvm_user_version { eval { PVE::Tools::run_command([$binary, '--version'], outfunc => $code); }; warn $@ if $@; - return $kvm_user_version->{$binary}; + return defined($kvm_user_version->{$binary}) ? $kvm_user_version->{$binary} : 'unknown'; } # Paths and directories -- 2.47.3