From nobody Sat May 18 22:15:01 2024 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=1603141545; cv=none; d=zohomail.com; s=zohoarc; b=Hugu6IlqRkLT5VUtm9eMTHL56Dt9VJ30ZReRDg9jdVncj+z76h7RzZGxpRXn+lKNGiRhcVSO1GMjzBYr4orXvZvwNtT1OZmcHnkH6XgzI53/JspKU19Wr2CTAjsYknVSMDY7Dm+eC70qfETUCnH9silpAp/9xcZysPZabp+sU4I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603141545; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=wrIWKTp/tHcOOrS6WgrYn7X5sPGb0zz9A8KkpgXkDJU=; b=A331ACPPuOnP9m5bvQcm8WRqxXyp5/ZUyTDHz7E7MU0p/KVYNSpE9spzcpRJiQ7pFWcPXpTk9D4TwnXP+4hW0UPPjJHZD2iXNlJ3oIqHQvQqki6Fp9PQpcsMEjX4D9dchnsD7zd2mvwbgX81ntOCkTO62ffNNc14IJzUNnrLESA= 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 1603141545882585.5515659164877; Mon, 19 Oct 2020 14:05:45 -0700 (PDT) Received: from localhost ([::1]:41206 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kUcLg-0000JW-42 for importer@patchew.org; Mon, 19 Oct 2020 17:05:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40076) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kUcKj-0008J8-KJ for qemu-devel@nongnu.org; Mon, 19 Oct 2020 17:04:46 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:25574) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kUcKe-0008A2-Ek for qemu-devel@nongnu.org; Mon, 19 Oct 2020 17:04:43 -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-278-HfrOnx2tOqK5R39E2LtYQA-1; Mon, 19 Oct 2020 17:04:36 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3D3FF108E1A2 for ; Mon, 19 Oct 2020 21:04:35 +0000 (UTC) Received: from scv.redhat.com (ovpn-113-237.rdu2.redhat.com [10.10.113.237]) by smtp.corp.redhat.com (Postfix) with ESMTP id 91BD56EF59; Mon, 19 Oct 2020 21:04:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603141477; 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; bh=wrIWKTp/tHcOOrS6WgrYn7X5sPGb0zz9A8KkpgXkDJU=; b=i6LL+tlISkVnwBZK+ZkLgUSWe7e2ntC0WXhgMkfKxC7LtSul8X6RFRC/KtF4pZRj7DRvXw 32m05Dz5WKXnUPSAHrOYGor9KDk5cqQI/65x26G06HYXR95Cc/Kw13HZ4rVq/nQGB3e1Tr i26phqwr0M7tlUgh0VUedrewlT9XEWQ= X-MC-Unique: HfrOnx2tOqK5R39E2LtYQA-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH] scripts/qmp: delete 'qmp' script Date: Mon, 19 Oct 2020 17:04:30 -0400 Message-Id: <20201019210430.1063390-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@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=63.128.21.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/19 02:32:01 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_H5=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: John Snow , Markus Armbruster , Eduardo Habkost 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" 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 Reviewed-by: Eric Blake Reviewed-by: Thomas Huth --- 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