Stefan Reiter 1e18c15ad1 Fix #2476: Fix auto-ballooning QMP command
Commit 77123edbd0 (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>
2019-11-21 14:23:58 +01:00
2019-11-05 07:26:28 +01:00
2019-11-20 20:46:21 +01:00
2019-11-19 15:02:50 +01:00
2018-05-04 14:50:04 +02:00
Description
No description provided
276 MiB
Languages
JavaScript 62.6%
Perl 35%
Makefile 1.2%
CSS 0.6%
Smarty 0.3%
Other 0.2%