From patchwork Mon Jun 7 20:06:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Snow X-Patchwork-Id: 12304603 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CF14BC47095 for ; Mon, 7 Jun 2021 20:09:04 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6B6E2610A2 for ; Mon, 7 Jun 2021 20:09:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6B6E2610A2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:55412 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lqLYV-0006i0-G7 for qemu-devel@archiver.kernel.org; Mon, 07 Jun 2021 16:09:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37408) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lqLWo-0003i7-Ka for qemu-devel@nongnu.org; Mon, 07 Jun 2021 16:07:18 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:25504) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lqLWm-0006Qn-ON for qemu-devel@nongnu.org; Mon, 07 Jun 2021 16:07:18 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623096436; 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=ys+pu8pJpD/QUjd/0x88ST0XWpw4cZ8kYrMyzX22SS0=; b=AZQKYIFAun/Cw0b+FF/SBPCQuOyw9xNchMnJkl/iGbZsdEgPnb0aKPsaEKCVDUAa/r70+f mOg0LCN4v0+wgRf+N1WZbjP99eOiiVSqtzqth81yGArYB1RVRvc4cLzeTwhOfZHv+tay06 rppTheFnzZqIH8uzzEH5/qCFKGqvKqg= 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-517-I20pNxPVP_Gs-63DeA5jxA-1; Mon, 07 Jun 2021 16:07:15 -0400 X-MC-Unique: I20pNxPVP_Gs-63DeA5jxA-1 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id BC3A6188E3DA; Mon, 7 Jun 2021 20:06:51 +0000 (UTC) Received: from scv.redhat.com (ovpn-116-137.rdu2.redhat.com [10.10.116.137]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7ACF55C1C2; Mon, 7 Jun 2021 20:06:50 +0000 (UTC) From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH 01/42] scripts/qmp-shell: apply isort rules Date: Mon, 7 Jun 2021 16:06:08 -0400 Message-Id: <20210607200649.1840382-2-jsnow@redhat.com> In-Reply-To: <20210607200649.1840382-1-jsnow@redhat.com> References: <20210607200649.1840382-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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 Received-SPF: pass client-ip=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.2, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, 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: "Niteesh G . S ." , Cleber Rosa , John Snow , Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: John Snow --- scripts/qmp/qmp-shell | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/scripts/qmp/qmp-shell b/scripts/qmp/qmp-shell index d5ae8a9b21..a00efe6fea 100755 --- a/scripts/qmp/qmp-shell +++ b/scripts/qmp/qmp-shell @@ -65,18 +65,20 @@ # which will echo back the properly formatted JSON-compliant QMP that is being # sent to QEMU, which is useful for debugging and documentation generation. -import json import ast -import readline -import sys -import os -import errno import atexit +import errno +import json +import os import re +import readline +import sys + sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'python')) from qemu import qmp + class QMPCompleter(list): def complete(self, text, state): for cmd in self: From patchwork Mon Jun 7 20:06:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Snow X-Patchwork-Id: 12304597 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9B0DDC47082 for ; Mon, 7 Jun 2021 20:08:58 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0FA2A610A2 for ; Mon, 7 Jun 2021 20:08:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0FA2A610A2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:54794 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lqLYP-0006Iy-1q for qemu-devel@archiver.kernel.org; Mon, 07 Jun 2021 16:08:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37332) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lqLWk-0003cg-80 for qemu-devel@nongnu.org; Mon, 07 Jun 2021 16:07:14 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:35263) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lqLWi-0006OJ-3P for qemu-devel@nongnu.org; Mon, 07 Jun 2021 16:07:14 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623096431; 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=YWNgd3ihg75wc6K9YcMqeNR/Xp7RpQgn6le4pkbHX8A=; b=Hf756SQuP8UVQbtW2ZT3d8qnUXKNm13fb2qec9gFjjGrGABqIjPyHV8aQkybDwbr1CR3gH JSQ/xbxj9Kmkr3Vi9y5f8TbucLYKdaE5chrO+CVe8+Dwsp62pNE53ScZOvP0A69HmQkLvM 5Qc9Tv7Mg/u4SEKtBHF6LcG1JK+Exbg= 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-142-gO6suDmIPmSNU4fOADCEnA-1; Mon, 07 Jun 2021 16:07:08 -0400 X-MC-Unique: gO6suDmIPmSNU4fOADCEnA-1 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id D892E1019632; Mon, 7 Jun 2021 20:06:52 +0000 (UTC) Received: from scv.redhat.com (ovpn-116-137.rdu2.redhat.com [10.10.116.137]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0B9A45C1C2; Mon, 7 Jun 2021 20:06:51 +0000 (UTC) From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH 02/42] scripts/qmp-shell: Apply flake8 rules Date: Mon, 7 Jun 2021 16:06:09 -0400 Message-Id: <20210607200649.1840382-3-jsnow@redhat.com> In-Reply-To: <20210607200649.1840382-1-jsnow@redhat.com> References: <20210607200649.1840382-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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 Received-SPF: pass client-ip=170.10.133.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.2, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, 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: "Niteesh G . S ." , Cleber Rosa , John Snow , Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" A lot of fiddling around to get us below 80 columns. Signed-off-by: John Snow --- scripts/qmp/qmp-shell | 64 +++++++++++++++++++++++++++++-------------- 1 file changed, 43 insertions(+), 21 deletions(-) diff --git a/scripts/qmp/qmp-shell b/scripts/qmp/qmp-shell index a00efe6fea..62a6377e06 100755 --- a/scripts/qmp/qmp-shell +++ b/scripts/qmp/qmp-shell @@ -88,6 +88,7 @@ class QMPCompleter(list): else: state -= 1 + class QMPShellError(Exception): pass @@ -105,6 +106,7 @@ class FuzzyJSON(ast.NodeTransformer): node.id = 'None' return node + # TODO: QMPShell's interface is a bit ugly (eg. _fill_completion() and # _execute_cmd()). Let's design a better one. class QMPShell(qmp.QEMUMonitorProtocol): @@ -131,8 +133,8 @@ class QMPShell(qmp.QEMUMonitorProtocol): readline.set_history_length(1024) readline.set_completer(self._completer.complete) readline.parse_and_bind("tab: complete") - # XXX: default delimiters conflict with some command names (eg. query-), - # clearing everything as it doesn't seem to matter + # NB: default delimiters conflict with some command names + # (eg. query-), clearing everything as it doesn't seem to matter readline.set_completer_delims('') try: readline.read_history_file(self._histfile) @@ -180,7 +182,9 @@ class QMPShell(qmp.QEMUMonitorProtocol): for arg in tokens: (key, sep, val) = arg.partition('=') if sep != '=': - raise QMPShellError("Expected a key=value pair, got '%s'" % arg) + raise QMPShellError( + f"Expected a key=value pair, got '{arg!s}'" + ) value = self.__parse_value(val) optpath = key.split('.') @@ -189,14 +193,16 @@ class QMPShell(qmp.QEMUMonitorProtocol): curpath.append(p) d = parent.get(p, {}) if type(d) is not dict: - raise QMPShellError('Cannot use "%s" as both leaf and non-leaf key' % '.'.join(curpath)) + msg = 'Cannot use "{:s}" as both leaf and non-leaf key' + raise QMPShellError(msg.format('.'.join(curpath))) parent[p] = d parent = d if optpath[-1] in parent: if type(parent[optpath[-1]]) is dict: - raise QMPShellError('Cannot use "%s" as both leaf and non-leaf key' % '.'.join(curpath)) + msg = 'Cannot use "{:s}" as both leaf and non-leaf key' + raise QMPShellError(msg.format('.'.join(curpath))) else: - raise QMPShellError('Cannot set "%s" multiple times' % key) + raise QMPShellError(f'Cannot set "{key}" multiple times') parent[optpath[-1]] = value def __build_cmd(self, cmdline): @@ -206,7 +212,8 @@ class QMPShell(qmp.QEMUMonitorProtocol): < command-name > [ arg-name1=arg1 ] ... [ arg-nameN=argN ] """ - cmdargs = re.findall(r'''(?:[^\s"']|"(?:\\.|[^"])*"|'(?:\\.|[^'])*')+''', cmdline) + argument_regex = r'''(?:[^\s"']|"(?:\\.|[^"])*"|'(?:\\.|[^'])*')+''' + cmdargs = re.findall(argument_regex, cmdline) # Transactional CLI entry/exit: if cmdargs[0] == 'transaction(': @@ -215,9 +222,12 @@ class QMPShell(qmp.QEMUMonitorProtocol): elif cmdargs[0] == ')' and self._transmode: self._transmode = False if len(cmdargs) > 1: - raise QMPShellError("Unexpected input after close of Transaction sub-shell") - qmpcmd = { 'execute': 'transaction', - 'arguments': { 'actions': self._actions } } + msg = 'Unexpected input after close of Transaction sub-shell' + raise QMPShellError(msg) + qmpcmd = { + 'execute': 'transaction', + 'arguments': {'actions': self._actions} + } self._actions = list() return qmpcmd @@ -228,7 +238,7 @@ class QMPShell(qmp.QEMUMonitorProtocol): # Parse and then cache this Transactional Action if self._transmode: finalize = False - action = { 'type': cmdargs[0], 'data': {} } + action = {'type': cmdargs[0], 'data': {}} if cmdargs[-1] == ')': cmdargs.pop(-1) finalize = True @@ -237,7 +247,7 @@ class QMPShell(qmp.QEMUMonitorProtocol): return self.__build_cmd(')') if finalize else None # Standard command: parse and return it to be executed. - qmpcmd = { 'execute': cmdargs[0], 'arguments': {} } + qmpcmd = {'execute': cmdargs[0], 'arguments': {}} self.__cli_expr(cmdargs[1:], qmpcmd['arguments']) return qmpcmd @@ -278,7 +288,7 @@ class QMPShell(qmp.QEMUMonitorProtocol): print('Connected') return version = self._greeting['QMP']['version']['qemu'] - print('Connected to QEMU %d.%d.%d\n' % (version['major'],version['minor'],version['micro'])) + print("Connected to QEMU {major}.{minor}.{micro}\n".format(**version)) def get_prompt(self): if self._transmode: @@ -307,6 +317,7 @@ class QMPShell(qmp.QEMUMonitorProtocol): def set_verbosity(self, verbose): self._verbose = verbose + class HMPShell(QMPShell): def __init__(self, address): QMPShell.__init__(self, address) @@ -315,7 +326,7 @@ class HMPShell(QMPShell): def __cmd_completion(self): for cmd in self.__cmd_passthrough('help')['return'].split('\r\n'): if cmd and cmd[0] != '[' and cmd[0] != '\t': - name = cmd.split()[0] # drop help text + name = cmd.split()[0] # drop help text if name == 'info': continue if name.find('|') != -1: @@ -327,7 +338,7 @@ class HMPShell(QMPShell): else: name = opt[0] self._completer.append(name) - self._completer.append('help ' + name) # help completion + self._completer.append('help ' + name) # help completion def __info_completion(self): for cmd in self.__cmd_passthrough('info')['return'].split('\r\n'): @@ -343,17 +354,21 @@ class HMPShell(QMPShell): self.__info_completion() self.__other_completion() - def __cmd_passthrough(self, cmdline, cpu_index = 0): - return self.cmd_obj({ 'execute': 'human-monitor-command', 'arguments': - { 'command-line': cmdline, - 'cpu-index': cpu_index } }) + def __cmd_passthrough(self, cmdline, cpu_index=0): + return self.cmd_obj({ + 'execute': 'human-monitor-command', + 'arguments': { + 'command-line': cmdline, + 'cpu-index': cpu_index + } + }) def _execute_cmd(self, cmdline): if cmdline.split()[0] == "cpu": # trap the cpu command, it requires special setting try: idx = int(cmdline.split()[1]) - if not 'return' in self.__cmd_passthrough('info version', idx): + if 'return' not in self.__cmd_passthrough('info version', idx): print('bad CPU index') return True self.__cpu_index = idx @@ -377,20 +392,26 @@ class HMPShell(QMPShell): def show_banner(self): QMPShell.show_banner(self, msg='Welcome to the HMP shell!') + def die(msg): sys.stderr.write('ERROR: %s\n' % msg) sys.exit(1) + def fail_cmdline(option=None): if option: sys.stderr.write('ERROR: bad command-line option \'%s\'\n' % option) - sys.stderr.write('qmp-shell [ -v ] [ -p ] [ -H ] [ -N ] < UNIX socket path> | < TCP address:port >\n') + sys.stderr.write( + 'qmp-shell [ -v ] [ -p ] [ -H ] [ -N ] ' + '< UNIX socket path> | < TCP address:port >\n' + ) sys.stderr.write(' -v Verbose (echo command sent and received)\n') sys.stderr.write(' -p Pretty-print JSON\n') sys.stderr.write(' -H Use HMP interface\n') sys.stderr.write(' -N Skip negotiate (for qemu-ga)\n') sys.exit(1) + def main(): addr = '' qemu = None @@ -440,5 +461,6 @@ def main(): pass qemu.close() + if __name__ == '__main__': main() From patchwork Mon Jun 7 20:06:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Snow X-Patchwork-Id: 12304615 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3E955C47082 for ; Mon, 7 Jun 2021 20:12:54 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id F0B4861073 for ; Mon, 7 Jun 2021 20:12:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F0B4861073 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:43862 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lqLcD-0000zl-6a for qemu-devel@archiver.kernel.org; Mon, 07 Jun 2021 16:12:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37518) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lqLWt-0003wu-3i for qemu-devel@nongnu.org; Mon, 07 Jun 2021 16:07:23 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:20479) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lqLWr-0006TV-8Y for qemu-devel@nongnu.org; Mon, 07 Jun 2021 16:07:22 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623096440; 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=Y7SnlXV0bbBfI64T/zFD5GkVt7ViDW4VlUSmx+fvVQs=; b=DTcO1fBjoDAa8YTBkBb403mqoGavTXLcIErx2LAFq3oNhwdFBPBg8EgiYk6mxUnrOHlsgm wxdJoYQtNtUaT5u6/qYutDNSdtF8sCoxNTKupsyMqC4sQ3J+Roqo7aoxxFizlAYmiKnGXc weor6kRUa6Acs9/mB6VU4wARVk2Lqu0= 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-401-xXIMYFZWMxuA4A0Dy_aSnQ-1; Mon, 07 Jun 2021 16:07:15 -0400 X-MC-Unique: xXIMYFZWMxuA4A0Dy_aSnQ-1 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 114B1188E3EA; Mon, 7 Jun 2021 20:06:54 +0000 (UTC) Received: from scv.redhat.com (ovpn-116-137.rdu2.redhat.com [10.10.116.137]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0C4F55C1C2; Mon, 7 Jun 2021 20:06:52 +0000 (UTC) From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH 03/42] scripts/qmp-shell: fix show_banner signature Date: Mon, 7 Jun 2021 16:06:10 -0400 Message-Id: <20210607200649.1840382-4-jsnow@redhat.com> In-Reply-To: <20210607200649.1840382-1-jsnow@redhat.com> References: <20210607200649.1840382-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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 Received-SPF: pass client-ip=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.2, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, 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: "Niteesh G . S ." , Cleber Rosa , John Snow , Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" The signatures need to match. Signed-off-by: John Snow --- scripts/qmp/qmp-shell | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/qmp/qmp-shell b/scripts/qmp/qmp-shell index 62a6377e06..18bf49bb26 100755 --- a/scripts/qmp/qmp-shell +++ b/scripts/qmp/qmp-shell @@ -389,8 +389,8 @@ class HMPShell(QMPShell): print('%s: %s' % (resp['error']['class'], resp['error']['desc'])) return True - def show_banner(self): - QMPShell.show_banner(self, msg='Welcome to the HMP shell!') + def show_banner(self, msg='Welcome to the HMP shell!'): + QMPShell.show_banner(self, msg) def die(msg): From patchwork Mon Jun 7 20:06:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Snow X-Patchwork-Id: 12304627 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 25655C4743F for ; Mon, 7 Jun 2021 20:15:01 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E2329610A2 for ; Mon, 7 Jun 2021 20:15:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E2329610A2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:52668 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lqLeF-0006oj-U8 for qemu-devel@archiver.kernel.org; Mon, 07 Jun 2021 16:15:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37472) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lqLWr-0003rt-KU for qemu-devel@nongnu.org; Mon, 07 Jun 2021 16:07:21 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:36487) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lqLWp-0006Si-Uk for qemu-devel@nongnu.org; Mon, 07 Jun 2021 16:07:21 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623096439; 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=m7ok7UfqnQu4C8bfP6m+OMxVFGZvV04Dyu9edtiQSoY=; b=Wsu2dO8pu7Hw1E5swHSm9Nf8tD/K8fRNd1DgkuSeugYTwpeByBGLeXdSJASPsfaAAqGvMn 9ITrxRyzh5XLrPj8A89gPXK1kTUVEQWf7HDLXqQuJ+240HiX6/1x2kEgtEAYIblBf2UlnA /Ia5KDhLHR8fWhflA5K+guHm7mGUXzo= 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-183-5jaGSu1aMt-7NlwIj2kjpg-1; Mon, 07 Jun 2021 16:07:18 -0400 X-MC-Unique: 5jaGSu1aMt-7NlwIj2kjpg-1 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id B48F2100A8E7; Mon, 7 Jun 2021 20:06:55 +0000 (UTC) Received: from scv.redhat.com (ovpn-116-137.rdu2.redhat.com [10.10.116.137]) by smtp.corp.redhat.com (Postfix) with ESMTP id 541C55C1C2; Mon, 7 Jun 2021 20:06:54 +0000 (UTC) From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH 04/42] scripts/qmp-shell: fix exception handling Date: Mon, 7 Jun 2021 16:06:11 -0400 Message-Id: <20210607200649.1840382-5-jsnow@redhat.com> In-Reply-To: <20210607200649.1840382-1-jsnow@redhat.com> References: <20210607200649.1840382-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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 Received-SPF: pass client-ip=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.2, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, 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: "Niteesh G . S ." , Cleber Rosa , John Snow , Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Fixes: 50d189c Signed-off-by: John Snow --- scripts/qmp/qmp-shell | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/qmp/qmp-shell b/scripts/qmp/qmp-shell index 18bf49bb26..413dd4d2de 100755 --- a/scripts/qmp/qmp-shell +++ b/scripts/qmp/qmp-shell @@ -452,7 +452,7 @@ def main(): die('Didn\'t get QMP greeting message') except qmp.QMPCapabilitiesError: die('Could not negotiate capabilities') - except qemu.error: + except OSError: die('Could not connect to %s' % addr) qemu.show_banner() From patchwork Mon Jun 7 20:06:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Snow X-Patchwork-Id: 12304601 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4495AC47094 for ; Mon, 7 Jun 2021 20:09:03 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E9204610A2 for ; Mon, 7 Jun 2021 20:09:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E9204610A2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:55346 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lqLYT-0006ev-Um for qemu-devel@archiver.kernel.org; Mon, 07 Jun 2021 16:09:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37398) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lqLWo-0003hC-AG for qemu-devel@nongnu.org; Mon, 07 Jun 2021 16:07:18 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:22903) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lqLWm-0006Qj-CG for qemu-devel@nongnu.org; Mon, 07 Jun 2021 16:07:18 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623096435; 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=Qi48lIsVIKb8lBGvQ8stajfgcwS816EsIq9sMv5s0Ck=; b=HXz5e/06BdIfOilmkLbSKm1K8vwxne2T7CWawvw05ScEQROqG9dpAAOLLwBtUwN7u3ctxz yqTpPIkK9st9ffxamWmOv4B10HO2oiiKTcxaVBwcdngvls0JGPJzJdNZjK7RzDrSA09SEU xqooxPyN1Mc6YQKqJ6Yev5Pm43auqIc= 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-494-7XoWuGtbPb-tjeIAP4S4mw-1; Mon, 07 Jun 2021 16:07:14 -0400 X-MC-Unique: 7XoWuGtbPb-tjeIAP4S4mw-1 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id C8C28801B28; Mon, 7 Jun 2021 20:06:56 +0000 (UTC) Received: from scv.redhat.com (ovpn-116-137.rdu2.redhat.com [10.10.116.137]) by smtp.corp.redhat.com (Postfix) with ESMTP id 08C945C1C2; Mon, 7 Jun 2021 20:06:55 +0000 (UTC) From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH 05/42] scripts/qmp-shell: fix connect method signature Date: Mon, 7 Jun 2021 16:06:12 -0400 Message-Id: <20210607200649.1840382-6-jsnow@redhat.com> In-Reply-To: <20210607200649.1840382-1-jsnow@redhat.com> References: <20210607200649.1840382-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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 Received-SPF: pass client-ip=170.10.133.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.2, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, 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: "Niteesh G . S ." , Cleber Rosa , John Snow , Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" It needs to match the parent's signature -- the negotiate parameter must be optional. Signed-off-by: John Snow --- scripts/qmp/qmp-shell | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/qmp/qmp-shell b/scripts/qmp/qmp-shell index 413dd4d2de..04ca6a25ae 100755 --- a/scripts/qmp/qmp-shell +++ b/scripts/qmp/qmp-shell @@ -278,7 +278,7 @@ class QMPShell(qmp.QEMUMonitorProtocol): self._print(resp) return True - def connect(self, negotiate): + def connect(self, negotiate: bool = True): self._greeting = super(QMPShell, self).connect(negotiate) self.__completer_setup() From patchwork Mon Jun 7 20:06:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Snow X-Patchwork-Id: 12304609 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,TVD_SUBJ_WIPE_DEBT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6D900C47082 for ; Mon, 7 Jun 2021 20:11:14 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3616F610A2 for ; Mon, 7 Jun 2021 20:11:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3616F610A2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:35596 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lqLab-0003qe-BL for qemu-devel@archiver.kernel.org; Mon, 07 Jun 2021 16:11:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37430) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lqLWp-0003kF-HI for qemu-devel@nongnu.org; Mon, 07 Jun 2021 16:07:19 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:22207) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lqLWo-0006Ra-1w for qemu-devel@nongnu.org; Mon, 07 Jun 2021 16:07:19 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623096437; 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=6y7myM7C/9x8pLsZE2iz6HtP3ygBnSV+r4dF/RLoDaE=; b=RdGjDjCe8TF2ugjrVwyled4uYqClx3QQR4+j73XY/lB2QEwhFZ3kuv+Ta4Wuuu/uMesN2o UiRHcIEFhgnrhx4Qdk7Qd4X/e+Txt1kZnvcnwX/lMzjU+kuYNrzTvkRYK3i7b+efJQMl8b K8tvOX+OS+5rSTlyLdHu6XdQtuVYlXk= 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-554-eJ2ME9IdPs2iKFFFJh4FTg-1; Mon, 07 Jun 2021 16:07:16 -0400 X-MC-Unique: eJ2ME9IdPs2iKFFFJh4FTg-1 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 04E92814245; Mon, 7 Jun 2021 20:06:58 +0000 (UTC) Received: from scv.redhat.com (ovpn-116-137.rdu2.redhat.com [10.10.116.137]) by smtp.corp.redhat.com (Postfix) with ESMTP id F00EC5C1C2; Mon, 7 Jun 2021 20:06:56 +0000 (UTC) From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH 06/42] scripts/qmp-shell: remove shadowed variable from _print() Date: Mon, 7 Jun 2021 16:06:13 -0400 Message-Id: <20210607200649.1840382-7-jsnow@redhat.com> In-Reply-To: <20210607200649.1840382-1-jsnow@redhat.com> References: <20210607200649.1840382-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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 Received-SPF: pass client-ip=170.10.133.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.2, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, TVD_SUBJ_WIPE_DEBT=1.004 autolearn=no 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: "Niteesh G . S ." , Cleber Rosa , John Snow , Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Don't use 'qmp' here, which shadows the qmp module. Signed-off-by: John Snow --- scripts/qmp/qmp-shell | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/qmp/qmp-shell b/scripts/qmp/qmp-shell index 04ca6a25ae..ae3f04534a 100755 --- a/scripts/qmp/qmp-shell +++ b/scripts/qmp/qmp-shell @@ -251,11 +251,11 @@ class QMPShell(qmp.QEMUMonitorProtocol): self.__cli_expr(cmdargs[1:], qmpcmd['arguments']) return qmpcmd - def _print(self, qmp): + def _print(self, qmp_message): indent = None if self._pretty: indent = 4 - jsobj = json.dumps(qmp, indent=indent, sort_keys=self._pretty) + jsobj = json.dumps(qmp_message, indent=indent, sort_keys=self._pretty) print(str(jsobj)) def _execute_cmd(self, cmdline): From patchwork Mon Jun 7 20:06:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Snow X-Patchwork-Id: 12304605 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 640F1C47082 for ; Mon, 7 Jun 2021 20:11:11 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 295286108C for ; Mon, 7 Jun 2021 20:11:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 295286108C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:35260 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lqLaY-0003dS-0h for qemu-devel@archiver.kernel.org; Mon, 07 Jun 2021 16:11:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37464) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lqLWr-0003qv-CD for qemu-devel@nongnu.org; Mon, 07 Jun 2021 16:07:21 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:50629) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lqLWo-0006Rc-2e for qemu-devel@nongnu.org; Mon, 07 Jun 2021 16:07:21 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623096437; 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=fzogaGZiY6L5dMlPB022TbNiw/6llfUwVWUlRX8W6+A=; b=IzgdBaLG/SHYYDgNv5+aAF1mRu/4ECKJkAy7FmqacY5opUfNYmO6KG/8TJJI7Pw0NlQeT9 wg2SyiC/43ZHpYinNzBw/8/Kh4Zh5BE4sVkNrx413AzARJWXi2372ILZ9BZRay4aU1eBXw C+M2E/J5coEgfUzMkl7rKiMpGn15Nyg= 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-508-1Skylt3TPoiReoG-hqYR1A-1; Mon, 07 Jun 2021 16:07:16 -0400 X-MC-Unique: 1Skylt3TPoiReoG-hqYR1A-1 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id DE30D804028; Mon, 7 Jun 2021 20:06:58 +0000 (UTC) Received: from scv.redhat.com (ovpn-116-137.rdu2.redhat.com [10.10.116.137]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2B5745C1C2; Mon, 7 Jun 2021 20:06:58 +0000 (UTC) From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH 07/42] scripts/qmp-shell: use @classmethod where appropriate Date: Mon, 7 Jun 2021 16:06:14 -0400 Message-Id: <20210607200649.1840382-8-jsnow@redhat.com> In-Reply-To: <20210607200649.1840382-1-jsnow@redhat.com> References: <20210607200649.1840382-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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 Received-SPF: pass client-ip=170.10.133.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.2, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, 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: "Niteesh G . S ." , Cleber Rosa , John Snow , Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Methods with no self-use should belong to the class. Signed-off-by: John Snow --- scripts/qmp/qmp-shell | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/scripts/qmp/qmp-shell b/scripts/qmp/qmp-shell index ae3f04534a..f354549bf2 100755 --- a/scripts/qmp/qmp-shell +++ b/scripts/qmp/qmp-shell @@ -97,7 +97,8 @@ class FuzzyJSON(ast.NodeTransformer): '''This extension of ast.NodeTransformer filters literal "true/false/null" values in an AST and replaces them by proper "True/False/None" values that Python can properly evaluate.''' - def visit_Name(self, node): + @classmethod + def visit_Name(cls, node): if node.id == 'true': node.id = 'True' if node.id == 'false': @@ -152,7 +153,8 @@ class QMPShell(qmp.QEMUMonitorProtocol): except Exception as e: print("Failed to save history file '%s'; %s" % (self._histfile, e)) - def __parse_value(self, val): + @classmethod + def __parse_value(cls, val): try: return int(val) except ValueError: From patchwork Mon Jun 7 20:06:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Snow X-Patchwork-Id: 12304643 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6100FC47094 for ; Mon, 7 Jun 2021 20:19:26 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 22E21610A2 for ; Mon, 7 Jun 2021 20:19:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 22E21610A2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:41416 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lqLiX-0001NT-0b for qemu-devel@archiver.kernel.org; Mon, 07 Jun 2021 16:19:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37556) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lqLWu-000428-CF for qemu-devel@nongnu.org; Mon, 07 Jun 2021 16:07:27 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:51466) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lqLWs-0006Ue-Kj for qemu-devel@nongnu.org; Mon, 07 Jun 2021 16:07:24 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623096442; 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=m3eZVpU1OwgWErmk/8aUvtXTtENNJP+HSbODrndiE8U=; b=VC1EsrxFoDY2F0VdVPgtZsncw1rZluRsE/7PLtQ8sF0mMfMGcCM10oFPhNM1IRnS0yYO6U uQlrID9xKQWsAGeO8DdZlDU6U77uDynv4osSv5q5yUs4rvLMtUZask11K9GKQVuIvgU3Lj qyvIwOpKyjDyo8KnAvpTHkKXVc/MRhc= 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-264-gwo6osCfO1qPNFtJTgxf-g-1; Mon, 07 Jun 2021 16:07:21 -0400 X-MC-Unique: gwo6osCfO1qPNFtJTgxf-g-1 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id E495910067A3; Mon, 7 Jun 2021 20:06:59 +0000 (UTC) Received: from scv.redhat.com (ovpn-116-137.rdu2.redhat.com [10.10.116.137]) by smtp.corp.redhat.com (Postfix) with ESMTP id 10A515C1C2; Mon, 7 Jun 2021 20:06:58 +0000 (UTC) From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH 08/42] scripts/qmp-shell: Use python3-style super() Date: Mon, 7 Jun 2021 16:06:15 -0400 Message-Id: <20210607200649.1840382-9-jsnow@redhat.com> In-Reply-To: <20210607200649.1840382-1-jsnow@redhat.com> References: <20210607200649.1840382-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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 Received-SPF: pass client-ip=170.10.133.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.2, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, 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: "Niteesh G . S ." , Cleber Rosa , John Snow , Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: John Snow --- scripts/qmp/qmp-shell | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/qmp/qmp-shell b/scripts/qmp/qmp-shell index f354549bf2..3066e37ae5 100755 --- a/scripts/qmp/qmp-shell +++ b/scripts/qmp/qmp-shell @@ -112,7 +112,7 @@ class FuzzyJSON(ast.NodeTransformer): # _execute_cmd()). Let's design a better one. class QMPShell(qmp.QEMUMonitorProtocol): def __init__(self, address, pretty=False): - super(QMPShell, self).__init__(self.parse_address(address)) + super().__init__(self.parse_address(address)) self._greeting = None self._completer = None self._pretty = pretty @@ -281,7 +281,7 @@ class QMPShell(qmp.QEMUMonitorProtocol): return True def connect(self, negotiate: bool = True): - self._greeting = super(QMPShell, self).connect(negotiate) + self._greeting = super().connect(negotiate) self.__completer_setup() def show_banner(self, msg='Welcome to the QMP low-level shell!'): @@ -322,7 +322,7 @@ class QMPShell(qmp.QEMUMonitorProtocol): class HMPShell(QMPShell): def __init__(self, address): - QMPShell.__init__(self, address) + super().__init__(address) self.__cpu_index = 0 def __cmd_completion(self): From patchwork Mon Jun 7 20:06:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Snow X-Patchwork-Id: 12304651 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 31E64C47095 for ; Mon, 7 Jun 2021 20:21:15 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CEF37610A2 for ; Mon, 7 Jun 2021 20:21:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CEF37610A2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:49970 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lqLkI-00076T-1k for qemu-devel@archiver.kernel.org; Mon, 07 Jun 2021 16:21:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37592) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lqLWy-000455-8O for qemu-devel@nongnu.org; Mon, 07 Jun 2021 16:07:28 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:52751) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lqLWs-0006Up-Tn for qemu-devel@nongnu.org; Mon, 07 Jun 2021 16:07:24 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623096442; 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=zHI3sotISO/+EmTZzDwTpTwkGuvzwEiSH5pIT1imIFE=; b=B56SAK7DoJzdfXPKU/IC7HExJYJa3QEOyO1V2PYser4x5RYyjuT5m6N2mKEOm8i0NPdH27 hx+7s6964LqP2yoFYqqr7zDXeOt7rISZN9YM+poq55jxmACyebvCrPKSm7tbNCbiPCqkBg UVcWVko6efVkFrLYADceAtOLUlCDvjA= 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-582-E9P5vzJdNsCZBPRNz1Ka2g-1; Mon, 07 Jun 2021 16:07:21 -0400 X-MC-Unique: E9P5vzJdNsCZBPRNz1Ka2g-1 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1E37C18BA29A; Mon, 7 Jun 2021 20:07:01 +0000 (UTC) Received: from scv.redhat.com (ovpn-116-137.rdu2.redhat.com [10.10.116.137]) by smtp.corp.redhat.com (Postfix) with ESMTP id 17C895C1C2; Mon, 7 Jun 2021 20:07:00 +0000 (UTC) From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH 09/42] scripts/qmp-shell: declare verbose in __init__ Date: Mon, 7 Jun 2021 16:06:16 -0400 Message-Id: <20210607200649.1840382-10-jsnow@redhat.com> In-Reply-To: <20210607200649.1840382-1-jsnow@redhat.com> References: <20210607200649.1840382-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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 Received-SPF: pass client-ip=170.10.133.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.2, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, 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: "Niteesh G . S ." , Cleber Rosa , John Snow , Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Linters get angry when we don't define state at init time. Signed-off-by: John Snow --- scripts/qmp/qmp-shell | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/qmp/qmp-shell b/scripts/qmp/qmp-shell index 3066e37ae5..4027454324 100755 --- a/scripts/qmp/qmp-shell +++ b/scripts/qmp/qmp-shell @@ -120,6 +120,7 @@ class QMPShell(qmp.QEMUMonitorProtocol): self._actions = list() self._histfile = os.path.join(os.path.expanduser('~'), '.qmp-shell_history') + self._verbose = False def _fill_completion(self): cmds = self.cmd('query-commands') From patchwork Mon Jun 7 20:06:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Snow X-Patchwork-Id: 12304607 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CF462C47094 for ; Mon, 7 Jun 2021 20:11:13 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 92ADE6108C for ; Mon, 7 Jun 2021 20:11:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 92ADE6108C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:35494 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lqLaa-0003mn-PF for qemu-devel@archiver.kernel.org; Mon, 07 Jun 2021 16:11:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37664) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lqLX1-0004BL-14 for qemu-devel@nongnu.org; Mon, 07 Jun 2021 16:07:31 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:39080) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lqLWt-0006VB-OO for qemu-devel@nongnu.org; Mon, 07 Jun 2021 16:07:30 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623096443; 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=lYEIEuOiUfczvUk0wccyUyookxEsbAjnVk/W2hoXNFg=; b=cCBAzDzO0EwKm1oJfWjc+nWPDK1yuSUvb4LCGJqnyOoh1wQYcWpCqiJIEq5LnZxHoNA4cw TUlxGA4ll4TVyldkMpdsNVo3CBgLe+zJpShV+/EBxv1+rtNjqC9+0UFikCwbGpR6ThaDav 1uk545xFX658Z6erdRVUqooDwQrtlXc= 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-449-PuF58be1OkqgHFX1yEE3jw-1; Mon, 07 Jun 2021 16:07:22 -0400 X-MC-Unique: PuF58be1OkqgHFX1yEE3jw-1 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5448C107AD46; Mon, 7 Jun 2021 20:07:02 +0000 (UTC) Received: from scv.redhat.com (ovpn-116-137.rdu2.redhat.com [10.10.116.137]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5FBBF5C1D1; Mon, 7 Jun 2021 20:07:01 +0000 (UTC) From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH 10/42] scripts/qmp-shell: use triple-double-quote docstring style Date: Mon, 7 Jun 2021 16:06:17 -0400 Message-Id: <20210607200649.1840382-11-jsnow@redhat.com> In-Reply-To: <20210607200649.1840382-1-jsnow@redhat.com> References: <20210607200649.1840382-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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 Received-SPF: pass client-ip=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.2, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, 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: "Niteesh G . S ." , Cleber Rosa , John Snow , Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" (2014 me had never written python before.) Signed-off-by: John Snow --- scripts/qmp/qmp-shell | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/scripts/qmp/qmp-shell b/scripts/qmp/qmp-shell index 4027454324..c46f4f516b 100755 --- a/scripts/qmp/qmp-shell +++ b/scripts/qmp/qmp-shell @@ -94,9 +94,12 @@ class QMPShellError(Exception): class FuzzyJSON(ast.NodeTransformer): - '''This extension of ast.NodeTransformer filters literal "true/false/null" + """ + This extension of ast.NodeTransformer filters literal "true/false/null" values in an AST and replaces them by proper "True/False/None" values that - Python can properly evaluate.''' + Python can properly evaluate. + """ + @classmethod def visit_Name(cls, node): if node.id == 'true': From patchwork Mon Jun 7 20:06:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Snow X-Patchwork-Id: 12304621 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3BA9DC47095 for ; Mon, 7 Jun 2021 20:13:05 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 07550610A1 for ; Mon, 7 Jun 2021 20:13:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 07550610A1 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:44314 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lqLcO-0001Hd-7G for qemu-devel@archiver.kernel.org; Mon, 07 Jun 2021 16:13:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37530) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lqLWt-0003yJ-Gg for qemu-devel@nongnu.org; Mon, 07 Jun 2021 16:07:23 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:37045) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lqLWr-0006Th-Gd for qemu-devel@nongnu.org; Mon, 07 Jun 2021 16:07:23 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623096440; 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=w+zqroIjrEg3wP3ptlzDIsDSmPg/VCScpYQYBpWF01Q=; b=AvBZcYqh3shXQBIxREPCmHv4BWHNmNVwJXOfVVtJFg/jg7biwLX5O/tDG0jsAJSpY8AUIT R3j0PTEn8e7NTMW5u+V3JiKJbXyrnQax6yVmf4v6z3EmTlnooXY7/FiQjRS8BfQ3qQwR1o MgDaeXJUwfCfD7BueGspB9HdH6gNf7Y= 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-531-5ByBGAr3NqevbP2kc6bg0w-1; Mon, 07 Jun 2021 16:07:19 -0400 X-MC-Unique: 5ByBGAr3NqevbP2kc6bg0w-1 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 369668145F3; Mon, 7 Jun 2021 20:07:03 +0000 (UTC) Received: from scv.redhat.com (ovpn-116-137.rdu2.redhat.com [10.10.116.137]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7A4BF5C1C2; Mon, 7 Jun 2021 20:07:02 +0000 (UTC) From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH 11/42] scripts/qmp-shell: ignore visit_Name name Date: Mon, 7 Jun 2021 16:06:18 -0400 Message-Id: <20210607200649.1840382-12-jsnow@redhat.com> In-Reply-To: <20210607200649.1840382-1-jsnow@redhat.com> References: <20210607200649.1840382-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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 Received-SPF: pass client-ip=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.2, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, 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: "Niteesh G . S ." , Cleber Rosa , John Snow , Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Not something I control, sorry, pylint. Signed-off-by: John Snow --- scripts/qmp/qmp-shell | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/qmp/qmp-shell b/scripts/qmp/qmp-shell index c46f4f516b..ea6a87e0b3 100755 --- a/scripts/qmp/qmp-shell +++ b/scripts/qmp/qmp-shell @@ -101,7 +101,7 @@ class FuzzyJSON(ast.NodeTransformer): """ @classmethod - def visit_Name(cls, node): + def visit_Name(cls, node): # pylint: disable=invalid-name if node.id == 'true': node.id = 'True' if node.id == 'false': From patchwork Mon Jun 7 20:06:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Snow X-Patchwork-Id: 12304599 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0E5B5C47082 for ; Mon, 7 Jun 2021 20:09:02 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A6C766108C for ; Mon, 7 Jun 2021 20:09:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A6C766108C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:55178 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lqLYS-0006YT-LY for qemu-devel@archiver.kernel.org; Mon, 07 Jun 2021 16:09:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37358) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lqLWn-0003f1-0Q for qemu-devel@nongnu.org; Mon, 07 Jun 2021 16:07:17 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:35862) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lqLWl-0006QO-GD for qemu-devel@nongnu.org; Mon, 07 Jun 2021 16:07:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623096435; 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=nMSwvQ6htUamofKSaidY7dBC0SMohCzKNif7cyoiNS4=; b=jR4llffAXW1a4/iwv6MhjNeRNefPHC3/pNkfcZll2yDDRIpudHuY519AuxrkD97BouYqFY hgKp2vFCSGpWj0bjfsAwYQIn7N3bDahs/nEZ4uDUtRn+nUY5k2xJpfeEe5voi3UK8fj6k6 8xDgkJuVjXaGu3QgOIQfLr76N4NbJYs= 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-360-OHIvBuhqOLqoDVo3nfcizw-1; Mon, 07 Jun 2021 16:07:13 -0400 X-MC-Unique: OHIvBuhqOLqoDVo3nfcizw-1 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 195B610529DA; Mon, 7 Jun 2021 20:07:04 +0000 (UTC) Received: from scv.redhat.com (ovpn-116-137.rdu2.redhat.com [10.10.116.137]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5E6905C1C2; Mon, 7 Jun 2021 20:07:03 +0000 (UTC) From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH 12/42] scripts/qmp-shell: make QMPCompleter returns explicit Date: Mon, 7 Jun 2021 16:06:19 -0400 Message-Id: <20210607200649.1840382-13-jsnow@redhat.com> In-Reply-To: <20210607200649.1840382-1-jsnow@redhat.com> References: <20210607200649.1840382-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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 Received-SPF: pass client-ip=170.10.133.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.2, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, 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: "Niteesh G . S ." , Cleber Rosa , John Snow , Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" This function returns None when it doesn't find a match; do that explicitly. Signed-off-by: John Snow --- scripts/qmp/qmp-shell | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/qmp/qmp-shell b/scripts/qmp/qmp-shell index ea6a87e0b3..8d84467b53 100755 --- a/scripts/qmp/qmp-shell +++ b/scripts/qmp/qmp-shell @@ -83,10 +83,10 @@ class QMPCompleter(list): def complete(self, text, state): for cmd in self: if cmd.startswith(text): - if not state: + if state == 0: return cmd - else: - state -= 1 + state -= 1 + return None class QMPShellError(Exception): From patchwork Mon Jun 7 20:06:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Snow X-Patchwork-Id: 12304669 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E84DBC47082 for ; Mon, 7 Jun 2021 20:25:22 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 70F8E610FB for ; Mon, 7 Jun 2021 20:25:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 70F8E610FB Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:38964 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lqLoH-0001ia-LT for qemu-devel@archiver.kernel.org; Mon, 07 Jun 2021 16:25:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38006) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lqLXQ-00050v-Mj for qemu-devel@nongnu.org; Mon, 07 Jun 2021 16:07:56 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:25929) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lqLX6-0006bI-Hx for qemu-devel@nongnu.org; Mon, 07 Jun 2021 16:07:56 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623096455; 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=8u1Vg37+JUQxC31C5AOgiFyu8sPopp/4P13GEoYJ798=; b=FZKJ4hqrYZKn7fYeSvzIANGQco2cCkIau30oq6LjrwM03uaNAhEN5O7vSny/o87tyeGHja PML2cR7MLEZY4jvHdxHWN/Nu2/3ojtyMA8fr+IYzNRSXpNYdpeIZ6Xu2u5B1j4u+/1Gs3Y ZrpGEmmp15LJ71XZG8tKH5ohX9nme0U= 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-583-hJbkSx-lNf2CBXvNoC_U_g-1; Mon, 07 Jun 2021 16:07:33 -0400 X-MC-Unique: hJbkSx-lNf2CBXvNoC_U_g-1 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6669280F042; Mon, 7 Jun 2021 20:07:05 +0000 (UTC) Received: from scv.redhat.com (ovpn-116-137.rdu2.redhat.com [10.10.116.137]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3FE625C1D1; Mon, 7 Jun 2021 20:07:04 +0000 (UTC) From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH 13/42] scripts/qmp-shell: rename one and two-letter variables Date: Mon, 7 Jun 2021 16:06:20 -0400 Message-Id: <20210607200649.1840382-14-jsnow@redhat.com> In-Reply-To: <20210607200649.1840382-1-jsnow@redhat.com> References: <20210607200649.1840382-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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 Received-SPF: pass client-ip=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.2, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, 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: "Niteesh G . S ." , Cleber Rosa , John Snow , Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" A bit of churn and housekeeping for pylint, flake8 et al. Signed-off-by: John Snow --- scripts/qmp/qmp-shell | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/scripts/qmp/qmp-shell b/scripts/qmp/qmp-shell index 8d84467b53..afb4b0c544 100755 --- a/scripts/qmp/qmp-shell +++ b/scripts/qmp/qmp-shell @@ -176,8 +176,8 @@ class QMPShell(qmp.QEMUMonitorProtocol): pass # Try once again as FuzzyJSON: try: - st = ast.parse(val, mode='eval') - return ast.literal_eval(FuzzyJSON().visit(st)) + tree = ast.parse(val, mode='eval') + return ast.literal_eval(FuzzyJSON().visit(tree)) except SyntaxError: pass except ValueError: @@ -195,14 +195,14 @@ class QMPShell(qmp.QEMUMonitorProtocol): value = self.__parse_value(val) optpath = key.split('.') curpath = [] - for p in optpath[:-1]: - curpath.append(p) - d = parent.get(p, {}) - if type(d) is not dict: + for path in optpath[:-1]: + curpath.append(path) + obj = parent.get(path, {}) + if type(obj) is not dict: msg = 'Cannot use "{:s}" as both leaf and non-leaf key' raise QMPShellError(msg.format('.'.join(curpath))) - parent[p] = d - parent = d + parent[path] = obj + parent = obj if optpath[-1] in parent: if type(parent[optpath[-1]]) is dict: msg = 'Cannot use "{:s}" as both leaf and non-leaf key' @@ -267,8 +267,8 @@ class QMPShell(qmp.QEMUMonitorProtocol): def _execute_cmd(self, cmdline): try: qmpcmd = self.__build_cmd(cmdline) - except Exception as e: - print('Error while parsing command line: %s' % e) + except Exception as err: + print('Error while parsing command line: %s' % err) print('command format: ', end=' ') print('[arg-name1=arg1] ... [arg-nameN=argN]') return True @@ -313,8 +313,8 @@ class QMPShell(qmp.QEMUMonitorProtocol): print() return False if cmdline == '': - for ev in self.get_events(): - print(ev) + for event in self.get_events(): + print(event) self.clear_events() return True else: From patchwork Mon Jun 7 20:06:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Snow X-Patchwork-Id: 12304639 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 74A4BC47082 for ; Mon, 7 Jun 2021 20:17:17 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3AE7E610A2 for ; Mon, 7 Jun 2021 20:17:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3AE7E610A2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:32962 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lqLgS-0004AU-Bt for qemu-devel@archiver.kernel.org; Mon, 07 Jun 2021 16:17:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37548) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lqLWu-00040r-3y for qemu-devel@nongnu.org; Mon, 07 Jun 2021 16:07:24 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:58541) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lqLWr-0006Td-CO for qemu-devel@nongnu.org; Mon, 07 Jun 2021 16:07:23 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623096440; 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=aFdMebTZtktL5NyDif849KWKWu9G8Vjv7Rd+8LY3fiE=; b=U0akUwGTh0mgpnazKRVbIbkrf2pAOVolhmU8NIZ9Lj32gmzoRQ4d9Gpeq15cTXgiH91BXm M5+ZaqTZS20J7ixZCbv5YEv7sjFc8Nj4WXNhJe1vDXoPJD1tjWNKqxPLZ/wEUyReIlS2HA 7SiFpT0HeQUwnr6iQia8yL3T049HMjc= 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-387-ntZYl8WHN8aMsJeQEz1hhQ-1; Mon, 07 Jun 2021 16:07:19 -0400 X-MC-Unique: ntZYl8WHN8aMsJeQEz1hhQ-1 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 66A7581843A; Mon, 7 Jun 2021 20:07:06 +0000 (UTC) Received: from scv.redhat.com (ovpn-116-137.rdu2.redhat.com [10.10.116.137]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9E50C5C1C2; Mon, 7 Jun 2021 20:07:05 +0000 (UTC) From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH 14/42] scripts/qmp-shell: fix shell history exception handling Date: Mon, 7 Jun 2021 16:06:21 -0400 Message-Id: <20210607200649.1840382-15-jsnow@redhat.com> In-Reply-To: <20210607200649.1840382-1-jsnow@redhat.com> References: <20210607200649.1840382-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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 Received-SPF: pass client-ip=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.2, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, 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: "Niteesh G . S ." , Cleber Rosa , John Snow , Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" We want to remove exceptions that are too broad here; we only want to catch IOErrors that get raised as a direct result of the open call. Signed-off-by: John Snow --- scripts/qmp/qmp-shell | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/scripts/qmp/qmp-shell b/scripts/qmp/qmp-shell index afb4b0c544..80cd432607 100755 --- a/scripts/qmp/qmp-shell +++ b/scripts/qmp/qmp-shell @@ -67,7 +67,6 @@ import ast import atexit -import errno import json import os import re @@ -143,19 +142,17 @@ class QMPShell(qmp.QEMUMonitorProtocol): readline.set_completer_delims('') try: readline.read_history_file(self._histfile) - except Exception as e: - if isinstance(e, IOError) and e.errno == errno.ENOENT: - # File not found. No problem. - pass - else: - print("Failed to read history '%s'; %s" % (self._histfile, e)) + except FileNotFoundError: + pass + except IOError as err: + print(f"Failed to read history '{self._histfile}': {err!s}") atexit.register(self.__save_history) def __save_history(self): try: readline.write_history_file(self._histfile) - except Exception as e: - print("Failed to save history file '%s'; %s" % (self._histfile, e)) + except IOError as err: + print(f"Failed to save history file '{self._histfile}': {err!s}") @classmethod def __parse_value(cls, val): From patchwork Mon Jun 7 20:06:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Snow X-Patchwork-Id: 12304647 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 81DDFC47082 for ; Mon, 7 Jun 2021 20:19:32 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 30825601FC for ; Mon, 7 Jun 2021 20:19:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 30825601FC Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:41940 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lqLid-0001iO-CZ for qemu-devel@archiver.kernel.org; Mon, 07 Jun 2021 16:19:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37688) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lqLX1-0004F0-V6 for qemu-devel@nongnu.org; Mon, 07 Jun 2021 16:07:32 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:34549) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lqLWt-0006Ux-DC for qemu-devel@nongnu.org; Mon, 07 Jun 2021 16:07:31 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623096442; 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=VTvYJjV0DdCsRUQ2Qj9FZq4CydYoH9OZSoyEzd+P5O4=; b=A3GSwaYBaBf69R5SfY+93RX6hj8esO3G0zqi60ZRqGvS2Llx3pCimsZ5EKPxua7q3cd2qS IJPrsx36I03LFnZR419qDmAh3NdA2PxGwLnuGPHfB3Jp+H2RhzBAL958770x4heDgrsw0T p6IpnPhG/Hv48Q8ArUtZABR9f2HKTDY= 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-28-W94eu-0IPjOGLihYocCOGw-1; Mon, 07 Jun 2021 16:07:19 -0400 X-MC-Unique: W94eu-0IPjOGLihYocCOGw-1 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 53D3A80EDB9; Mon, 7 Jun 2021 20:07:07 +0000 (UTC) Received: from scv.redhat.com (ovpn-116-137.rdu2.redhat.com [10.10.116.137]) by smtp.corp.redhat.com (Postfix) with ESMTP id 92BEE5C1C2; Mon, 7 Jun 2021 20:07:06 +0000 (UTC) From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH 15/42] scripts/qmp-shell: remove if-raise-else patterns Date: Mon, 7 Jun 2021 16:06:22 -0400 Message-Id: <20210607200649.1840382-16-jsnow@redhat.com> In-Reply-To: <20210607200649.1840382-1-jsnow@redhat.com> References: <20210607200649.1840382-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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 Received-SPF: pass client-ip=170.10.133.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.2, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, 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: "Niteesh G . S ." , Cleber Rosa , John Snow , Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Shushes pylint. I don't always mind these patterns personally, but I'm not as sure that I want to remove the warning from pylint's repertoire entirely. Oh well. Signed-off-by: John Snow --- scripts/qmp/qmp-shell | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/qmp/qmp-shell b/scripts/qmp/qmp-shell index 80cd432607..bf7a49dfc1 100755 --- a/scripts/qmp/qmp-shell +++ b/scripts/qmp/qmp-shell @@ -204,8 +204,7 @@ class QMPShell(qmp.QEMUMonitorProtocol): if type(parent[optpath[-1]]) is dict: msg = 'Cannot use "{:s}" as both leaf and non-leaf key' raise QMPShellError(msg.format('.'.join(curpath))) - else: - raise QMPShellError(f'Cannot set "{key}" multiple times') + raise QMPShellError(f'Cannot set "{key}" multiple times') parent[optpath[-1]] = value def __build_cmd(self, cmdline): @@ -309,13 +308,14 @@ class QMPShell(qmp.QEMUMonitorProtocol): except EOFError: print() return False + if cmdline == '': for event in self.get_events(): print(event) self.clear_events() return True - else: - return self._execute_cmd(cmdline) + + return self._execute_cmd(cmdline) def set_verbosity(self, verbose): self._verbose = verbose From patchwork Mon Jun 7 20:06:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Snow X-Patchwork-Id: 12304659 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 66B06C47082 for ; Mon, 7 Jun 2021 20:23:12 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 327D6610FB for ; Mon, 7 Jun 2021 20:23:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 327D6610FB Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:58440 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lqLmB-0004K1-5O for qemu-devel@archiver.kernel.org; Mon, 07 Jun 2021 16:23:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37698) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lqLX2-0004G7-Cn for qemu-devel@nongnu.org; Mon, 07 Jun 2021 16:07:32 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:51602) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lqLWy-0006WZ-13 for qemu-devel@nongnu.org; Mon, 07 Jun 2021 16:07:31 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623096445; 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=f7z4slaRs6UmoJ1JXsZshdZkQIHhnb0hvpgKg0Fce+w=; b=NbZw/cr9025MAzWT1RxY8wAj9R+eBmj0WHsaloCBhft+xoR3//6JKYQxJm4kPEYcY5yO15 mUytjNT1OUDBMDvCt/jda+gBqBV11SjgshWo3hQcEz4kHR62EdUN2xbFp7nZ7VPJrD4gKK 8hgST8xA/4n+garT/JzH7wR/ZRdveU0= 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-389-MT9dcRzCMT-HHz_lqpDZOg-1; Mon, 07 Jun 2021 16:07:24 -0400 X-MC-Unique: MT9dcRzCMT-HHz_lqpDZOg-1 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 25F1B107B466; Mon, 7 Jun 2021 20:07:09 +0000 (UTC) Received: from scv.redhat.com (ovpn-116-137.rdu2.redhat.com [10.10.116.137]) by smtp.corp.redhat.com (Postfix) with ESMTP id CE9435C1C2; Mon, 7 Jun 2021 20:07:07 +0000 (UTC) From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH 16/42] scripts/qmp-shell: use isinstance() instead of type() Date: Mon, 7 Jun 2021 16:06:23 -0400 Message-Id: <20210607200649.1840382-17-jsnow@redhat.com> In-Reply-To: <20210607200649.1840382-1-jsnow@redhat.com> References: <20210607200649.1840382-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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 Received-SPF: pass client-ip=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.2, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, 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: "Niteesh G . S ." , Cleber Rosa , John Snow , Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" A bit more idiomatic, and quiets some linter warnings. Signed-off-by: John Snow --- scripts/qmp/qmp-shell | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/qmp/qmp-shell b/scripts/qmp/qmp-shell index bf7a49dfc1..970f43dd00 100755 --- a/scripts/qmp/qmp-shell +++ b/scripts/qmp/qmp-shell @@ -195,13 +195,13 @@ class QMPShell(qmp.QEMUMonitorProtocol): for path in optpath[:-1]: curpath.append(path) obj = parent.get(path, {}) - if type(obj) is not dict: + if not isinstance(obj, dict): msg = 'Cannot use "{:s}" as both leaf and non-leaf key' raise QMPShellError(msg.format('.'.join(curpath))) parent[path] = obj parent = obj if optpath[-1] in parent: - if type(parent[optpath[-1]]) is dict: + if isinstance(parent[optpath[-1]], dict): msg = 'Cannot use "{:s}" as both leaf and non-leaf key' raise QMPShellError(msg.format('.'.join(curpath))) raise QMPShellError(f'Cannot set "{key}" multiple times') From patchwork Mon Jun 7 20:06:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Snow X-Patchwork-Id: 12304653 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 31E33C47094 for ; Mon, 7 Jun 2021 20:21:15 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id BA2E1601FC for ; Mon, 7 Jun 2021 20:21:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BA2E1601FC Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:49940 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lqLkH-00075B-Pq for qemu-devel@archiver.kernel.org; Mon, 07 Jun 2021 16:21:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37906) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lqLXL-0004iK-Px for qemu-devel@nongnu.org; Mon, 07 Jun 2021 16:07:51 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:25062) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lqLX1-0006aM-FI for qemu-devel@nongnu.org; Mon, 07 Jun 2021 16:07:51 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623096450; 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=TsGdxw3HZiTGbhxjycNjoxP0LdzwfbIW6vuKmMO6JTA=; b=jEOL0pyfm+J/EFN+jlJv5nFk5QkqVelztv9l3tX4U1mrhZc7XQAO3FaAk/Mq3igSGuYbjO 5p9x6ThLH5OiEogGHHQ9+kFCXbej4BjS8n3b3uX6jj3TNO6ChoV9sqxwsqIQmZduQuFGA+ Gbh94d2YLAlA0xG6aLNZRe2XrtGBXqU= 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-206-otBtEFFSN4mMmODQ9ZT0rQ-1; Mon, 07 Jun 2021 16:07:24 -0400 X-MC-Unique: otBtEFFSN4mMmODQ9ZT0rQ-1 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0E8E01074641; Mon, 7 Jun 2021 20:07:10 +0000 (UTC) Received: from scv.redhat.com (ovpn-116-137.rdu2.redhat.com [10.10.116.137]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4D71B5C1C2; Mon, 7 Jun 2021 20:07:09 +0000 (UTC) From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH 17/42] scripts/qmp-shell: use argparse Date: Mon, 7 Jun 2021 16:06:24 -0400 Message-Id: <20210607200649.1840382-18-jsnow@redhat.com> In-Reply-To: <20210607200649.1840382-1-jsnow@redhat.com> References: <20210607200649.1840382-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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 Received-SPF: pass client-ip=170.10.133.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.2, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, 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: "Niteesh G . S ." , Cleber Rosa , John Snow , Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Use argparse instead of an open-coded CLI parser, for consistency with everything else. Signed-off-by: John Snow --- scripts/qmp/qmp-shell | 82 +++++++++++++++++-------------------------- 1 file changed, 32 insertions(+), 50 deletions(-) diff --git a/scripts/qmp/qmp-shell b/scripts/qmp/qmp-shell index 970f43dd00..5317dcd516 100755 --- a/scripts/qmp/qmp-shell +++ b/scripts/qmp/qmp-shell @@ -64,7 +64,7 @@ # Use the -v and -p options to activate the verbose and pretty-print options, # which will echo back the properly formatted JSON-compliant QMP that is being # sent to QEMU, which is useful for debugging and documentation generation. - +import argparse import ast import atexit import json @@ -401,65 +401,47 @@ def die(msg): sys.exit(1) -def fail_cmdline(option=None): - if option: - sys.stderr.write('ERROR: bad command-line option \'%s\'\n' % option) - sys.stderr.write( - 'qmp-shell [ -v ] [ -p ] [ -H ] [ -N ] ' - '< UNIX socket path> | < TCP address:port >\n' - ) - sys.stderr.write(' -v Verbose (echo command sent and received)\n') - sys.stderr.write(' -p Pretty-print JSON\n') - sys.stderr.write(' -H Use HMP interface\n') - sys.stderr.write(' -N Skip negotiate (for qemu-ga)\n') - sys.exit(1) - - def main(): - addr = '' - qemu = None - hmp = False - pretty = False - verbose = False - negotiate = True + parser = argparse.ArgumentParser() + parser.add_argument('-H', '--hmp', action='store_true', + help='Use HMP interface') + parser.add_argument('-N', '--skip-negotiation', action='store_true', + help='Skip negotiate (for qemu-ga)') + parser.add_argument('-v', '--verbose', action='store_true', + help='Verbose (echo commands sent and received)') + parser.add_argument('-p', '--pretty', action='store_true', + help='Pretty-print JSON') + default_server = os.environ.get('QMP_SOCKET') + parser.add_argument('qmp_server', action='store', + default=default_server, + help='< UNIX socket path | TCP address:port >') + + args = parser.parse_args() + if args.qmp_server is None: + parser.error("QMP socket or TCP address must be specified") + + qemu: QMPShell try: - for arg in sys.argv[1:]: - if arg == "-H": - if qemu is not None: - fail_cmdline(arg) - hmp = True - elif arg == "-p": - pretty = True - elif arg == "-N": - negotiate = False - elif arg == "-v": - verbose = True - else: - if qemu is not None: - fail_cmdline(arg) - if hmp: - qemu = HMPShell(arg) - else: - qemu = QMPShell(arg, pretty) - addr = arg - - if qemu is None: - fail_cmdline() + if args.hmp: + qemu = HMPShell(args.qmp_server) + else: + qemu = QMPShell(args.qmp_server, args.pretty) except qmp.QMPBadPortError: - die('bad port number in command-line') + parser.error(f"Bad port number: {args.qmp_server}") + return # pycharm doesn't know error() is noreturn try: - qemu.connect(negotiate) + qemu.connect(negotiate=not args.skip_negotiation) except qmp.QMPConnectError: - die('Didn\'t get QMP greeting message') + die("Didn't get QMP greeting message") except qmp.QMPCapabilitiesError: - die('Could not negotiate capabilities') - except OSError: - die('Could not connect to %s' % addr) + die("Couldn't negotiate capabilities") + except OSError as err: + die(f"Couldn't connect to {args.qmp_server}: {err!s}") qemu.show_banner() - qemu.set_verbosity(verbose) + qemu.set_verbosity(args.verbose) while qemu.read_exec_command(qemu.get_prompt()): pass qemu.close() From patchwork Mon Jun 7 20:06:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Snow X-Patchwork-Id: 12304655 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 77239C47082 for ; Mon, 7 Jun 2021 20:21:20 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3D9F261108 for ; Mon, 7 Jun 2021 20:21:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3D9F261108 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:50522 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lqLkN-0007Sb-7O for qemu-devel@archiver.kernel.org; Mon, 07 Jun 2021 16:21:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37706) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lqLX2-0004H9-Im for qemu-devel@nongnu.org; Mon, 07 Jun 2021 16:07:32 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:43856) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lqLWy-0006WU-2S for qemu-devel@nongnu.org; Mon, 07 Jun 2021 16:07:32 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623096445; 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=P83Oz0etO9/+oEHLz0XwcO5PY8Ka7apyx/+3fDzVr6Y=; b=J7tBfEAFW7VdS930KCR8WkhbHWngu7H9NlZ+8MllplBgO5wXXGSDur/8MLahAcMgnV3CbM JQzrKfq75HHNSGWHAxVG/yuCR1aQslAr9FTHJ6Ph17y0siGfAWyuWfRY/cyQagt2bRerjj OhZaikJzL4jahPSysTlyUWK2wDsi9Sw= 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-138-05BgXlbmN6KZAI1Lmd0lYA-1; Mon, 07 Jun 2021 16:07:24 -0400 X-MC-Unique: 05BgXlbmN6KZAI1Lmd0lYA-1 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 674F6C73AB; Mon, 7 Jun 2021 20:07:11 +0000 (UTC) Received: from scv.redhat.com (ovpn-116-137.rdu2.redhat.com [10.10.116.137]) by smtp.corp.redhat.com (Postfix) with ESMTP id 34C7B5C1C2; Mon, 7 Jun 2021 20:07:10 +0000 (UTC) From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH 18/42] scripts/qmp-shell: Add pretty attribute to HMP shell Date: Mon, 7 Jun 2021 16:06:25 -0400 Message-Id: <20210607200649.1840382-19-jsnow@redhat.com> In-Reply-To: <20210607200649.1840382-1-jsnow@redhat.com> References: <20210607200649.1840382-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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 Received-SPF: pass client-ip=170.10.133.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.2, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, 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: "Niteesh G . S ." , Cleber Rosa , John Snow , Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" It's less useful, but it makes the initialization methods LSP consistent, which quiets a mypy complaint. Signed-off-by: John Snow --- scripts/qmp/qmp-shell | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/scripts/qmp/qmp-shell b/scripts/qmp/qmp-shell index 5317dcd516..de5fa189f0 100755 --- a/scripts/qmp/qmp-shell +++ b/scripts/qmp/qmp-shell @@ -322,8 +322,8 @@ class QMPShell(qmp.QEMUMonitorProtocol): class HMPShell(QMPShell): - def __init__(self, address): - super().__init__(address) + def __init__(self, address, pretty=False): + super().__init__(address, pretty) self.__cpu_index = 0 def __cmd_completion(self): @@ -421,12 +421,9 @@ def main(): if args.qmp_server is None: parser.error("QMP socket or TCP address must be specified") - qemu: QMPShell + shell_class = HMPShell if args.hmp else QMPShell try: - if args.hmp: - qemu = HMPShell(args.qmp_server) - else: - qemu = QMPShell(args.qmp_server, args.pretty) + qemu = shell_class(args.qmp_server, args.pretty) except qmp.QMPBadPortError: parser.error(f"Bad port number: {args.qmp_server}") return # pycharm doesn't know error() is noreturn From patchwork Mon Jun 7 20:06:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Snow X-Patchwork-Id: 12304641 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 63380C47094 for ; Mon, 7 Jun 2021 20:17:21 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2C55F601FC for ; Mon, 7 Jun 2021 20:17:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2C55F601FC Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:33386 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lqLgW-0004S9-9G for qemu-devel@archiver.kernel.org; Mon, 07 Jun 2021 16:17:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37640) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lqLX0-00049s-8P for qemu-devel@nongnu.org; Mon, 07 Jun 2021 16:07:30 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:22147) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lqLWt-0006V6-OO for qemu-devel@nongnu.org; Mon, 07 Jun 2021 16:07:30 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623096442; 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=0yi3zJ/W406FA0wH8HIrQXSAWRKf9EFPpOyS7sMrer8=; b=UA+7PllmgkXkBBPvx1BqbnCBqs04BbkaloQR332d8RXiqfEYQC/0qdyeqQ/cagsvybaiXN IkJ513gNJzQQ6iN6fu5nEmyokA+NJjfhYN2/SoYygDl54MkAtbe0akApHOFKKKR4zThD9B EZAD14s49rCj+QkFhRyvxgnaW4QjAU8= 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-376-AJR95NzSOy-r0Mag9JaFjQ-1; Mon, 07 Jun 2021 16:07:21 -0400 X-MC-Unique: AJR95NzSOy-r0Mag9JaFjQ-1 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 583451922987; Mon, 7 Jun 2021 20:07:12 +0000 (UTC) Received: from scv.redhat.com (ovpn-116-137.rdu2.redhat.com [10.10.116.137]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9B5725C1C2; Mon, 7 Jun 2021 20:07:11 +0000 (UTC) From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH 19/42] scripts/qmp-shell: Make verbose a public attribute Date: Mon, 7 Jun 2021 16:06:26 -0400 Message-Id: <20210607200649.1840382-20-jsnow@redhat.com> In-Reply-To: <20210607200649.1840382-1-jsnow@redhat.com> References: <20210607200649.1840382-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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 Received-SPF: pass client-ip=170.10.133.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.2, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, 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: "Niteesh G . S ." , Cleber Rosa , John Snow , Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" No real reason to hide this behind an underscore; make it part of the initializer and make it a regular RW attribute. Signed-off-by: John Snow --- scripts/qmp/qmp-shell | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/scripts/qmp/qmp-shell b/scripts/qmp/qmp-shell index de5fa189f0..cfcefb95f9 100755 --- a/scripts/qmp/qmp-shell +++ b/scripts/qmp/qmp-shell @@ -113,7 +113,7 @@ class FuzzyJSON(ast.NodeTransformer): # TODO: QMPShell's interface is a bit ugly (eg. _fill_completion() and # _execute_cmd()). Let's design a better one. class QMPShell(qmp.QEMUMonitorProtocol): - def __init__(self, address, pretty=False): + def __init__(self, address, pretty=False, verbose=False): super().__init__(self.parse_address(address)) self._greeting = None self._completer = None @@ -122,7 +122,7 @@ class QMPShell(qmp.QEMUMonitorProtocol): self._actions = list() self._histfile = os.path.join(os.path.expanduser('~'), '.qmp-shell_history') - self._verbose = False + self.verbose = verbose def _fill_completion(self): cmds = self.cmd('query-commands') @@ -271,7 +271,7 @@ class QMPShell(qmp.QEMUMonitorProtocol): # For transaction mode, we may have just cached the action: if qmpcmd is None: return True - if self._verbose: + if self.verbose: self._print(qmpcmd) resp = self.cmd_obj(qmpcmd) if resp is None: @@ -317,13 +317,10 @@ class QMPShell(qmp.QEMUMonitorProtocol): return self._execute_cmd(cmdline) - def set_verbosity(self, verbose): - self._verbose = verbose - class HMPShell(QMPShell): - def __init__(self, address, pretty=False): - super().__init__(address, pretty) + def __init__(self, address, pretty=False, verbose=False): + super().__init__(address, pretty, verbose) self.__cpu_index = 0 def __cmd_completion(self): @@ -423,7 +420,7 @@ def main(): shell_class = HMPShell if args.hmp else QMPShell try: - qemu = shell_class(args.qmp_server, args.pretty) + qemu = shell_class(args.qmp_server, args.pretty, args.verbose) except qmp.QMPBadPortError: parser.error(f"Bad port number: {args.qmp_server}") return # pycharm doesn't know error() is noreturn @@ -438,7 +435,6 @@ def main(): die(f"Couldn't connect to {args.qmp_server}: {err!s}") qemu.show_banner() - qemu.set_verbosity(args.verbose) while qemu.read_exec_command(qemu.get_prompt()): pass qemu.close() From patchwork Mon Jun 7 20:06:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Snow X-Patchwork-Id: 12304635 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 84CF3C47082 for ; Mon, 7 Jun 2021 20:17:14 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 44408610A2 for ; Mon, 7 Jun 2021 20:17:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 44408610A2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:60960 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lqLgP-000417-EP for qemu-devel@archiver.kernel.org; Mon, 07 Jun 2021 16:17:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37656) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lqLX0-0004AF-OQ for qemu-devel@nongnu.org; Mon, 07 Jun 2021 16:07:30 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:32674) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lqLWu-0006VR-6P for qemu-devel@nongnu.org; Mon, 07 Jun 2021 16:07:29 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623096443; 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=41nzjdfGcYxm08qpgzCMhR4G/L3vqz4EVmVVtqOyyKg=; b=BXZ3fapGGggFN8PovrdRtsnHHbuac/21ojnmViTbJrwee5cb/qUKN3XIgw/zTviE7981xe MFqtCnJMGnUnczMSLW15Q//66o/rKEVzMqNeyvqslfgetzbHtHqWCVdaWCBEZ2go8GZdGk l90xAOQIRBBuYRcIfqaDgaiuKVbtL2Q= 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-173-IGtoQkFgNUq63hzb0Fgp9w-1; Mon, 07 Jun 2021 16:07:22 -0400 X-MC-Unique: IGtoQkFgNUq63hzb0Fgp9w-1 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3860C192299A; Mon, 7 Jun 2021 20:07:13 +0000 (UTC) Received: from scv.redhat.com (ovpn-116-137.rdu2.redhat.com [10.10.116.137]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7E2765C1C2; Mon, 7 Jun 2021 20:07:12 +0000 (UTC) From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH 20/42] scripts/qmp-shell: move get_prompt() to prompt property Date: Mon, 7 Jun 2021 16:06:27 -0400 Message-Id: <20210607200649.1840382-21-jsnow@redhat.com> In-Reply-To: <20210607200649.1840382-1-jsnow@redhat.com> References: <20210607200649.1840382-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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 Received-SPF: pass client-ip=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.2, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, 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: "Niteesh G . S ." , Cleber Rosa , John Snow , Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Small tidying; treat "prompt" like an immutable property instead of function/method/routine. Signed-off-by: John Snow --- scripts/qmp/qmp-shell | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/scripts/qmp/qmp-shell b/scripts/qmp/qmp-shell index cfcefb95f9..3b86ef7d88 100755 --- a/scripts/qmp/qmp-shell +++ b/scripts/qmp/qmp-shell @@ -292,10 +292,11 @@ class QMPShell(qmp.QEMUMonitorProtocol): version = self._greeting['QMP']['version']['qemu'] print("Connected to QEMU {major}.{minor}.{micro}\n".format(**version)) - def get_prompt(self): + @property + def prompt(self): if self._transmode: - return "TRANS> " - return "(QEMU) " + return 'TRANS> ' + return '(QEMU) ' def read_exec_command(self, prompt): """ @@ -435,7 +436,7 @@ def main(): die(f"Couldn't connect to {args.qmp_server}: {err!s}") qemu.show_banner() - while qemu.read_exec_command(qemu.get_prompt()): + while qemu.read_exec_command(qemu.prompt): pass qemu.close() From patchwork Mon Jun 7 20:06:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Snow X-Patchwork-Id: 12304611 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F353BC47094 for ; Mon, 7 Jun 2021 20:11:15 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A37FE6108C for ; Mon, 7 Jun 2021 20:11:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A37FE6108C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:35722 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lqLac-0003wr-Pu for qemu-devel@archiver.kernel.org; Mon, 07 Jun 2021 16:11:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37498) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lqLWs-0003u6-Bc for qemu-devel@nongnu.org; Mon, 07 Jun 2021 16:07:22 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:20280) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lqLWq-0006Sq-Gu for qemu-devel@nongnu.org; Mon, 07 Jun 2021 16:07:22 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623096439; 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=7MGenEmQCy7A7wWLmQu/WXlCAa7L+/WkY6uv/P9+IJg=; b=J+083Ngh2AMe1nqeZMJGKWmBmlR9ESfPn8jvmC086b+4huqbbzcL+9hdRYoT6Vbbcx8jXH NjVDBZ3anrxTei08LbbScVdlRKaib1W2xVq3x8i2TzrKUKuqG0lAqdZymcl0UdOAHv7/Xz Mu5g7FJI/96MekEYikAdTX3XRyc0YH8= 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-562-xzbl0VztP6qjdXyHqHPm5Q-1; Mon, 07 Jun 2021 16:07:16 -0400 X-MC-Unique: xzbl0VztP6qjdXyHqHPm5Q-1 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7A41B106BD1E; Mon, 7 Jun 2021 20:07:14 +0000 (UTC) Received: from scv.redhat.com (ovpn-116-137.rdu2.redhat.com [10.10.116.137]) by smtp.corp.redhat.com (Postfix) with ESMTP id 651A15C1C2; Mon, 7 Jun 2021 20:07:13 +0000 (UTC) From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH 21/42] scripts/qmp-shell: remove prompt argument from read_exec_command Date: Mon, 7 Jun 2021 16:06:28 -0400 Message-Id: <20210607200649.1840382-22-jsnow@redhat.com> In-Reply-To: <20210607200649.1840382-1-jsnow@redhat.com> References: <20210607200649.1840382-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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 Received-SPF: pass client-ip=170.10.133.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.2, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, 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: "Niteesh G . S ." , Cleber Rosa , John Snow , Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" It's only ever used by one caller, we can just absorb that logic. Signed-off-by: John Snow --- scripts/qmp/qmp-shell | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/qmp/qmp-shell b/scripts/qmp/qmp-shell index 3b86ef7d88..31269859c4 100755 --- a/scripts/qmp/qmp-shell +++ b/scripts/qmp/qmp-shell @@ -298,14 +298,14 @@ class QMPShell(qmp.QEMUMonitorProtocol): return 'TRANS> ' return '(QEMU) ' - def read_exec_command(self, prompt): + def read_exec_command(self): """ Read and execute a command. @return True if execution was ok, return False if disconnected. """ try: - cmdline = input(prompt) + cmdline = input(self.prompt) except EOFError: print() return False @@ -436,7 +436,7 @@ def main(): die(f"Couldn't connect to {args.qmp_server}: {err!s}") qemu.show_banner() - while qemu.read_exec_command(qemu.prompt): + while qemu.read_exec_command(): pass qemu.close() From patchwork Mon Jun 7 20:06:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Snow X-Patchwork-Id: 12304679 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5571AC47082 for ; Mon, 7 Jun 2021 20:28:26 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0EDEF61153 for ; Mon, 7 Jun 2021 20:28:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0EDEF61153 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:52014 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lqLrE-00022C-Sp for qemu-devel@archiver.kernel.org; Mon, 07 Jun 2021 16:28:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37826) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lqLXF-0004Xg-LS for qemu-devel@nongnu.org; Mon, 07 Jun 2021 16:07:45 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:56919) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lqLWz-0006YO-74 for qemu-devel@nongnu.org; Mon, 07 Jun 2021 16:07:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623096448; 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=6JFYZ5aWR4oY4cjKUnYQGoBn1ZloRqHNXwD6Qoqasz0=; b=X4k62bnYkgYW8l3mktiv3tL6oQSqYG1MwbGyvy4y2gxAzkcXYdfsk2cpsL8CIyr+G9rN5i RgAZpld6YLnxFfMKv8S3hcl/vkVTja1oZQjeAHa/iOukLFj22B8wU9X/OhSR+oM9I6gIms FzVKtrF7ahFlkGOulNqMiDDBEs8w0OQ= 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-257-fGPw07k0MDWeotn2hC3ahg-1; Mon, 07 Jun 2021 16:07:27 -0400 X-MC-Unique: fGPw07k0MDWeotn2hC3ahg-1 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 063BC106F8FB; Mon, 7 Jun 2021 20:07:16 +0000 (UTC) Received: from scv.redhat.com (ovpn-116-137.rdu2.redhat.com [10.10.116.137]) by smtp.corp.redhat.com (Postfix) with ESMTP id BCF485C1C2; Mon, 7 Jun 2021 20:07:14 +0000 (UTC) From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH 22/42] scripts/qmp-shell: move the REPL functionality into QMPShell Date: Mon, 7 Jun 2021 16:06:29 -0400 Message-Id: <20210607200649.1840382-23-jsnow@redhat.com> In-Reply-To: <20210607200649.1840382-1-jsnow@redhat.com> References: <20210607200649.1840382-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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 Received-SPF: pass client-ip=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.2, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable 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: "Niteesh G . S ." , Cleber Rosa , John Snow , Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Instead of doing this in main, move it into the class itself. (This makes it easier to put into the qemu.qmp package later by removing as much as we can from the main() function.) Signed-off-by: John Snow --- scripts/qmp/qmp-shell | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/scripts/qmp/qmp-shell b/scripts/qmp/qmp-shell index 31269859c4..aa148517a8 100755 --- a/scripts/qmp/qmp-shell +++ b/scripts/qmp/qmp-shell @@ -318,6 +318,12 @@ class QMPShell(qmp.QEMUMonitorProtocol): return self._execute_cmd(cmdline) + def repl(self): + self.show_banner() + while self.read_exec_command(): + yield + self.close() + class HMPShell(QMPShell): def __init__(self, address, pretty=False, verbose=False): @@ -435,10 +441,8 @@ def main(): except OSError as err: die(f"Couldn't connect to {args.qmp_server}: {err!s}") - qemu.show_banner() - while qemu.read_exec_command(): + for _ in qemu.repl(): pass - qemu.close() if __name__ == '__main__': From patchwork Mon Jun 7 20:06:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Snow X-Patchwork-Id: 12304657 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9488DC47082 for ; Mon, 7 Jun 2021 20:22:03 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5B16660FE9 for ; Mon, 7 Jun 2021 20:22:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5B16660FE9 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:52824 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lqLl4-0000bZ-Dn for qemu-devel@archiver.kernel.org; Mon, 07 Jun 2021 16:22:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37794) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lqLXE-0004SR-FA for qemu-devel@nongnu.org; Mon, 07 Jun 2021 16:07:44 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:39062) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lqLWy-0006YF-OM for qemu-devel@nongnu.org; Mon, 07 Jun 2021 16:07:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623096448; 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=6I1ffH67Oby/X5z1JMtzleyrDhl2w0HdTScRKZu2wHk=; b=ctLrRs7lfquP7Pg5MLS7Ng5i/KlzHJ9ZLKj1ghuLhvfZepTk0H82HMo9S7BwDwDjOoEeuT yNxPTdcS5I+GS56p4DaBoCZKViZ6MzRrccW4OBQAAkYst/2S2lmsituoE1uVsnrcCw09Nj 2MrANXUivtu4lqizDVKUTDvG+cDJ+5Y= 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-481-hpqAkDckMUWLXq2LGbK_EA-1; Mon, 07 Jun 2021 16:07:24 -0400 X-MC-Unique: hpqAkDckMUWLXq2LGbK_EA-1 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0A6FB19251CE; Mon, 7 Jun 2021 20:07:17 +0000 (UTC) Received: from scv.redhat.com (ovpn-116-137.rdu2.redhat.com [10.10.116.137]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4EC055C1C2; Mon, 7 Jun 2021 20:07:16 +0000 (UTC) From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH 23/42] scripts/qmp-shell: Fix "FuzzyJSON" parser Date: Mon, 7 Jun 2021 16:06:30 -0400 Message-Id: <20210607200649.1840382-24-jsnow@redhat.com> In-Reply-To: <20210607200649.1840382-1-jsnow@redhat.com> References: <20210607200649.1840382-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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 Received-SPF: pass client-ip=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.2, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable 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: "Niteesh G . S ." , Cleber Rosa , John Snow , Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" I'm not sure when this regressed (Or maybe if it was ever working right to begin with?), but the Python AST requires you to change "Names" to "Constants" in order to truly convert `false` to `False`. Signed-off-by: John Snow --- scripts/qmp/qmp-shell | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/scripts/qmp/qmp-shell b/scripts/qmp/qmp-shell index aa148517a8..847d34890f 100755 --- a/scripts/qmp/qmp-shell +++ b/scripts/qmp/qmp-shell @@ -95,18 +95,19 @@ class QMPShellError(Exception): class FuzzyJSON(ast.NodeTransformer): """ This extension of ast.NodeTransformer filters literal "true/false/null" - values in an AST and replaces them by proper "True/False/None" values that - Python can properly evaluate. + values in a Python AST and replaces them by proper "True/False/None" values + that Python can properly evaluate. """ @classmethod - def visit_Name(cls, node): # pylint: disable=invalid-name + def visit_Name(cls, # pylint: disable=invalid-name + node: ast.Name) -> ast.AST: if node.id == 'true': - node.id = 'True' + return ast.Constant(value=True) if node.id == 'false': - node.id = 'False' + return ast.Constant(value=False) if node.id == 'null': - node.id = 'None' + return ast.Constant(value=None) return node @@ -174,10 +175,9 @@ class QMPShell(qmp.QEMUMonitorProtocol): # Try once again as FuzzyJSON: try: tree = ast.parse(val, mode='eval') - return ast.literal_eval(FuzzyJSON().visit(tree)) - except SyntaxError: - pass - except ValueError: + transformed = FuzzyJSON().visit(tree) + return ast.literal_eval(transformed) + except (SyntaxError, ValueError): pass return val From patchwork Mon Jun 7 20:06:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Snow X-Patchwork-Id: 12304617 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1882AC47094 for ; Mon, 7 Jun 2021 20:13:01 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id BF478610A1 for ; Mon, 7 Jun 2021 20:13:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BF478610A1 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:44054 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lqLcJ-00017S-ME for qemu-devel@archiver.kernel.org; Mon, 07 Jun 2021 16:12:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37732) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lqLX4-0004Ju-IS for qemu-devel@nongnu.org; Mon, 07 Jun 2021 16:07:34 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:24409) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lqLWy-0006Wi-3M for qemu-devel@nongnu.org; Mon, 07 Jun 2021 16:07:32 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623096445; 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=+UWpmj4W74ZQ6psp83CzBWcMlKbSUwNHNbqQljXJPJs=; b=SAtGwZnRXkH2o7sZWr6j6KI5sUHqDm2107z+YhMqluKXvmfWTZU0BnTdan+RwYhphtLRfZ EOYIOiXGodCLMlhBUrT4b7gs1bjUxV3J4Z/d/E3WdcdGNk46jgi1hoy/OR1h5zIsii/iyI RQvAgW/fm2i8j5cqBga9du0OHyUGqSg= 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-250-XkM1FuS2P1O_IFfEksk6lA-1; Mon, 07 Jun 2021 16:07:24 -0400 X-MC-Unique: XkM1FuS2P1O_IFfEksk6lA-1 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id E132D8042D1; Mon, 7 Jun 2021 20:07:17 +0000 (UTC) Received: from scv.redhat.com (ovpn-116-137.rdu2.redhat.com [10.10.116.137]) by smtp.corp.redhat.com (Postfix) with ESMTP id 349F15C1C2; Mon, 7 Jun 2021 20:07:17 +0000 (UTC) From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH 24/42] scripts/qmp-shell: refactor QMPCompleter Date: Mon, 7 Jun 2021 16:06:31 -0400 Message-Id: <20210607200649.1840382-25-jsnow@redhat.com> In-Reply-To: <20210607200649.1840382-1-jsnow@redhat.com> References: <20210607200649.1840382-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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 Received-SPF: pass client-ip=170.10.133.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.2, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, 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: "Niteesh G . S ." , Cleber Rosa , John Snow , Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" list is a generic type, but we expect to use strings directly. We could subclass list[str], but pylint does not presently understand that invocation. Change this class to envelop a list instead of *being* a list, for simpler mypy typing. Signed-off-by: John Snow --- scripts/qmp/qmp-shell | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/scripts/qmp/qmp-shell b/scripts/qmp/qmp-shell index 847d34890f..73694035b2 100755 --- a/scripts/qmp/qmp-shell +++ b/scripts/qmp/qmp-shell @@ -78,9 +78,17 @@ sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'python')) from qemu import qmp -class QMPCompleter(list): - def complete(self, text, state): - for cmd in self: +class QMPCompleter: + # NB: Python 3.9+ will probably allow us to subclass list[str] directly, + # but pylint as of today does not know that List[str] is simply 'list'. + def __init__(self) -> None: + self._matches: List[str] = [] + + def append(self, value: str) -> None: + return self._matches.append(value) + + def complete(self, text: str, state: int) -> Optional[str]: + for cmd in self._matches: if cmd.startswith(text): if state == 0: return cmd From patchwork Mon Jun 7 20:06:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Snow X-Patchwork-Id: 12304623 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D0A32C47082 for ; Mon, 7 Jun 2021 20:14:58 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 73612610A2 for ; Mon, 7 Jun 2021 20:14:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 73612610A2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:52408 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lqLeD-0006eg-Cw for qemu-devel@archiver.kernel.org; Mon, 07 Jun 2021 16:14:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37596) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lqLWy-00045Y-BE for qemu-devel@nongnu.org; Mon, 07 Jun 2021 16:07:28 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:53578) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lqLWr-0006Tv-Om for qemu-devel@nongnu.org; Mon, 07 Jun 2021 16:07:28 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623096441; 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=iN1p6DfzIVIssCxn/al08/xzeOUyneYx8OUH3UbSuKQ=; b=HSORugfmeHGRBGR7gQupE/YAEKBnRtio9r8xHBZuBL0wBjx6KSurAgioeK0C5ZXV56NNk9 kaC/HMncM0UnHAvnWNKGWB7vNNg/p5BpLLC6SpoHSbygyT0OP3vwuKLlAZIfnJb5yqJLXD NSiKjx3qDvvTDGmGLqC6LQCUFua9XbQ= 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-48-B8wM4bSmPdCDpjDMJQnjtw-1; Mon, 07 Jun 2021 16:07:19 -0400 X-MC-Unique: B8wM4bSmPdCDpjDMJQnjtw-1 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id C527F108C22E; Mon, 7 Jun 2021 20:07:18 +0000 (UTC) Received: from scv.redhat.com (ovpn-116-137.rdu2.redhat.com [10.10.116.137]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1379E5C1C2; Mon, 7 Jun 2021 20:07:17 +0000 (UTC) From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH 25/42] scripts/qmp-shell: initialize completer early Date: Mon, 7 Jun 2021 16:06:32 -0400 Message-Id: <20210607200649.1840382-26-jsnow@redhat.com> In-Reply-To: <20210607200649.1840382-1-jsnow@redhat.com> References: <20210607200649.1840382-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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 Received-SPF: pass client-ip=170.10.133.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.2, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, 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: "Niteesh G . S ." , Cleber Rosa , John Snow , Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Add an empty completer as a more type-safe placeholder instead of 'None'. Signed-off-by: John Snow --- scripts/qmp/qmp-shell | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/qmp/qmp-shell b/scripts/qmp/qmp-shell index 73694035b2..670361322c 100755 --- a/scripts/qmp/qmp-shell +++ b/scripts/qmp/qmp-shell @@ -125,7 +125,7 @@ class QMPShell(qmp.QEMUMonitorProtocol): def __init__(self, address, pretty=False, verbose=False): super().__init__(self.parse_address(address)) self._greeting = None - self._completer = None + self._completer = QMPCompleter() self._pretty = pretty self._transmode = False self._actions = list() From patchwork Mon Jun 7 20:06:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Snow X-Patchwork-Id: 12304649 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6ABE6C47095 for ; Mon, 7 Jun 2021 20:19:54 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 198AA610A2 for ; Mon, 7 Jun 2021 20:19:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 198AA610A2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:44316 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lqLiz-0003I5-8a for qemu-devel@archiver.kernel.org; Mon, 07 Jun 2021 16:19:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37788) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lqLXE-0004RR-8c for qemu-devel@nongnu.org; Mon, 07 Jun 2021 16:07:44 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:59043) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lqLWz-0006YM-73 for qemu-devel@nongnu.org; Mon, 07 Jun 2021 16:07:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623096448; 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=zZz5DZjerOVbN/xV4beZ8e7VKezfVNObonBZzZKxPdE=; b=hsZN3Y/WyBWcP4TSPxbKU66yddCedg6WTUMGPbhS6loypAcZMcbO5OtS4QamN+gzJkuJoH 0FrXk3SXDEenAhsF0PLYqZJUio7sb3gj5vALmNKNhzt+m1IBUJI+iKbqpillZ+je5vWEva 69DbcSBbudrqMciFPuR/gg5rvLz5780= 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-337-WU780hVsMTmU6apGk9641g-1; Mon, 07 Jun 2021 16:07:27 -0400 X-MC-Unique: WU780hVsMTmU6apGk9641g-1 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id A7580CC62B; Mon, 7 Jun 2021 20:07:19 +0000 (UTC) Received: from scv.redhat.com (ovpn-116-137.rdu2.redhat.com [10.10.116.137]) by smtp.corp.redhat.com (Postfix) with ESMTP id ECC1C5C1C2; Mon, 7 Jun 2021 20:07:18 +0000 (UTC) From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH 26/42] python/qmp: add QMPObject type alias Date: Mon, 7 Jun 2021 16:06:33 -0400 Message-Id: <20210607200649.1840382-27-jsnow@redhat.com> In-Reply-To: <20210607200649.1840382-1-jsnow@redhat.com> References: <20210607200649.1840382-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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 Received-SPF: pass client-ip=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.2, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable 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: "Niteesh G . S ." , Cleber Rosa , John Snow , Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" This is meant to represent any generic object seen in a QMPMessage, not just the root object itself. Signed-off-by: John Snow --- python/qemu/qmp/__init__.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/python/qemu/qmp/__init__.py b/python/qemu/qmp/__init__.py index a6e1a7b857..ba0d2281d6 100644 --- a/python/qemu/qmp/__init__.py +++ b/python/qemu/qmp/__init__.py @@ -41,6 +41,9 @@ #: QMPReturnValue is the 'return' value of a command. QMPReturnValue = object +#: QMPObject is any object in a QMP message. +QMPObject = Dict[str, object] + # QMPMessage can be outgoing commands or incoming events/returns. # QMPReturnValue is usually a dict/json object, but due to QAPI's # 'returns-whitelist', it can actually be anything. From patchwork Mon Jun 7 20:06:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Snow X-Patchwork-Id: 12304629 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6364BC47094 for ; Mon, 7 Jun 2021 20:15:04 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0957E61073 for ; Mon, 7 Jun 2021 20:15:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0957E61073 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:52964 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lqLeJ-00070Z-1h for qemu-devel@archiver.kernel.org; Mon, 07 Jun 2021 16:15:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37614) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lqLWy-00046o-VT for qemu-devel@nongnu.org; Mon, 07 Jun 2021 16:07:28 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:23504) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lqLWt-0006V4-IN for qemu-devel@nongnu.org; Mon, 07 Jun 2021 16:07:28 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623096442; 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=X67zZQznA/dmqztz2ytUiTTb1EaymoszsnIuKjXCVEg=; b=ctQpGeBpCxeU1xrCYu+WWHf0nN0rqR5nyQJjltcyXseV20usQ/7Ocp6n2G+KGlLXflFRcz pK4+qrldHH1ib/0i+XeeoNHj+F1WbcGjtuXJ0m/Cw4oqr5jx5/FBHE1Xg6wj1Fq2CpzHo8 MqPd9SOy5eqhFvZLLKCKssp9GqXDVkI= 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-356-kyn71RS_OS2MWPcv8Vb6iA-1; Mon, 07 Jun 2021 16:07:21 -0400 X-MC-Unique: kyn71RS_OS2MWPcv8Vb6iA-1 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id BEC27108C2AD; Mon, 7 Jun 2021 20:07:20 +0000 (UTC) Received: from scv.redhat.com (ovpn-116-137.rdu2.redhat.com [10.10.116.137]) by smtp.corp.redhat.com (Postfix) with ESMTP id CDFC05C1C2; Mon, 7 Jun 2021 20:07:19 +0000 (UTC) From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH 27/42] scripts/qmp-shell: add mypy types Date: Mon, 7 Jun 2021 16:06:34 -0400 Message-Id: <20210607200649.1840382-28-jsnow@redhat.com> In-Reply-To: <20210607200649.1840382-1-jsnow@redhat.com> References: <20210607200649.1840382-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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 Received-SPF: pass client-ip=170.10.133.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.2, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, 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: "Niteesh G . S ." , Cleber Rosa , John Snow , Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" As per my usual, this patch is annotations only. Any changes with side effects are done elsewhere. Note: pylint does not understand the subscripts for Collection in Python 3.6, so use the stronger Sequence type as a workaround. Signed-off-by: John Snow --- scripts/qmp/qmp-shell | 67 ++++++++++++++++++++++++++----------------- 1 file changed, 41 insertions(+), 26 deletions(-) diff --git a/scripts/qmp/qmp-shell b/scripts/qmp/qmp-shell index 670361322c..2d0e85b5f7 100755 --- a/scripts/qmp/qmp-shell +++ b/scripts/qmp/qmp-shell @@ -72,10 +72,18 @@ import os import re import readline import sys +from typing import ( + Iterator, + List, + NoReturn, + Optional, + Sequence, +) sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'python')) from qemu import qmp +from qemu.qmp import QMPMessage class QMPCompleter: @@ -122,25 +130,26 @@ class FuzzyJSON(ast.NodeTransformer): # TODO: QMPShell's interface is a bit ugly (eg. _fill_completion() and # _execute_cmd()). Let's design a better one. class QMPShell(qmp.QEMUMonitorProtocol): - def __init__(self, address, pretty=False, verbose=False): + def __init__(self, address: str, pretty: bool = False, + verbose: bool = False): super().__init__(self.parse_address(address)) - self._greeting = None + self._greeting: Optional[QMPMessage] = None self._completer = QMPCompleter() self._pretty = pretty self._transmode = False - self._actions = list() + self._actions: List[QMPMessage] = [] self._histfile = os.path.join(os.path.expanduser('~'), '.qmp-shell_history') self.verbose = verbose - def _fill_completion(self): + def _fill_completion(self) -> None: cmds = self.cmd('query-commands') if 'error' in cmds: return for cmd in cmds['return']: self._completer.append(cmd['name']) - def __completer_setup(self): + def __completer_setup(self) -> None: self._completer = QMPCompleter() self._fill_completion() readline.set_history_length(1024) @@ -157,14 +166,14 @@ class QMPShell(qmp.QEMUMonitorProtocol): print(f"Failed to read history '{self._histfile}': {err!s}") atexit.register(self.__save_history) - def __save_history(self): + def __save_history(self) -> None: try: readline.write_history_file(self._histfile) except IOError as err: print(f"Failed to save history file '{self._histfile}': {err!s}") @classmethod - def __parse_value(cls, val): + def __parse_value(cls, val: str) -> object: try: return int(val) except ValueError: @@ -189,7 +198,9 @@ class QMPShell(qmp.QEMUMonitorProtocol): pass return val - def __cli_expr(self, tokens, parent): + def __cli_expr(self, + tokens: Sequence[str], + parent: qmp.QMPObject) -> None: for arg in tokens: (key, sep, val) = arg.partition('=') if sep != '=': @@ -215,7 +226,7 @@ class QMPShell(qmp.QEMUMonitorProtocol): raise QMPShellError(f'Cannot set "{key}" multiple times') parent[optpath[-1]] = value - def __build_cmd(self, cmdline): + def __build_cmd(self, cmdline: str) -> Optional[QMPMessage]: """ Build a QMP input object from a user provided command-line in the following format: @@ -224,6 +235,7 @@ class QMPShell(qmp.QEMUMonitorProtocol): """ argument_regex = r'''(?:[^\s"']|"(?:\\.|[^"])*"|'(?:\\.|[^'])*')+''' cmdargs = re.findall(argument_regex, cmdline) + qmpcmd: QMPMessage # Transactional CLI entry/exit: if cmdargs[0] == 'transaction(': @@ -261,14 +273,14 @@ class QMPShell(qmp.QEMUMonitorProtocol): self.__cli_expr(cmdargs[1:], qmpcmd['arguments']) return qmpcmd - def _print(self, qmp_message): + def _print(self, qmp_message: object) -> None: indent = None if self._pretty: indent = 4 jsobj = json.dumps(qmp_message, indent=indent, sort_keys=self._pretty) print(str(jsobj)) - def _execute_cmd(self, cmdline): + def _execute_cmd(self, cmdline: str) -> bool: try: qmpcmd = self.__build_cmd(cmdline) except Exception as err: @@ -288,11 +300,12 @@ class QMPShell(qmp.QEMUMonitorProtocol): self._print(resp) return True - def connect(self, negotiate: bool = True): + def connect(self, negotiate: bool = True) -> None: self._greeting = super().connect(negotiate) self.__completer_setup() - def show_banner(self, msg='Welcome to the QMP low-level shell!'): + def show_banner(self, + msg: str = 'Welcome to the QMP low-level shell!') -> None: print(msg) if not self._greeting: print('Connected') @@ -301,12 +314,12 @@ class QMPShell(qmp.QEMUMonitorProtocol): print("Connected to QEMU {major}.{minor}.{micro}\n".format(**version)) @property - def prompt(self): + def prompt(self) -> str: if self._transmode: return 'TRANS> ' return '(QEMU) ' - def read_exec_command(self): + def read_exec_command(self) -> bool: """ Read and execute a command. @@ -326,7 +339,7 @@ class QMPShell(qmp.QEMUMonitorProtocol): return self._execute_cmd(cmdline) - def repl(self): + def repl(self) -> Iterator[None]: self.show_banner() while self.read_exec_command(): yield @@ -334,11 +347,12 @@ class QMPShell(qmp.QEMUMonitorProtocol): class HMPShell(QMPShell): - def __init__(self, address, pretty=False, verbose=False): + def __init__(self, address: str, + pretty: bool = False, verbose: bool = False): super().__init__(address, pretty, verbose) self.__cpu_index = 0 - def __cmd_completion(self): + def __cmd_completion(self) -> None: for cmd in self.__cmd_passthrough('help')['return'].split('\r\n'): if cmd and cmd[0] != '[' and cmd[0] != '\t': name = cmd.split()[0] # drop help text @@ -355,21 +369,22 @@ class HMPShell(QMPShell): self._completer.append(name) self._completer.append('help ' + name) # help completion - def __info_completion(self): + def __info_completion(self) -> None: for cmd in self.__cmd_passthrough('info')['return'].split('\r\n'): if cmd: self._completer.append('info ' + cmd.split()[1]) - def __other_completion(self): + def __other_completion(self) -> None: # special cases self._completer.append('help info') - def _fill_completion(self): + def _fill_completion(self) -> None: self.__cmd_completion() self.__info_completion() self.__other_completion() - def __cmd_passthrough(self, cmdline, cpu_index=0): + def __cmd_passthrough(self, cmdline: str, + cpu_index: int = 0) -> QMPMessage: return self.cmd_obj({ 'execute': 'human-monitor-command', 'arguments': { @@ -378,7 +393,7 @@ class HMPShell(QMPShell): } }) - def _execute_cmd(self, cmdline): + def _execute_cmd(self, cmdline: str) -> bool: if cmdline.split()[0] == "cpu": # trap the cpu command, it requires special setting try: @@ -404,16 +419,16 @@ class HMPShell(QMPShell): print('%s: %s' % (resp['error']['class'], resp['error']['desc'])) return True - def show_banner(self, msg='Welcome to the HMP shell!'): + def show_banner(self, msg: str = 'Welcome to the HMP shell!') -> None: QMPShell.show_banner(self, msg) -def die(msg): +def die(msg: str) -> NoReturn: sys.stderr.write('ERROR: %s\n' % msg) sys.exit(1) -def main(): +def main() -> None: parser = argparse.ArgumentParser() parser.add_argument('-H', '--hmp', action='store_true', help='Use HMP interface') From patchwork Mon Jun 7 20:06:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Snow X-Patchwork-Id: 12304625 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 56B63C47095 for ; Mon, 7 Jun 2021 20:15:00 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E9D2261073 for ; Mon, 7 Jun 2021 20:14:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E9D2261073 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:52546 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lqLeF-0006kA-2O for qemu-devel@archiver.kernel.org; Mon, 07 Jun 2021 16:14:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37802) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lqLXE-0004Sx-Hv for qemu-devel@nongnu.org; Mon, 07 Jun 2021 16:07:44 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:49384) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lqLWz-0006YJ-6x for qemu-devel@nongnu.org; Mon, 07 Jun 2021 16:07:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623096448; 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=QXlhesmPbzCIA8W9+kfAympNOmyEcxU3C855rPM9wUw=; b=cdNIKs8A+/zHDp6FIKeZFF/qPswkuK6ztBozfQmT7IQ5b6+dybRbyenHe0JHqgPzYrQmg3 JQsPZinod9OCZOniWK6Fj2j3QJ/pqGpowako5ElLqQlD+Ko8+ehPnnmLOloux5atyTZii+ x++Te62aYkeyU25BGpuPu3iH8pTm+E0= 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-398-nWMOvKY3Mdi4Ppro0pkavg-1; Mon, 07 Jun 2021 16:07:27 -0400 X-MC-Unique: nWMOvKY3Mdi4Ppro0pkavg-1 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4D5D3CC642; Mon, 7 Jun 2021 20:07:22 +0000 (UTC) Received: from scv.redhat.com (ovpn-116-137.rdu2.redhat.com [10.10.116.137]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0BAB55C1C2; Mon, 7 Jun 2021 20:07:20 +0000 (UTC) From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH 28/42] scripts/qmp-shell: Accept SocketAddrT instead of string Date: Mon, 7 Jun 2021 16:06:35 -0400 Message-Id: <20210607200649.1840382-29-jsnow@redhat.com> In-Reply-To: <20210607200649.1840382-1-jsnow@redhat.com> References: <20210607200649.1840382-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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 Received-SPF: pass client-ip=170.10.133.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.2, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, 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: "Niteesh G . S ." , Cleber Rosa , John Snow , Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Don't "extend" QEMUMonitorProtocol by changing the argument types. Move the string parsing just outside of the class instead. Signed-off-by: John Snow --- scripts/qmp/qmp-shell | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/scripts/qmp/qmp-shell b/scripts/qmp/qmp-shell index 2d0e85b5f7..b465c7f9e2 100755 --- a/scripts/qmp/qmp-shell +++ b/scripts/qmp/qmp-shell @@ -130,9 +130,9 @@ class FuzzyJSON(ast.NodeTransformer): # TODO: QMPShell's interface is a bit ugly (eg. _fill_completion() and # _execute_cmd()). Let's design a better one. class QMPShell(qmp.QEMUMonitorProtocol): - def __init__(self, address: str, pretty: bool = False, - verbose: bool = False): - super().__init__(self.parse_address(address)) + def __init__(self, address: qmp.SocketAddrT, + pretty: bool = False, verbose: bool = False): + super().__init__(address) self._greeting: Optional[QMPMessage] = None self._completer = QMPCompleter() self._pretty = pretty @@ -347,7 +347,7 @@ class QMPShell(qmp.QEMUMonitorProtocol): class HMPShell(QMPShell): - def __init__(self, address: str, + def __init__(self, address: qmp.SocketAddrT, pretty: bool = False, verbose: bool = False): super().__init__(address, pretty, verbose) self.__cpu_index = 0 @@ -450,11 +450,13 @@ def main() -> None: shell_class = HMPShell if args.hmp else QMPShell try: - qemu = shell_class(args.qmp_server, args.pretty, args.verbose) + address = shell_class.parse_address(args.qmp_server) except qmp.QMPBadPortError: parser.error(f"Bad port number: {args.qmp_server}") return # pycharm doesn't know error() is noreturn + qemu = shell_class(address, args.pretty, args.verbose) + try: qemu.connect(negotiate=not args.skip_negotiation) except qmp.QMPConnectError: From patchwork Mon Jun 7 20:06:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Snow X-Patchwork-Id: 12304667 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 898DAC47082 for ; Mon, 7 Jun 2021 20:25:20 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2E1FC610FB for ; Mon, 7 Jun 2021 20:25:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2E1FC610FB Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:38752 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lqLoF-0001ZU-7T for qemu-devel@archiver.kernel.org; Mon, 07 Jun 2021 16:25:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37754) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lqLX7-0004MI-C8 for qemu-devel@nongnu.org; Mon, 07 Jun 2021 16:07:40 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:28559) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lqLWy-0006Y2-JX for qemu-devel@nongnu.org; Mon, 07 Jun 2021 16:07:34 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623096447; 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=OxtQICMg+llXuJ1+mXUC4D6FKwgN/rkmTfJ91X8Qjvk=; b=Oglpc0Yl6SaPusw5Duvz+85a4tOvTu+8pwKHZ656iWMkBLQ9hKECAFx/9UU4oVJR4vL/qW MptqukHdsJ1rFw/BZHlht6Exlk9TvA3KSGGe8a7YH1k89EUD9ygZqROTebwSR1itLwOHpA MRNd41ngQwvpeY3+Nvu8BDxTChcOdFU= 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-359-mCPuLsAvNNe1XK13zCa6Uw-1; Mon, 07 Jun 2021 16:07:25 -0400 X-MC-Unique: mCPuLsAvNNe1XK13zCa6Uw-1 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4242219253E1; Mon, 7 Jun 2021 20:07:23 +0000 (UTC) Received: from scv.redhat.com (ovpn-116-137.rdu2.redhat.com [10.10.116.137]) by smtp.corp.redhat.com (Postfix) with ESMTP id 886045C1C2; Mon, 7 Jun 2021 20:07:22 +0000 (UTC) From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH 29/42] scripts/qmp-shell: unprivatize 'pretty' property Date: Mon, 7 Jun 2021 16:06:36 -0400 Message-Id: <20210607200649.1840382-30-jsnow@redhat.com> In-Reply-To: <20210607200649.1840382-1-jsnow@redhat.com> References: <20210607200649.1840382-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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 Received-SPF: pass client-ip=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.2, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, 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: "Niteesh G . S ." , Cleber Rosa , John Snow , Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Similar to verbose, there's no reason this needs to be hidden. Signed-off-by: John Snow --- 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 b465c7f9e2..f14fe211cc 100755 --- a/scripts/qmp/qmp-shell +++ b/scripts/qmp/qmp-shell @@ -135,11 +135,11 @@ class QMPShell(qmp.QEMUMonitorProtocol): super().__init__(address) self._greeting: Optional[QMPMessage] = None self._completer = QMPCompleter() - self._pretty = pretty self._transmode = False self._actions: List[QMPMessage] = [] self._histfile = os.path.join(os.path.expanduser('~'), '.qmp-shell_history') + self.pretty = pretty self.verbose = verbose def _fill_completion(self) -> None: @@ -274,10 +274,9 @@ class QMPShell(qmp.QEMUMonitorProtocol): return qmpcmd def _print(self, qmp_message: object) -> None: - indent = None - if self._pretty: - indent = 4 - jsobj = json.dumps(qmp_message, indent=indent, sort_keys=self._pretty) + jsobj = json.dumps(qmp_message, + indent=4 if self.pretty else None, + sort_keys=self.pretty) print(str(jsobj)) def _execute_cmd(self, cmdline: str) -> bool: From patchwork Mon Jun 7 20:06:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Snow X-Patchwork-Id: 12304673 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 47D39C47094 for ; Mon, 7 Jun 2021 20:26:46 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C9A2960551 for ; Mon, 7 Jun 2021 20:26:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C9A2960551 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:45660 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lqLpd-0006Fb-0V for qemu-devel@archiver.kernel.org; Mon, 07 Jun 2021 16:26:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37792) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lqLXE-0004SP-F5 for qemu-devel@nongnu.org; Mon, 07 Jun 2021 16:07:44 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:56166) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lqLWy-0006Wq-0s for qemu-devel@nongnu.org; Mon, 07 Jun 2021 16:07:41 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623096446; 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=drhO7maKnFK/dygu7B7vSQX9bQQT1ADNA2BhhT2YwfQ=; b=R4QArEyctCHeMqbPX55qa4Zf5+dQXtJpabHcbRFVJsCrDWdIHWs+GokN4aUQRuOH3ePBUh +4eYfQlJFXtFegJAlPUNrgf7EdhXUO6JZtd3ShujgF5ZuGz9HGMsbcQLfy1hmBgHkM6x4I vBFJWbk1zOPSVeznfc7Bu3qSBZx3+Uo= 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-260-014Q1ZQ0MyS21ms5Dv8i8g-1; Mon, 07 Jun 2021 16:07:24 -0400 X-MC-Unique: 014Q1ZQ0MyS21ms5Dv8i8g-1 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2846B108C2A0; Mon, 7 Jun 2021 20:07:24 +0000 (UTC) Received: from scv.redhat.com (ovpn-116-137.rdu2.redhat.com [10.10.116.137]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6A89C5C1C2; Mon, 7 Jun 2021 20:07:23 +0000 (UTC) From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH 30/42] python/qmp: return generic type from context manager Date: Mon, 7 Jun 2021 16:06:37 -0400 Message-Id: <20210607200649.1840382-31-jsnow@redhat.com> In-Reply-To: <20210607200649.1840382-1-jsnow@redhat.com> References: <20210607200649.1840382-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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 Received-SPF: pass client-ip=170.10.133.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.2, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, 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: "Niteesh G . S ." , Cleber Rosa , John Snow , Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" __enter__ can be invoked from a subclass, so it needs a more flexible type. Signed-off-by: John Snow --- python/qemu/qmp/__init__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/python/qemu/qmp/__init__.py b/python/qemu/qmp/__init__.py index ba0d2281d6..376954cb6d 100644 --- a/python/qemu/qmp/__init__.py +++ b/python/qemu/qmp/__init__.py @@ -30,6 +30,7 @@ TextIO, Tuple, Type, + TypeVar, Union, cast, ) @@ -220,7 +221,9 @@ def __get_events(self, wait: Union[bool, float] = False) -> None: if ret is None: raise QMPConnectError("Error while reading from socket") - def __enter__(self) -> 'QEMUMonitorProtocol': + T = TypeVar('T') + + def __enter__(self: T) -> T: # Implement context manager enter function. return self From patchwork Mon Jun 7 20:06:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Snow X-Patchwork-Id: 12304645 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6A513C47095 for ; Mon, 7 Jun 2021 20:19:26 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 36DF4601FC for ; Mon, 7 Jun 2021 20:19:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 36DF4601FC Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:41368 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lqLiX-0001Kt-8F for qemu-devel@archiver.kernel.org; Mon, 07 Jun 2021 16:19:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37886) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lqLXJ-0004g3-3l for qemu-devel@nongnu.org; Mon, 07 Jun 2021 16:07:49 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:59909) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lqLX0-0006Yo-0P for qemu-devel@nongnu.org; Mon, 07 Jun 2021 16:07:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623096449; 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=qWM7zQP5jEatBVThriKtqwuGdlszJA/g98wRUfpjLWY=; b=Ss0GyzoPgV1b+OeJFnPyp4IaVKwSFm+8Cz/38R9u0j854TgEG0M6GFrQ7RN2OE77jH6iJS AyjCHjXGpezJ6pJ9oCjKiohot8Wp5/6/DD2+i2SMT6nA4DLUcPMIhEAVAWsyYXv4EONRD8 HErKqV1qP5Uvxp3Xvj6/kOHE4OBAy1s= 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-360-qMJYIyngPleTcR4dni6nvg-1; Mon, 07 Jun 2021 16:07:26 -0400 X-MC-Unique: qMJYIyngPleTcR4dni6nvg-1 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0EB728049C5; Mon, 7 Jun 2021 20:07:25 +0000 (UTC) Received: from scv.redhat.com (ovpn-116-137.rdu2.redhat.com [10.10.116.137]) by smtp.corp.redhat.com (Postfix) with ESMTP id 506CE5C1C2; Mon, 7 Jun 2021 20:07:24 +0000 (UTC) From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH 31/42] scripts/qmp-shell: Use context manager instead of atexit Date: Mon, 7 Jun 2021 16:06:38 -0400 Message-Id: <20210607200649.1840382-32-jsnow@redhat.com> In-Reply-To: <20210607200649.1840382-1-jsnow@redhat.com> References: <20210607200649.1840382-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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 Received-SPF: pass client-ip=170.10.133.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.2, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, 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: "Niteesh G . S ." , Cleber Rosa , John Snow , Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" We can invoke the shell history writing when we leave the QMPShell scope instead of relying on atexit. Doing so may be preferable to avoid global state being registered from within a class instead of from the application logic directly. Use QMP's context manager to hook this history saving at close time, which gets invoked when we leave the context block. Signed-off-by: John Snow --- scripts/qmp/qmp-shell | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/scripts/qmp/qmp-shell b/scripts/qmp/qmp-shell index f14fe211cc..ec028d662e 100755 --- a/scripts/qmp/qmp-shell +++ b/scripts/qmp/qmp-shell @@ -66,7 +66,6 @@ # sent to QEMU, which is useful for debugging and documentation generation. import argparse import ast -import atexit import json import os import re @@ -142,6 +141,11 @@ class QMPShell(qmp.QEMUMonitorProtocol): self.pretty = pretty self.verbose = verbose + def close(self) -> None: + # Hook into context manager of parent to save shell history. + self._save_history() + super().close() + def _fill_completion(self) -> None: cmds = self.cmd('query-commands') if 'error' in cmds: @@ -164,9 +168,8 @@ class QMPShell(qmp.QEMUMonitorProtocol): pass except IOError as err: print(f"Failed to read history '{self._histfile}': {err!s}") - atexit.register(self.__save_history) - def __save_history(self) -> None: + def _save_history(self) -> None: try: readline.write_history_file(self._histfile) except IOError as err: @@ -448,25 +451,25 @@ def main() -> None: parser.error("QMP socket or TCP address must be specified") shell_class = HMPShell if args.hmp else QMPShell + try: address = shell_class.parse_address(args.qmp_server) except qmp.QMPBadPortError: parser.error(f"Bad port number: {args.qmp_server}") return # pycharm doesn't know error() is noreturn - qemu = shell_class(address, args.pretty, args.verbose) + with shell_class(address, args.pretty, args.verbose) as qemu: + try: + qemu.connect(negotiate=not args.skip_negotiation) + except qmp.QMPConnectError: + die("Didn't get QMP greeting message") + except qmp.QMPCapabilitiesError: + die("Couldn't negotiate capabilities") + except OSError as err: + die(f"Couldn't connect to {args.qmp_server}: {err!s}") - try: - qemu.connect(negotiate=not args.skip_negotiation) - except qmp.QMPConnectError: - die("Didn't get QMP greeting message") - except qmp.QMPCapabilitiesError: - die("Couldn't negotiate capabilities") - except OSError as err: - die(f"Couldn't connect to {args.qmp_server}: {err!s}") - - for _ in qemu.repl(): - pass + for _ in qemu.repl(): + pass if __name__ == '__main__': From patchwork Mon Jun 7 20:06:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Snow X-Patchwork-Id: 12304665 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D5BDEC47094 for ; Mon, 7 Jun 2021 20:23:50 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7655660FE9 for ; Mon, 7 Jun 2021 20:23:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7655660FE9 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:33160 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lqLmn-0006GO-IM for qemu-devel@archiver.kernel.org; Mon, 07 Jun 2021 16:23:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37846) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lqLXG-0004bJ-UD for qemu-devel@nongnu.org; Mon, 07 Jun 2021 16:07:47 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:44285) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lqLWz-0006YW-ER for qemu-devel@nongnu.org; Mon, 07 Jun 2021 16:07:46 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623096448; 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=nJKSyaG5GvppvHaM5g2i8F+h46QUiR6jQEhlJ4nKF6A=; b=afaEnEVJ39enEajLgAgLDZ0Jl3BAeJPw+KOlv+MqfLAg3ovcLO/kF1SndOjrGLKsAOuVrn fCjhS1Mpi5lk0ZegxdqJ5CU3uTrCoDPzcVCxkkpCCtZm6GOxZqPY3N8EkwtJfiVSKS5QLs c3Z3+xBW+yWVd4jtz74333VvBmCSGzs= 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-591-3T4m_a4FPya6_TH2RItRkg-1; Mon, 07 Jun 2021 16:07:27 -0400 X-MC-Unique: 3T4m_a4FPya6_TH2RItRkg-1 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4B41ECC653; Mon, 7 Jun 2021 20:07:26 +0000 (UTC) Received: from scv.redhat.com (ovpn-116-137.rdu2.redhat.com [10.10.116.137]) by smtp.corp.redhat.com (Postfix) with ESMTP id 34D7A5C1C2; Mon, 7 Jun 2021 20:07:25 +0000 (UTC) From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH 32/42] scripts/qmp-shell: use logging to show warnings Date: Mon, 7 Jun 2021 16:06:39 -0400 Message-Id: <20210607200649.1840382-33-jsnow@redhat.com> In-Reply-To: <20210607200649.1840382-1-jsnow@redhat.com> References: <20210607200649.1840382-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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 Received-SPF: pass client-ip=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.2, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, 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: "Niteesh G . S ." , Cleber Rosa , John Snow , Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" A perfect candidate is non-fatal shell history messages. Signed-off-by: John Snow --- scripts/qmp/qmp-shell | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/scripts/qmp/qmp-shell b/scripts/qmp/qmp-shell index ec028d662e..0199a13a34 100755 --- a/scripts/qmp/qmp-shell +++ b/scripts/qmp/qmp-shell @@ -67,6 +67,7 @@ import argparse import ast import json +import logging import os import re import readline @@ -85,6 +86,9 @@ from qemu import qmp from qemu.qmp import QMPMessage +LOG = logging.getLogger(__name__) + + class QMPCompleter: # NB: Python 3.9+ will probably allow us to subclass list[str] directly, # but pylint as of today does not know that List[str] is simply 'list'. @@ -167,13 +171,15 @@ class QMPShell(qmp.QEMUMonitorProtocol): except FileNotFoundError: pass except IOError as err: - print(f"Failed to read history '{self._histfile}': {err!s}") + msg = f"Failed to read history '{self._histfile}': {err!s}" + LOG.warning(msg) def _save_history(self) -> None: try: readline.write_history_file(self._histfile) except IOError as err: - print(f"Failed to save history file '{self._histfile}': {err!s}") + msg = f"Failed to save history file '{self._histfile}': {err!s}" + LOG.warning(msg) @classmethod def __parse_value(cls, val: str) -> object: From patchwork Mon Jun 7 20:06:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Snow X-Patchwork-Id: 12304663 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7CBFCC47082 for ; Mon, 7 Jun 2021 20:23:19 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4A92061108 for ; Mon, 7 Jun 2021 20:23:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4A92061108 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:59222 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lqLmI-0004pl-HI for qemu-devel@archiver.kernel.org; Mon, 07 Jun 2021 16:23:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37860) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lqLXH-0004d8-Rp for qemu-devel@nongnu.org; Mon, 07 Jun 2021 16:07:47 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:31162) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lqLX0-0006ZX-D7 for qemu-devel@nongnu.org; Mon, 07 Jun 2021 16:07:47 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623096449; 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=/l/64DGhEr2qD2z/9sUePyNGBjPN0d/7zravnqUwKAw=; b=WwF60FMJq38Bjwk1XU0xdEtilWyGZ3ZtfyrJ6YikahVYrCyIuKmJqxhlXwNM2DD35fbSbg XeZ8wEEwk0RZlWK2IfdyohFuwu2yWy1Bupx4EaYPKxzOaNW+VTRCge47cVf42lQ8XFXHSN AjoCOpKqumI7V4MYT9x8EsouS26u1Lc= 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-493-f0sYGs53PTKwOFUqU9fGjw-1; Mon, 07 Jun 2021 16:07:28 -0400 X-MC-Unique: f0sYGs53PTKwOFUqU9fGjw-1 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id A7F54108883C; Mon, 7 Jun 2021 20:07:27 +0000 (UTC) Received: from scv.redhat.com (ovpn-116-137.rdu2.redhat.com [10.10.116.137]) by smtp.corp.redhat.com (Postfix) with ESMTP id 913D95C1C2; Mon, 7 Jun 2021 20:07:26 +0000 (UTC) From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH 33/42] scripts/qmp-shell: remove TODO Date: Mon, 7 Jun 2021 16:06:40 -0400 Message-Id: <20210607200649.1840382-34-jsnow@redhat.com> In-Reply-To: <20210607200649.1840382-1-jsnow@redhat.com> References: <20210607200649.1840382-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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 Received-SPF: pass client-ip=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.2, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, 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: "Niteesh G . S ." , Cleber Rosa , John Snow , Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" We still want to revamp qmp-shell again, but there's much more to the idea than the comment now intuits. Remove it. Signed-off-by: John Snow --- scripts/qmp/qmp-shell | 2 -- 1 file changed, 2 deletions(-) diff --git a/scripts/qmp/qmp-shell b/scripts/qmp/qmp-shell index 0199a13a34..3c32b576a3 100755 --- a/scripts/qmp/qmp-shell +++ b/scripts/qmp/qmp-shell @@ -130,8 +130,6 @@ class FuzzyJSON(ast.NodeTransformer): return node -# TODO: QMPShell's interface is a bit ugly (eg. _fill_completion() and -# _execute_cmd()). Let's design a better one. class QMPShell(qmp.QEMUMonitorProtocol): def __init__(self, address: qmp.SocketAddrT, pretty: bool = False, verbose: bool = False): From patchwork Mon Jun 7 20:06:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Snow X-Patchwork-Id: 12304637 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C159EC47094 for ; Mon, 7 Jun 2021 20:17:16 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 82F95610A2 for ; Mon, 7 Jun 2021 20:17:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 82F95610A2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:32854 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lqLgR-000465-KU for qemu-devel@archiver.kernel.org; Mon, 07 Jun 2021 16:17:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37872) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lqLXI-0004ec-CL for qemu-devel@nongnu.org; Mon, 07 Jun 2021 16:07:49 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:39375) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lqLX1-0006aV-Nw for qemu-devel@nongnu.org; Mon, 07 Jun 2021 16:07:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623096451; 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=zV+e+y2+DzmyOBOZVWkGYPaZC9gbrIzL6764Vos/ObE=; b=IF6UyW/aQrbIodgkN1KBtlr25XR1RsD7cwQBwOGw/DdPen4yfcMWG/HiA13B+IJP6dbny0 SCX+BMIwSXatTh6Q4ar9m7JxnkR2cDkxoIV1tgnAKHJLxbEjR03qw2vgGQtUDOjfx+9ktK lwPAjaodHGFRdR6H5UpztvbDgE/Eshk= 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-564-1lhLcm6pNf-EqFRcI5dILQ-1; Mon, 07 Jun 2021 16:07:29 -0400 X-MC-Unique: 1lhLcm6pNf-EqFRcI5dILQ-1 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 14F44108C303; Mon, 7 Jun 2021 20:07:29 +0000 (UTC) Received: from scv.redhat.com (ovpn-116-137.rdu2.redhat.com [10.10.116.137]) by smtp.corp.redhat.com (Postfix) with ESMTP id EB5175C1C2; Mon, 7 Jun 2021 20:07:27 +0000 (UTC) From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH 34/42] scripts/qmp-shell: Fix empty-transaction invocation Date: Mon, 7 Jun 2021 16:06:41 -0400 Message-Id: <20210607200649.1840382-35-jsnow@redhat.com> In-Reply-To: <20210607200649.1840382-1-jsnow@redhat.com> References: <20210607200649.1840382-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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 Received-SPF: pass client-ip=170.10.133.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.2, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, 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: "Niteesh G . S ." , Cleber Rosa , John Snow , Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" calling "transaction( )" is pointless, but valid. Rework the parser to allow this kind of invocation. This helps clean up exception handling later by removing accidental breakages of the parser that aren't explicitly forbidden. Signed-off-by: John Snow --- scripts/qmp/qmp-shell | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/scripts/qmp/qmp-shell b/scripts/qmp/qmp-shell index 3c32b576a3..78e4eae007 100755 --- a/scripts/qmp/qmp-shell +++ b/scripts/qmp/qmp-shell @@ -244,11 +244,14 @@ class QMPShell(qmp.QEMUMonitorProtocol): cmdargs = re.findall(argument_regex, cmdline) qmpcmd: QMPMessage - # Transactional CLI entry/exit: - if cmdargs[0] == 'transaction(': + # Transactional CLI entry: + if cmdargs and cmdargs[0] == 'transaction(': self._transmode = True + self._actions = [] cmdargs.pop(0) - elif cmdargs[0] == ')' and self._transmode: + + # Transactional CLI exit: + if cmdargs and cmdargs[0] == ')' and self._transmode: self._transmode = False if len(cmdargs) > 1: msg = 'Unexpected input after close of Transaction sub-shell' @@ -257,15 +260,14 @@ class QMPShell(qmp.QEMUMonitorProtocol): 'execute': 'transaction', 'arguments': {'actions': self._actions} } - self._actions = list() return qmpcmd - # Nothing to process? + # No args, or no args remaining if not cmdargs: return None - # Parse and then cache this Transactional Action if self._transmode: + # Parse and cache this Transactional Action finalize = False action = {'type': cmdargs[0], 'data': {}} if cmdargs[-1] == ')': From patchwork Mon Jun 7 20:06:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Snow X-Patchwork-Id: 12304671 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9A564C47094 for ; Mon, 7 Jun 2021 20:25:46 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 67A6161108 for ; Mon, 7 Jun 2021 20:25:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 67A6161108 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:41232 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lqLof-0003EJ-Ii for qemu-devel@archiver.kernel.org; Mon, 07 Jun 2021 16:25:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37914) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lqLXM-0004kW-Gd for qemu-devel@nongnu.org; Mon, 07 Jun 2021 16:07:52 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:36746) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lqLX4-0006au-Br for qemu-devel@nongnu.org; Mon, 07 Jun 2021 16:07:52 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623096452; 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=TAzzHCMk2rbmO5fnugwgd1vprQvI9nXdQ6sXcsz86Po=; b=W11AueBnJe6OmVTtwzLdjsAtR3I00BzZoc3oEQSJKJN4+sdq+9BP/jG1We3CzqyURM7PQJ MNwKywHVlgWD0e97Pa4W+S4fvRbY/Dxuf252v6MhffqD8KDarHv8pKj/nyxDmfwSAP56qu EwWaQuKpRkgNfLfVNR1rGb3/ijUKfFQ= 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-561-FFANlAZ8NcG9Tj_uuyDbiQ-1; Mon, 07 Jun 2021 16:07:31 -0400 X-MC-Unique: FFANlAZ8NcG9Tj_uuyDbiQ-1 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2E98D19253E0; Mon, 7 Jun 2021 20:07:30 +0000 (UTC) Received: from scv.redhat.com (ovpn-116-137.rdu2.redhat.com [10.10.116.137]) by smtp.corp.redhat.com (Postfix) with ESMTP id 717F05C1C2; Mon, 7 Jun 2021 20:07:29 +0000 (UTC) From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH 35/42] scripts/qmp-shell: Remove too-broad-exception Date: Mon, 7 Jun 2021 16:06:42 -0400 Message-Id: <20210607200649.1840382-36-jsnow@redhat.com> In-Reply-To: <20210607200649.1840382-1-jsnow@redhat.com> References: <20210607200649.1840382-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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 Received-SPF: pass client-ip=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.2, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, 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: "Niteesh G . S ." , Cleber Rosa , John Snow , Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" We are only anticipating QMPShellErrors here, for syntax we weren't able to understand. Other errors, if any, should be allowed to percolate upwards. Signed-off-by: John Snow --- scripts/qmp/qmp-shell | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/scripts/qmp/qmp-shell b/scripts/qmp/qmp-shell index 78e4eae007..8d5845ab48 100755 --- a/scripts/qmp/qmp-shell +++ b/scripts/qmp/qmp-shell @@ -291,10 +291,13 @@ class QMPShell(qmp.QEMUMonitorProtocol): def _execute_cmd(self, cmdline: str) -> bool: try: qmpcmd = self.__build_cmd(cmdline) - except Exception as err: - print('Error while parsing command line: %s' % err) - print('command format: ', end=' ') - print('[arg-name1=arg1] ... [arg-nameN=argN]') + except QMPShellError as err: + print( + f"Error while parsing command line: {err!s}\n" + "command format: " + "[arg-name1=arg1] ... [arg-nameN=argN", + file=sys.stderr + ) return True # For transaction mode, we may have just cached the action: if qmpcmd is None: From patchwork Mon Jun 7 20:06:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Snow X-Patchwork-Id: 12304677 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2CA93C47082 for ; Mon, 7 Jun 2021 20:27:10 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C125661108 for ; Mon, 7 Jun 2021 20:27:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C125661108 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:47786 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lqLq0-0007dT-Up for qemu-devel@archiver.kernel.org; Mon, 07 Jun 2021 16:27:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37938) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lqLXN-0004nM-9U for qemu-devel@nongnu.org; Mon, 07 Jun 2021 16:07:53 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:51768) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lqLX4-0006b6-Bm for qemu-devel@nongnu.org; Mon, 07 Jun 2021 16:07:53 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623096453; 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=La2XoCWtUSupmNGpFMLMOVf/SbpI42raeAiGn2vtP5c=; b=I/eRtJMfhPm+jdGsrxyP7AOBdnJq6PAljq2SfNvreIdQUG3jMeAFUEkwdvQXiOdBK0Lyeo pZnzOnamfmLAdxMZSNFaIMy+zUL9K9dutV5KRaUG4W9KNN2KTUd3LzMQAQGfSWsRAKRZ90 6DTPtfJLtC4LvOxjAp7k5mx2tuzaalo= 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-49-j_Z1OsdOP9Sg-VHWAw3bFA-1; Mon, 07 Jun 2021 16:07:32 -0400 X-MC-Unique: j_Z1OsdOP9Sg-VHWAw3bFA-1 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 800CD805EFF; Mon, 7 Jun 2021 20:07:31 +0000 (UTC) Received: from scv.redhat.com (ovpn-116-137.rdu2.redhat.com [10.10.116.137]) by smtp.corp.redhat.com (Postfix) with ESMTP id 554E25C1C2; Mon, 7 Jun 2021 20:07:30 +0000 (UTC) From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH 36/42] scripts/qmp-shell: convert usage comment to docstring Date: Mon, 7 Jun 2021 16:06:43 -0400 Message-Id: <20210607200649.1840382-37-jsnow@redhat.com> In-Reply-To: <20210607200649.1840382-1-jsnow@redhat.com> References: <20210607200649.1840382-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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 Received-SPF: pass client-ip=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.2, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, 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: "Niteesh G . S ." , Cleber Rosa , John Snow , Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" The nice usage comment should be a docstring instead of a comment, so that it's visible from other python tooling. Signed-off-by: John Snow --- scripts/qmp/qmp-shell | 128 ++++++++++++++++++++++++------------------ 1 file changed, 72 insertions(+), 56 deletions(-) diff --git a/scripts/qmp/qmp-shell b/scripts/qmp/qmp-shell index 8d5845ab48..82fe16cff8 100755 --- a/scripts/qmp/qmp-shell +++ b/scripts/qmp/qmp-shell @@ -1,7 +1,5 @@ #!/usr/bin/env python3 # -# Low-level QEMU shell on top of QMP. -# # Copyright (C) 2009, 2010 Red Hat Inc. # # Authors: @@ -10,60 +8,78 @@ # This work is licensed under the terms of the GNU GPL, version 2. See # the COPYING file in the top-level directory. # -# Usage: -# -# Start QEMU with: -# -# # qemu [...] -qmp unix:./qmp-sock,server -# -# Run the shell: -# -# $ qmp-shell ./qmp-sock -# -# Commands have the following format: -# -# < command-name > [ arg-name1=arg1 ] ... [ arg-nameN=argN ] -# -# For example: -# -# (QEMU) device_add driver=e1000 id=net1 -# {u'return': {}} -# (QEMU) -# -# key=value pairs also support Python or JSON object literal subset notations, -# without spaces. Dictionaries/objects {} are supported as are arrays []. -# -# example-command arg-name1={'key':'value','obj'={'prop':"value"}} -# -# Both JSON and Python formatting should work, including both styles of -# string literal quotes. Both paradigms of literal values should work, -# including null/true/false for JSON and None/True/False for Python. -# -# -# Transactions have the following multi-line format: -# -# transaction( -# action-name1 [ arg-name1=arg1 ] ... [arg-nameN=argN ] -# ... -# action-nameN [ arg-name1=arg1 ] ... [arg-nameN=argN ] -# ) -# -# One line transactions are also supported: -# -# transaction( action-name1 ... ) -# -# For example: -# -# (QEMU) transaction( -# TRANS> block-dirty-bitmap-add node=drive0 name=bitmap1 -# TRANS> block-dirty-bitmap-clear node=drive0 name=bitmap0 -# TRANS> ) -# {"return": {}} -# (QEMU) -# -# Use the -v and -p options to activate the verbose and pretty-print options, -# which will echo back the properly formatted JSON-compliant QMP that is being -# sent to QEMU, which is useful for debugging and documentation generation. + +""" +Low-level QEMU shell on top of QMP. + +usage: qmp-shell [-h] [-H] [-N] [-v] [-p] qmp_server + +positional arguments: + qmp_server < UNIX socket path | TCP address:port > + +optional arguments: + -h, --help show this help message and exit + -H, --hmp Use HMP interface + -N, --skip-negotiation + Skip negotiate (for qemu-ga) + -v, --verbose Verbose (echo commands sent and received) + -p, --pretty Pretty-print JSON + + +Start QEMU with: + +# qemu [...] -qmp unix:./qmp-sock,server + +Run the shell: + +$ qmp-shell ./qmp-sock + +Commands have the following format: + + < command-name > [ arg-name1=arg1 ] ... [ arg-nameN=argN ] + +For example: + +(QEMU) device_add driver=e1000 id=net1 +{'return': {}} +(QEMU) + +key=value pairs also support Python or JSON object literal subset notations, +without spaces. Dictionaries/objects {} are supported as are arrays []. + + example-command arg-name1={'key':'value','obj'={'prop':"value"}} + +Both JSON and Python formatting should work, including both styles of +string literal quotes. Both paradigms of literal values should work, +including null/true/false for JSON and None/True/False for Python. + + +Transactions have the following multi-line format: + + transaction( + action-name1 [ arg-name1=arg1 ] ... [arg-nameN=argN ] + ... + action-nameN [ arg-name1=arg1 ] ... [arg-nameN=argN ] + ) + +One line transactions are also supported: + + transaction( action-name1 ... ) + +For example: + + (QEMU) transaction( + TRANS> block-dirty-bitmap-add node=drive0 name=bitmap1 + TRANS> block-dirty-bitmap-clear node=drive0 name=bitmap0 + TRANS> ) + {"return": {}} + (QEMU) + +Use the -v and -p options to activate the verbose and pretty-print options, +which will echo back the properly formatted JSON-compliant QMP that is being +sent to QEMU, which is useful for debugging and documentation generation. +""" + import argparse import ast import json From patchwork Mon Jun 7 20:06:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Snow X-Patchwork-Id: 12304661 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A2D7DC47094 for ; Mon, 7 Jun 2021 20:23:12 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 339A461108 for ; Mon, 7 Jun 2021 20:23:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 339A461108 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:58516 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lqLmB-0004Mr-5J for qemu-devel@archiver.kernel.org; Mon, 07 Jun 2021 16:23:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37968) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lqLXP-0004vz-GD for qemu-devel@nongnu.org; Mon, 07 Jun 2021 16:07:55 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:55173) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lqLX5-0006bE-Ux for qemu-devel@nongnu.org; Mon, 07 Jun 2021 16:07:55 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623096454; 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=eRnQF8+6II9xrALDRpJDJ+WoC32D8OjwWM8myOHUUmI=; b=a4Uo9tBhPqxeWdkezb/QOy2xOd2ihSy9SVKVueFqPkQ3UC0tN4dt63I3i3vMqFoMJZkkgK YPQpT2FHed+X2efLjNCMYZNO1L3TPlF9xuSkuf+sDDP7XQ4r0Hejqu1X/HJRYHzspTZf8W Rf4VoXvIGtKJGlUSFsZNWSkwY0eYO+k= 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-16-iZughClPNhyrwcVoh2fAUg-1; Mon, 07 Jun 2021 16:07:33 -0400 X-MC-Unique: iZughClPNhyrwcVoh2fAUg-1 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id A60CB107ACCD; Mon, 7 Jun 2021 20:07:32 +0000 (UTC) Received: from scv.redhat.com (ovpn-116-137.rdu2.redhat.com [10.10.116.137]) by smtp.corp.redhat.com (Postfix) with ESMTP id C7EA95C1C2; Mon, 7 Jun 2021 20:07:31 +0000 (UTC) From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH 37/42] scripts/qmp-shell: remove double-underscores Date: Mon, 7 Jun 2021 16:06:44 -0400 Message-Id: <20210607200649.1840382-38-jsnow@redhat.com> In-Reply-To: <20210607200649.1840382-1-jsnow@redhat.com> References: <20210607200649.1840382-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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 Received-SPF: pass client-ip=170.10.133.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.2, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, 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: "Niteesh G . S ." , Cleber Rosa , John Snow , Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" They're not needed; single underscore is enough to express intent that these methods are "internal". double underscore is used as a weak name mangling, but that isn't beneficial for us here. Signed-off-by: John Snow --- scripts/qmp/qmp-shell | 52 +++++++++++++++++++++---------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/scripts/qmp/qmp-shell b/scripts/qmp/qmp-shell index 82fe16cff8..40ff9e0a82 100755 --- a/scripts/qmp/qmp-shell +++ b/scripts/qmp/qmp-shell @@ -171,7 +171,7 @@ class QMPShell(qmp.QEMUMonitorProtocol): for cmd in cmds['return']: self._completer.append(cmd['name']) - def __completer_setup(self) -> None: + def _completer_setup(self) -> None: self._completer = QMPCompleter() self._fill_completion() readline.set_history_length(1024) @@ -196,7 +196,7 @@ class QMPShell(qmp.QEMUMonitorProtocol): LOG.warning(msg) @classmethod - def __parse_value(cls, val: str) -> object: + def _parse_value(cls, val: str) -> object: try: return int(val) except ValueError: @@ -221,9 +221,9 @@ class QMPShell(qmp.QEMUMonitorProtocol): pass return val - def __cli_expr(self, - tokens: Sequence[str], - parent: qmp.QMPObject) -> None: + def _cli_expr(self, + tokens: Sequence[str], + parent: qmp.QMPObject) -> None: for arg in tokens: (key, sep, val) = arg.partition('=') if sep != '=': @@ -231,7 +231,7 @@ class QMPShell(qmp.QEMUMonitorProtocol): f"Expected a key=value pair, got '{arg!s}'" ) - value = self.__parse_value(val) + value = self._parse_value(val) optpath = key.split('.') curpath = [] for path in optpath[:-1]: @@ -249,7 +249,7 @@ class QMPShell(qmp.QEMUMonitorProtocol): raise QMPShellError(f'Cannot set "{key}" multiple times') parent[optpath[-1]] = value - def __build_cmd(self, cmdline: str) -> Optional[QMPMessage]: + def _build_cmd(self, cmdline: str) -> Optional[QMPMessage]: """ Build a QMP input object from a user provided command-line in the following format: @@ -289,13 +289,13 @@ class QMPShell(qmp.QEMUMonitorProtocol): if cmdargs[-1] == ')': cmdargs.pop(-1) finalize = True - self.__cli_expr(cmdargs[1:], action['data']) + 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': {}} - self.__cli_expr(cmdargs[1:], qmpcmd['arguments']) + self._cli_expr(cmdargs[1:], qmpcmd['arguments']) return qmpcmd def _print(self, qmp_message: object) -> None: @@ -306,7 +306,7 @@ class QMPShell(qmp.QEMUMonitorProtocol): def _execute_cmd(self, cmdline: str) -> bool: try: - qmpcmd = self.__build_cmd(cmdline) + qmpcmd = self._build_cmd(cmdline) except QMPShellError as err: print( f"Error while parsing command line: {err!s}\n" @@ -329,7 +329,7 @@ class QMPShell(qmp.QEMUMonitorProtocol): def connect(self, negotiate: bool = True) -> None: self._greeting = super().connect(negotiate) - self.__completer_setup() + self._completer_setup() def show_banner(self, msg: str = 'Welcome to the QMP low-level shell!') -> None: @@ -377,10 +377,10 @@ class HMPShell(QMPShell): def __init__(self, address: qmp.SocketAddrT, pretty: bool = False, verbose: bool = False): super().__init__(address, pretty, verbose) - self.__cpu_index = 0 + self._cpu_index = 0 - def __cmd_completion(self) -> None: - for cmd in self.__cmd_passthrough('help')['return'].split('\r\n'): + def _cmd_completion(self) -> None: + for cmd in self._cmd_passthrough('help')['return'].split('\r\n'): if cmd and cmd[0] != '[' and cmd[0] != '\t': name = cmd.split()[0] # drop help text if name == 'info': @@ -396,22 +396,22 @@ class HMPShell(QMPShell): self._completer.append(name) self._completer.append('help ' + name) # help completion - def __info_completion(self) -> None: - for cmd in self.__cmd_passthrough('info')['return'].split('\r\n'): + def _info_completion(self) -> None: + for cmd in self._cmd_passthrough('info')['return'].split('\r\n'): if cmd: self._completer.append('info ' + cmd.split()[1]) - def __other_completion(self) -> None: + def _other_completion(self) -> None: # special cases self._completer.append('help info') def _fill_completion(self) -> None: - self.__cmd_completion() - self.__info_completion() - self.__other_completion() + self._cmd_completion() + self._info_completion() + self._other_completion() - def __cmd_passthrough(self, cmdline: str, - cpu_index: int = 0) -> QMPMessage: + def _cmd_passthrough(self, cmdline: str, + cpu_index: int = 0) -> QMPMessage: return self.cmd_obj({ 'execute': 'human-monitor-command', 'arguments': { @@ -425,14 +425,14 @@ class HMPShell(QMPShell): # trap the cpu command, it requires special setting try: idx = int(cmdline.split()[1]) - if 'return' not in self.__cmd_passthrough('info version', idx): + if 'return' not in self._cmd_passthrough('info version', idx): print('bad CPU index') return True - self.__cpu_index = idx + self._cpu_index = idx except ValueError: print('cpu command takes an integer argument') return True - resp = self.__cmd_passthrough(cmdline, self.__cpu_index) + resp = self._cmd_passthrough(cmdline, self._cpu_index) if resp is None: print('Disconnected') return False From patchwork Mon Jun 7 20:06:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Snow X-Patchwork-Id: 12304675 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7E752C47094 for ; Mon, 7 Jun 2021 20:26:48 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2FF3A60E0B for ; Mon, 7 Jun 2021 20:26:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2FF3A60E0B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:45890 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lqLpf-0006OX-DH for qemu-devel@archiver.kernel.org; Mon, 07 Jun 2021 16:26:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38048) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lqLXS-000582-Pz for qemu-devel@nongnu.org; Mon, 07 Jun 2021 16:07:58 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:60570) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lqLXE-0006ci-C4 for qemu-devel@nongnu.org; Mon, 07 Jun 2021 16:07:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623096463; 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=pOEXh/mPgCzLDMqzPo5a34FQiHAqb0jl6RfWziAlhRs=; b=esmW547E4WmZHEdi4g+L6+aFXfGEebj+c7jnkZVMlBhlozzN3g0hEOcpLC+wyFHqcOFxiC MIQfLqyIkun7fzLxd5FsiQ1G6yXD7oTEgfySGmloXNxOeXvIkOtJpEAU4PWzeGL7ga6kwN Yo5CU2I8n2NL6TMLZMdW+FRx6x9e/4I= 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-165-a9bNkrp1MO6usSvxnUw4Dg-1; Mon, 07 Jun 2021 16:07:34 -0400 X-MC-Unique: a9bNkrp1MO6usSvxnUw4Dg-1 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 93360807324; Mon, 7 Jun 2021 20:07:33 +0000 (UTC) Received: from scv.redhat.com (ovpn-116-137.rdu2.redhat.com [10.10.116.137]) by smtp.corp.redhat.com (Postfix) with ESMTP id CCC985C1C2; Mon, 7 Jun 2021 20:07:32 +0000 (UTC) From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH 38/42] scripts/qmp-shell: make QMPShellError inherit QMPError Date: Mon, 7 Jun 2021 16:06:45 -0400 Message-Id: <20210607200649.1840382-39-jsnow@redhat.com> In-Reply-To: <20210607200649.1840382-1-jsnow@redhat.com> References: <20210607200649.1840382-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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 Received-SPF: pass client-ip=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.2, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, 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: "Niteesh G . S ." , Cleber Rosa , John Snow , Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" In preparation for moving qmp-shell into the qemu.qmp package, make QMPShellError inherit from QMPError so that all custom errors in this package all derive from QMPError. Signed-off-by: John Snow --- scripts/qmp/qmp-shell | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/qmp/qmp-shell b/scripts/qmp/qmp-shell index 40ff9e0a82..1a8a4ba18a 100755 --- a/scripts/qmp/qmp-shell +++ b/scripts/qmp/qmp-shell @@ -123,7 +123,7 @@ class QMPCompleter: return None -class QMPShellError(Exception): +class QMPShellError(qmp.QMPError): pass From patchwork Mon Jun 7 20:06:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Snow X-Patchwork-Id: 12304681 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8528FC47082 for ; Mon, 7 Jun 2021 20:28:29 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0B4D461153 for ; Mon, 7 Jun 2021 20:28:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0B4D461153 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:52264 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lqLrI-0002CD-37 for qemu-devel@archiver.kernel.org; Mon, 07 Jun 2021 16:28:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38074) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lqLXU-0005Bg-9J for qemu-devel@nongnu.org; Mon, 07 Jun 2021 16:08:01 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:31056) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lqLX9-0006bT-I5 for qemu-devel@nongnu.org; Mon, 07 Jun 2021 16:08:00 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623096456; 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=XCrZyO1qNkd4rITWYizcF326ntxeg9vgg3xUH2rFyZY=; b=hi5V/jHZu7wAg9VDG+mkQQmx0zBhfRjKW1gqskzNsR/zceRnDcG+XMVX4FqBfi+LyTw7lb 5yBX/WpwkfPQABMm4C24xvqDCMT0RWWZ6SHV2kbAczXGsQQfpcSldJDPzlm/r1fUKFm2yx qurnALqXQF39DVlB/1ZKPYTX8Wh3kto= 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-245-ZGjCfHpdOvqiflp_J2r9EQ-1; Mon, 07 Jun 2021 16:07:35 -0400 X-MC-Unique: ZGjCfHpdOvqiflp_J2r9EQ-1 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 70D2710CE780; Mon, 7 Jun 2021 20:07:34 +0000 (UTC) Received: from scv.redhat.com (ovpn-116-137.rdu2.redhat.com [10.10.116.137]) by smtp.corp.redhat.com (Postfix) with ESMTP id B77A65C1C2; Mon, 7 Jun 2021 20:07:33 +0000 (UTC) From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH 39/42] scripts/qmp-shell: add docstrings Date: Mon, 7 Jun 2021 16:06:46 -0400 Message-Id: <20210607200649.1840382-40-jsnow@redhat.com> In-Reply-To: <20210607200649.1840382-1-jsnow@redhat.com> References: <20210607200649.1840382-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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 Received-SPF: pass client-ip=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.2, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, 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: "Niteesh G . S ." , Cleber Rosa , John Snow , Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: John Snow --- scripts/qmp/qmp-shell | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/scripts/qmp/qmp-shell b/scripts/qmp/qmp-shell index 1a8a4ba18a..15aedb80c2 100755 --- a/scripts/qmp/qmp-shell +++ b/scripts/qmp/qmp-shell @@ -106,15 +106,20 @@ LOG = logging.getLogger(__name__) class QMPCompleter: + """ + QMPCompleter provides a readline library tab-complete behavior. + """ # NB: Python 3.9+ will probably allow us to subclass list[str] directly, # but pylint as of today does not know that List[str] is simply 'list'. def __init__(self) -> None: self._matches: List[str] = [] def append(self, value: str) -> None: + """Append a new valid completion to the list of possibilities.""" return self._matches.append(value) def complete(self, text: str, state: int) -> Optional[str]: + """readline.set_completer() callback implementation.""" for cmd in self._matches: if cmd.startswith(text): if state == 0: @@ -124,7 +129,9 @@ class QMPCompleter: class QMPShellError(qmp.QMPError): - pass + """ + QMP Shell Base error class. + """ class FuzzyJSON(ast.NodeTransformer): @@ -137,6 +144,9 @@ class FuzzyJSON(ast.NodeTransformer): @classmethod def visit_Name(cls, # pylint: disable=invalid-name node: ast.Name) -> ast.AST: + """ + Transform Name nodes with certain values into Constant (keyword) nodes. + """ if node.id == 'true': return ast.Constant(value=True) if node.id == 'false': @@ -147,6 +157,13 @@ class FuzzyJSON(ast.NodeTransformer): class QMPShell(qmp.QEMUMonitorProtocol): + """ + QMPShell provides a basic readline-based QMP shell. + + :param address: Address of the QMP server. + :param pretty: Pretty-print QMP messages. + :param verbose: Echo outgoing QMP messages to console. + """ def __init__(self, address: qmp.SocketAddrT, pretty: bool = False, verbose: bool = False): super().__init__(address) @@ -333,6 +350,9 @@ class QMPShell(qmp.QEMUMonitorProtocol): def show_banner(self, msg: str = 'Welcome to the QMP low-level shell!') -> None: + """ + Print to stdio a greeting, and the QEMU version if available. + """ print(msg) if not self._greeting: print('Connected') @@ -342,6 +362,9 @@ class QMPShell(qmp.QEMUMonitorProtocol): @property def prompt(self) -> str: + """ + Return the current shell prompt, including a trailing space. + """ if self._transmode: return 'TRANS> ' return '(QEMU) ' @@ -367,6 +390,9 @@ class QMPShell(qmp.QEMUMonitorProtocol): return self._execute_cmd(cmdline) def repl(self) -> Iterator[None]: + """ + Return an iterator that implements the REPL. + """ self.show_banner() while self.read_exec_command(): yield @@ -374,6 +400,13 @@ class QMPShell(qmp.QEMUMonitorProtocol): class HMPShell(QMPShell): + """ + HMPShell provides a basic readline-based HMP shell, tunnelled via QMP. + + :param address: Address of the QMP server. + :param pretty: Pretty-print QMP messages. + :param verbose: Echo outgoing QMP messages to console. + """ def __init__(self, address: qmp.SocketAddrT, pretty: bool = False, verbose: bool = False): super().__init__(address, pretty, verbose) @@ -451,11 +484,15 @@ class HMPShell(QMPShell): def die(msg: str) -> NoReturn: + """Write an error to stderr, then exit with a return code of 1.""" sys.stderr.write('ERROR: %s\n' % msg) sys.exit(1) def main() -> None: + """ + qmp-shell entry point: parse command line arguments and start the REPL. + """ parser = argparse.ArgumentParser() parser.add_argument('-H', '--hmp', action='store_true', help='Use HMP interface') From patchwork Mon Jun 7 20:06:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Snow X-Patchwork-Id: 12304689 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E37F9C47094 for ; Mon, 7 Jun 2021 20:32:53 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id AABE161153 for ; Mon, 7 Jun 2021 20:32:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AABE161153 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:37714 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lqLvY-00038U-Qy for qemu-devel@archiver.kernel.org; Mon, 07 Jun 2021 16:32:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38044) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lqLXS-00057A-K3 for qemu-devel@nongnu.org; Mon, 07 Jun 2021 16:07:58 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:51810) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lqLXF-0006cu-D4 for qemu-devel@nongnu.org; Mon, 07 Jun 2021 16:07:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623096463; 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=Uj/+X9tEhB6PMDtkWS+mJ08uubEJsn5SGPuAtUv84EM=; b=DB+TuUXWMJxzY0OlF4F9oSLs8uvF88i4c6GREh7Xym8OI6o5tcHocGvUPPw0bFFus+Yqjz 7ShssmZeVkFkJmfWkFiIMpfdw6HSw5Ne67ZZs0i0SBKw+l43tyMVI6A392gAeQ2KXtIGOE 9Z5XG674GtlxEC3Cwal9pETmguPXTYg= 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-311-bsDLdlsvOumMrLF6XJ2T8g-1; Mon, 07 Jun 2021 16:07:36 -0400 X-MC-Unique: bsDLdlsvOumMrLF6XJ2T8g-1 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 521D2107ACCA; Mon, 7 Jun 2021 20:07:35 +0000 (UTC) Received: from scv.redhat.com (ovpn-116-137.rdu2.redhat.com [10.10.116.137]) by smtp.corp.redhat.com (Postfix) with ESMTP id 96BE55C1C2; Mon, 7 Jun 2021 20:07:34 +0000 (UTC) From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH 40/42] scripts/qmp-shell: move to python/qemu/qmp/qmp_shell.py Date: Mon, 7 Jun 2021 16:06:47 -0400 Message-Id: <20210607200649.1840382-41-jsnow@redhat.com> In-Reply-To: <20210607200649.1840382-1-jsnow@redhat.com> References: <20210607200649.1840382-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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 Received-SPF: pass client-ip=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.2, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, 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: "Niteesh G . S ." , Cleber Rosa , John Snow , Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" The script will be unavailable for a commit or two, which will help preserve development history attached to the new file. A forwarder will be added shortly afterwards. With qmp_shell in the python qemu.qmp package, now it is fully type checked, linted, etc. via the Python CI. It will be quite a bit harder to accidentally break it again in the future. Signed-off-by: John Snow --- scripts/qmp/qmp-shell => python/qemu/qmp/qmp_shell.py | 3 --- 1 file changed, 3 deletions(-) rename scripts/qmp/qmp-shell => python/qemu/qmp/qmp_shell.py (99%) mode change 100755 => 100644 diff --git a/scripts/qmp/qmp-shell b/python/qemu/qmp/qmp_shell.py old mode 100755 new mode 100644 similarity index 99% rename from scripts/qmp/qmp-shell rename to python/qemu/qmp/qmp_shell.py index 15aedb80c2..337acfce2d --- a/scripts/qmp/qmp-shell +++ b/python/qemu/qmp/qmp_shell.py @@ -1,4 +1,3 @@ -#!/usr/bin/env python3 # # Copyright (C) 2009, 2010 Red Hat Inc. # @@ -96,8 +95,6 @@ Sequence, ) - -sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'python')) from qemu import qmp from qemu.qmp import QMPMessage From patchwork Mon Jun 7 20:06:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Snow X-Patchwork-Id: 12304683 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C5468C4743F for ; Mon, 7 Jun 2021 20:30:23 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6CDF961139 for ; Mon, 7 Jun 2021 20:30:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6CDF961139 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:58320 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lqLt8-0006Hd-I7 for qemu-devel@archiver.kernel.org; Mon, 07 Jun 2021 16:30:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38042) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lqLXS-00056u-JI for qemu-devel@nongnu.org; Mon, 07 Jun 2021 16:07:58 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:49982) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lqLXD-0006bf-MP for qemu-devel@nongnu.org; Mon, 07 Jun 2021 16:07:57 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623096458; 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=Zi4NVowHRGZQikoPuHP58GxVmMyYOGnE+BIcdyLxsgE=; b=Macz7Fq3R9G1Pqlv5hzHuIOarrNSDyj0cQHQBSLcnDd2rf8Ln/IB02sadVFTAGLyQuD9Kn AUKTSWXoAYhye0OxIjbgUKHKFYoj23LxGzbboKHlCGmDGM38Qnoyo8e5+XN6EelmFkwuPd 4lheKKpILjXC9ocf6rMQL3QaWxuRB18= 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-391-mUbzvydrPeOJ26qJ_ELohA-1; Mon, 07 Jun 2021 16:07:37 -0400 X-MC-Unique: mUbzvydrPeOJ26qJ_ELohA-1 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 359F3CC622; Mon, 7 Jun 2021 20:07:36 +0000 (UTC) Received: from scv.redhat.com (ovpn-116-137.rdu2.redhat.com [10.10.116.137]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7975B5C1C2; Mon, 7 Jun 2021 20:07:35 +0000 (UTC) From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH 41/42] python: add qmp-shell entry point Date: Mon, 7 Jun 2021 16:06:48 -0400 Message-Id: <20210607200649.1840382-42-jsnow@redhat.com> In-Reply-To: <20210607200649.1840382-1-jsnow@redhat.com> References: <20210607200649.1840382-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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 Received-SPF: pass client-ip=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.2, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, 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: "Niteesh G . S ." , Cleber Rosa , John Snow , Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" now 'qmp-shell' should be available from the command line when installing the python package. Signed-off-by: John Snow --- python/setup.cfg | 1 + 1 file changed, 1 insertion(+) diff --git a/python/setup.cfg b/python/setup.cfg index 7f3c59d74e..85cecbb41b 100644 --- a/python/setup.cfg +++ b/python/setup.cfg @@ -51,6 +51,7 @@ console_scripts = qom-tree = qemu.qmp.qom:QOMTree.entry_point qom-fuse = qemu.qmp.qom_fuse:QOMFuse.entry_point [fuse] qemu-ga-client = qemu.qmp.qemu_ga_client:main + qmp-shell = qemu.qmp.qmp_shell:main [flake8] extend-ignore = E722 # Prefer pylint's bare-except checks to flake8's From patchwork Mon Jun 7 20:06:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Snow X-Patchwork-Id: 12304685 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8A241C47082 for ; Mon, 7 Jun 2021 20:31:44 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 45C7B6023E for ; Mon, 7 Jun 2021 20:31:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 45C7B6023E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:60474 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lqLuR-0007lU-5T for qemu-devel@archiver.kernel.org; Mon, 07 Jun 2021 16:31:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38022) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lqLXR-00052D-8T for qemu-devel@nongnu.org; Mon, 07 Jun 2021 16:07:57 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:31326) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lqLXD-0006cR-Gd for qemu-devel@nongnu.org; Mon, 07 Jun 2021 16:07:57 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623096460; 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=FMknIMLrZor1YOnZxmqCPZV/8txVGYQoegX+OqAj16k=; b=Cy+PG/+31UOaUGRUHMXDgMUAm6+7Z1OrvgcVEtC9v+K0Jchaic88zkv8evHLZXlw+/3DdC rRntM020Q2XIRV2xCtPdS5UfqFo9snxFDx9iY7SyysYXYo+Z5Rj+/lgOz31osk4uzq2H29 bddQDDiE+vFaIIh3SkIjzudiFqy49UI= 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-123-Ugj-7dvKMLClyt1SNQdqZQ-1; Mon, 07 Jun 2021 16:07:38 -0400 X-MC-Unique: Ugj-7dvKMLClyt1SNQdqZQ-1 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 17F6910CE780; Mon, 7 Jun 2021 20:07:37 +0000 (UTC) Received: from scv.redhat.com (ovpn-116-137.rdu2.redhat.com [10.10.116.137]) by smtp.corp.redhat.com (Postfix) with ESMTP id 583245C1C2; Mon, 7 Jun 2021 20:07:36 +0000 (UTC) From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH 42/42] scripts/qmp-shell: add redirection shim Date: Mon, 7 Jun 2021 16:06:49 -0400 Message-Id: <20210607200649.1840382-43-jsnow@redhat.com> In-Reply-To: <20210607200649.1840382-1-jsnow@redhat.com> References: <20210607200649.1840382-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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 Received-SPF: pass client-ip=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.2, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, 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: "Niteesh G . S ." , Cleber Rosa , John Snow , Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" qmp-shell has a new home, add a redirect for a little while as the dust settles. Signed-off-by: John Snow --- scripts/qmp/qmp-shell | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100755 scripts/qmp/qmp-shell diff --git a/scripts/qmp/qmp-shell b/scripts/qmp/qmp-shell new file mode 100755 index 0000000000..4a20f97db7 --- /dev/null +++ b/scripts/qmp/qmp-shell @@ -0,0 +1,11 @@ +#!/usr/bin/env python3 + +import os +import sys + +sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'python')) +from qemu.qmp import qmp_shell + + +if __name__ == '__main__': + qmp_shell.main()