[pve-devel] [PATCH qemu-server] vm status: force int where appropriate

Fabian Ebner f.ebner at proxmox.com
Mon May 31 16:37:25 CEST 2021


to avoid potential problems with stringified numbers in Javascript and
elsewehere.

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 <f.ebner at proxmox.com>
---
 PVE/QemuServer.pm | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 25ac052..2cad00b 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -2652,7 +2652,7 @@ sub vmstatus {
 	my $conf = PVE::QemuConfig->load_config($vmid);
 
 	my $d = { vmid => $vmid };
-	$d->{pid} = $list->{$vmid}->{pid};
+	$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






More information about the pve-devel mailing list