From: Nicolas Frey <n.frey@proxmox.com>
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 [thread overview]
Message-ID: <20260922123325.498271-3-n.frey@proxmox.com> (raw)
In-Reply-To: <20260922123325.498271-1-n.frey@proxmox.com>
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 <n.frey@proxmox.com>
---
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
prev parent reply other threads:[~2026-09-22 12:33 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-22 12:33 [PATCH manager/storage 0/2] fix #6202: warn if sockets exceed target node Nicolas Frey
2026-09-22 12:33 ` [PATCH pve-manager 1/2] fix #6202: ui: guest import: " Nicolas Frey
2026-09-22 12:33 ` Nicolas Frey [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260922123325.498271-3-n.frey@proxmox.com \
--to=n.frey@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox