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 AC1311FF0AA for ; Tue, 22 Sep 2026 14:33:48 +0200 (CEST) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id CE9C3215E2; Tue, 22 Sep 2026 14:33:31 +0200 (CEST) From: Nicolas Frey To: pve-devel@lists.proxmox.com Subject: [PATCH pve-storage 2/2] esxi: guard against zero 'cpuid.coresPerSocket' Date: Tue, 22 Sep 2026 14:33:25 +0200 Message-ID: <20260922123325.498271-3-n.frey@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260922123325.498271-1-n.frey@proxmox.com> References: <20260922123325.498271-1-n.frey@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 1 AWL -0.910 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) KAM_LAZY_DOMAIN_SECURITY 1 Sending domain does not have any anti-forgery methods RDNS_NONE 1.274 Delivered to internal network by a host with no rDNS SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_NONE 0.001 SPF: sender does not publish an SPF Record Message-ID-Hash: P7U6KQAUZKYGGCYFZVXDEAXCNBKGPRQ3 X-Message-ID-Hash: P7U6KQAUZKYGGCYFZVXDEAXCNBKGPRQ3 X-MailFrom: nfrey@miso.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: ESXi sets 'cpuid.coresPerSocket' to 0 when the CPU topology is set to 'Assigned at power on'. cpu_info() divided by it unconditionally, so such a VM aborted the import with "Illegal division by zero". Fall back to one core per socket, matching the default already used for a missing key, and log a warning so the resulting topology can be checked. Signed-off-by: Nicolas Frey --- Notes: The warning could also be emitted in case 'cpuid.coresPerSocket' is not present at all (right above) src/PVE/Storage/ESXiPlugin.pm | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/PVE/Storage/ESXiPlugin.pm b/src/PVE/Storage/ESXiPlugin.pm index 19f23bb..4d27bff 100644 --- a/src/PVE/Storage/ESXiPlugin.pm +++ b/src/PVE/Storage/ESXiPlugin.pm @@ -746,6 +746,8 @@ use strict; use warnings; use feature 'fc'; +use PVE::RESTEnvironment qw(log_warn); + # FIXME: see if vmx files can actually have escape sequences in their quoted values? my sub unquote : prototype($) { my ($value) = @_; @@ -890,6 +892,12 @@ sub cpu_info { my ($self) = @_; my $cps = int($self->{'cpuid.coresPerSocket'} // 1); + # ESXi reports 0 when the CPU topology is 'Assigned at power on'. + if ($cps == 0) { + log_warn("'cpuid.coresPerSocket' is set to 0, assuming 1 core per socket\n"); + $cps = 1; + } + my $max = int($self->{numvcpus} // $cps); return ($cps, ($max / $cps)); -- 2.47.3