qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH] full introspection support for QMP


From: Amos Kong
Subject: Re: [Qemu-devel] [PATCH] full introspection support for QMP
Date: Wed, 19 Jun 2013 20:49:14 +0800
User-agent: Mutt/1.5.21 (2010-09-15)

On Wed, Jun 19, 2013 at 08:24:37PM +0800, Amos Kong wrote:
> Introduces new monitor command to query QMP schema information,
> the return data is a nested dict/list, it contains the useful
> metadata.
> 
> we can add events definations to qapi-schema.json, then it can
> also be queried.
 
I didn't implement to return complete schema in one go in this
version, will do it in next version. We have a recursive define
'DataObject', we only display one layer for it.

>>>> dict
  {'type': 't1', 'data': {'a1': 'b1'} }
  {'type': 't2', 'data': {'a2': 't1'} }

then we would retrieve t2 to:

   {'type': 't2', 'data': {'a2': {'a1': 'b1'} } }

>>>> list
  {'enum': 't1', 'data': ['a1', 'b1'] }
  {'type': 't2', 'data': {'a2': 't1'} }

then we would retrieve t2 to:

   {'type': 't2', 'data': {'a2': ['a1', 'b1'] } }

>>>> union
  {'union': 't1', 'data': {'a1':'v1', 'b1':'v2'} }
  {'type': 't2', 'data': {'a2': 't1'} }

then we would retrieve t2 to:

   {'type': 't2', 'data': {'a2': {'a2': ['a1', 'b1'] } } }

 
> Signed-off-by: Amos Kong <address@hidden>
> ---
>  Makefile                 |   4 +-
>  qapi-schema.json         |  68 +++++++++++++++++++
>  qmp-commands.hx          |  39 +++++++++++
>  qmp.c                    | 170 
> +++++++++++++++++++++++++++++++++++++++++++++++
>  scripts/qapi-commands.py |   2 +-
>  scripts/qapi-types.py    |  34 +++++++++-
>  scripts/qapi-visit.py    |   2 +-
>  scripts/qapi.py          |   7 +-
>  8 files changed, 320 insertions(+), 6 deletions(-)


You can find three kind of examples(string/list/dict) in the bottom.
Attached (query-qmp-schema--output.txt) the full output of execut 
query-qmp-schema command.

String:
{ 'command': 'query-name', 'returns': 'NameInfo' }
---------------------------------------------------------------------
        {
            "name": "NameInfo",
            "type": "Type",
            "data": [
                {
                    "name": "*name",
                    "type": "str"
                }
            ]
        },


List:
{ 'enum': 'ErrorClass',
  'data': [ 'GenericError', 'CommandNotFound', 'DeviceEncrypted',
            'DeviceNotActive', 'DeviceNotFound', 'KVMMissingCap' ] }
---------------------------------------------------------------------
        {
            "name": "ErrorClass",
            "type": "Enumeration",
            "data": [
                {
                    "type": "GenericError"
                },
                {
                    "type": "CommandNotFound"
                },
                {
                    "type": "DeviceEncrypted"
                },
                {
                    "type": "DeviceNotActive"
                },
                {
                    "type": "DeviceNotFound"
                },
                {
                    "type": "KVMMissingCap"
                }
            ]
        },


Dict:
{ 'type': 'VersionInfo',
  'data': {'qemu': {'major': 'int', 'minor': 'int', 'micro': 'int'},
           'package': 'str'} }
---------------------------------------------------------------------
        {
            "name": "VersionInfo",
            "type": "Type",
            "data": [
                {
                    "name": "qemu",
                    "data": [
                        {
                            "name": "micro",
                            "type": "int"
                        },
                        {
                            "name": "minor",
                            "type": "int"
                        },
                        {
                            "name": "major",
                            "type": "int"
                        }
                    ]
                },
                {
                    "name": "package",
                    "type": "str"
                }
            ]
        },



Attachment: query-qmp-schema--output.txt
Description: Text document


reply via email to

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