From: Eric Blake <eblake@redhat.com>
To: Amos Kong <akong@redhat.com>
Cc: aliguori@us.ibm.com, mdroth@linux.vnet.ibm.com,
Markus Armbruster <armbru@redhat.com>,
qemu-devel <qemu-devel@nongnu.org>,
qiaonuohan@cn.fujitsu.com, Ronen Hod <rhod@redhat.com>,
lcapitulino@redhat.com
Subject: Re: [Qemu-devel] RFC: Full introspection support for QMP (with draft patch)
Date: Fri, 14 Jun 2013 11:59:43 +0100 [thread overview]
Message-ID: <51BAF79F.3070708@redhat.com> (raw)
In-Reply-To: <20130614095244.GA24720@t430s.nay.redhat.com>
[-- Attachment #1: Type: text/plain, Size: 3495 bytes --]
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 #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 621 bytes --]
next prev parent reply other threads:[~2013-06-14 11:00 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-22 13:40 [Qemu-devel] RFC: Full introspection support for QMP Amos Kong
2013-05-22 14:44 ` Kevin Wolf
2013-05-22 16:14 ` Anthony Liguori
2013-05-23 8:18 ` Kevin Wolf
2013-05-23 12:08 ` Anthony Liguori
2013-05-23 12:40 ` Luiz Capitulino
2013-05-23 12:52 ` Anthony Liguori
2013-05-23 12:54 ` Kevin Wolf
2013-05-23 13:52 ` Anthony Liguori
2013-05-23 14:17 ` Eric Blake
2013-05-23 14:29 ` Kevin Wolf
2013-05-22 17:56 ` Luiz Capitulino
2013-05-23 12:58 ` Eric Blake
2013-06-07 10:12 ` [Qemu-devel] RFC: Full introspection support for QMP (with draft patch) Amos Kong
2013-06-07 10:17 ` Amos Kong
2013-06-14 9:52 ` Amos Kong
2013-06-14 10:59 ` Eric Blake [this message]
2013-06-14 11:09 ` Eric Blake
2013-06-18 12:21 ` Amos Kong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=51BAF79F.3070708@redhat.com \
--to=eblake@redhat.com \
--cc=akong@redhat.com \
--cc=aliguori@us.ibm.com \
--cc=armbru@redhat.com \
--cc=lcapitulino@redhat.com \
--cc=mdroth@linux.vnet.ibm.com \
--cc=qemu-devel@nongnu.org \
--cc=qiaonuohan@cn.fujitsu.com \
--cc=rhod@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).