From patchwork Fri Aug 4 21:36:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eduardo Habkost X-Patchwork-Id: 798039 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xPL6n2DQpz9s76 for ; Sat, 5 Aug 2017 07:44:33 +1000 (AEST) Received: from localhost ([::1]:54496 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ddkOV-0003MC-Eu for incoming@patchwork.ozlabs.org; Fri, 04 Aug 2017 17:44:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39484) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ddkNT-0002zM-80 for qemu-devel@nongnu.org; Fri, 04 Aug 2017 17:43:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ddkNQ-0006hL-4M for qemu-devel@nongnu.org; Fri, 04 Aug 2017 17:43:27 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43466) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ddkNP-0006gU-Uy for qemu-devel@nongnu.org; Fri, 04 Aug 2017 17:43:24 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6533B4629B for ; Fri, 4 Aug 2017 21:36:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 6533B4629B Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=ehabkost@redhat.com Received: from localhost (ovpn-116-46.gru2.redhat.com [10.97.116.46]) by smtp.corp.redhat.com (Postfix) with ESMTP id E9FDD5D9C0; Fri, 4 Aug 2017 21:36:30 +0000 (UTC) From: Eduardo Habkost To: qemu-devel@nongnu.org Date: Fri, 4 Aug 2017 18:36:22 -0300 Message-Id: <20170804213625.3756-3-ehabkost@redhat.com> In-Reply-To: <20170804213625.3756-1-ehabkost@redhat.com> References: <20170804213625.3756-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Fri, 04 Aug 2017 21:36:31 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH for-2.11 2/5] qmp-shell: Pass split cmdargs to __build_cmd() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: armbru@redhat.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" This will allow us to implement a method to run a command that is already split in a list. Signed-off-by: Eduardo Habkost Reviewed-by: Stefan Hajnoczi --- scripts/qmp/qmp-shell | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/scripts/qmp/qmp-shell b/scripts/qmp/qmp-shell index c276b90..5fe6162 100755 --- a/scripts/qmp/qmp-shell +++ b/scripts/qmp/qmp-shell @@ -212,15 +212,13 @@ class QMPShell(qmp.QEMUMonitorProtocol): raise QMPShellError('Cannot set "%s" multiple times' % key) parent[optpath[-1]] = value - def __build_cmd(self, cmdline): + def __build_cmd(self, cmdargs): """ Build a QMP input object from a user provided command-line in the following format: < command-name > [ arg-name1=arg1 ] ... [ arg-nameN=argN ] """ - cmdargs = cmdline.split() - # Transactional CLI entry/exit: if cmdargs[0] == 'transaction(': self._transmode = True @@ -247,7 +245,7 @@ class QMPShell(qmp.QEMUMonitorProtocol): finalize = True self.__cli_expr(cmdargs[1:], action['data']) self._actions.append(action) - return self.__build_cmd(')') if finalize else None + return self.__build_cmd([')']) if finalize else None # Standard command: parse and return it to be executed. qmpcmd = { 'execute': cmdargs[0], 'arguments': {} } @@ -262,8 +260,9 @@ class QMPShell(qmp.QEMUMonitorProtocol): print str(jsobj) def _execute_cmd(self, cmdline): + cmdargs = cmdline.split() try: - qmpcmd = self.__build_cmd(cmdline) + qmpcmd = self.__build_cmd(cmdargs) except Exception as e: print 'Error while parsing command line: %s' % e print 'command format: ',