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 88388741CD for ; Tue, 1 Jun 2021 08:43:10 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 75C3F25654 for ; Tue, 1 Jun 2021 08:43:10 +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 C0F1F25643 for ; Tue, 1 Jun 2021 08:43:09 +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 686DF4353B for ; Tue, 1 Jun 2021 08:43:09 +0200 (CEST) From: Fabian Ebner To: pve-devel@lists.proxmox.com Date: Tue, 1 Jun 2021 08:43:06 +0200 Message-Id: <20210601064306.13507-2-f.ebner@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210601064306.13507-1-f.ebner@proxmox.com> References: <20210601064306.13507-1-f.ebner@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.011 Adjusted score from AWL reputation of From: address 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 URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [qemuserver.pm] Subject: [pve-devel] [PATCH v2 qemu-server] vm status: force int where appropriate 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, 01 Jun 2021 06:43:10 -0000 to avoid potential problems with stringified numbers in Javascript and elsewehere. The vmid was not always an integer as the return schema expects, namely when there was an opt_vmid argument, because the 'ne' comparision coerced the vmid to be a string then. Signed-off-by: Fabian Ebner --- Changes from v1: * also make vmid an integer. PVE/QemuServer.pm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm index 25ac052..830a6e4 100644 --- a/PVE/QemuServer.pm +++ b/PVE/QemuServer.pm @@ -2651,8 +2651,8 @@ sub vmstatus { my $conf = PVE::QemuConfig->load_config($vmid); - my $d = { vmid => $vmid }; - $d->{pid} = $list->{$vmid}->{pid}; + my $d = { vmid => int($vmid) }; + $d->{pid} = int($list->{$vmid}->{pid}); # fixme: better status? $d->{status} = $list->{$vmid}->{pid} ? 'running' : 'stopped'; @@ -2711,8 +2711,8 @@ sub vmstatus { $d->{netin} += $netdev->{$dev}->{transmit}; if ($full) { - $d->{nics}->{$dev}->{netout} = $netdev->{$dev}->{receive}; - $d->{nics}->{$dev}->{netin} = $netdev->{$dev}->{transmit}; + $d->{nics}->{$dev}->{netout} = int($netdev->{$dev}->{receive}); + $d->{nics}->{$dev}->{netin} = int($netdev->{$dev}->{transmit}); } } -- 2.30.2