From nobody Mon Nov 17 12:05:12 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1603793958; cv=none; d=zohomail.com; s=zohoarc; b=aspqNjt5klZ4wz8Pq24K5G+WQl3yxU5vVj7RpCZCu4xGQqo0RJoThG1R1yTiJ5DgI/zSfDHYTw75wscaXj9yMbOjpoRqhgfOJDIlBtxYLRCkld/4tZiCe2g78Xvj+jFn8BtU6bW6djIYviEgpcGNtDpSV8oRTVv4D69KrlMGfC8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603793958; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=/ZvcjIFipLmB2yeqWuLImtzpnfkfJSGR6QF/uPVnN6g=; b=cRx6jwshZwcrNyaHtm1ZNDu9mRq9sJuXfZ1ji7m+xJPA3f3ldI8nAC5T/QKRkEKu1wRtxLwiYM/gfVN7/eoelxU687VeOk5k9lweFk1iYq+vs7mdlzx3GDwmw+Qrs2kS+2ruHyAx9HSjg2zocak0vYvuCCOR33Txn+vlK5gL8HY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1603793958219512.0829726836386; Tue, 27 Oct 2020 03:19:18 -0700 (PDT) Received: from localhost ([::1]:42824 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kXM4T-0007fB-0F for importer@patchew.org; Tue, 27 Oct 2020 06:19:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59874) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kXM2g-0006fe-4D for qemu-devel@nongnu.org; Tue, 27 Oct 2020 06:17:26 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:54552) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kXM2Y-0006km-7s for qemu-devel@nongnu.org; Tue, 27 Oct 2020 06:17:25 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-345-6AJO8gMCPfmCC2HuuyRtyA-1; Tue, 27 Oct 2020 06:17:10 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 748DF1074645; Tue, 27 Oct 2020 10:17:09 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-182.ams2.redhat.com [10.36.112.182]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0C4CF5B4AF; Tue, 27 Oct 2020 10:17:09 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 8C9961138461; Tue, 27 Oct 2020 11:17:07 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603793832; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/ZvcjIFipLmB2yeqWuLImtzpnfkfJSGR6QF/uPVnN6g=; b=ZLFesMBbUm04UHGcrKhQ58LEQMm8vCkZCOF0qmxuv9EPM91gtx9y5qFU+EBsSP5uwPq9ed F6jZE1GQlaVXixRbSVm378jbBfrgw2R5ltGCen0jFlKIR38pIHfhTBUsfTxKkdDFuRCQH3 k9INrMLhasy9gtJAoFSJ8bIN1Rk0aJY= X-MC-Unique: 6AJO8gMCPfmCC2HuuyRtyA-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 2/2] scripts/qmp: delete 'qmp' script Date: Tue, 27 Oct 2020 11:17:07 +0100 Message-Id: <20201027101707.2988553-3-armbru@redhat.com> In-Reply-To: <20201027101707.2988553-1-armbru@redhat.com> References: <20201027101707.2988553-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/27 01:06:06 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, Thomas Huth , John Snow Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: John Snow This script has not seen a patch that was specifically for this script since it was moved to this location in 2013, and I doubt it is used. It uses "man qmp" for its help message, which does not exist. It also presumes there is a manual page for qmp-XXX, for each defined qmp command XXX. I don't think that's true. The format it expects arguments in is something like: block-dirty-bitmap-add --node=3Dfoo --name=3Dbar and has no capacity to support nested JSON arguments, either. Most developers use either qmp-shell or socat (or pasting JSON directly into qmp stdio), so this duplication and additional alternate syntax is not helpful. Remove it. Leave a breadcrumb script just in case, to be removed next release cycle. Signed-off-by: John Snow Message-Id: <20201019210430.1063390-1-jsnow@redhat.com> Reviewed-by: Eric Blake Reviewed-by: Thomas Huth Signed-off-by: Markus Armbruster --- scripts/qmp/qmp | 131 +++--------------------------------------------- 1 file changed, 7 insertions(+), 124 deletions(-) diff --git a/scripts/qmp/qmp b/scripts/qmp/qmp index 8e52e4a54d..0f12307c87 100755 --- a/scripts/qmp/qmp +++ b/scripts/qmp/qmp @@ -1,128 +1,11 @@ #!/usr/bin/env python3 -# -# 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. =20 -import sys, os +import sys =20 -sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'pytho= n')) -from qemu.qmp import QEMUMonitorProtocol +print('''This unmaintained and undocumented script was removed in preferen= ce +for qmp-shell. The assumption is that most users are using either +qmp-shell, socat, or pasting/piping JSON into stdio. The duplication of +facilities here is unwanted, and the divergence of syntax harmful.''', + file=3Dsys.stderr) =20 -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 'QMP_PATH' in os.environ: - 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 'error' in rsp: - 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:])) +sys.exit(1) --=20 2.26.2