qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [qapi] Cannot use list of strings


From: Eric Blake
Subject: Re: [Qemu-devel] [qapi] Cannot use list of strings
Date: Tue, 16 Apr 2013 06:36:38 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130402 Thunderbird/17.0.5

On 04/16/2013 04:13 AM, Amos Kong wrote:
> Eric said String list contains additional JSON structure.
> At least, it works.

Using the fat 'String' wrapper works, but requires more effort to decode.

> 
> ===================== using StringList
>     '*unicast':        ['String'],
>     '*multicast':      ['String']
> 
> {
>     "return": [
>         {
>             "name": "virtio-net-pci.0", 
>             "multicast": [
>                 {
>                     "str": "01:80:c2:00:00:21"
>                 }, 
>                 {
>                     "str": "00:00:00:00:00:00"
>                 }
>             ]

Libvirt can live with this, even though it is more work, if you can't
figure out how to make 'str' work.  I don't know enough about the JSON
generator to quickly dive in and figure out why you can't make an array
of native types, though.

>         }, 
>         ....
>     ]
> }
> ======================== using strList
>     '*unicast':        ['str'],
>     '*multicast':      ['str']
> 
> Eric, is it expected format?
> 
> {
>     "return": [
>         {
>             "name": "virtio-net-pci.0", 
>             "multicast": [
>                     "str": "01:80:c2:00:00:21",
>                     "str": "00:00:00:00:00:00"
>             ]

No.  This is not valid JSON.  ':' is only allowed inside {}.  The point
of an array is to either have an array of objects (as in [
{'name':value}, {'name':value} ]) or an array of native types (as in [
value, value ]).  The ideal solution is for the output QMP to look like:

    "multicast": [
        "01:80:c2:00:00:21",
        "00:00:00:00:00:00"
    ]

which seems like it should work as '*multicast':['str'], if you can
figure out how to make the generator play along.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]