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: Amos Kong
Subject: Re: [Qemu-devel] RFC: Full introspection support for QMP (with draft patch)
Date: Tue, 18 Jun 2013 20:21:12 +0800
User-agent: Mutt/1.5.21 (2010-09-15)

On Fri, Jun 14, 2013 at 12:09:33PM +0100, Eric Blake wrote:
> On 06/14/2013 10:52 AM, Amos Kong wrote:

> > +const char *type;
> > +const char *name;
> > +const char *data;
> > +const char *returns;
> > +} qmp_schema_table[] = {
> > +"""
> > +
> > +for i in exprs_all[1]:
> > +    print i
> > +
> > +    data = returns = ""
> > +    type = i.keys()[0]
> > +    name = i[type]
> > +    for k in i.keys():
> > +        if isinstance(i[k], OrderedDict):
> > +            ret = {}
> > +            for key in i[k]:
> > +                ret[key] = i[k][key]
> > +            i[k] = ret
> > +
> > +    if i.has_key('data'):
> > +        data = i['data']
> 
> I think this is where you'd need to do more processing of data to spit
> it out in a more structured format, but my python is too weak to
> actually write that conversion.

I found a solution :-)

 Generate a string array in C head file to record the raw json string;
 Convert each json string to QObject, and convert the QObject to QDict
 for traversal by recursion;

 Define a new type and uion [1] to describe dynamical date for QMP.
 and allocate & connect nested members in recursion function.

 Finally, we can provide dynamical data with metadate according the
 definition in json file.

I will send a v1 patch later.


---- [1] ----
{ 'union': 'DataValue', 'data': { 'string': 'str', 'obj': 'DataObj' } }
{ 'type': 'DataObj', 'data': { '*key': 'str', 'value': 'DataValue' } }
{ 'type': 'SchemaData',
  'data': { 'type': 'str', 'name': 'str', '*data': ['DataObj'], '*returns': 
['DataObj'] } }

-- 
                        Amos.



reply via email to

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