From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [45.144.208.40]) by lore.proxmox.com (Postfix) with ESMTPS id 2B8351FF0EC for ; Sat, 07 Nov 2026 23:11:39 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 34E7821470; Sat, 07 Nov 2026 23:11:37 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1794089485; x=1794694285; darn=lists.proxmox.com; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=RGHgBvZcX3zRBAa/GXH8BRCGDUtcTjG+hzWdRubIVxQ=; b=yqAlN6gYm2V+rEFEBzD5mzMi4QSVqd4A+jiTFD8UwP7UdobOYd31mDgCuGYdpvKn6l 0VoEsiHxziq+dRiOoyHrfHxpM9UfPgXUneDF74Emt8YvWKn9BDCsGv47FrqZVWCWPlUd hoaiM21kB2hRd37i5reUAlQ1zt8pQapk44rXhjEWsxpQSvuIFav780QXKaL7N6O6Kdx7 Wg00qlhmJiCoe9lgKRV3b0XUzqiEcpRf2TabTkhaAXcQxUP4pytX9xqUtaG8YQHWGLLl lBBOdThec2Ku2f9fYfLY0kMsiDC3FMQpbCbc5zUUKn2SFoz6yy9PmayjiMC9YYICdi9K DrbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1794089485; x=1794694285; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to:content-type; bh=RGHgBvZcX3zRBAa/GXH8BRCGDUtcTjG+hzWdRubIVxQ=; b=jvb4jG/Wz5L3c4cbk5Px68fJ1j4vcmwmapBJ3gw+f/5JybcuslrC+t6T8+ILFXOuAj FdbyjVAEnu4Cc+f5KU2AblM9RGNOTVbkmlV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6WGXjjCcec4ab5Oydd9ZaiXAg= X-Received: by 2002:a05:690e:44cd:b0:679:ba28:1263 with SMTP id 956f58d0204a3-67c3da5598dmr44104d50.88.1794089485141; Sat, 07 Nov 2026 14:11:25 -0800 (PST) From: Lucas Barros To: pve-devel@lists.proxmox.com Subject: [PATCH container] fix #8162: status: always return 'cpus' as number Date: Sat, 7 Nov 2026 19:11:20 -0300 Message-ID: <20261107221120.13176-1-lucasbarros.kam@gmail.com> X-Mailer: git-send-email 2.50.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.150 Adjusted score from AWL reputation of From: address DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain DMARC_PASS -0.1 DMARC pass policy FREEMAIL_FROM 0.001 Sender email is commonly abused enduser mail provider RCVD_IN_DNSWL_NONE -0.0001 Sender listed at https://www.dnswl.org/, no 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: M35IMTOIV4SHBRMQH2KTZBFL6MTOZKIH X-Message-ID-Hash: M35IMTOIV4SHBRMQH2KTZBFL6MTOZKIH X-MailFrom: lucasbarros.kam@gmail.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: For containers that only have 'cpulimit' set, the 'cpus' property of the status API endpoints was encoded as a JSON string, for example "cpus":"2", while the API schema declares it as a number. Clients that decode the response strictly by the schema, like the Terraform provider for Proxmox VE, fail to parse it. The config parser keeps values of 'number' typed options like 'cpulimit' as string, while 'integer' options like 'cores' are converted with int(). Explicitly convert the value to a number, so 'cpus' has the same type regardless of which option it comes from. Signed-off-by: Lucas Barros --- Checked the JSON encoding of the resulting value for cpulimit only, fractional cpulimit, cores and neither being set. An alternative would be to return the value as number from the 'number' branch of check_type() in PVE::LXC::Config, which would fix this for every 'number' option at once, but that also changes the value that is used when writing the config, so I went with the narrower fix. This patch was prepared with the help of an LLM based coding assistant; I reviewed the change and ran the tests mentioned above myself. src/PVE/LXC.pm | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/PVE/LXC.pm b/src/PVE/LXC.pm index 59d803d..09fb00a 100644 --- a/src/PVE/LXC.pm +++ b/src/PVE/LXC.pm @@ -290,8 +290,9 @@ sub vmstatus { $d->{name} = $conf->{'hostname'} || "CT$vmid"; $d->{name} =~ s/[\s]//g; - $d->{cpus} = $conf->{cores} || $conf->{cpulimit}; - $d->{cpus} = $cpucount if !$d->{cpus}; + # cpulimit is a fractional value kept as string by the config parser, so + # convert it explicitly to have 'cpus' encoded as a JSON number + $d->{cpus} = ($conf->{cores} || $conf->{cpulimit} || $cpucount) + 0; $d->{tags} = $conf->{tags} if defined($conf->{tags}); -- 2.50.1 (Apple Git-155)