From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58016) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W8XOz-0000lr-FN for qemu-devel@nongnu.org; Wed, 29 Jan 2014 10:50:14 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W8XOs-0004Wj-Ax for qemu-devel@nongnu.org; Wed, 29 Jan 2014 10:50:09 -0500 Received: from paradis.irqsave.net ([62.212.105.220]:48628) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W8XOs-0004W3-1C for qemu-devel@nongnu.org; Wed, 29 Jan 2014 10:50:02 -0500 Date: Wed, 29 Jan 2014 16:50:01 +0100 From: =?iso-8859-1?Q?Beno=EEt?= Canet Message-ID: <20140129155001.GF3079@irqsave.net> References: <1390994251-21768-1-git-send-email-stefanha@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <1390994251-21768-1-git-send-email-stefanha@redhat.com> Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH] QMP: allow JSON dict arguments in qmp-shell List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi Cc: Kevin Wolf , qemu-devel@nongnu.org, Luiz Capitulino Le Wednesday 29 Jan 2014 =E0 12:17:31 (+0100), Stefan Hajnoczi a =E9crit = : > qmp-shell hides the QMP wire protocol JSON encoding from the user. Mos= t > of the time this is helpful and makes the command-line human-friendly. >=20 > Some QMP commands take a dict as an argument. In order to express this > we need to revert back to JSON notation. >=20 > This patch allows JSON dict arguments in qmp-shell so commands like > blockdev-add and nbd-server-start can be invoked: >=20 > (QEMU) blockdev-add options=3D{"driver":"file","id":"drive1",...} >=20 > Note that spaces are not allowed since str.split() is used to break up > the command-line arguments first. >=20 > Signed-off-by: Stefan Hajnoczi > --- > scripts/qmp/qmp-shell | 3 +++ > 1 file changed, 3 insertions(+) >=20 > 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) > =20 > import qmp > +import json > import readline > import sys > import pprint > @@ -107,6 +108,8 @@ class QMPShell(qmp.QEMUMonitorProtocol): > value =3D True > elif opt[1] =3D=3D 'false': > value =3D False > + elif opt[1].startswith('{'): > + value =3D json.loads(opt[1]) > else: > value =3D opt[1] > qmpcmd['arguments'][opt[0]] =3D value > --=20 > 1.8.5.3 >=20 >=20 This patch is very usefull. Reviewed-by: Benoit Canet