]> git.proxmox.com Git - qemu-server.git/commitdiff
vm status: force int where appropriate
authorFabian Ebner <f.ebner@proxmox.com>
Tue, 1 Jun 2021 06:43:06 +0000 (08:43 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 17 Jun 2021 12:47:35 +0000 (14:47 +0200)
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>
PVE/QemuServer.pm

index f435cc121e2a04388150b68e828e14ba83254b6a..6d9cf2d159519dd6de84e02a3ed125352ce78f72 100644 (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});
        }
 
     }