From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33695) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WCxhm-0001lu-4u for qemu-devel@nongnu.org; Mon, 10 Feb 2014 15:43:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WCxhc-0002z8-Qh for qemu-devel@nongnu.org; Mon, 10 Feb 2014 15:43:50 -0500 Received: from mx1.redhat.com ([209.132.183.28]:22421) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WCxhc-0002z4-JH for qemu-devel@nongnu.org; Mon, 10 Feb 2014 15:43:40 -0500 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s1AKhdlR032138 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 10 Feb 2014 15:43:39 -0500 Date: Mon, 10 Feb 2014 15:43:37 -0500 From: Luiz Capitulino Message-ID: <20140210154337.62d19898@redhat.com> In-Reply-To: <1390994251-21768-1-git-send-email-stefanha@redhat.com> References: <1390994251-21768-1-git-send-email-stefanha@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit 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 On Wed, 29 Jan 2014 12:17:31 +0100 Stefan Hajnoczi wrote: > 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 Applied to the qmp branch, thanks. > --- > 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