From: Fabian Ebner <f.ebner@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: Re: [pve-devel] [PATCH container] vm status: force int where appropriate
Date: Tue, 1 Jun 2021 08:07:06 +0200 [thread overview]
Message-ID: <c640d1b6-824d-de4b-4427-653e52094587@proxmox.com> (raw)
In-Reply-To: <20210531143725.2190-1-f.ebner@proxmox.com>
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 <f.ebner@proxmox.com>
> ---
> 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;
>
prev parent reply other threads:[~2021-06-01 6:07 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-31 14:37 Fabian Ebner
2021-05-31 14:37 ` [pve-devel] [PATCH qemu-server] " Fabian Ebner
2021-06-01 6:07 ` Fabian Ebner [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=c640d1b6-824d-de4b-4427-653e52094587@proxmox.com \
--to=f.ebner@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