[pve-devel] [PATCH qemu-server] fix #2697: map netdev_add options to correct json types

Stefan Reiter s.reiter at proxmox.com
Tue Apr 21 16:38:34 CEST 2020


On 21/04/2020 16:01, Dominik Csapak wrote:
> netdev_add is now a proper qmp command, which means that it verifies
> the parameter types properly
> 

The patch looks reasonable, but I'm confused how that worked before? 
'git blame' tells me the typed QMP schema for netdev_add has been in 
QEMU since 2017..

> instead of sending strings, we now have to choose the correct
> types for the parameters
> 
> bool for vhost
> and uint64 for queues
> 
> Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
> ---
> i checked and i found no other parameter or qmp call that needs
> changing, but maybe someone else can also check this, just to be sure
> 
>   PVE/QemuServer.pm | 8 ++++++++
>   1 file changed, 8 insertions(+)
> 
> diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
> index 37c7320..030e04b 100644
> --- a/PVE/QemuServer.pm
> +++ b/PVE/QemuServer.pm
> @@ -4047,6 +4047,14 @@ sub qemu_netdevadd {
>       my $netdev = print_netdev_full($vmid, $conf, $arch, $device, $deviceid, 1);
>       my %options =  split(/[=,]/, $netdev);
>   
> +    if (defined(my $vhost = $options{vhost})) {
> +	$options{vhost} = JSON::boolean(PVE::JSONSchema::parse_boolean($vhost));
> +    }
> +
> +    if (defined(my $queues = $options{queues})) {
> +	$options{queues} = $queues + 0;
> +    }
> +
>       mon_cmd($vmid, "netdev_add",  %options);
>       return 1;
>   }
> 




More information about the pve-devel mailing list