From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38245) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WDApv-0007Zx-Bu for qemu-devel@nongnu.org; Tue, 11 Feb 2014 05:45:13 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WDApp-00056f-Dw for qemu-devel@nongnu.org; Tue, 11 Feb 2014 05:45:07 -0500 Received: from mx1.redhat.com ([209.132.183.28]:29703) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WDApp-00056I-5x for qemu-devel@nongnu.org; Tue, 11 Feb 2014 05:45:01 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s1BAj0tc011106 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 11 Feb 2014 05:45:00 -0500 From: Fam Zheng Date: Tue, 11 Feb 2014 18:45:05 +0800 Message-Id: <1392115505-21969-1-git-send-email-famz@redhat.com> In-Reply-To: <1390994251-21768-1-git-send-email-stefanha@redhat.com> References: <1390994251-21768-1-git-send-email-stefanha@redhat.com> Subject: [Qemu-devel] [PATCH] QMP: allow dot separated dict path arguments in qmp-shell List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Igor Mammedov , Stefan Hajnoczi , Luiz Capitulino As another convinience to allow using commands that expect a dict as argument, this patch adds support for foo.bar=value syntax, similar to command line argument style: (QEMU) blockdev-add options.driver=file options.id=drive1 options.filename=... Signed-off-by: Fam Zheng -- Applies on top of Stefan's patch [PATCH] QMP: allow JSON dict arguments in qmp-shell Signed-off-by: Fam Zheng --- scripts/qmp/qmp-shell | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/scripts/qmp/qmp-shell b/scripts/qmp/qmp-shell index d374b35..9c84551 100755 --- a/scripts/qmp/qmp-shell +++ b/scripts/qmp/qmp-shell @@ -112,7 +112,14 @@ class QMPShell(qmp.QEMUMonitorProtocol): value = json.loads(opt[1]) else: value = opt[1] - qmpcmd['arguments'][opt[0]] = value + optpath = opt[0].split('.') + parent = qmpcmd['arguments'] + for p in optpath[:-1]: + if not p in parent: + d = dict() + parent[p] = d + parent = d + parent[optpath[-1]] = value return qmpcmd def _execute_cmd(self, cmdline): -- 1.8.5.4