]> git.proxmox.com Git - pve-manager.git/commit
Fix #2476: Fix auto-ballooning QMP command
authorStefan Reiter <s.reiter@proxmox.com>
Thu, 21 Nov 2019 12:22:16 +0000 (13:22 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 21 Nov 2019 13:23:58 +0000 (14:23 +0100)
commite2509f4e37adfadb1df8ab8a87c0d14d0833b680
tree19f16eca1a1dcc5b9364a833dfd18112809686b6
parent6fba05b2b636eaf7be4ede0e4f9cffc9edbc9516
Fix #2476: Fix auto-ballooning QMP command

Commit 0dd73a7fec (statd: refactor update_node_status) changed $target
in pvestatd's auto_balloning sub into a variable:

    my $target = int($res->{$vmid});

but then uses it in a string as a parameter to the $log function:

    $log->("BALLOON $vmid to $target (%d)\n", $target - $current);

This surprisingly causes the variable to be incorrectly converted into a
JSON string by perl's to_json (called in QMPClient after mon_cmd):

    {"value":"1234"}

instead of

    {"value":1234}

which causes QEMU to report the parameter as invalid:

    "Invalid parameter type for 'value', expected: integer"

This behaviour is made even trickier, since $target internally is still
considered more of an 'int' (although that's a weak claim in perl
anyway), showing up without quotes in Dumper et. al. - but the perldoc
for to_json scheds some light:

    simple scalars
        Simple Perl scalars (any scalar that is not a reference) are the
        most difficult objects to encode: this module will encode undefined
        scalars as JSON "null" values, scalars that have last been used in a
        string context before encoding as JSON strings, and anything else as
        number value

So coerce to_json to treat $target as an integer by using it as one and
everything is fine again.

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
PVE/Service/pvestatd.pm