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) server-digest SHA256) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 742D0741BC for ; Tue, 1 Jun 2021 08:07:16 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 67FC524DD7 for ; Tue, 1 Jun 2021 08:07:16 +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) server-digest SHA256) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 3F7FA24DC6 for ; Tue, 1 Jun 2021 08:07:15 +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 11E2742ACC for ; Tue, 1 Jun 2021 08:07:15 +0200 (CEST) To: pve-devel@lists.proxmox.com References: <20210531143725.2190-1-f.ebner@proxmox.com> From: Fabian Ebner Message-ID: Date: Tue, 1 Jun 2021 08:07:06 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.0 MIME-Version: 1.0 In-Reply-To: <20210531143725.2190-1-f.ebner@proxmox.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.298 Adjusted score from AWL reputation of From: address KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment NICE_REPLY_A -0.613 Looks like a legit reply (A) 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. [lxc.pm] Subject: Re: [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: Tue, 01 Jun 2021 06:07:16 -0000 Am 31.05.21 um 16:37 schrieb Fabian Ebner: > 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. This is false, I missed where the vmid is assigned... I'll send a v2, sorry for the noise. > > 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; >