qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] RFC: Full introspection support for QMP (with draft pat


From: Eric Blake
Subject: Re: [Qemu-devel] RFC: Full introspection support for QMP (with draft patch)
Date: Fri, 14 Jun 2013 11:59:43 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130514 Thunderbird/17.0.6

On 06/14/2013 10:52 AM, Amos Kong wrote:
> On Fri, Jun 07, 2013 at 06:17:26PM +0800, Amos Kong wrote:
>> On Fri, Jun 07, 2013 at 06:12:30PM +0800, Amos Kong wrote:
>>> Sent out a draft patch in the end of this week. It doesn't support:
>>> * output all stuffs in one shot.
>>> * introspect event
>>> * provide metadata date
>>>
>>> How can we define a dynamic dict in qmp-schema.json ?
>>>
>>> Currently I just output the raw json dict by a string, Libvirt needs
>>> parse two times, convert the string to json format.
>>>
>>> qmp-schema.h: auto generated head file by qapi script
>>>
>>> Attached some examples.
> 
> 
> Hello all,
> 
> I defined a new type 'SchemaData', it contains 4 keys (type, name, data, 
> returns)
> 
> | { 'type': 'SchemaData',
> |   'data': { 'type': 'str', 'name': 'str', '*data': 'str', '*returns': 'str' 
> } }

It seems like 'type' should be an enum rather than an open-coded 'str'.

Returning 'data' and 'returns' as an open-coded 'str' is not nice - it
requires the client to do further parsing.  I was serious when I
suggested adding additional layers of formalized structure to the
result.  My suggestion was something like:

{ 'type': 'SchemaDataMember', 'data': {
    'option': 'str', 'type': 'str', '*optional': 'bool' } }
{ 'enum': 'SchemaMetatype', 'data': [ 'command', 'type', 'event' ] }
{ 'type': 'SchemaData', 'data': {
    'name': 'str',
    'metatype': 'SchemaMetatype',
    '*returns': 'str',
    '*data': [ 'SchemaDataMember' ] } }

> | 
> | { 'command': 'query-qmp-schema', 'data': { '*type': 'str', '*name': 'str' },
> |   'returns': ['SchemaData'] }


I'm still not sure whether optional filtering will be used by libvirt,
or if it adds any complexity on your end (I'm not opposed to it, but I
know that there hasn't been universal agreement on filtering queries yet).

Again, it seems like 'type' should be an enum.  Something like:

{ 'command': 'query-qmp-schema',
  'data': { '*type': 'SchemaMetatype', '*name': 'str' },
  'returns': ['SchemaData'] }

> 
> Then we can provice meaningful result to Libvirt. Currently I set a string
> for SchemaData['data'].
> 
> 
> I tried to define a dynamical dict for 'data', but it's failed. 
> 
> | { 'type': 'SchemaData',
> |   'data': { 'type': 'str', 'name': 'str', '*data': '**', '*returns': 'str' 
> } }  (Failed!!)
> 
> 
> Does qapi support to define a dynamical dict, then I can convert dict string
> and set to SchemaData['data'] ?

Rather, you want to take an arbitrary dict, and turn it into an array
describing each key of the dict.  That is, given the .json file containing:

{ 'command': 'add_client',
  'data': { 'protocol': 'str', 'fdname': 'str', '*skipauth': 'bool',
            '*tls': 'bool' } }

you would create an array of four members, describing each of the four
dict members, resulting in this exchange:

=> { "execute": "query-qmp-schema",
     "arguments": { "name": "add_client" } }
<= { "return": [
     { "name": "add_client",
       "type": "command",
       "data": [
         { "name": "protocol",
           "type": "str" },
         { "name": "fdname",
           "type": "str" },
         { "name": "skipauth",
           "type": "bool",
           "optional": true },
         { "name": "tls",
           "type": "bool",
           "optional": true }
       ] } ] }

-- 
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]