qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH] QMP: allow JSON dict arguments in qmp-shell


From: Benoît Canet
Subject: Re: [Qemu-devel] [PATCH] QMP: allow JSON dict arguments in qmp-shell
Date: Wed, 29 Jan 2014 16:50:01 +0100
User-agent: Mutt/1.5.21 (2010-09-15)

Le Wednesday 29 Jan 2014 à 12:17:31 (+0100), Stefan Hajnoczi a écrit :
> qmp-shell hides the QMP wire protocol JSON encoding from the user.  Most
> of the time this is helpful and makes the command-line human-friendly.
> 
> Some QMP commands take a dict as an argument.  In order to express this
> we need to revert back to JSON notation.
> 
> This patch allows JSON dict arguments in qmp-shell so commands like
> blockdev-add and nbd-server-start can be invoked:
> 
>   (QEMU) blockdev-add options={"driver":"file","id":"drive1",...}
> 
> Note that spaces are not allowed since str.split() is used to break up
> the command-line arguments first.
> 
> Signed-off-by: Stefan Hajnoczi <address@hidden>
> ---
>  scripts/qmp/qmp-shell | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/scripts/qmp/qmp-shell b/scripts/qmp/qmp-shell
> index d6b420f..d374b35 100755
> --- a/scripts/qmp/qmp-shell
> +++ b/scripts/qmp/qmp-shell
> @@ -31,6 +31,7 @@
>  # (QEMU)
>  
>  import qmp
> +import json
>  import readline
>  import sys
>  import pprint
> @@ -107,6 +108,8 @@ class QMPShell(qmp.QEMUMonitorProtocol):
>                      value = True
>                  elif opt[1] == 'false':
>                      value = False
> +                elif opt[1].startswith('{'):
> +                    value = json.loads(opt[1])
>                  else:
>                      value = opt[1]
>              qmpcmd['arguments'][opt[0]] = value
> -- 
> 1.8.5.3
> 
> 
This patch is very usefull.
Reviewed-by: Benoit Canet <address@hidden>




reply via email to

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