vm status: force int where appropriate

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 <f.ebner@proxmox.com>
This commit is contained in:
Fabian Ebner 2021-06-01 08:43:06 +02:00 committed by Thomas Lamprecht
parent ef88eaaa58
commit ad2cad72be

View File

@ -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});
}
}