On 01/23/2014 07:46 AM, Amos Kong wrote: > This patch introduces a new monitor command to query QMP schema > information, the return data is a range of schema structs, which > contains the useful metadata to help management to check supported > features, QMP commands detail, etc. > > We use qapi-introspect.py to parse all json definition in > qapi-schema.json, and generate a range of dictionaries with metadata. > The query command will visit the dictionaries and fill the data > to allocated struct tree. Then QMP infrastructure will convert > the tree to json string and return to QMP client. > > TODO:
Do we still want this TODO in the commit message? It would be nice to get both of these features (introspection, and events described in qapi) in for 2.0; I'm trying to spend some review time to help get us there. > Wenchao Xia is working to convert QMP events to qapi-schema.json, > then event can also be queried by this interface. > > I will introduce another command 'query-qga-schema' to query QGA > schema information, it's easy to add this support based on this > patch. Yes, we want that too :) Have you started that patch, or are you trying to get more feedback on this patch to make sure you're on the right track? > > Signed-off-by: Amos Kong <ak...@redhat.com> > --- > qapi-schema.json | 11 +++ > qmp-commands.hx | 42 +++++++++++ > qmp.c | 215 > +++++++++++++++++++++++++++++++++++++++++++++++++++++++ > 3 files changed, 268 insertions(+) > > diff --git a/qapi-schema.json b/qapi-schema.json > index c63f0ca..6033383 100644 > --- a/qapi-schema.json > +++ b/qapi-schema.json > @@ -4411,3 +4411,14 @@ > 'reference-type': 'String', > 'type': 'DataObjectType', > 'unionobj': 'DataObjectUnion' } } > + > +## > +# @query-qmp-schema > +# > +# Query QMP schema information > +# > +# @returns: list of @DataObject > +# > +# Since: 1.8 2.0 And here's where an optional bool on whether to expand may be worthwhile, as well as an optional argument allowing callers to filter data. > +## > +{ 'command': 'query-qmp-schema', 'returns': ['DataObject'] } > +Return a json-object with the following information: > + > +- "name": qmp schema name (json-string) > +- "type": qmp schema type, it can be 'comand', 'type', 'enum', 'union' s/comand/command/ > +++ b/qmp.c > +static DataObjectMember *qobject_to_dataobjmem(QObject *data) > +{ > + > + DataObjectMember *member = g_malloc0(sizeof(DataObjectMember)); The blank line here looks unusual. I didn't look at the code very closely; I want to look at the generated .h file first. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature