From nobody Mon Feb 9 03:12:59 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1501882706764323.589098880468; Fri, 4 Aug 2017 14:38:26 -0700 (PDT) Received: from localhost ([::1]:54481 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ddkIb-0008Va-CV for importer@patchew.org; Fri, 04 Aug 2017 17:38:25 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33827) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ddkGt-0007EE-J7 for qemu-devel@nongnu.org; Fri, 04 Aug 2017 17:36:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ddkGs-0001nJ-FF for qemu-devel@nongnu.org; Fri, 04 Aug 2017 17:36:39 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34464) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ddkGs-0001m4-6T for qemu-devel@nongnu.org; Fri, 04 Aug 2017 17:36:38 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 20CC8883AB for ; Fri, 4 Aug 2017 21:36:37 +0000 (UTC) Received: from localhost (ovpn-116-46.gru2.redhat.com [10.97.116.46]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9DA5C69505; Fri, 4 Aug 2017 21:36:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 20CC8883AB Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=ehabkost@redhat.com From: Eduardo Habkost To: qemu-devel@nongnu.org Date: Fri, 4 Aug 2017 18:36:25 -0300 Message-Id: <20170804213625.3756-6-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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Fri, 04 Aug 2017 21:36:37 +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 5/5] Remove scripts/qmp/qmp 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The only purpose of scripts/qmp/qmp was the ability to run QMP commands non-interactively. Now it is possible to run qmp-shell non-interactively by providing a QMP command a command-line argument, making scripts/qmp/qmp obsolete. Signed-off-by: Eduardo Habkost Reviewed-by: Stefan Hajnoczi --- scripts/qmp/qmp | 126 ----------------------------------------------------= ---- 1 file changed, 126 deletions(-) delete mode 100755 scripts/qmp/qmp diff --git a/scripts/qmp/qmp b/scripts/qmp/qmp deleted file mode 100755 index 514b539..0000000 --- a/scripts/qmp/qmp +++ /dev/null @@ -1,126 +0,0 @@ -#!/usr/bin/python -# -# QMP command line tool -# -# Copyright IBM, Corp. 2011 -# -# Authors: -# Anthony Liguori -# -# This work is licensed under the terms of the GNU GPLv2 or later. -# See the COPYING file in the top-level directory. - -import sys, os -from qmp import QEMUMonitorProtocol - -def print_response(rsp, prefix=3D[]): - if type(rsp) =3D=3D list: - i =3D 0 - for item in rsp: - if prefix =3D=3D []: - prefix =3D ['item'] - print_response(item, prefix[:-1] + ['%s[%d]' % (prefix[-1], i)= ]) - i +=3D 1 - elif type(rsp) =3D=3D dict: - for key in rsp.keys(): - print_response(rsp[key], prefix + [key]) - else: - if len(prefix): - print '%s: %s' % ('.'.join(prefix), rsp) - else: - print '%s' % (rsp) - -def main(args): - path =3D None - - # Use QMP_PATH if it's set - if os.environ.has_key('QMP_PATH'): - path =3D os.environ['QMP_PATH'] - - while len(args): - arg =3D args[0] - - if arg.startswith('--'): - arg =3D arg[2:] - if arg.find('=3D') =3D=3D -1: - value =3D True - else: - arg, value =3D arg.split('=3D', 1) - - if arg in ['path']: - if type(value) =3D=3D str: - path =3D value - elif arg in ['help']: - os.execlp('man', 'man', 'qmp') - else: - print 'Unknown argument "%s"' % arg - - args =3D args[1:] - else: - break - - if not path: - print "QMP path isn't set, use --path=3Dqmp-monitor-address or set= QMP_PATH" - return 1 - - if len(args): - command, args =3D args[0], args[1:] - else: - print 'No command found' - print 'Usage: "qmp [--path=3Dqmp-monitor-address] qmp-cmd argument= s"' - return 1 - - if command in ['help']: - os.execlp('man', 'man', 'qmp') - - srv =3D QEMUMonitorProtocol(path) - srv.connect() - - def do_command(srv, cmd, **kwds): - rsp =3D srv.cmd(cmd, kwds) - if rsp.has_key('error'): - raise Exception(rsp['error']['desc']) - return rsp['return'] - - commands =3D map(lambda x: x['name'], do_command(srv, 'query-commands'= )) - - srv.close() - - if command not in commands: - fullcmd =3D 'qmp-%s' % command - try: - os.environ['QMP_PATH'] =3D path - os.execvp(fullcmd, [fullcmd] + args) - except OSError as exc: - if exc.errno =3D=3D 2: - print 'Command "%s" not found.' % (fullcmd) - return 1 - raise - return 0 - - srv =3D QEMUMonitorProtocol(path) - srv.connect() - - arguments =3D {} - for arg in args: - if not arg.startswith('--'): - print 'Unknown argument "%s"' % arg - return 1 - - arg =3D arg[2:] - if arg.find('=3D') =3D=3D -1: - value =3D True - else: - arg, value =3D arg.split('=3D', 1) - - if arg in ['help']: - os.execlp('man', 'man', 'qmp-%s' % command) - return 1 - - arguments[arg] =3D value - - rsp =3D do_command(srv, command, **arguments) - print_response(rsp) - -if __name__ =3D=3D '__main__': - sys.exit(main(sys.argv[1:])) --=20 2.9.4