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 DCDF7740AB for ; Mon, 31 May 2021 16:37:30 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id D151820E92 for ; Mon, 31 May 2021 16:37:30 +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 37A8620E84 for ; Mon, 31 May 2021 16:37:30 +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 06C1542B84 for ; Mon, 31 May 2021 16:37:30 +0200 (CEST) From: Fabian Ebner To: pve-devel@lists.proxmox.com Date: Mon, 31 May 2021 16:37:24 +0200 Message-Id: <20210531143725.2190-1-f.ebner@proxmox.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.008 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 Subject: [pve-devel] [PATCH container] 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: Mon, 31 May 2021 14:37:30 -0000 In the case of a running container with cgroupv2, swap would be a string, causing a size.toFixed is not a function error for the format_size call in the containers's "Summary" page in the UI. The 'vmid' is still a string, because the property is injected via the 'links' property in the return type schema. Signed-off-by: Fabian Ebner --- src/PVE/LXC.pm | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/PVE/LXC.pm b/src/PVE/LXC.pm index bb1cbdb..1ec4818 100644 --- a/src/PVE/LXC.pm +++ b/src/PVE/LXC.pm @@ -187,7 +187,7 @@ sub vmstatus { foreach my $vmid (keys %$list) { my $d = $list->{$vmid}; - eval { $d->{pid} = find_lxc_pid($vmid) if defined($active_hash->{$vmid}); }; + eval { $d->{pid} = int(find_lxc_pid($vmid)) if defined($active_hash->{$vmid}); }; warn $@ if $@; # ignore errors (consider them stopped) $d->{status} = $active_hash->{$vmid} ? 'running' : 'stopped'; @@ -207,8 +207,8 @@ sub vmstatus { if ($d->{pid}) { my $res = get_container_disk_usage($vmid, $d->{pid}); - $d->{disk} = $res->{used}; - $d->{maxdisk} = $res->{total}; + $d->{disk} = int($res->{used}); + $d->{maxdisk} = int($res->{total}); } else { $d->{disk} = 0; # use 4GB by default ?? @@ -252,16 +252,16 @@ sub vmstatus { my $cgroups = PVE::LXC::CGroup->new($vmid); if (defined(my $mem = $cgroups->get_memory_stat())) { - $d->{mem} = $mem->{mem}; - $d->{swap} = $mem->{swap}; + $d->{mem} = int($mem->{mem}); + $d->{swap} = int($mem->{swap}); } else { $d->{mem} = 0; $d->{swap} = 0; } if (defined(my $blkio = $cgroups->get_io_stats())) { - $d->{diskread} = $blkio->{diskread}; - $d->{diskwrite} = $blkio->{diskwrite}; + $d->{diskread} = int($blkio->{diskread}); + $d->{diskwrite} = int($blkio->{diskwrite}); } else { $d->{diskread} = 0; $d->{diskwrite} = 0; -- 2.30.2