From nobody Fri May 17 07:07:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1604450674; cv=none; d=zohomail.com; s=zohoarc; b=ZWYvZ+0SUTcYnJ6XXwoRJupLshvonV8Of5WPl7x3N0Ju6Qbyt3OR+V49Ot9+nHK0h3f4Fs9fm7Rwvf9gr/CnKQOjsgIfGdUWmGC9Ima3OPe6K2y7wOmN/2RgvSGBBbVKgivqEtiESEsvlmjRqegqRKpAyDYd2cKUNqughmE699Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604450674; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=aRs9bWy/l+OS7Dmw/otXBWJQ78D/TeE5mmlSCOg0PRA=; b=PefNUsw/UjIkR9s1/X1kZxOMy9FHc5Y11/0LueALSnZ4OBg0F/hV5GpcZAxr5wfCXOXpqOdiByWc9FUt6ZB74t7j6uj7ez6Ku2LKitmJhD7XewcyFFx0eWiKt5h+GaJNvebSnUUSwY8Hng6X88lBFFJuf1E1/Jeg088sV6sZfbk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604450674208103.6934024356193; Tue, 3 Nov 2020 16:44:34 -0800 (PST) Received: from localhost ([::1]:50414 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ka6uf-0006nr-07 for importer@patchew.org; Tue, 03 Nov 2020 19:44:33 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:35230) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ka6mm-00061b-VA for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:36:24 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:28251) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1ka6mi-0004ms-7h for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:36:24 -0500 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-189-lbBUdxKmOVCwyaYgRb2fsA-1; Tue, 03 Nov 2020 19:36:14 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 819366D596 for ; Wed, 4 Nov 2020 00:36:13 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-97.rdu2.redhat.com [10.10.119.97]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7EDAA55766; Wed, 4 Nov 2020 00:36:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604450179; 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=aRs9bWy/l+OS7Dmw/otXBWJQ78D/TeE5mmlSCOg0PRA=; b=CTavUqjEqnR4f93Wh53JJVMUfO+zmcirk5ob7AY3IYFUgGZsQ1ArSDq4VW7wILGFv/sYqU R8yWZA080pRa6daDqD/p4MbqPT9u9g2ZGkoCr7eAmQBBKnTiSVRehJkvCnwc8tJI9Uywt1 lS+ELpfWFEyq7tRwlEg5PWR4Wqbhc3c= X-MC-Unique: lbBUdxKmOVCwyaYgRb2fsA-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v2 01/72] python/qmp: Add qom script rewrites Date: Tue, 3 Nov 2020 19:34:51 -0500 Message-Id: <20201104003602.1293560-2-jsnow@redhat.com> In-Reply-To: <20201104003602.1293560-1-jsnow@redhat.com> References: <20201104003602.1293560-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 00:03:41 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Cleber Rosa , John Snow , Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Inspired by qom-set, qom-get, qom-tree and qom-list; combine all four of those scripts into one script. A later addition of qom-fuse necessitates that some common features are split out and shared between them. Signed-off-by: John Snow --- python/qemu/qmp/qom.py | 207 ++++++++++++++++++++++++++++++++++ python/qemu/qmp/qom_common.py | 153 +++++++++++++++++++++++++ 2 files changed, 360 insertions(+) create mode 100644 python/qemu/qmp/qom.py create mode 100644 python/qemu/qmp/qom_common.py diff --git a/python/qemu/qmp/qom.py b/python/qemu/qmp/qom.py new file mode 100644 index 000000000000..912d1809e60d --- /dev/null +++ b/python/qemu/qmp/qom.py @@ -0,0 +1,207 @@ +""" +QEMU Object Model testing tools. + +usage: qom.py [-h] {set,get,list,tree} ... + +Query and manipulate QOM data + +optional arguments: + -h, --help show this help message and exit + +QOM commands: + {set,get,list,tree,fuse} + set Set a QOM property value + get Get a QOM property value + list List QOM properties at a given path + tree Show QOM tree from a given path +""" +## +# Copyright John Snow 2020, for Red Hat, Inc. +# Copyright IBM, Corp. 2011 +# +# Authors: +# John Snow +# Anthony Liguori +# +# This work is licensed under the terms of the GNU GPL, version 2 or later. +# See the COPYING file in the top-level directory. +# +# Based on ./scripts/qmp/qom-[set|get|tree|list] +## + +import argparse +import sys + +from . import QMPResponseError +from .qom_common import QOMCommand + + +class QOMSet(QOMCommand): + """QOM Command - Set a property to a given value.""" + name =3D 'set' + help =3D 'Set a QOM property value' + + @classmethod + def configure_parser(cls, parser: argparse.ArgumentParser) -> None: + super().configure_parser(parser) + cls.add_path_prop_arg(parser) + parser.add_argument( + 'value', + metavar=3D'', + action=3D'store', + help=3D'new QOM property value' + ) + + def __init__(self, args: argparse.Namespace): + super().__init__(args) + self.path, self.prop =3D args.path_prop.rsplit('.', 1) + self.value =3D args.value + + def run(self) -> int: + rsp =3D self.qmp.command( + 'qom-set', + path=3Dself.path, + property=3Dself.prop, + value=3Dself.value + ) + print(rsp) + return 0 + + +class QOMGet(QOMCommand): + """QOM Command - Get a property's current value.""" + name =3D 'get' + help =3D 'Get a QOM property value' + + @classmethod + def configure_parser(cls, parser: argparse.ArgumentParser) -> None: + super().configure_parser(parser) + cls.add_path_prop_arg(parser) + + def __init__(self, args: argparse.Namespace): + super().__init__(args) + try: + tmp =3D args.path_prop.rsplit('.', 1) + except ValueError as err: + raise ValueError('Invalid format for .') from = err + self.path =3D tmp[0] + self.prop =3D tmp[1] + + def run(self) -> int: + rsp =3D self.qmp.command( + 'qom-get', + path=3Dself.path, + property=3Dself.prop + ) + if isinstance(rsp, dict): + for key, value in rsp.items(): + print(f"{key}: {value}") + else: + print(rsp) + return 0 + + +class QOMList(QOMCommand): + """QOM Command - List the properties at a given path.""" + name =3D 'list' + help =3D 'List QOM properties at a given path' + + @classmethod + def configure_parser(cls, parser: argparse.ArgumentParser) -> None: + super().configure_parser(parser) + parser.add_argument( + 'path', + metavar=3D'', + action=3D'store', + help=3D'QOM path', + ) + + def __init__(self, args: argparse.Namespace): + super().__init__(args) + self.path =3D args.path + + def run(self) -> int: + rsp =3D self.qom_list(self.path) + for item in rsp: + if item.child: + print(f"{item.name}/") + elif item.link: + print(f"@{item.name}/") + else: + print(item.name) + return 0 + + +class QOMTree(QOMCommand): + """QOM Command - Show the full tree below a given path.""" + name =3D 'tree' + help =3D 'Show QOM tree from a given path' + + @classmethod + def configure_parser(cls, parser: argparse.ArgumentParser) -> None: + super().configure_parser(parser) + parser.add_argument( + 'path', + metavar=3D'', + action=3D'store', + help=3D'QOM path', + nargs=3D'?', + default=3D'/' + ) + + def __init__(self, args: argparse.Namespace): + super().__init__(args) + self.path =3D args.path + + def _list_node(self, path: str) -> None: + print(path) + items =3D self.qom_list(path) + for item in items: + if item.child: + continue + try: + rsp =3D self.qmp.command('qom-get', path=3Dpath, + property=3Ditem.name) + print(f" {item.name}: {rsp} ({item.type})") + except QMPResponseError as err: + print(f" {item.name}: ({item.type})") + print('') + for item in items: + if not item.child: + continue + if path =3D=3D '/': + path =3D '' + self._list_node(f"{path}/{item.name}") + + def run(self) -> int: + self._list_node(self.path) + return 0 + + +def main() -> int: + """QOM script main entry point.""" + parser =3D argparse.ArgumentParser( + description=3D'Query and manipulate QOM data' + ) + subparsers =3D parser.add_subparsers( + title=3D'QOM commands', + dest=3D'command' + ) + + for command in QOMCommand.__subclasses__(): + command.register(subparsers) + + args =3D parser.parse_args() + + if args.command is None: + parser.error('Command not specified.') + return 1 + + assert issubclass(args.cmd_class, QOMCommand) + cmd =3D args.cmd_class(args) + assert isinstance(cmd, QOMCommand) + return cmd.run() + + +if __name__ =3D=3D '__main__': + sys.exit(main()) diff --git a/python/qemu/qmp/qom_common.py b/python/qemu/qmp/qom_common.py new file mode 100644 index 000000000000..3890b247ae68 --- /dev/null +++ b/python/qemu/qmp/qom_common.py @@ -0,0 +1,153 @@ +""" +QOM Command abstractions. +""" +## +# Copyright John Snow 2020, for Red Hat, Inc. +# Copyright IBM, Corp. 2011 +# +# Authors: +# John Snow +# Anthony Liguori +# +# This work is licensed under the terms of the GNU GPL, version 2 or later. +# See the COPYING file in the top-level directory. +# +# Based on ./scripts/qmp/qom-[set|get|tree|list] +## + +import argparse +import os +from typing import ( + Any, + Dict, + List, + Optional, +) + +from . import QEMUMonitorProtocol + + +Subparsers =3D argparse._SubParsersAction # pylint: disable=3Dprotected-a= ccess + + +class ObjectPropertyInfo: + """ + Represents the return type from e.g. qom-list. + """ + def __init__(self, name: str, type_: str, + description: Optional[str] =3D None, + default_value: Optional[object] =3D None): + self.name =3D name + self.type =3D type_ + self.description =3D description + self.default_value =3D default_value + + @classmethod + def make(cls, value: Dict[str, Any]) -> 'ObjectPropertyInfo': + """ + Build an ObjectPropertyInfo from a Dict with an unknown shape. + """ + assert value.keys() >=3D {'name', 'type'} + assert value.keys() <=3D {'name', 'type', 'description', 'default-= value'} + return cls(value['name'], value['type'], + value.get('description'), + value.get('default-value')) + + @property + def child(self) -> bool: + """Is this property a child property?""" + return self.type.startswith('child<') + + @property + def link(self) -> bool: + """Is this property a link property?""" + return self.type.startswith('link<') + + +class QOMCommand: + """ + Represents a QOM sub-command. + + :param args: Parsed arguments, as returned from parser.parse_args. + """ + name: str + help: str + + def __init__(self, args: argparse.Namespace): + if args.socket is None: + raise Exception("No QMP socket path or address given") + self.qmp =3D QEMUMonitorProtocol(args.socket) + self.qmp.connect() + + @classmethod + def register(cls, subparsers: Subparsers) -> None: + """ + Register this command with the argument parser. + + :param subparsers: argparse subparsers object, from "add_subparser= s". + """ + subparser =3D subparsers.add_parser(cls.name, help=3Dcls.help, + description=3Dcls.help) + cls.configure_parser(subparser) + + @classmethod + def configure_parser(cls, parser: argparse.ArgumentParser) -> None: + """ + Configure a parser with this command's arguments. + + :param parser: argparse parser or subparser object. + """ + default_path =3D os.environ.get('QMP_SOCKET') + parser.add_argument( + '--socket', '-s', + dest=3D'socket', + action=3D'store', + help=3D'QMP socket path or address (addr:port).' + ' May also be set via QMP_SOCKET environment variable.', + default=3Ddefault_path + ) + parser.set_defaults(cmd_class=3Dcls) + + @classmethod + def add_path_prop_arg(cls, parser: argparse.ArgumentParser) -> None: + """ + Add the . positional argument to this command. + + :param parser: The parser to add the argument to. + """ + parser.add_argument( + 'path_prop', + metavar=3D'.', + action=3D'store', + help=3D"QOM path and property, separated by a period '.'" + ) + + def run(self) -> int: + """ + Run this command. + + :return: 0 on success, 1 otherwise. + """ + raise NotImplementedError + + def qom_list(self, path: str) -> List[ObjectPropertyInfo]: + """ + :return: a strongly typed list from the 'qom-list' command. + """ + rsp =3D self.qmp.command('qom-list', path=3Dpath) + # qom-list returns List[ObjectPropertyInfo] + assert isinstance(rsp, list) + return [ObjectPropertyInfo.make(x) for x in rsp] + + @classmethod + def entry_point(cls) -> int: + """ + Build this command's parser, parse arguments, and run the command. + + :return: `run`'s return code. + """ + parser =3D argparse.ArgumentParser(description=3Dcls.help) + cls.configure_parser(parser) + args =3D parser.parse_args() + cmd =3D cls(args) + return cmd.run() --=20 2.26.2 From nobody Fri May 17 07:07:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1604450302; cv=none; d=zohomail.com; s=zohoarc; b=ABYaEbwNXdXTrNEdBuSPJp9CbaBwJz6ql8CiWCcaMM5dQIaI6VAtJlCwxUirxvKMieyMfbtz6KPVTTH9mbDzQMGC+arH5lFtzbhfZZqTmeuMXNWMMJtTGn+6xADVZIoxBJkE11qAOcCaXy1zKQc6zb2b+chMIGBnvuecY+lukMk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604450302; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=DwvcW7jNpBKcFtSfGFunStKf7oby9QF8aWFLGmTigZ8=; b=KZKOLhkbPaDTgAgixF0H/R9VJtObiLNETayj3gF/CYHtQytJ7WXolL4ILvjMGsiK0MvrF3OwfU+K95m1Vbv26JyoAC2M8E9tYKyPqQ6gStC1mjsiAVj1usGfuELfwja9+iV0TxoY7RF+nLep4e3G9yFl95gBk215f4mPNqCW1gM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604450302567833.334150891128; Tue, 3 Nov 2020 16:38:22 -0800 (PST) Received: from localhost ([::1]:33104 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ka6oe-0007t8-IS for importer@patchew.org; Tue, 03 Nov 2020 19:38:20 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:35180) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ka6ml-00060S-30 for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:36:23 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:29646) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1ka6mi-0004mp-BV for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:36:22 -0500 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-547-3GElkm8JOMSGv7CsPXMHqA-1; Tue, 03 Nov 2020 19:36:15 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E41B1804774 for ; Wed, 4 Nov 2020 00:36:14 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-97.rdu2.redhat.com [10.10.119.97]) by smtp.corp.redhat.com (Postfix) with ESMTP id AE0C855766; Wed, 4 Nov 2020 00:36:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604450178; 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=DwvcW7jNpBKcFtSfGFunStKf7oby9QF8aWFLGmTigZ8=; b=P6htm2sO2nJh+hjh1MSjDaja2YdKdI0JZ5BPOM3T64CIKkh9Z0Aar62TcJypFVUkfnq6yG xNCPsdenOwVXdx47/enVzIt/b//Xw3Q46eEKer9y68oaP7MRnUXvfykXX7k5YYmimQ1ujq dq5l+ri28vGCcuuT3ZcyHyoDL84Xj2c= X-MC-Unique: 3GElkm8JOMSGv7CsPXMHqA-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v2 02/72] python/qmp: add qom script entry points Date: Tue, 3 Nov 2020 19:34:52 -0500 Message-Id: <20201104003602.1293560-3-jsnow@redhat.com> In-Reply-To: <20201104003602.1293560-1-jsnow@redhat.com> References: <20201104003602.1293560-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 00:03:41 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Cleber Rosa , John Snow , Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Add the 'qom', 'qom-set', 'qom-get', 'qom-list', and 'qom-tree' scripts to the qemu.qmp package. When you install this package, these scripts will become available on your command line. Signed-off-by: John Snow Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- python/setup.cfg | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/python/setup.cfg b/python/setup.cfg index 2c12d9ab89b4..c8b7215996e9 100644 --- a/python/setup.cfg +++ b/python/setup.cfg @@ -28,6 +28,13 @@ devel =3D pylint >=3D 2.6.0 pytest >=3D 3.0.0 =20 +[options.entry_points] +console_scripts =3D + qom =3D qemu.qmp.qom:main + qom-set =3D qemu.qmp.qom:QOMSet.entry_point + qom-get =3D qemu.qmp.qom:QOMGet.entry_point + qom-list =3D qemu.qmp.qom:QOMList.entry_point + qom-tree =3D qemu.qmp.qom:QOMTree.entry_point =20 [flake8] extend-ignore =3D E722 # Prefer pylint's bare-except checks to flake8's --=20 2.26.2 From nobody Fri May 17 07:07:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1604450488; cv=none; d=zohomail.com; s=zohoarc; b=SGpKt4s0KFjBVptjgK8J+GXUjRrn6HcOkVkxlxEF4AB/P6F2jwTU1TxX0EY18TWt/ThR4TyUjHAOxdenohn3+T2/lK9/UowBmsneJqWxNtuHUE9sZYGAUin8KKnbki1lr1bodPls7aUTBH+rd1YNCGPMpuxKOf6nOXQAMMoAljQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604450488; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=pWo0qZcLTd/XRbHuj4Syg08TijkYWoqG5hzND40eqf0=; b=AKQdRtoiHcl2/J9ohDzO6/wybWYdzeoLoB3PmwZIUAoIJrUAykAw7N6Yh9EchVZMBRXhRXXDHK7I3tDzxha/ey4niI/inC094XvwCbzoGs9awz6TO+rcg0GBof+EBjQY6fsdXRkpg5xbgGGeN6q75++SRTh6ySS9+qEMdYAbOBE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604450488978845.5068906854053; Tue, 3 Nov 2020 16:41:28 -0800 (PST) Received: from localhost ([::1]:41872 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ka6rf-0003E2-QD for importer@patchew.org; Tue, 03 Nov 2020 19:41:27 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:35208) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ka6ml-00060i-Fb for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:36:23 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:47623) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1ka6mi-0004n7-S7 for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:36:23 -0500 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-62-jp0Ox0YSPpWHkoCKtISfbg-1; Tue, 03 Nov 2020 19:36:16 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E592018A2257 for ; Wed, 4 Nov 2020 00:36:15 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-97.rdu2.redhat.com [10.10.119.97]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1DF0A55766; Wed, 4 Nov 2020 00:36:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604450179; 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=pWo0qZcLTd/XRbHuj4Syg08TijkYWoqG5hzND40eqf0=; b=Up3vRmokQth1FmeOTEjQmX267u8osDsOIN+E/Zdc6uedGcaGabVQGG+374B+L/GYER2psf Jyy0Z9cz7l1zZsa+5atADfjG9shOX+siR8VqXWsKpSIVw9jv2S+ySx97KxOLQIUeRFAiQo YqapBapZhGtDDwCmlR4wa+ZOd0LO598= X-MC-Unique: jp0Ox0YSPpWHkoCKtISfbg-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v2 03/72] scripts/qmp: redirect qom-xxx scripts to python/qemu/qmp/ Date: Tue, 3 Nov 2020 19:34:53 -0500 Message-Id: <20201104003602.1293560-4-jsnow@redhat.com> In-Reply-To: <20201104003602.1293560-1-jsnow@redhat.com> References: <20201104003602.1293560-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 01:02:05 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Cleber Rosa , John Snow , Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Redirect to the new qom scripts. These forwarders can be deleted eventually when there has been more time for the dust on the Python packaging to settle and people understand how to find these commands. Note: You can run these by setting $PYTHONPATH in your shell and then running "python3 -m qemu.qmp.qom", or you can install the qemu namespace package and use the "qom" or "qom-set" scripts. I've written how to install the package elsewhere, but for the sake of git-blame, cd to ./python, and then do: - pip3 install [--user] [-e] . --user will install to your local user install (will not work inside of a venv), omitting this flag installs to your system-wide packages (outside of a venv) or to your current virtual environment (inside the venv). When installing to a venv or to your system-wide packages, "qom" should be in your $PATH already. If you do a user install, you may need to add ~/.local/bin to your $PATH if you haven't already. -e installs in editable mode: the installed package is effectively just a symlink to this folder; so changes to your git working tree are reflected in the installed package. Alternatively to the above, If you have `pipenv` installed (`pip3 install --user pipenv`), you may also invoke 'pipenv shell' to enter a pipenv-managed virtual environment (as a shell process that you may leave with ctrt+d) that has 'qom' already in $PATH. Signed-off-by: John Snow Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- scripts/qmp/qom-get | 66 +++------------------------------------ scripts/qmp/qom-list | 63 +++---------------------------------- scripts/qmp/qom-set | 63 +++---------------------------------- scripts/qmp/qom-tree | 74 +++----------------------------------------- 4 files changed, 16 insertions(+), 250 deletions(-) diff --git a/scripts/qmp/qom-get b/scripts/qmp/qom-get index 666df718320c..e4f3e0c01381 100755 --- a/scripts/qmp/qom-get +++ b/scripts/qmp/qom-get @@ -1,69 +1,11 @@ #!/usr/bin/env python3 -## -# QEMU Object Model test tools -# -# Copyright IBM, Corp. 2011 -# -# Authors: -# Anthony Liguori -# -# This work is licensed under the terms of the GNU GPL, version 2 or later= . See -# the COPYING file in the top-level directory. -## =20 -import sys import os +import sys =20 sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'pytho= n')) -from qemu.qmp import QEMUMonitorProtocol +from qemu.qmp.qom import QOMGet =20 -cmd, args =3D sys.argv[0], sys.argv[1:] -socket_path =3D None -path =3D None -prop =3D None =20 -def usage(): - return '''environment variables: - QMP_SOCKET=3D -usage: - %s [-h] [-s ] . -''' % cmd - -def usage_error(error_msg =3D "unspecified error"): - sys.stderr.write('%s\nERROR: %s\n' % (usage(), error_msg)) - exit(1) - -if len(args) > 0: - if args[0] =3D=3D "-h": - print(usage()) - exit(0); - elif args[0] =3D=3D "-s": - try: - socket_path =3D args[1] - except: - usage_error("missing argument: QMP socket path or address"); - args =3D args[2:] - -if not socket_path: - if 'QMP_SOCKET' in os.environ: - socket_path =3D os.environ['QMP_SOCKET'] - else: - usage_error("no QMP socket path or address given"); - -if len(args) > 0: - try: - path, prop =3D args[0].rsplit('.', 1) - except: - usage_error("invalid format for path/property/value") -else: - usage_error("not enough arguments") - -srv =3D QEMUMonitorProtocol(socket_path) -srv.connect() - -rsp =3D srv.command('qom-get', path=3Dpath, property=3Dprop) -if type(rsp) =3D=3D dict: - for i in rsp.keys(): - print('%s: %s' % (i, rsp[i])) -else: - print(rsp) +if __name__ =3D=3D '__main__': + sys.exit(QOMGet.entry_point()) diff --git a/scripts/qmp/qom-list b/scripts/qmp/qom-list index 5074fd939f4a..7a071a54e1e7 100755 --- a/scripts/qmp/qom-list +++ b/scripts/qmp/qom-list @@ -1,66 +1,11 @@ #!/usr/bin/env python3 -## -# QEMU Object Model test tools -# -# Copyright IBM, Corp. 2011 -# -# Authors: -# Anthony Liguori -# -# This work is licensed under the terms of the GNU GPL, version 2 or later= . See -# the COPYING file in the top-level directory. -## =20 -import sys import os +import sys =20 sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'pytho= n')) -from qemu.qmp import QEMUMonitorProtocol +from qemu.qmp.qom import QOMList =20 -cmd, args =3D sys.argv[0], sys.argv[1:] -socket_path =3D None -path =3D None -prop =3D None =20 -def usage(): - return '''environment variables: - QMP_SOCKET=3D -usage: - %s [-h] [-s ] [] -''' % cmd - -def usage_error(error_msg =3D "unspecified error"): - sys.stderr.write('%s\nERROR: %s\n' % (usage(), error_msg)) - exit(1) - -if len(args) > 0: - if args[0] =3D=3D "-h": - print(usage()) - exit(0); - elif args[0] =3D=3D "-s": - try: - socket_path =3D args[1] - except: - usage_error("missing argument: QMP socket path or address"); - args =3D args[2:] - -if not socket_path: - if 'QMP_SOCKET' in os.environ: - socket_path =3D os.environ['QMP_SOCKET'] - else: - usage_error("no QMP socket path or address given"); - -srv =3D QEMUMonitorProtocol(socket_path) -srv.connect() - -if len(args) =3D=3D 0: - print('/') - sys.exit(0) - -for item in srv.command('qom-list', path=3Dargs[0]): - if item['type'].startswith('child<'): - print('%s/' % item['name']) - elif item['type'].startswith('link<'): - print('@%s/' % item['name']) - else: - print('%s' % item['name']) +if __name__ =3D=3D '__main__': + sys.exit(QOMList.entry_point()) diff --git a/scripts/qmp/qom-set b/scripts/qmp/qom-set index 240a78187f9b..9ca9e2ba106b 100755 --- a/scripts/qmp/qom-set +++ b/scripts/qmp/qom-set @@ -1,66 +1,11 @@ #!/usr/bin/env python3 -## -# QEMU Object Model test tools -# -# Copyright IBM, Corp. 2011 -# -# Authors: -# Anthony Liguori -# -# This work is licensed under the terms of the GNU GPL, version 2 or later= . See -# the COPYING file in the top-level directory. -## =20 -import sys import os +import sys =20 sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'pytho= n')) -from qemu.qmp import QEMUMonitorProtocol +from qemu.qmp.qom import QOMSet =20 -cmd, args =3D sys.argv[0], sys.argv[1:] -socket_path =3D None -path =3D None -prop =3D None -value =3D None =20 -def usage(): - return '''environment variables: - QMP_SOCKET=3D -usage: - %s [-h] [-s ] . -''' % cmd - -def usage_error(error_msg =3D "unspecified error"): - sys.stderr.write('%s\nERROR: %s\n' % (usage(), error_msg)) - exit(1) - -if len(args) > 0: - if args[0] =3D=3D "-h": - print(usage()) - exit(0); - elif args[0] =3D=3D "-s": - try: - socket_path =3D args[1] - except: - usage_error("missing argument: QMP socket path or address"); - args =3D args[2:] - -if not socket_path: - if 'QMP_SOCKET' in os.environ: - socket_path =3D os.environ['QMP_SOCKET'] - else: - usage_error("no QMP socket path or address given"); - -if len(args) > 1: - try: - path, prop =3D args[0].rsplit('.', 1) - except: - usage_error("invalid format for path/property/value") - value =3D args[1] -else: - usage_error("not enough arguments") - -srv =3D QEMUMonitorProtocol(socket_path) -srv.connect() - -print(srv.command('qom-set', path=3Dpath, property=3Dprop, value=3Dvalue)) +if __name__ =3D=3D '__main__': + sys.exit(QOMSet.entry_point()) diff --git a/scripts/qmp/qom-tree b/scripts/qmp/qom-tree index 25b0781323cc..7d0ccca3a4dd 100755 --- a/scripts/qmp/qom-tree +++ b/scripts/qmp/qom-tree @@ -1,77 +1,11 @@ #!/usr/bin/env python3 -## -# QEMU Object Model test tools -# -# Copyright IBM, Corp. 2011 -# Copyright (c) 2013 SUSE LINUX Products GmbH -# -# Authors: -# Anthony Liguori -# Andreas Faerber -# -# This work is licensed under the terms of the GNU GPL, version 2 or later= . See -# the COPYING file in the top-level directory. -## =20 -import sys import os +import sys =20 sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'pytho= n')) -from qemu.qmp import QEMUMonitorProtocol +from qemu.qmp.qom import QOMTree =20 -cmd, args =3D sys.argv[0], sys.argv[1:] -socket_path =3D None -path =3D None -prop =3D None =20 -def usage(): - return '''environment variables: - QMP_SOCKET=3D -usage: - %s [-h] [-s ] [] -''' % cmd - -def usage_error(error_msg =3D "unspecified error"): - sys.stderr.write('%s\nERROR: %s\n' % (usage(), error_msg)) - exit(1) - -if len(args) > 0: - if args[0] =3D=3D "-h": - print(usage()) - exit(0); - elif args[0] =3D=3D "-s": - try: - socket_path =3D args[1] - except: - usage_error("missing argument: QMP socket path or address"); - args =3D args[2:] - -if not socket_path: - if 'QMP_SOCKET' in os.environ: - socket_path =3D os.environ['QMP_SOCKET'] - else: - usage_error("no QMP socket path or address given"); - -srv =3D QEMUMonitorProtocol(socket_path) -srv.connect() - -def list_node(path): - print('%s' % path) - items =3D srv.command('qom-list', path=3Dpath) - for item in items: - if not item['type'].startswith('child<'): - try: - print(' %s: %s (%s)' % (item['name'], srv.command('qom-ge= t', path=3Dpath, property=3Ditem['name']), item['type'])) - except: - print(' %s: (%s)' % (item['name'], item['type= '])) - print('') - for item in items: - if item['type'].startswith('child<'): - list_node((path if (path !=3D '/') else '') + '/' + item['nam= e']) - -if len(args) =3D=3D 0: - path =3D '/' -else: - path =3D args[0] - -list_node(path) +if __name__ =3D=3D '__main__': + sys.exit(QOMTree.entry_point()) --=20 2.26.2 From nobody Fri May 17 07:07:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1604450307; cv=none; d=zohomail.com; s=zohoarc; b=Xry2Kzg0497DHOzgAHZi+39waylc/WIaeW3q5hv6bRd27nbBhHzuV3+GuMI1gRgKWIA1Zf2e6gJdumHvWQYsR3hNwSLi32Zzgh/GbtVcS+vukQgfNExCUxsWjFTnEkxd9ZgG1pGYe+vABDH79tt1+XqwTHz8vN1Mf874jwzGPSI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604450307; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=NtPqYDlMwDVDZ/3ryxoYSA5f/GpDjZdGVM7WpES8EFc=; b=nu49qGIEQBTbBZOuhe0p498/3jUQnhMRCpmkgXjXJaj1hynBV1bDJTcL2KTgIlNCJ+QeHSzu3knH9FQ4QE5Rav15TzkhBnXN52DiLXI+YmZaizB5WsrQSW71eMMcqIyT+8D1gptp6xrdrGChLll6929tae14DHYI249kNCTIF/E= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604450306928710.7131217335867; Tue, 3 Nov 2020 16:38:26 -0800 (PST) Received: from localhost ([::1]:33560 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ka6oj-00084q-P6 for importer@patchew.org; Tue, 03 Nov 2020 19:38:25 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:35240) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ka6mn-00062q-LA for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:36:25 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:56065) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1ka6mk-0004nS-Tx for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:36:25 -0500 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-552-fjX5GEaMOs2HUcWIZUacmQ-1; Tue, 03 Nov 2020 19:36:20 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 180441028D50 for ; Wed, 4 Nov 2020 00:36:17 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-97.rdu2.redhat.com [10.10.119.97]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1CBE055766; Wed, 4 Nov 2020 00:36:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604450182; 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=NtPqYDlMwDVDZ/3ryxoYSA5f/GpDjZdGVM7WpES8EFc=; b=IuLHDz0hB2SwydZrO0fVk/PLROJTmrbmOFSDPZ7now63q3ZsCIQRioWD7lj3CGN/OTOFHK WGVnWI9+J/kYFsfkwLoI+/Erg5fKef1m1IgnPwg6m2qPcUQCUKCLWyZ4vMtX5iu1+ZUwC6 wo/3J9EH56HCWHvDqsf4q1PTznRyiwg= X-MC-Unique: fjX5GEaMOs2HUcWIZUacmQ-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v2 04/72] scripts/qom-fuse: apply isort rules Date: Tue, 3 Nov 2020 19:34:54 -0500 Message-Id: <20201104003602.1293560-5-jsnow@redhat.com> In-Reply-To: <20201104003602.1293560-1-jsnow@redhat.com> References: <20201104003602.1293560-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 01:02:05 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Cleber Rosa , John Snow , Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Hint: you can use symlinks to create qom_fuse.py in python/qemu/qmp/ and point to scripts/qom-fuse to apply the standard linting rules to this script. Signed-off-by: John Snow Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- scripts/qmp/qom-fuse | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/scripts/qmp/qom-fuse b/scripts/qmp/qom-fuse index 7c7cff8edfba..62deb9adb12d 100755 --- a/scripts/qmp/qom-fuse +++ b/scripts/qmp/qom-fuse @@ -13,14 +13,20 @@ # the COPYING file in the top-level directory. ## =20 -import fuse, stat -from fuse import FUSE, FuseOSError, Operations -import os, posix, sys from errno import * +import os +import posix +import stat +import sys + +import fuse +from fuse import FUSE, FuseOSError, Operations + =20 sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'pytho= n')) from qemu.qmp import QEMUMonitorProtocol =20 + fuse.fuse_python_api =3D (0, 2) =20 class QOMFS(Operations): --=20 2.26.2 From nobody Fri May 17 07:07:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1604450485; cv=none; d=zohomail.com; s=zohoarc; b=E4Y2yxqnff1kfClrearaopTeuZ0IgayU81D4mKvb3kKzKa2PUA+5Txnr2I/vFhXYONN+lAuFIaHpfHv4KehLNsmtoE3JiaNW41UwwWOwCevmxm6dcH51zm8/5U1eA9ZgyzgVIj9eKx1aTCUhzO0NmMQUj2kHMtuw0MX59o5FyDo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604450485; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=GoN6FiR7SXqCjEjgaiCivn1MHyl3p6NfHJ/cTW8wnyM=; b=KF6545CxbnTp+6UAmijQ71NEsrmQ2lcp1M6z7W6U5GSMyTwOanZK3OucmHd35wbbmC2ZZMNrxRkmASc+iCxHGP8WxfMKnGtr5p21KcB3DZxq5CfgdJnh/12fr+JjNOVGEUAHVeMUPkQ8UrKzCoYc/NwlOgCoX/709B3tRJtuh0k= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604450485553907.4659151567157; Tue, 3 Nov 2020 16:41:25 -0800 (PST) Received: from localhost ([::1]:41534 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ka6rc-00033A-GB for importer@patchew.org; Tue, 03 Nov 2020 19:41:24 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:35246) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ka6mo-00064p-J4 for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:36:26 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:28160) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1ka6mm-0004np-NP for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:36:26 -0500 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-590-4gATjyqCMyehv5r0C8SepA-1; Tue, 03 Nov 2020 19:36:22 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8671D1052519 for ; Wed, 4 Nov 2020 00:36:18 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-97.rdu2.redhat.com [10.10.119.97]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4528255766; Wed, 4 Nov 2020 00:36:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604450183; 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=GoN6FiR7SXqCjEjgaiCivn1MHyl3p6NfHJ/cTW8wnyM=; b=GhqguQEkoWPfQILduoqDzHcK5vVTMjEVoTACadyZlWT2favFYaR1qFR2Fde38o4QhYjLmJ /dFqpSxJ7dv4Kh0C5JlneVeGJsD76VvDrTEkzJ6FnYdNWJp3LOK/AqgkALMv+WkaFGD1f4 luInRNoKstXDikpJ2bTktgZpcSsYFIM= X-MC-Unique: 4gATjyqCMyehv5r0C8SepA-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v2 05/72] scripts/qom-fuse: apply flake8 rules Date: Tue, 3 Nov 2020 19:34:55 -0500 Message-Id: <20201104003602.1293560-6-jsnow@redhat.com> In-Reply-To: <20201104003602.1293560-1-jsnow@redhat.com> References: <20201104003602.1293560-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 01:02:05 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Cleber Rosa , John Snow , Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" flake8 still has one warning because of the sys.path hack, but that will be going away by the end of this patch series. Signed-off-by: John Snow --- scripts/qmp/qom-fuse | 81 +++++++++++++++++++++++--------------------- 1 file changed, 43 insertions(+), 38 deletions(-) diff --git a/scripts/qmp/qom-fuse b/scripts/qmp/qom-fuse index 62deb9adb12d..ca30e928679e 100755 --- a/scripts/qmp/qom-fuse +++ b/scripts/qmp/qom-fuse @@ -9,13 +9,12 @@ # Anthony Liguori # Markus Armbruster # -# This work is licensed under the terms of the GNU GPL, version 2 or later= . See -# the COPYING file in the top-level directory. +# This work is licensed under the terms of the GNU GPL, version 2 or later. +# See the COPYING file in the top-level directory. ## =20 -from errno import * +from errno import ENOENT, EPERM import os -import posix import stat import sys =20 @@ -29,6 +28,7 @@ from qemu.qmp import QEMUMonitorProtocol =20 fuse.fuse_python_api =3D (0, 2) =20 + class QOMFS(Operations): def __init__(self, qmp): self.qmp =3D qmp @@ -45,7 +45,7 @@ class QOMFS(Operations): =20 def is_object(self, path): try: - items =3D self.qmp.command('qom-list', path=3Dpath) + self.qmp.command('qom-list', path=3Dpath) return True except: return False @@ -85,7 +85,7 @@ class QOMFS(Operations): path =3D '/' try: data =3D self.qmp.command('qom-get', path=3Dpath, property=3Dp= rop) - data +=3D '\n' # make values shell friendly + data +=3D '\n' # make values shell friendly except: raise FuseOSError(EPERM) =20 @@ -104,38 +104,44 @@ class QOMFS(Operations): =20 def getattr(self, path, fh=3DNone): if self.is_link(path): - value =3D { 'st_mode': 0o755 | stat.S_IFLNK, - 'st_ino': self.get_ino(path), - 'st_dev': 0, - 'st_nlink': 2, - 'st_uid': 1000, - 'st_gid': 1000, - 'st_size': 4096, - 'st_atime': 0, - 'st_mtime': 0, - 'st_ctime': 0 } + value =3D { + 'st_mode': 0o755 | stat.S_IFLNK, + 'st_ino': self.get_ino(path), + 'st_dev': 0, + 'st_nlink': 2, + 'st_uid': 1000, + 'st_gid': 1000, + 'st_size': 4096, + 'st_atime': 0, + 'st_mtime': 0, + 'st_ctime': 0 + } elif self.is_object(path): - value =3D { 'st_mode': 0o755 | stat.S_IFDIR, - 'st_ino': self.get_ino(path), - 'st_dev': 0, - 'st_nlink': 2, - 'st_uid': 1000, - 'st_gid': 1000, - 'st_size': 4096, - 'st_atime': 0, - 'st_mtime': 0, - 'st_ctime': 0 } + value =3D { + 'st_mode': 0o755 | stat.S_IFDIR, + 'st_ino': self.get_ino(path), + 'st_dev': 0, + 'st_nlink': 2, + 'st_uid': 1000, + 'st_gid': 1000, + 'st_size': 4096, + 'st_atime': 0, + 'st_mtime': 0, + 'st_ctime': 0 + } elif self.is_property(path): - value =3D { 'st_mode': 0o644 | stat.S_IFREG, - 'st_ino': self.get_ino(path), - 'st_dev': 0, - 'st_nlink': 1, - 'st_uid': 1000, - 'st_gid': 1000, - 'st_size': 4096, - 'st_atime': 0, - 'st_mtime': 0, - 'st_ctime': 0 } + value =3D { + 'st_mode': 0o644 | stat.S_IFREG, + 'st_ino': self.get_ino(path), + 'st_dev': 0, + 'st_nlink': 1, + 'st_uid': 1000, + 'st_gid': 1000, + 'st_size': 4096, + 'st_atime': 0, + 'st_mtime': 0, + 'st_ctime': 0 + } else: raise FuseOSError(ENOENT) return value @@ -146,8 +152,7 @@ class QOMFS(Operations): for item in self.qmp.command('qom-list', path=3Dpath): yield str(item['name']) =20 + if __name__ =3D=3D '__main__': - import os - fuse =3D FUSE(QOMFS(QEMUMonitorProtocol(os.environ['QMP_SOCKET'])), sys.argv[1], foreground=3DTrue) --=20 2.26.2 From nobody Fri May 17 07:07:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1604450311; cv=none; d=zohomail.com; s=zohoarc; b=gBw8zh/T0JSEUNT/eEwAhh8g8jvS20k7CSAlwbFSeDJBnkY8v6gWe1c4xDN8cLsV7z4F76NBI71dr5oefsxrKjg420xlkX/1DYPTqcrJUbIKyFibTbfblckqkNa/C67KeUnq2kL6fCEPAkCvB1I7gj2PDeR2YpxRhI4MocaCI+g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604450311; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=/7XfrPNcUA+ASzGoojQUyH/mfhYmKp7PqWjbFYoevKc=; b=VioFKaWXKuseFwQXZmzv73x93EoUkTDdW1rZ8hHLhqIUVpL5q/X9eopg5UnYoqpiK7kckncw3JEQequHM0zQemiF5pW8xxucwxDoCjifR1LTzRRjaYD+4H54B1f8MK5MAwbekEpcdJeQIN/nQldbCbF0JHUVieRE9LQs/RqdHUE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604450311838888.8008112496619; Tue, 3 Nov 2020 16:38:31 -0800 (PST) Received: from localhost ([::1]:34004 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ka6oo-0008Fr-L0 for importer@patchew.org; Tue, 03 Nov 2020 19:38:30 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:35258) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ka6mq-000681-4I for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:36:28 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:39962) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1ka6mo-0004oB-CL for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:36:27 -0500 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-399-DKFH0nmROUWH4gMVaJ8daw-1; Tue, 03 Nov 2020 19:36:24 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EFC1FE06D8 for ; Wed, 4 Nov 2020 00:36:19 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-97.rdu2.redhat.com [10.10.119.97]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7E5298358B; Wed, 4 Nov 2020 00:36:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604450185; 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=/7XfrPNcUA+ASzGoojQUyH/mfhYmKp7PqWjbFYoevKc=; b=bIEvkjHXeV9DsNpub8l8JZ/yaKEjtaieKlPJ5mlZ1ax04YZ8cj64ydGipB5vvBvTAJA169 ohQAVSf0V1mPb6lV9PVvejl+Elrg4fT4KcjBvFOGqfkvmCOFDFzTu1BR9jTaH/k2ALZpeY ZYBUVrS/bScCDHlbp0CWs83KpH/B1a4= X-MC-Unique: DKFH0nmROUWH4gMVaJ8daw-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v2 06/72] python: Add 'fh' to known-good variable names Date: Tue, 3 Nov 2020 19:34:56 -0500 Message-Id: <20201104003602.1293560-7-jsnow@redhat.com> In-Reply-To: <20201104003602.1293560-1-jsnow@redhat.com> References: <20201104003602.1293560-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 00:03:41 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Cleber Rosa , John Snow , Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" fd and fh are fine: we often use these for "file descriptor" or "file handle" accordingly. It is rarely the case that you need to enforce a more semantically meaningful name beyond "This is the file we are using right now." While we're here: add comments for all of the non-standard pylint names. (And the underscore.) Signed-off-by: John Snow --- python/setup.cfg | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/python/setup.cfg b/python/setup.cfg index c8b7215996e9..c963d05527aa 100644 --- a/python/setup.cfg +++ b/python/setup.cfg @@ -68,9 +68,10 @@ good-names=3Di, k, ex, Run, - _, - fd, - c, + _, # By convention: Unused variable + fh, # fh =3D open(...) + fd, # fd =3D os.open(...) + c, # for c in string: ... =20 [pylint.similarities] # Ignore imports when computing similarities. --=20 2.26.2 From nobody Fri May 17 07:07:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1604450764; cv=none; d=zohomail.com; s=zohoarc; b=bFWEG5q5MsLKZQpUfGmZcYQAy9l5vQMQpNNViCO6qmYvqgtQr8hgYNKhAFK5v7QhTZf0APtj91ce6f7rqiS23m6dnsQLh0kM5+UNJwurydvlAbfB5NflZPRSkBQGE0TKc3xSaV3n9M21YFwOLXalKAcLICkhJhs3H+cQIUR5bQ0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604450764; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=fB1rH87GsDpMYD9z/NEMczfG2TJxteUGF9x5BkNa1OY=; b=Q69kWnKF/QJ2cJrTxs7UKS7iOju6u00SLpkcHvntqQATXtQxryGWgHiit5T0XGZhjuEGRFkAsKn6pbKiBIpPhpnSgbRdpGZftlaiTiIk+j9Tmn/leKqiVnxzvpvD/6VqRHo6K8JwULgm8JPbDbXjFrlZrUyGMotisMwvLtZgxGE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 160445076478244.19731472948865; Tue, 3 Nov 2020 16:46:04 -0800 (PST) Received: from localhost ([::1]:58360 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ka6w7-0001gh-Jh for importer@patchew.org; Tue, 03 Nov 2020 19:46:03 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:35280) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ka6ms-0006Bo-23 for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:36:30 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:28602) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1ka6mq-0004oP-9j for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:36:29 -0500 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-529-ap_egA23MsC9IgMjNxH5FA-1; Tue, 03 Nov 2020 19:36:25 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 56AB0186842A for ; Wed, 4 Nov 2020 00:36:21 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-97.rdu2.redhat.com [10.10.119.97]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2D7A155766; Wed, 4 Nov 2020 00:36:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604450187; 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=fB1rH87GsDpMYD9z/NEMczfG2TJxteUGF9x5BkNa1OY=; b=hhjRIzztpRRXx76SitCnufDBv70LZ1rWZKwBzCW9VACx6yxlpQRofE0xgvdHr9m5ad2MwZ Zp937b6lExzZq2tyZnHWU+5QzWkSnWWfzeTHO4IyNPM4cuO0c3gaQBV5a3lRcKUnlbOUDL QKVDxAjHS0YFevBwtxuamkmpEMeWm98= X-MC-Unique: ap_egA23MsC9IgMjNxH5FA-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v2 07/72] scripts/qom-fuse: Apply pylint rules Date: Tue, 3 Nov 2020 19:34:57 -0500 Message-Id: <20201104003602.1293560-8-jsnow@redhat.com> In-Reply-To: <20201104003602.1293560-1-jsnow@redhat.com> References: <20201104003602.1293560-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 00:03:41 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Cleber Rosa , John Snow , Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) - Catch specific exceptions from QMP - Reraise errors with explicit context - method parameters should match parent's names Signed-off-by: John Snow Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- scripts/qmp/qom-fuse | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/scripts/qmp/qom-fuse b/scripts/qmp/qom-fuse index ca30e928679e..805e99c8ecde 100755 --- a/scripts/qmp/qom-fuse +++ b/scripts/qmp/qom-fuse @@ -23,7 +23,7 @@ from fuse import FUSE, FuseOSError, Operations =20 =20 sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'pytho= n')) -from qemu.qmp import QEMUMonitorProtocol +from qemu.qmp import QEMUMonitorProtocol, QMPResponseError =20 =20 fuse.fuse_python_api =3D (0, 2) @@ -47,7 +47,7 @@ class QOMFS(Operations): try: self.qmp.command('qom-list', path=3Dpath) return True - except: + except QMPResponseError: return False =20 def is_property(self, path): @@ -59,7 +59,7 @@ class QOMFS(Operations): if item['name'] =3D=3D prop: return True return False - except: + except QMPResponseError: return False =20 def is_link(self, path): @@ -73,10 +73,10 @@ class QOMFS(Operations): return True return False return False - except: + except QMPResponseError: return False =20 - def read(self, path, length, offset, fh): + def read(self, path, size, offset, fh): if not self.is_property(path): return -ENOENT =20 @@ -86,13 +86,13 @@ class QOMFS(Operations): try: data =3D self.qmp.command('qom-get', path=3Dpath, property=3Dp= rop) data +=3D '\n' # make values shell friendly - except: - raise FuseOSError(EPERM) + except QMPResponseError as err: + raise FuseOSError(EPERM) from err =20 if offset > len(data): return '' =20 - return bytes(data[offset:][:length], encoding=3D'utf-8') + return bytes(data[offset:][:size], encoding=3D'utf-8') =20 def readlink(self, path): if not self.is_link(path): --=20 2.26.2 From nobody Fri May 17 07:07:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1604450661; cv=none; d=zohomail.com; s=zohoarc; b=aFHGlKT9emryeAm1xVb4DFUIaLA7l7ILE2qm4/dJsGtbL/WWWkGECXQuuUM8SkZ7TYIpHAXdDoj8k9QTYbQChvxMm/m4cAiwBjXSH+fX8kxx9O69WyREwyWbgfF0ffDnupfOlTv1z+WL+sBKcMusI0C5tpl/9OYUhJJIjtG41Og= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604450661; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=DiMgE0UtyeBtSOs2ViahvnsUVOSuIpj0nZaYzc/xmlg=; b=am74AAXzV3CSPCo+zcr4KI1zuEknTe4ODH3CzkfhVtnya0q/gvSYL6ogqysNybpDej5LcfZhjq+ZfzSknaPvpcC4ovlxJVcYkasMavDFyTfEP8rbqZC+GvvaEqeymVTD7X+Az2YiMOyHW20ILLrMoayn5tPQmZma4H1XDl42upM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 160445066173634.57015527988767; Tue, 3 Nov 2020 16:44:21 -0800 (PST) Received: from localhost ([::1]:49934 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ka6uS-0006bf-8Y for importer@patchew.org; Tue, 03 Nov 2020 19:44:20 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:35278) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ka6mr-0006Ap-BX for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:36:29 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:45504) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1ka6mp-0004oI-HS for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:36:29 -0500 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-468-OzsU2WcHNFORJ4w_CEHVMQ-1; Tue, 03 Nov 2020 19:36:25 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 321051016CF5 for ; Wed, 4 Nov 2020 00:36:22 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-97.rdu2.redhat.com [10.10.119.97]) by smtp.corp.redhat.com (Postfix) with ESMTP id 66FAC55766; Wed, 4 Nov 2020 00:36:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604450186; 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=DiMgE0UtyeBtSOs2ViahvnsUVOSuIpj0nZaYzc/xmlg=; b=Gf5T5cSH8NB3iJs9NFeT1Ev7K0NFULWv5S8976LGoBmwOSU4hak7pnbNhnCBQtaMiVD5MS QSakOesaDeQKyZy6X2NU673qZhbO9JSyS5FS3IZ6O/6l0S+Xi2xbd6ATUinNe/xhS+pRv6 4r4TS3keT0GYhY+k9LZvoEsBX+LKjhQ= X-MC-Unique: OzsU2WcHNFORJ4w_CEHVMQ-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v2 08/72] scripts/qom-fuse: Add docstrings Date: Tue, 3 Nov 2020 19:34:58 -0500 Message-Id: <20201104003602.1293560-9-jsnow@redhat.com> In-Reply-To: <20201104003602.1293560-1-jsnow@redhat.com> References: <20201104003602.1293560-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 01:02:05 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Cleber Rosa , John Snow , Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" The methods inherited from fuse don't need docstrings; that's up to fusepy to handle. Signed-off-by: John Snow --- scripts/qmp/qom-fuse | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/scripts/qmp/qom-fuse b/scripts/qmp/qom-fuse index 805e99c8ecde..5b80da9df66b 100755 --- a/scripts/qmp/qom-fuse +++ b/scripts/qmp/qom-fuse @@ -1,7 +1,20 @@ #!/usr/bin/env python3 +""" +QEMU Object Model FUSE filesystem tool + +This script offers a simple FUSE filesystem within which the QOM tree +may be browsed, queried and edited using traditional shell tooling. + +This script requires the 'fusepy' python package; +you may install it by using ``pip3 install --user fusepy``. + +ENV: + QMP_SOCKET: Path to the QMP server socket + +Usage: + qom-fuse /mount/to/here +""" ## -# QEMU Object Model test tools -# # Copyright IBM, Corp. 2012 # Copyright (C) 2020 Red Hat, Inc. # @@ -30,6 +43,7 @@ fuse.fuse_python_api =3D (0, 2) =20 =20 class QOMFS(Operations): + """QOMFS implements fuse.Operations to provide a QOM filesystem.""" def __init__(self, qmp): self.qmp =3D qmp self.qmp.connect() @@ -37,6 +51,7 @@ class QOMFS(Operations): self.ino_count =3D 1 =20 def get_ino(self, path): + """Get an inode number for a given QOM path.""" if path in self.ino_map: return self.ino_map[path] self.ino_map[path] =3D self.ino_count @@ -44,6 +59,7 @@ class QOMFS(Operations): return self.ino_map[path] =20 def is_object(self, path): + """Is the given QOM path an object?""" try: self.qmp.command('qom-list', path=3Dpath) return True @@ -51,6 +67,7 @@ class QOMFS(Operations): return False =20 def is_property(self, path): + """Is the given QOM path a property?""" path, prop =3D path.rsplit('/', 1) if path =3D=3D '': path =3D '/' @@ -63,6 +80,7 @@ class QOMFS(Operations): return False =20 def is_link(self, path): + """Is the given QOM path a link?""" path, prop =3D path.rsplit('/', 1) if path =3D=3D '': path =3D '/' --=20 2.26.2 From nobody Fri May 17 07:07:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1604450769; cv=none; d=zohomail.com; s=zohoarc; b=AGftVVpT5Z+acaTlrxsVEWGSAKymbH22EDPq8BWtcm3m6L78eRVbAAzfdgr0Odx9CV+XveAFhYPfX//nUpw8ZQ8UCAXzbcA5Hxb6PilUgFE8aT+wWw/PyocPNldsBQ8zrYdNRPt/GuwK3llbKxOb86YrKCKs5qQFqOxoEAx5hAQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604450769; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=za4rE4qH6a3IQrOThgWqsc64uRgYKF2HZZqGYd/r9FY=; b=G8SzCTt9DnWpWQHRZOB5YQgimQ92DQakHB8/wVQbQO4hkVjdYFOnwIX/SfQJwqjh7rYAx5ykogc174GOT0kPvGMMQ5c4GSuVH1mzYwdyjpEDHS0YQCmrUGoaS0V3j+BrapSXiiHZjy+e8fltbg/eHM/wR4uVXvQW2VlU39txCSA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604450769476482.77601531065136; Tue, 3 Nov 2020 16:46:09 -0800 (PST) Received: from localhost ([::1]:58918 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ka6wC-0001ud-A3 for importer@patchew.org; Tue, 03 Nov 2020 19:46:08 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:35292) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ka6mt-0006F3-TC for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:36:33 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:33286) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1ka6mr-0004ob-U1 for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:36:31 -0500 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-32-uUKHd0VmPoiN976UBPs3rQ-1; Tue, 03 Nov 2020 19:36:27 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A26C3100F949 for ; Wed, 4 Nov 2020 00:36:23 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-97.rdu2.redhat.com [10.10.119.97]) by smtp.corp.redhat.com (Postfix) with ESMTP id 857E755766; Wed, 4 Nov 2020 00:36:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604450189; 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=za4rE4qH6a3IQrOThgWqsc64uRgYKF2HZZqGYd/r9FY=; b=ivAHj1e+xksz5UaJRUImgrOxH2fu0pR/Oalq7lq5gWeFy75R1gcZuJLMi1YFJtzV0a7Vlb uRHfF68XwVpz09e/4oUpNsXnyMSZQhB0qpHsqe+BM9oo4xffcjBnMIxK9cb1ns0v2J2nKW LMqZD80/vsvQlikaj0ts5+A1t0sq4/s= X-MC-Unique: uUKHd0VmPoiN976UBPs3rQ-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v2 09/72] scripts/qom-fuse: Convert to QOMCommand Date: Tue, 3 Nov 2020 19:34:59 -0500 Message-Id: <20201104003602.1293560-10-jsnow@redhat.com> In-Reply-To: <20201104003602.1293560-1-jsnow@redhat.com> References: <20201104003602.1293560-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 01:02:05 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Cleber Rosa , John Snow , Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Move qom-fuse onto the QOMCommand base established in python/qemu/qmp/qom_common.py. The interface doesn't change incompatibly, "qom-fuse mountpoint" still works as an invocation, and QMP_SOCKET is still used as the environment variable. Signed-off-by: John Snow --- scripts/qmp/qom-fuse | 59 ++++++++++++++++++++++++++++++++++---------- 1 file changed, 46 insertions(+), 13 deletions(-) diff --git a/scripts/qmp/qom-fuse b/scripts/qmp/qom-fuse index 5b80da9df66b..f9bf85f38217 100755 --- a/scripts/qmp/qom-fuse +++ b/scripts/qmp/qom-fuse @@ -8,11 +8,19 @@ may be browsed, queried and edited using traditional shel= l tooling. This script requires the 'fusepy' python package; you may install it by using ``pip3 install --user fusepy``. =20 -ENV: - QMP_SOCKET: Path to the QMP server socket =20 -Usage: - qom-fuse /mount/to/here +usage: qom-fuse [-h] [--socket SOCKET] + +Mount a QOM tree as a FUSE filesystem + +positional arguments: + Mount point + +optional arguments: + -h, --help show this help message and exit + --socket SOCKET, -s SOCKET + QMP socket path or address (addr:port). May also be + set via QMP_SOCKET environment variable. """ ## # Copyright IBM, Corp. 2012 @@ -26,30 +34,56 @@ Usage: # See the COPYING file in the top-level directory. ## =20 +import argparse from errno import ENOENT, EPERM import os import stat import sys +from typing import Dict =20 import fuse from fuse import FUSE, FuseOSError, Operations =20 =20 sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'pytho= n')) -from qemu.qmp import QEMUMonitorProtocol, QMPResponseError +from qemu.qmp import QMPResponseError +from qemu.qmp.qom_common import QOMCommand =20 =20 fuse.fuse_python_api =3D (0, 2) =20 =20 -class QOMFS(Operations): - """QOMFS implements fuse.Operations to provide a QOM filesystem.""" - def __init__(self, qmp): - self.qmp =3D qmp - self.qmp.connect() - self.ino_map =3D {} +class QOMFuse(QOMCommand, Operations): + """ + QOMFuse implements both fuse.Operations and QOMCommand. + + Operations implements the FS, and QOMCommand implements the CLI comman= d. + """ + name =3D 'fuse' + help =3D 'Mount a QOM tree as a FUSE filesystem' + fuse: FUSE + + @classmethod + def configure_parser(cls, parser: argparse.ArgumentParser) -> None: + super().configure_parser(parser) + parser.add_argument( + 'mount', + metavar=3D'', + action=3D'store', + help=3D"Mount point", + ) + + def __init__(self, args: argparse.Namespace): + super().__init__(args) + self.mount =3D args.mount + self.ino_map: Dict[str, int] =3D {} self.ino_count =3D 1 =20 + def run(self) -> int: + print(f"Mounting QOMFS to '{self.mount}'", file=3Dsys.stderr) + self.fuse =3D FUSE(self, self.mount, foreground=3DTrue) + return 0 + def get_ino(self, path): """Get an inode number for a given QOM path.""" if path in self.ino_map: @@ -172,5 +206,4 @@ class QOMFS(Operations): =20 =20 if __name__ =3D=3D '__main__': - fuse =3D FUSE(QOMFS(QEMUMonitorProtocol(os.environ['QMP_SOCKET'])), - sys.argv[1], foreground=3DTrue) + sys.exit(QOMFuse.entry_point()) --=20 2.26.2 From nobody Fri May 17 07:07:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1604450677; cv=none; d=zohomail.com; s=zohoarc; b=DR3m/mgkfueD+9mp/Q3fAxRF9qytBoIjpYGO0OZvzmjwUKnou3nXhN/3oWj+ILdkhG6g7sF0/6a5woT3HLyWS+XB4Ml04062cI7yilCx/zbcPddbeTFF78VA9TADzEe9HBhS7n0OuniLsG42bBb87XB/famjd7V/asWQUvX1ZVA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604450677; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=sA6VFb1LRcC1wcG4j9cZhiPji9rUnXMqeMGltu8wD0k=; b=bGsnXW4XE9D+mcd7vptcP40Uqv26PSBHWr2ekTcp7aBuFBkM0DxBp9iSg2ursIZHiSh7f/vcyJM5IeJQa+DquWYmcQDhXzyRBodG76efs4ZrQ/XMkjO82ZerdDMeXqyXexhSP5I8NoB5gJD92JVg7wfj2udNKKYgYdHY6s/y9mU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604450677530342.4789508827623; Tue, 3 Nov 2020 16:44:37 -0800 (PST) Received: from localhost ([::1]:50816 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ka6ui-0006xs-ET for importer@patchew.org; Tue, 03 Nov 2020 19:44:36 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:35366) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ka6n3-0006KD-CJ for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:36:44 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:60063) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1ka6mx-0004or-Cx for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:36:41 -0500 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-92-HOzc8W9zOiy-RrNPjAnIKA-1; Tue, 03 Nov 2020 19:36:32 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E1DBB11BD35A for ; Wed, 4 Nov 2020 00:36:24 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-97.rdu2.redhat.com [10.10.119.97]) by smtp.corp.redhat.com (Postfix) with ESMTP id EA8807512C; Wed, 4 Nov 2020 00:36:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604450193; 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=sA6VFb1LRcC1wcG4j9cZhiPji9rUnXMqeMGltu8wD0k=; b=CmDRMu7mzrz4MU0fHCNCSt/LeqyunIHaF5T+P4K62vgDouqi2dyulc6oZofsGtAY9csWQl L3AFx4ds48nzjqpsKxykU/N5hQTN7AXnGxTM6xwNNoiWeWvrEuiV4LD7zbaf4Wl5LlNHmc YQsWHzLOS95r4wgo4wxpdKP9Vco/kBs= X-MC-Unique: HOzc8W9zOiy-RrNPjAnIKA-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v2 10/72] scripts/qom-fuse: use QOMCommand.qom_list() Date: Tue, 3 Nov 2020 19:35:00 -0500 Message-Id: <20201104003602.1293560-11-jsnow@redhat.com> In-Reply-To: <20201104003602.1293560-1-jsnow@redhat.com> References: <20201104003602.1293560-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 01:02:05 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Cleber Rosa , John Snow , Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" the qom_list method provides a type-safe object that's easier to type check, so switch to using it. Signed-off-by: John Snow --- scripts/qmp/qom-fuse | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/scripts/qmp/qom-fuse b/scripts/qmp/qom-fuse index f9bf85f38217..b1030273efaa 100755 --- a/scripts/qmp/qom-fuse +++ b/scripts/qmp/qom-fuse @@ -95,7 +95,7 @@ class QOMFuse(QOMCommand, Operations): def is_object(self, path): """Is the given QOM path an object?""" try: - self.qmp.command('qom-list', path=3Dpath) + self.qom_list(path) return True except QMPResponseError: return False @@ -106,8 +106,8 @@ class QOMFuse(QOMCommand, Operations): if path =3D=3D '': path =3D '/' try: - for item in self.qmp.command('qom-list', path=3Dpath): - if item['name'] =3D=3D prop: + for item in self.qom_list(path): + if item.name =3D=3D prop: return True return False except QMPResponseError: @@ -119,11 +119,9 @@ class QOMFuse(QOMCommand, Operations): if path =3D=3D '': path =3D '/' try: - for item in self.qmp.command('qom-list', path=3Dpath): - if item['name'] =3D=3D prop: - if item['type'].startswith('link<'): - return True - return False + for item in self.qom_list(path): + if item.name =3D=3D prop and item.link: + return True return False except QMPResponseError: return False @@ -201,8 +199,8 @@ class QOMFuse(QOMCommand, Operations): def readdir(self, path, fh): yield '.' yield '..' - for item in self.qmp.command('qom-list', path=3Dpath): - yield str(item['name']) + for item in self.qom_list(path): + yield item.name =20 =20 if __name__ =3D=3D '__main__': --=20 2.26.2 From nobody Fri May 17 07:07:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1604450494; cv=none; d=zohomail.com; s=zohoarc; b=BGDpIb2F94234LvbMMALxgnpsPOUhYk/XDsgmSWbKFGT52E4FwEalZ69LEiCAWhvq3CrCYHg7mcDHvaPzVIBQ18iEK89yxvJ6H+7nOzJmdSAKAW0j0GvaxhyFeSX7orkmLInFQ65vmV0T885hoRBB1MhxLj4mvBp04joWl0e5BI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604450494; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=9cPHbgqyv+0Pkq8TWRjZx8HPizlCf0BBMFHwPUW/NYk=; b=j2weRDnyM0yj5FmgPiSf7XhT38qDqBSxLToQsGHwMPM4GJ5MT32KwPGGI7hUM/6nxeqwBnnzW+B6DMhoUhNXagT67dqq1NmPMNG+W6gqlu7bA3eFcDW63QX/3n6NTAnuADcTVHBePIfbg7vHswegAxS97Fp8uXx34NQWFxELRnw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604450494698894.651431087831; Tue, 3 Nov 2020 16:41:34 -0800 (PST) Received: from localhost ([::1]:42430 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ka6rl-0003Rm-Hj for importer@patchew.org; Tue, 03 Nov 2020 19:41:33 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:35348) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ka6n1-0006JS-Hw for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:36:41 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:53543) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1ka6mx-0004ot-Cu for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:36:39 -0500 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-575-u5dDua1nPxKqVerEolyyxg-1; Tue, 03 Nov 2020 19:36:32 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4E8781015ED6 for ; Wed, 4 Nov 2020 00:36:26 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-97.rdu2.redhat.com [10.10.119.97]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2649255766; Wed, 4 Nov 2020 00:36:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604450194; 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=9cPHbgqyv+0Pkq8TWRjZx8HPizlCf0BBMFHwPUW/NYk=; b=YQv2MZvc3R4gR+i4QK5YBEUAhoUcgoVsZeg8csPzDtrcj1V9gGvLfOezJzcWPkQpJmHF7W aImZgYpnnQy1dD2JF3y36E6GrTJypaWEt50/txMkYhDecuL4Hl4pIgEwdWV9V33OSzoUvN WB0DRBwcMH5icWyOO8sQS+RYDSn80Lk= X-MC-Unique: u5dDua1nPxKqVerEolyyxg-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v2 11/72] scripts/qom-fuse: ensure QOMFuse.read always returns bytes Date: Tue, 3 Nov 2020 19:35:01 -0500 Message-Id: <20201104003602.1293560-12-jsnow@redhat.com> In-Reply-To: <20201104003602.1293560-1-jsnow@redhat.com> References: <20201104003602.1293560-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 00:03:41 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Cleber Rosa , John Snow , Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) - Use FuseOSError to signal ENOENT instead of returning it - Wrap qom-get in str(), as we don't always know its type - The empty return should be b'', not ''. Signed-off-by: John Snow Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- scripts/qmp/qom-fuse | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/qmp/qom-fuse b/scripts/qmp/qom-fuse index b1030273efaa..b120b93391ba 100755 --- a/scripts/qmp/qom-fuse +++ b/scripts/qmp/qom-fuse @@ -128,19 +128,19 @@ class QOMFuse(QOMCommand, Operations): =20 def read(self, path, size, offset, fh): if not self.is_property(path): - return -ENOENT + raise FuseOSError(ENOENT) =20 path, prop =3D path.rsplit('/', 1) if path =3D=3D '': path =3D '/' try: - data =3D self.qmp.command('qom-get', path=3Dpath, property=3Dp= rop) + data =3D str(self.qmp.command('qom-get', path=3Dpath, property= =3Dprop)) data +=3D '\n' # make values shell friendly except QMPResponseError as err: raise FuseOSError(EPERM) from err =20 if offset > len(data): - return '' + return b'' =20 return bytes(data[offset:][:size], encoding=3D'utf-8') =20 --=20 2.26.2 From nobody Fri May 17 07:07:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1604450489; cv=none; d=zohomail.com; s=zohoarc; b=kaCisEqNPFZ4uSPTXDygr0jREq1O1Sf/hkP4u+BZPmmsHtcHEGz7chllsFmh+fqUExWfSdXS9+YVFp9WeNfVKUx5ETJvekug6dvKmp//8M7qStr0vyE4YzAqQppW00yt8ob2dXKszZILYc44xohb5LSoJp0RTtLdN+pOjFX9AaA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604450489; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=GGcU+WiqYF3cUrhrW7XyOR5inrltfoG0DI+PJ1gIrXQ=; b=FhPu0qGh1AAFoTE+0OW86Ob1w+WCjwsQjFj3hCsMoNzBhE9GcyNgGOWgqc6R+7hmEOQJ1LdLUJUlWMeYxqJjpxPt4m1VOdH1REu7dQdeSTH5A7dLfCn+jQtUc9h4+qS05+bQKxWzw6afUZmAP5wIhJM3Bh7RC/CHTTlJ0+jpaLk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604450489563488.2393731327694; Tue, 3 Nov 2020 16:41:29 -0800 (PST) Received: from localhost ([::1]:41958 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ka6rg-0003GF-DO for importer@patchew.org; Tue, 03 Nov 2020 19:41:28 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:35326) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ka6mz-0006I4-V5 for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:36:38 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:56807) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1ka6mx-0004oy-CZ for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:36:37 -0500 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-445-CXKWxVIJMkiP9Z5JPaeMZA-1; Tue, 03 Nov 2020 19:36:32 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7B240876E3A for ; Wed, 4 Nov 2020 00:36:27 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-97.rdu2.redhat.com [10.10.119.97]) by smtp.corp.redhat.com (Postfix) with ESMTP id 875DF55766; Wed, 4 Nov 2020 00:36:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604450194; 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=GGcU+WiqYF3cUrhrW7XyOR5inrltfoG0DI+PJ1gIrXQ=; b=OmRf2EQu+cuZgVnGPu6kVlkwJQaTwMEka5L74TmTq11lFujNbrxNihrYxxW9Q3obmNxTZc RDM0FGDxuGejwCp4EZLV9SE6mAvWe59WnBJF6T/M9zze/ASOP/f05NidCA3oSxIPBnKlbV j6+aDCH/vzTPMspsRbfCHr8jJfMKtrQ= X-MC-Unique: CXKWxVIJMkiP9Z5JPaeMZA-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v2 12/72] scripts/qom-fuse: add static type hints Date: Tue, 3 Nov 2020 19:35:02 -0500 Message-Id: <20201104003602.1293560-13-jsnow@redhat.com> In-Reply-To: <20201104003602.1293560-1-jsnow@redhat.com> References: <20201104003602.1293560-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 00:03:41 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Cleber Rosa , John Snow , Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Because fusepy does not have type hints, add some targeted warning suppressions. NOTE: Prior to this change, running 'mypy qemu' from the python directory worked OK, but only coincidentally. Going forward, you will need to run 'mypy -p qemu' instead. These invocation forms will be codified in a CI test soon. Signed-off-by: John Snow --- python/setup.cfg | 8 ++++++++ scripts/qmp/qom-fuse | 26 +++++++++++++++++--------- 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/python/setup.cfg b/python/setup.cfg index c963d05527aa..831555552f16 100644 --- a/python/setup.cfg +++ b/python/setup.cfg @@ -47,6 +47,14 @@ python_version =3D 3.6 warn_unused_configs =3D True namespace_packages =3D True =20 +[mypy-qemu.qmp.qom_fuse] +# fusepy has no type stubs: +allow_subclassing_any =3D True + +[mypy-fuse] +# fusepy has no type stubs: +ignore_missing_imports =3D True + [pylint.messages control] # Disable the message, report, category or checker with the given id(s). Y= ou # can either give multiple identifiers separated by comma (,) or put this diff --git a/scripts/qmp/qom-fuse b/scripts/qmp/qom-fuse index b120b93391ba..22be36634967 100755 --- a/scripts/qmp/qom-fuse +++ b/scripts/qmp/qom-fuse @@ -39,7 +39,14 @@ from errno import ENOENT, EPERM import os import stat import sys -from typing import Dict +from typing import ( + IO, + Dict, + Iterator, + Mapping, + Optional, + Union, +) =20 import fuse from fuse import FUSE, FuseOSError, Operations @@ -84,7 +91,7 @@ class QOMFuse(QOMCommand, Operations): self.fuse =3D FUSE(self, self.mount, foreground=3DTrue) return 0 =20 - def get_ino(self, path): + def get_ino(self, path: str) -> int: """Get an inode number for a given QOM path.""" if path in self.ino_map: return self.ino_map[path] @@ -92,7 +99,7 @@ class QOMFuse(QOMCommand, Operations): self.ino_count +=3D 1 return self.ino_map[path] =20 - def is_object(self, path): + def is_object(self, path: str) -> bool: """Is the given QOM path an object?""" try: self.qom_list(path) @@ -100,7 +107,7 @@ class QOMFuse(QOMCommand, Operations): except QMPResponseError: return False =20 - def is_property(self, path): + def is_property(self, path: str) -> bool: """Is the given QOM path a property?""" path, prop =3D path.rsplit('/', 1) if path =3D=3D '': @@ -113,7 +120,7 @@ class QOMFuse(QOMCommand, Operations): except QMPResponseError: return False =20 - def is_link(self, path): + def is_link(self, path: str) -> bool: """Is the given QOM path a link?""" path, prop =3D path.rsplit('/', 1) if path =3D=3D '': @@ -126,7 +133,7 @@ class QOMFuse(QOMCommand, Operations): except QMPResponseError: return False =20 - def read(self, path, size, offset, fh): + def read(self, path: str, size: int, offset: int, fh: IO[bytes]) -> by= tes: if not self.is_property(path): raise FuseOSError(ENOENT) =20 @@ -144,7 +151,7 @@ class QOMFuse(QOMCommand, Operations): =20 return bytes(data[offset:][:size], encoding=3D'utf-8') =20 - def readlink(self, path): + def readlink(self, path: str) -> Union[bool, str]: if not self.is_link(path): return False path, prop =3D path.rsplit('/', 1) @@ -152,7 +159,8 @@ class QOMFuse(QOMCommand, Operations): return prefix + str(self.qmp.command('qom-get', path=3Dpath, property=3Dprop)) =20 - def getattr(self, path, fh=3DNone): + def getattr(self, path: str, + fh: Optional[IO[bytes]] =3D None) -> Mapping[str, object]: if self.is_link(path): value =3D { 'st_mode': 0o755 | stat.S_IFLNK, @@ -196,7 +204,7 @@ class QOMFuse(QOMCommand, Operations): raise FuseOSError(ENOENT) return value =20 - def readdir(self, path, fh): + def readdir(self, path: str, fh: IO[bytes]) -> Iterator[str]: yield '.' yield '..' for item in self.qom_list(path): --=20 2.26.2 From nobody Fri May 17 07:07:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1604450669; cv=none; d=zohomail.com; s=zohoarc; b=WZ1xcPB4vaumPmGHtwOXXPZib0Nga0FQE7y6XsnTc0NVKxo2xAqdCwdS5ppAYgLiNV2H/nkI1CLBPoHS0CksZDSXHivxqnHLegfrvvgos/NoGHhcb/2zdeJzezsXEBNp9ynIz3Gur2aRlYAUDPNMKBL+dPHdg09DRu+hhxvgFB8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604450669; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=3OoUf1st3MKD0IcbpFlD7Ia+O2+OCjeATl4hUL6sx0k=; b=m1aj5y7tKaQz98nZvYAdCMGgkpluxP3T6ICDeQeVOqPwkCQYjnwLiuatQ4a8ynca9CNVrnofc8giet9UEo4lIYsD3dzOOGvMd2ojauIU3ztavTu6V6IgFBdkGguAaAeRaVB7q2E1yw2Hlh9Sq4D6yAza1wZEP+1ya0OtLOTaKQc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604450669714356.00121804179344; Tue, 3 Nov 2020 16:44:29 -0800 (PST) Received: from localhost ([::1]:50330 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ka6uZ-0006lZ-DI for importer@patchew.org; Tue, 03 Nov 2020 19:44:28 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:35380) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ka6n4-0006KF-5Y for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:36:44 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:28014) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1ka6mz-0004p9-8j for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:36:41 -0500 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-453-XbrXsa8NPhKMtkV07kXhHQ-1; Tue, 03 Nov 2020 19:36:34 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6F32418A62AB for ; Wed, 4 Nov 2020 00:36:28 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-97.rdu2.redhat.com [10.10.119.97]) by smtp.corp.redhat.com (Postfix) with ESMTP id AAA6455766; Wed, 4 Nov 2020 00:36:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604450196; 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=3OoUf1st3MKD0IcbpFlD7Ia+O2+OCjeATl4hUL6sx0k=; b=SiTjd1cYKDw4mUY2vYODzjExaUgOUZSUrSqW5xIOvPBy72cT0sfs8SkOjR0RVujW4xwJDo DSKcV9SUzhwYkaAfM9lFm1rGdMtP4Y5wRTQUChhqzRS3FoXr/2Gb5w3UXtcBLDi6CU2cvX osuh3ZpOYclLvDJPmfGkqQPf9RQ1pj4= X-MC-Unique: XbrXsa8NPhKMtkV07kXhHQ-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v2 13/72] scripts/qom-fuse: move to python/qemu/qmp/qom_fuse.py Date: Tue, 3 Nov 2020 19:35:03 -0500 Message-Id: <20201104003602.1293560-14-jsnow@redhat.com> In-Reply-To: <20201104003602.1293560-1-jsnow@redhat.com> References: <20201104003602.1293560-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 00:03:41 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Cleber Rosa , John Snow , Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Move qom-fuse over to the python package now that it passes the linter. Update the import paradigms so that it passes. Immediately add 'fusepy' to the development requirements and re-lock the pipenv so that the test suite continues to pass. Signed-off-by: John Snow --- python/Pipfile.lock | 13 ++++++++++--- scripts/qmp/qom-fuse =3D> python/qemu/qmp/qom_fuse.py | 12 ++---------- python/setup.cfg | 1 + 3 files changed, 13 insertions(+), 13 deletions(-) rename scripts/qmp/qom-fuse =3D> python/qemu/qmp/qom_fuse.py (95%) mode change 100755 =3D> 100644 diff --git a/python/Pipfile.lock b/python/Pipfile.lock index 0352a628ef6f..d1e56cbcafc6 100644 --- a/python/Pipfile.lock +++ b/python/Pipfile.lock @@ -46,6 +46,12 @@ "markers": "python_version >=3D '2.7' and python_version not i= n '3.0, 3.1, 3.2, 3.3'", "version": "=3D=3D3.8.4" }, + "fusepy": { + "hashes": [ + "sha256:72ff783ec2f43de3ab394e3f7457605bf04c8cf288a2f4068b= 4cde141d4ee6bd" + ], + "version": "=3D=3D3.0.1" + }, "importlib-metadata": { "hashes": [ "sha256:77a540690e24b0305878c37ffd421785a6f7e53c8b5720d211= b211de8d0e95da", @@ -208,10 +214,11 @@ }, "toml": { "hashes": [ - "sha256:926b612be1e5ce0634a2ca03470f95169cf16f939018233a67= 0519cb4ac58b0f", - "sha256:bda89d5935c2eac546d648028b9901107a595863cb36bae0c7= 3ac804a9b4ce88" + "sha256:806143ae5bfb6a3c6e736a764057db0e6a0e05e338b5630894= a5f779cabb4f9b", + "sha256:b3bda1d108d5dd99f4a20d24d9c348e91c4db7ab1b749200bd= ed2f839ccbe68f" ], - "version": "=3D=3D0.10.1" + "markers": "python_version >=3D '2.6' and python_version not i= n '3.0, 3.1, 3.2'", + "version": "=3D=3D0.10.2" }, "typed-ast": { "hashes": [ diff --git a/scripts/qmp/qom-fuse b/python/qemu/qmp/qom_fuse.py old mode 100755 new mode 100644 similarity index 95% rename from scripts/qmp/qom-fuse rename to python/qemu/qmp/qom_fuse.py index 22be36634967..b0adcc1f8e62 --- a/scripts/qmp/qom-fuse +++ b/python/qemu/qmp/qom_fuse.py @@ -1,4 +1,3 @@ -#!/usr/bin/env python3 """ QEMU Object Model FUSE filesystem tool =20 @@ -36,7 +35,6 @@ =20 import argparse from errno import ENOENT, EPERM -import os import stat import sys from typing import ( @@ -51,10 +49,8 @@ import fuse from fuse import FUSE, FuseOSError, Operations =20 - -sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'pytho= n')) -from qemu.qmp import QMPResponseError -from qemu.qmp.qom_common import QOMCommand +from . import QMPResponseError +from .qom_common import QOMCommand =20 =20 fuse.fuse_python_api =3D (0, 2) @@ -209,7 +205,3 @@ def readdir(self, path: str, fh: IO[bytes]) -> Iterator= [str]: yield '..' for item in self.qom_list(path): yield item.name - - -if __name__ =3D=3D '__main__': - sys.exit(QOMFuse.entry_point()) diff --git a/python/setup.cfg b/python/setup.cfg index 831555552f16..a9a76784d45a 100644 --- a/python/setup.cfg +++ b/python/setup.cfg @@ -27,6 +27,7 @@ devel =3D mypy >=3D 0.770 pylint >=3D 2.6.0 pytest >=3D 3.0.0 + fusepy >=3D 2.0.4 =20 [options.entry_points] console_scripts =3D --=20 2.26.2 From nobody Fri May 17 07:07:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1604451132; cv=none; d=zohomail.com; s=zohoarc; b=fVkgQbEUiMdB4vvurY0nvKLomRUmv6zrN7OB2Mxxh9Kyrzz/amqC/yoM8eYm6LrDtkGoOVzGZDADKEBI0iC7iKvGG1mS8jQMQHDC+UM/gLk3dq9ZIrI8oDfwL/wBEUJTDalCPQGOur82ZzNXq2GMqdttmybJ35m6ug+nRiHebXE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604451132; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=8OUsqD1A5AmHCSv1ZS7ONZ7SFH5PBswPDcfSyVuf8AE=; b=ZdwmeRnmwBnxgyDiudQpsJqXIEZuHk5PUP50lJG4IiKwDQoDqS/uJan1L2U2ut/EvA8WVxVnBLaeHJ+gA6sDLzhRtQ04ieo0STYmD4Hmh0jhCvYJVlQWv6jLK1QYGeKlJ+YaHiKdDavUOo1GDs2rghWHtoHyq1uFuXAa78tdg5o= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604451132789465.62234781500626; Tue, 3 Nov 2020 16:52:12 -0800 (PST) Received: from localhost ([::1]:55394 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ka723-0003iq-Ng for importer@patchew.org; Tue, 03 Nov 2020 19:52:11 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:35420) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ka6nA-0006Lp-Cx for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:36:48 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:54748) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1ka6n1-0004pJ-5I for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:36:48 -0500 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-193-VQN2NIf2POOQ-pBPfauNZA-1; Tue, 03 Nov 2020 19:36:35 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7D6756D59C for ; Wed, 4 Nov 2020 00:36:29 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-97.rdu2.redhat.com [10.10.119.97]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9C6D1747C6; Wed, 4 Nov 2020 00:36:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604450197; 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=8OUsqD1A5AmHCSv1ZS7ONZ7SFH5PBswPDcfSyVuf8AE=; b=Uya+ymPnmBUBShPYOVM6wuv2QxKxKcU3rRsTKSWFoftX1LZiyi2yfgrB5nvud/1i0pv7WA Me0I4OMlBJl7kGzLJk38ZA3EwdTw1pamHrukBbbIylOlxq04OVJOqZHSm308hc+HMKycAF /PTupmmjIESx1/BsJrq1tC+07WDWcPI= X-MC-Unique: VQN2NIf2POOQ-pBPfauNZA-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v2 14/72] scripts/qom-fuse: add redirection shim to python/qemu/qmp/qom-fuse.py Date: Tue, 3 Nov 2020 19:35:04 -0500 Message-Id: <20201104003602.1293560-15-jsnow@redhat.com> In-Reply-To: <20201104003602.1293560-1-jsnow@redhat.com> References: <20201104003602.1293560-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 00:03:41 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Cleber Rosa , John Snow , Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) By leaving the script absent for a commit, git-blame travels to the new file instead of staying on the shim. Signed-off-by: John Snow Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- scripts/qmp/qom-fuse | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100755 scripts/qmp/qom-fuse diff --git a/scripts/qmp/qom-fuse b/scripts/qmp/qom-fuse new file mode 100755 index 000000000000..a58c8ef9793b --- /dev/null +++ b/scripts/qmp/qom-fuse @@ -0,0 +1,11 @@ +#!/usr/bin/env python3 + +import os +import sys + +sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'pytho= n')) +from qemu.qmp.qom_fuse import QOMFuse + + +if __name__ =3D=3D '__main__': + sys.exit(QOMFuse.entry_point()) --=20 2.26.2 From nobody Fri May 17 07:07:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1604450893; cv=none; d=zohomail.com; s=zohoarc; b=G7fpjI0Kc/wfeZM5bsIA9cfiAQRBigCFC3O+CRDyBRMwvS+nlAIbjzjFsdWyDTbTM8MHFBPqhzWIwacdYQOWxcVHtjy0GEWs5ZLhagb1ASFvBlBEnuUrgyY8MGFDJmEOqjHgDcIYXiTEZ6HS0PdSXL07EGVP9UhlRrrqZw1Qr90= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604450893; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=3QuQaF6iiaUBvHFsB5tFzilcDmfaadSV7wQWEbVMWB8=; b=DhQCjPv8+4R8/uCeNEVp/YnWNKv8Qco6U1vu1R8DszTu/GSXFDDtuWUs8nJ59lgQDtcaPAgy+mIlsFgCPawENuw59WpVc08vlKcEwGx0ku7vxKg7nPUgttzGobRskuSbbd7F3ObrxhZpMPtJtPvv4FAsobaivU2KZVbJDrDZNbc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604450893268472.92966201804063; Tue, 3 Nov 2020 16:48:13 -0800 (PST) Received: from localhost ([::1]:38542 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ka6yC-00057z-7k for importer@patchew.org; Tue, 03 Nov 2020 19:48:12 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:35382) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ka6n5-0006KJ-7a for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:36:44 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:39860) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1ka6n1-0004pS-7o for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:36:42 -0500 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-514-UNPloPR3PwGBYVc2FyC8gg-1; Tue, 03 Nov 2020 19:36:36 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D396D9CC08 for ; Wed, 4 Nov 2020 00:36:30 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-97.rdu2.redhat.com [10.10.119.97]) by smtp.corp.redhat.com (Postfix) with ESMTP id BE03655766; Wed, 4 Nov 2020 00:36:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604450198; 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=3QuQaF6iiaUBvHFsB5tFzilcDmfaadSV7wQWEbVMWB8=; b=iaDNhD9BuZGPs3onPDNs+IKETFmDHx71wFF7KG9iciE6wAtbwpWgXrGBjk8CxMdSVrqICi ACxJAsrbGiFKweTGx4ugk8Dl716cpa1vmGPCqFWgC6hc4XJC3lcGN7Xq/tsh5R2BAT4Vcb I7stQgov5LCWMqtefJP9esL9larYLeo= X-MC-Unique: UNPloPR3PwGBYVc2FyC8gg-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v2 15/72] python: add fuse command to 'qom' tools Date: Tue, 3 Nov 2020 19:35:05 -0500 Message-Id: <20201104003602.1293560-16-jsnow@redhat.com> In-Reply-To: <20201104003602.1293560-1-jsnow@redhat.com> References: <20201104003602.1293560-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 01:02:05 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Cleber Rosa , John Snow , Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Signed-off-by: John Snow --- python/qemu/qmp/qom.py | 12 +++++++++++- python/setup.cfg | 1 + 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/python/qemu/qmp/qom.py b/python/qemu/qmp/qom.py index 912d1809e60d..52e06a949ab3 100644 --- a/python/qemu/qmp/qom.py +++ b/python/qemu/qmp/qom.py @@ -1,7 +1,7 @@ """ QEMU Object Model testing tools. =20 -usage: qom.py [-h] {set,get,list,tree} ... +usage: qom.py [-h] {set,get,list,tree,fuse} ... =20 Query and manipulate QOM data =20 @@ -14,6 +14,7 @@ get Get a QOM property value list List QOM properties at a given path tree Show QOM tree from a given path + fuse Mount a QOM tree as a FUSE filesystem """ ## # Copyright John Snow 2020, for Red Hat, Inc. @@ -36,6 +37,15 @@ from .qom_common import QOMCommand =20 =20 +try: + from .qom_fuse import QOMFuse +except ImportError: + # either fusepy isn't installed, or qom_fuse itself is broken. + pass +else: + assert issubclass(QOMFuse, QOMCommand) + + class QOMSet(QOMCommand): """QOM Command - Set a property to a given value.""" name =3D 'set' diff --git a/python/setup.cfg b/python/setup.cfg index a9a76784d45a..908e53527ddc 100644 --- a/python/setup.cfg +++ b/python/setup.cfg @@ -36,6 +36,7 @@ console_scripts =3D qom-get =3D qemu.qmp.qom:QOMGet.entry_point qom-list =3D qemu.qmp.qom:QOMList.entry_point qom-tree =3D qemu.qmp.qom:QOMTree.entry_point + qom-fuse =3D qemu.qmp.qom_fuse:QOMFuse.entry_point =20 [flake8] extend-ignore =3D E722 # Prefer pylint's bare-except checks to flake8's --=20 2.26.2 From nobody Fri May 17 07:07:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1604450771; cv=none; d=zohomail.com; s=zohoarc; b=jKyFA1neJDkY2DU9BwXnjRPi9JTrGZsKuQJJxCaItlAEUolKcxJcCWkpSLHJtt2tdyEr3C82qci8VRhWLfmTLqqC3e9+yMzlAgwv627TUOdawDXd1W45BUa65OErZ3iAub4fJe9BzRY9QkgUJooHryM3NVwk1QDODlsku5SrQ5w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604450771; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=GEyKfqCOMtTbCFwo/NxuRRQTpPJP7N2yFgtZYCeRkL0=; b=XPm3pC/irOznrQEy8kzmDnihHTaUnjpaCDu/1ZrOVaYEGmTtUJCuw4IoCSG+rEE+h4dSknyXOjr6nh1GaDBgYBNBL364ulCRcDkKPud2bgQvavTGprNKFqoqZe/i7tQStyA5CqtO5rJNl+FwSznkbrz+0Py7bhuoYLfYQfb75Cg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604450771832510.8325204257544; Tue, 3 Nov 2020 16:46:11 -0800 (PST) Received: from localhost ([::1]:59188 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ka6wE-00022c-OM for importer@patchew.org; Tue, 03 Nov 2020 19:46:10 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:35388) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ka6n7-0006Kq-C1 for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:36:47 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:27812) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1ka6n3-0004pb-2t for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:36:45 -0500 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-241-D6a73BdXOxiYsKGaNoEzPg-1; Tue, 03 Nov 2020 19:36:37 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 03A1B890771 for ; Wed, 4 Nov 2020 00:36:32 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-97.rdu2.redhat.com [10.10.119.97]) by smtp.corp.redhat.com (Postfix) with ESMTP id 28E9055766; Wed, 4 Nov 2020 00:36:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604450198; 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=GEyKfqCOMtTbCFwo/NxuRRQTpPJP7N2yFgtZYCeRkL0=; b=g4lIx8BgGXgknqRUbpqoVFlIGuPMpotAtg5pBzwgpZB1FFsWcj044oKBfsPnF0+zgUbn/a JALh1POfiYL1BkfvAPRL919zFmd6OFnvOXnbNXcBzZFBLTjSja2kiZdARMMNfApoJxIExR rA+Dneecj9LNvnME3kLfnFnIfFUuGWQ= X-MC-Unique: D6a73BdXOxiYsKGaNoEzPg-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v2 16/72] python: add optional fuse dependency Date: Tue, 3 Nov 2020 19:35:06 -0500 Message-Id: <20201104003602.1293560-17-jsnow@redhat.com> In-Reply-To: <20201104003602.1293560-1-jsnow@redhat.com> References: <20201104003602.1293560-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 00:03:41 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Cleber Rosa , John Snow , Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" This can be opted into by installing "qemu[fuse]" instead of just "qemu". The package ought to work perfectly well with or without it. Signed-off-by: John Snow --- python/setup.cfg | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/python/setup.cfg b/python/setup.cfg index 908e53527ddc..4e1c638d72d5 100644 --- a/python/setup.cfg +++ b/python/setup.cfg @@ -29,6 +29,10 @@ devel =3D pytest >=3D 3.0.0 fusepy >=3D 2.0.4 =20 +# Provides qom-fuse functionality +fuse =3D + fusepy >=3D 2.0.4 + [options.entry_points] console_scripts =3D qom =3D qemu.qmp.qom:main --=20 2.26.2 From nobody Fri May 17 07:07:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1604451031; cv=none; d=zohomail.com; s=zohoarc; b=F1o/H3RHs1cyCmRLsjJUHGdkUwj+7ds8jXEQDJT6Tf9g1yQNnbD8SRu2xJJwSur8BBAIO2NdF638Hv2VjS/HA8a9NyhuHD4zLjxdOjNQVITeIktkX/uUvFEeRKLNySAsqA8IgR6MGYSQ+acyxTrxzQCa93o8eaAyvo1QL+nTr7E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604451031; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=R+u+kSqbdZS8FFJfGmxFCCtl4DlAAKyVCV72nA5+Fag=; b=enk0UzHoPDOyUS3bM+IJCkPFkIZEOIdsq+9uMzLxRm0Iz/QSUtSGurWnVdgEeYnYeGQhrrP/Cn46/OJxQzHTMg75kT1S8qJC1GmlhlFuXoFgvlX11X/GbkkNbBFgmS3hKmLdOKhl5BqNVRfQ0eBNfxpXpmHOKzeX0aEOBg5Qv6I= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604451031781678.712781905438; Tue, 3 Nov 2020 16:50:31 -0800 (PST) Received: from localhost ([::1]:46924 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ka70Q-00009F-GA for importer@patchew.org; Tue, 03 Nov 2020 19:50:30 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:35418) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ka6nA-0006Ln-9s for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:36:48 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:35783) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1ka6n5-0004pp-0i for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:36:47 -0500 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-580-KDgQvT3GO4qZfRwQXeuUXQ-1; Tue, 03 Nov 2020 19:36:38 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EBF338BAF50 for ; Wed, 4 Nov 2020 00:36:32 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-97.rdu2.redhat.com [10.10.119.97]) by smtp.corp.redhat.com (Postfix) with ESMTP id 33FA255766; Wed, 4 Nov 2020 00:36:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604450201; 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=R+u+kSqbdZS8FFJfGmxFCCtl4DlAAKyVCV72nA5+Fag=; b=gZbWZzwuXFrMYnmZeftM3u8X9b/vFySLqNSF90fcwd8ShV9i1BqlQGup6ej1fRSh7ZD98C OP5D9Y4gdMzGHBocZaqB9GVPjGo6FMYv9CyvGep7V4tPxRMX3bKZVXblgEsxxh1Uq4dQc9 CJMV0vM8p/8DKkb6VPRBNiCzSUo9JIk= X-MC-Unique: KDgQvT3GO4qZfRwQXeuUXQ-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v2 17/72] scripts/qemu-ga-client: apply isort rules Date: Tue, 3 Nov 2020 19:35:07 -0500 Message-Id: <20201104003602.1293560-18-jsnow@redhat.com> In-Reply-To: <20201104003602.1293560-1-jsnow@redhat.com> References: <20201104003602.1293560-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 01:02:05 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Cleber Rosa , John Snow , Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Hint: > ln -s scripts/qmp/qemu-ga-client python/qemu/qmp/qemu_ga_client.py > cd python > isort qemu Signed-off-by: John Snow --- scripts/qmp/qemu-ga-client | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/scripts/qmp/qemu-ga-client b/scripts/qmp/qemu-ga-client index ce122984a9ca..ae71b30dfa43 100755 --- a/scripts/qmp/qemu-ga-client +++ b/scripts/qmp/qemu-ga-client @@ -36,10 +36,11 @@ # See also: https://wiki.qemu.org/Features/QAPI/GuestAgent # =20 -import os -import sys import base64 +import os import random +import sys + =20 sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'pytho= n')) from qemu import qmp @@ -279,9 +280,9 @@ def main(address, cmd, args): =20 =20 if __name__ =3D=3D '__main__': - import sys - import os import optparse + import os + import sys =20 address =3D os.environ['QGA_CLIENT_ADDRESS'] if 'QGA_CLIENT_ADDRESS' i= n os.environ else None =20 --=20 2.26.2 From nobody Fri May 17 07:07:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1604450911; cv=none; d=zohomail.com; s=zohoarc; b=UsZKSOdDL04sV0iLCThnvds+vdLGwhImrFLMA1o1ZO4loZndpyEaUykaHSnhGdKH+hCVVllZ7w3zDMw5VAKlx77MvViPcJJSKKDHzq7tu5KjJFWNt17CEHZ0dzWPoxvF6mr2TDRkKlvfh3W+Ii9ek6cBXW6j6UdNsyk0hvY+w4M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604450911; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=QOf6X564u68YDgrr4+ImRp2w40G6MZqV8eYk6Yyrpk4=; b=kpuoDdBN+KiK96OjRwL9tcenKuSgwrdQwhm49+v0l1KjOM6RP2RSIREZdX0WEghZZXDf4vcsvnDIMVhG3WbauZZj9ZxSfdKDEscUeshTa0EFSnMMBvS45/fveovo+ngNnEAwB84Bp6k9JN5O/bfH9zAhS5rMrjnzNTjB0EsIc/k= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604450911849583.9969372059674; Tue, 3 Nov 2020 16:48:31 -0800 (PST) Received: from localhost ([::1]:39164 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ka6yU-0005NP-EQ for importer@patchew.org; Tue, 03 Nov 2020 19:48:30 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:35430) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ka6nB-0006Mr-PT for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:36:49 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:57494) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1ka6n7-0004px-27 for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:36:49 -0500 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-55-EWfNmpFSPhSy29UJKR7V6w-1; Tue, 03 Nov 2020 19:36:40 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EDE071054FA5 for ; Wed, 4 Nov 2020 00:36:33 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-97.rdu2.redhat.com [10.10.119.97]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3C847747C6; Wed, 4 Nov 2020 00:36:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604450202; 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=QOf6X564u68YDgrr4+ImRp2w40G6MZqV8eYk6Yyrpk4=; b=N/Yekjwiaezdrdy5bqOTDtGC4elhD4JCEhkuzF8G4AvMXWSfSp+AAAStrpuCyfy5kZb5Nf yuqI+hf7QCxd1RuK4syzrEzCT4t7Qc/j4WlJhmnPZdMrng4xMNUDIrBGfIdWp4vI9XMXdn ZwWNysTCYVEQgApJ47ktmq7r+zIP5I0= X-MC-Unique: EWfNmpFSPhSy29UJKR7V6w-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v2 18/72] scripts/qemu-ga-client: apply (most) flake8 rules Date: Tue, 3 Nov 2020 19:35:08 -0500 Message-Id: <20201104003602.1293560-19-jsnow@redhat.com> In-Reply-To: <20201104003602.1293560-1-jsnow@redhat.com> References: <20201104003602.1293560-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 00:03:41 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Cleber Rosa , John Snow , Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" - Line length should be < 80 - You shouldn't perform unscoped imports except at the top of the module Notably, the sys.path hack creates problems with the import rule. This will be fixed later. Signed-off-by: John Snow --- scripts/qmp/qemu-ga-client | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/scripts/qmp/qemu-ga-client b/scripts/qmp/qemu-ga-client index ae71b30dfa43..a12e0e9b2a6e 100755 --- a/scripts/qmp/qemu-ga-client +++ b/scripts/qmp/qemu-ga-client @@ -12,7 +12,8 @@ # Start QEMU with: # # # qemu [...] -chardev socket,path=3D/tmp/qga.sock,server,nowait,id=3Dqga= 0 \ -# -device virtio-serial -device virtserialport,chardev=3Dqga0,name=3Dorg= .qemu.guest_agent.0 +# -device virtio-serial \ +# -device virtserialport,chardev=3Dqga0,name=3Dorg.qemu.guest_agent.0 # # Run the script: # @@ -37,6 +38,7 @@ # =20 import base64 +import optparse import os import random import sys @@ -94,9 +96,11 @@ class QemuGuestAgentClient: msgs =3D [] msgs.append('version: ' + info['version']) msgs.append('supported_commands:') - enabled =3D [c['name'] for c in info['supported_commands'] if c['e= nabled']] + enabled =3D [c['name'] for c in info['supported_commands'] + if c['enabled']] msgs.append('\tenabled: ' + ', '.join(enabled)) - disabled =3D [c['name'] for c in info['supported_commands'] if not= c['enabled']] + disabled =3D [c['name'] for c in info['supported_commands'] + if not c['enabled']] msgs.append('\tdisabled: ' + ', '.join(disabled)) =20 return '\n'.join(msgs) @@ -119,11 +123,11 @@ class QemuGuestAgentClient: if ipaddr['ip-address-type'] =3D=3D 'ipv4': addr =3D ipaddr['ip-address'] mask =3D self.__gen_ipv4_netmask(int(ipaddr['prefi= x'])) - msgs.append("\tinet %s netmask %s" % (addr, mask)) + msgs.append(f"\tinet {addr} netmask {mask}") elif ipaddr['ip-address-type'] =3D=3D 'ipv6': addr =3D ipaddr['ip-address'] prefix =3D ipaddr['prefix'] - msgs.append("\tinet6 %s prefixlen %s" % (addr, pr= efix)) + msgs.append(f"\tinet6 {addr} prefixlen {prefix}") if nif['hardware-address'] !=3D '00:00:00:00:00:00': msgs.append("\tether " + nif['hardware-address']) =20 @@ -237,6 +241,8 @@ def _cmd_suspend(client, args): =20 def _cmd_shutdown(client, args): client.shutdown() + + _cmd_powerdown =3D _cmd_shutdown =20 =20 @@ -280,17 +286,15 @@ def main(address, cmd, args): =20 =20 if __name__ =3D=3D '__main__': - import optparse - import os - import sys + address =3D os.environ.get('QGA_CLIENT_ADDRESS') =20 - address =3D os.environ['QGA_CLIENT_ADDRESS'] if 'QGA_CLIENT_ADDRESS' i= n os.environ else None - - usage =3D "%prog [--address=3D|] [a= rgs...]\n" + usage =3D ("%prog [--address=3D|]" + " [args...]\n") usage +=3D ': ' + ', '.join(commands) parser =3D optparse.OptionParser(usage=3Dusage) parser.add_option('--address', action=3D'store', type=3D'string', - default=3Daddress, help=3D'Specify a ip:port pair or= a unix socket path') + default=3Daddress, + help=3D'Specify a ip:port pair or a unix socket path= ') options, args =3D parser.parse_args() =20 address =3D options.address --=20 2.26.2 From nobody Fri May 17 07:07:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1604451040; cv=none; d=zohomail.com; s=zohoarc; b=I++QCDIxQ2hrElEIH/kDf/A1A+XXD08rXgNwPwF5QvqjsnblcPvKKGFHho8H5XdvexdnvbU0vYZ6hrHccnUM80/7fKIV7lcO5pGX1mhODQTQZ3D8u1KwePcKGoUydrmawwfou+wS57hhlqippSwZRkse60QRPa5fI4dXQaBEguk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604451040; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Y0FZblywsV7MpnNMYEH05TlxqkUSbriCMMi7VScKPRA=; b=iMQbI6EKP/qEsZ/xCtfyutPHRxJPNWU8OCaNheo2FsQrxaghPNVlCJDIL3+UMpJycNKOgkzTJjnldRWhYXe6VQ553AXknfVQ7IKdWBYNdctQKGA3V+lAGPL/lbfGx9TH0lsN15KjQTWSZfcYC2u//5rajCJkpEq4ZlGerQGoq2o= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604451040131571.8968799783161; Tue, 3 Nov 2020 16:50:40 -0800 (PST) Received: from localhost ([::1]:47710 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ka70Y-0000U2-QQ for importer@patchew.org; Tue, 03 Nov 2020 19:50:38 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:35464) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ka6nG-0006Pv-He for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:36:55 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:58182) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1ka6n9-0004q6-3e for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:36:52 -0500 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-157-zI7t13D1P6-2dq9ZzzvmqQ-1; Tue, 03 Nov 2020 19:36:42 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1FA0C84627E for ; Wed, 4 Nov 2020 00:36:35 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-97.rdu2.redhat.com [10.10.119.97]) by smtp.corp.redhat.com (Postfix) with ESMTP id 27F8D55766; Wed, 4 Nov 2020 00:36:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604450205; 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=Y0FZblywsV7MpnNMYEH05TlxqkUSbriCMMi7VScKPRA=; b=I3Sh+VXGLoy8AEDHBRnHcWJUQECKWdv5anWrOHY3vFKDmwkoSfi8WB7z+goB8niUi70kBh vioYez8MWmVaVfYePTVyv8/2GmCxaGs+7HnJlt31NQ7w534ZeHclrcnD+rK9Mqflt+kixA DXoXCA/Etj3ZVHIl250XGRD3quToHDA= X-MC-Unique: zI7t13D1P6-2dq9ZzzvmqQ-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v2 19/72] scripts/qemu-ga-client: Fix exception handling Date: Tue, 3 Nov 2020 19:35:09 -0500 Message-Id: <20201104003602.1293560-20-jsnow@redhat.com> In-Reply-To: <20201104003602.1293560-1-jsnow@redhat.com> References: <20201104003602.1293560-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 00:03:41 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Cleber Rosa , John Snow , Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Fixes: 50d189c Signed-off-by: John Snow --- scripts/qmp/qemu-ga-client | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/scripts/qmp/qemu-ga-client b/scripts/qmp/qemu-ga-client index a12e0e9b2a6e..c4fbb6165d54 100755 --- a/scripts/qmp/qemu-ga-client +++ b/scripts/qmp/qemu-ga-client @@ -56,8 +56,6 @@ class QemuGuestAgent(qmp.QEMUMonitorProtocol): =20 =20 class QemuGuestAgentClient: - error =3D QemuGuestAgent.error - def __init__(self, address): self.qga =3D QemuGuestAgent(address) self.qga.connect(negotiate=3DFalse) @@ -137,7 +135,7 @@ class QemuGuestAgentClient: self.qga.settimeout(timeout) try: self.qga.ping() - except self.qga.timeout: + except TimeoutError: return False return True =20 @@ -269,11 +267,11 @@ def main(address, cmd, args): =20 try: client =3D QemuGuestAgentClient(address) - except QemuGuestAgent.error as e: + except OSError as err: import errno =20 - print(e) - if e.errno =3D=3D errno.ECONNREFUSED: + print(err) + if err.errno =3D=3D errno.ECONNREFUSED: print('Hint: qemu is not running?') sys.exit(1) =20 --=20 2.26.2 From nobody Fri May 17 07:07:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1604451271; cv=none; d=zohomail.com; s=zohoarc; b=dxVTODZQA1Cblgkc7RkYOOqpCeaGEvhfwg/TwxTho8RFLZPC7A/deRhc1L97ggNNEuRNWbJyYyKzPpD6OI5hyBsOIwyFLj2lkYmEXA4IcZZmuUqG4SQUKsAtXaW2nUKffrGj5w4WoRtGwLriXAd9ZBrnHtuhN+LUCSPz3Z9prM0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604451271; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=zH9F/fE1H6BjT8CUqtLBJlNwoRHK1EiDge4D1sOBwrM=; b=jcPs4lxR9K/z7iZ9SGSM+e/MrsXQRY1KTstHs1J8F7QsxY5T1vajajanW6yVW9GTnK+6NMVH7jdDF4RET2W9xBlFMQuLfKOT6aXsxrSQBqSXkcoRU8nseInlWHGRSDB8X5dh8c/nOMdOq+2EyYvtjqXnePUGRw2Zy/upoUbkTvs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604451271984468.3010427287179; Tue, 3 Nov 2020 16:54:31 -0800 (PST) Received: from localhost ([::1]:35610 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ka74I-0007Bh-M8 for importer@patchew.org; Tue, 03 Nov 2020 19:54:30 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:35444) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ka6nD-0006NY-Rq for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:36:52 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:45302) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1ka6n9-0004qD-Av for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:36:51 -0500 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-24-ZRRLyHcnMlGGQXMCWDyWHg-1; Tue, 03 Nov 2020 19:36:44 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8AC541902EB1 for ; Wed, 4 Nov 2020 00:36:36 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-97.rdu2.redhat.com [10.10.119.97]) by smtp.corp.redhat.com (Postfix) with ESMTP id 70BC155766; Wed, 4 Nov 2020 00:36:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604450206; 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=zH9F/fE1H6BjT8CUqtLBJlNwoRHK1EiDge4D1sOBwrM=; b=BQgVyXkwYwaGIukNmGjI70QIrqu7o7LmehlUHZiUgS6CVEq05eUjg6oL8DwJ+fUB4seNkQ DoawepNI7OMWLwxLs6McxgQPSzUrJnmFpmnVnPKHAa9tS7d3ELT2CNLQwN0rtkeP41/wOu WXzV0as7jyCs8qEbXbEFDDN1jpMXceA= X-MC-Unique: ZRRLyHcnMlGGQXMCWDyWHg-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v2 20/72] scripts/qemu-ga-client: replace deprecated optparse with argparse Date: Tue, 3 Nov 2020 19:35:10 -0500 Message-Id: <20201104003602.1293560-21-jsnow@redhat.com> In-Reply-To: <20201104003602.1293560-1-jsnow@redhat.com> References: <20201104003602.1293560-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 01:02:05 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Cleber Rosa , John Snow , Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Signed-off-by: John Snow --- scripts/qmp/qemu-ga-client | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/scripts/qmp/qemu-ga-client b/scripts/qmp/qemu-ga-client index c4fbb6165d54..73d262e8beb4 100755 --- a/scripts/qmp/qemu-ga-client +++ b/scripts/qmp/qemu-ga-client @@ -37,8 +37,8 @@ # See also: https://wiki.qemu.org/Features/QAPI/GuestAgent # =20 +import argparse import base64 -import optparse import os import random import sys @@ -255,7 +255,7 @@ def _cmd_reboot(client, args): commands =3D [m.replace('_cmd_', '') for m in dir() if '_cmd_' in m] =20 =20 -def main(address, cmd, args): +def send_command(address, cmd, args): if not os.path.exists(address): print('%s not found' % address) sys.exit(1) @@ -283,25 +283,23 @@ def main(address, cmd, args): globals()['_cmd_' + cmd](client, args) =20 =20 -if __name__ =3D=3D '__main__': +def main(): address =3D os.environ.get('QGA_CLIENT_ADDRESS') =20 - usage =3D ("%prog [--address=3D|]" - " [args...]\n") - usage +=3D ': ' + ', '.join(commands) - parser =3D optparse.OptionParser(usage=3Dusage) - parser.add_option('--address', action=3D'store', type=3D'string', - default=3Daddress, - help=3D'Specify a ip:port pair or a unix socket path= ') - options, args =3D parser.parse_args() + parser =3D argparse.ArgumentParser() + parser.add_argument('--address', action=3D'store', + default=3Daddress, + help=3D'Specify a ip:port pair or a unix socket pa= th') + parser.add_argument('command', choices=3Dcommands) + parser.add_argument('args', nargs=3D'*') =20 - address =3D options.address - if address is None: + args =3D parser.parse_args() + if args.address is None: parser.error('address is not specified') sys.exit(1) =20 - if len(args) =3D=3D 0: - parser.error('Less argument') - sys.exit(1) + send_command(args.address, args.command, args.args) =20 - main(address, args[0], args[1:]) + +if __name__ =3D=3D '__main__': + main() --=20 2.26.2 From nobody Fri May 17 07:07:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1604451414; cv=none; d=zohomail.com; s=zohoarc; b=ELx3cskmP+Njsv7ftgiXQnqv70wUA/YhJdBMOcANXnyeumtKv/NkzApvT1iF12jADC721HFC+Q3FaNNoHOhBz7YXQf0t/qRci15LYwnV67fND781ocrn9JCulCKQ26cA7TV7HNLTXkSYuIPoJ6YLiwD/zOoGSiBspi/RmpUcPMg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604451414; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=McaAvtGLW0Lxx0emY5hblWCCh4ECxYbmLwQZTo/NtfY=; b=OR6Bu/Ux7IiUgDt0zriafTvyQ1/YncQoQw3xI1qsQaoWnvjupUhHoK1qEzTqjxTSPvlX7rq1v6DzKUPNDi4DMDz756uEElf0Yn2nvJUyGsYQpJCK9ZTvqxSOfxPesNT8NED+K2jxG19YDYBEHzDBefp9vyDyW6fP1poqp7UXJ6Y= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604451414113568.1956725079775; Tue, 3 Nov 2020 16:56:54 -0800 (PST) Received: from localhost ([::1]:44664 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ka76a-0002XD-Ou for importer@patchew.org; Tue, 03 Nov 2020 19:56:52 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:35528) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ka6nK-0006S4-V6 for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:36:59 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:38497) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1ka6nD-0004qW-DL for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:36:57 -0500 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-585-M0T4-NZpM_K_ZOzAOUZWhA-1; Tue, 03 Nov 2020 19:36:46 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 737C3806B21 for ; Wed, 4 Nov 2020 00:36:37 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-97.rdu2.redhat.com [10.10.119.97]) by smtp.corp.redhat.com (Postfix) with ESMTP id B135255766; Wed, 4 Nov 2020 00:36:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604450209; 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=McaAvtGLW0Lxx0emY5hblWCCh4ECxYbmLwQZTo/NtfY=; b=eOd7BtOzVESWR5VunSq4oQ5t19foP5gYjmrX9ZyilStVm+lIEvuwvyi4j/6kisYBroq94Y fb58oMWYim5hGcjPqBjjKZDbygCB1lZIG5t5QDrDoMPoByoy0nB8bxnBsu4t5yHXiMYAwJ ERuPyBjV5t5bwDIrVDZz7Dxzc6eimV8= X-MC-Unique: M0T4-NZpM_K_ZOzAOUZWhA-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v2 21/72] scripts/qemu-ga-client: add module docstring Date: Tue, 3 Nov 2020 19:35:11 -0500 Message-Id: <20201104003602.1293560-22-jsnow@redhat.com> In-Reply-To: <20201104003602.1293560-1-jsnow@redhat.com> References: <20201104003602.1293560-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 00:03:41 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Cleber Rosa , John Snow , Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Turn that nice usage comment into a docstring. Signed-off-by: John Snow --- scripts/qmp/qemu-ga-client | 65 +++++++++++++++++++------------------- 1 file changed, 33 insertions(+), 32 deletions(-) diff --git a/scripts/qmp/qemu-ga-client b/scripts/qmp/qemu-ga-client index 73d262e8beb4..1061d2eb1437 100755 --- a/scripts/qmp/qemu-ga-client +++ b/scripts/qmp/qemu-ga-client @@ -1,41 +1,42 @@ #!/usr/bin/env python3 =20 -# QEMU Guest Agent Client -# # Copyright (C) 2012 Ryota Ozaki # # 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 [...] -chardev socket,path=3D/tmp/qga.sock,server,nowait,id=3Dqga= 0 \ -# -device virtio-serial \ -# -device virtserialport,chardev=3Dqga0,name=3Dorg.qemu.guest_agent.0 -# -# Run the script: -# -# $ qemu-ga-client --address=3D/tmp/qga.sock [args...] -# -# or -# -# $ export QGA_CLIENT_ADDRESS=3D/tmp/qga.sock -# $ qemu-ga-client [args...] -# -# For example: -# -# $ qemu-ga-client cat /etc/resolv.conf -# # Generated by NetworkManager -# nameserver 10.0.2.3 -# $ qemu-ga-client fsfreeze status -# thawed -# $ qemu-ga-client fsfreeze freeze -# 2 filesystems frozen -# -# See also: https://wiki.qemu.org/Features/QAPI/GuestAgent -# + +""" +QEMU Guest Agent Client + +Usage: + +Start QEMU with: + +# qemu [...] -chardev socket,path=3D/tmp/qga.sock,server,nowait,id=3Dqga0 \ + -device virtio-serial \ + -device virtserialport,chardev=3Dqga0,name=3Dorg.qemu.guest_agent.0 + +Run the script: + +$ qemu-ga-client --address=3D/tmp/qga.sock [args...] + +or + +$ export QGA_CLIENT_ADDRESS=3D/tmp/qga.sock +$ qemu-ga-client [args...] + +For example: + +$ qemu-ga-client cat /etc/resolv.conf +# Generated by NetworkManager +nameserver 10.0.2.3 +$ qemu-ga-client fsfreeze status +thawed +$ qemu-ga-client fsfreeze freeze +2 filesystems frozen + +See also: https://wiki.qemu.org/Features/QAPI/GuestAgent +""" =20 import argparse import base64 --=20 2.26.2 From nobody Fri May 17 07:07:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1604451408; cv=none; d=zohomail.com; s=zohoarc; b=PyLRheGZGzzWwAptVsi1L7c631bdhY2XPBbpiUtase9Tif5BEpvTfmvoI2yAnLI89LmNBDGSJYmLbrH+XW9mvRHRiSn/bj8hHKVJXL/41Fur8FEePfFo2477uR5DxfGZPYnqWTL+jppKOIpbawjWLuP1gQH+D8ACaUIrBEY6j6A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604451408; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=dMO+7r18+Q3UhJY6oz0UqEMA/RbbAsgceTEHl6F+zUU=; b=ff0jYlvEH4mBroK/TBFL5okYgEe4RTPskvQ188WmNfZRs8ntPAMutZlyPVwY8LzBvK492eVOJLdpkkR2PAU1EhiXIXHNeHfPjlC2rYWrkKy/FPvGP1wFfnrUCkHKu2nuxmrIds0GOMfSPGic+mVXH9MalhCfljPHYuSfVb6rAKo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604451408627814.0582421465391; Tue, 3 Nov 2020 16:56:48 -0800 (PST) Received: from localhost ([::1]:44048 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ka76V-0002Hh-EV for importer@patchew.org; Tue, 03 Nov 2020 19:56:47 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:35476) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ka6nH-0006Q4-O3 for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:36:55 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:30699) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1ka6nB-0004qT-SW for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:36:55 -0500 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-585-xPCAocIWMGqddjo95UrZ2g-1; Tue, 03 Nov 2020 19:36:46 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id AACB0102C7D2 for ; Wed, 4 Nov 2020 00:36:38 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-97.rdu2.redhat.com [10.10.119.97]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9EE8355766; Wed, 4 Nov 2020 00:36:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604450209; 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=dMO+7r18+Q3UhJY6oz0UqEMA/RbbAsgceTEHl6F+zUU=; b=VUR0iSMh0N87jaTXxpLwe49O0yyLoQQKYmhV+IDu7lVCGFiC8T/aydUwVLCWklZzxK1ahC MuCY611VoUtLVChEr7NR97tFcwoFijRQZQcNuU2AhPWvBCwoVCpey/Yx6Pb1mvAJB8G7xZ EEJX+bc4x0W+5mNIx+Ylqr61mYs6KwM= X-MC-Unique: xPCAocIWMGqddjo95UrZ2g-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v2 22/72] scripts/qemu-ga-client: apply (most) pylint rules Date: Tue, 3 Nov 2020 19:35:12 -0500 Message-Id: <20201104003602.1293560-23-jsnow@redhat.com> In-Reply-To: <20201104003602.1293560-1-jsnow@redhat.com> References: <20201104003602.1293560-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 00:03:41 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Cleber Rosa , John Snow , Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" I'm only doing a very quick best-effort to preserve this script, to help keep it from breaking further. I think there are pending ideas swirling on the right way to implement better SDKs and better clients, and this script might be a handy reference for those discussions. It presents some interesting design problems, like static type safety when using an RPC-like mechanism. So; disable docstrings for now. If you would like to help improve this script, please add docstrings alongside any refactors or rejuvenations you might apply at that time. Signed-off-by: John Snow --- scripts/qmp/qemu-ga-client | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/scripts/qmp/qemu-ga-client b/scripts/qmp/qemu-ga-client index 1061d2eb1437..59b91c78d884 100755 --- a/scripts/qmp/qemu-ga-client +++ b/scripts/qmp/qemu-ga-client @@ -40,6 +40,7 @@ See also: https://wiki.qemu.org/Features/QAPI/GuestAgent =20 import argparse import base64 +import errno import os import random import sys @@ -49,6 +50,13 @@ sys.path.append(os.path.join(os.path.dirname(__file__), = '..', '..', 'python')) from qemu import qmp =20 =20 +# This script has not seen many patches or careful attention in quite +# some time. If you would like to improve it, please review the design +# carefully and add docstrings at that point in time. Until then: + +# pylint: disable=3Dmissing-docstring + + class QemuGuestAgent(qmp.QEMUMonitorProtocol): def __getattr__(self, name): def wrapper(**kwds): @@ -104,7 +112,8 @@ class QemuGuestAgentClient: =20 return '\n'.join(msgs) =20 - def __gen_ipv4_netmask(self, prefixlen): + @classmethod + def __gen_ipv4_netmask(cls, prefixlen): mask =3D int('1' * prefixlen + '0' * (32 - prefixlen), 2) return '.'.join([str(mask >> 24), str((mask >> 16) & 0xff), @@ -207,10 +216,12 @@ def _cmd_fstrim(client, args): =20 =20 def _cmd_ifconfig(client, args): + assert not args print(client.ifconfig()) =20 =20 def _cmd_info(client, args): + assert not args print(client.info()) =20 =20 @@ -239,6 +250,7 @@ def _cmd_suspend(client, args): =20 =20 def _cmd_shutdown(client, args): + assert not args client.shutdown() =20 =20 @@ -246,10 +258,12 @@ _cmd_powerdown =3D _cmd_shutdown =20 =20 def _cmd_halt(client, args): + assert not args client.shutdown('halt') =20 =20 def _cmd_reboot(client, args): + assert not args client.shutdown('reboot') =20 =20 @@ -269,8 +283,6 @@ def send_command(address, cmd, args): try: client =3D QemuGuestAgentClient(address) except OSError as err: - import errno - print(err) if err.errno =3D=3D errno.ECONNREFUSED: print('Hint: qemu is not running?') --=20 2.26.2 From nobody Fri May 17 07:07:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1604450796; cv=none; d=zohomail.com; s=zohoarc; b=MICtemXWI1aNQ4Vv0R0zGqUYtTHZtM+H+tszhjtNC7Ad+5Q1/H9ZSRbxcjoFePgM78WYAMoJBAPVx6JVLmzLLTtF+3ggGWrUurwLvgd4moLxROvAlU7m5WvTkYOFkMUXVc3wF1OAOyJ1p5cRrcs2vzkwtGzuAN60xp/eI1dHMPg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604450796; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Gb47x06Xv4WEjL+kSNq9tLgxvuZxDNFAxGhNTCLLNvU=; b=fe0xZh7q/MnWItcIahRjhWqD8N3ipyOS997GKgFCik78flkCbkg9Xe4fJK0FnMSymHjWaUAcNihOpsZq/4r9mD7KzRAjgC7qVHOOxLyPGaxjM7T9GDVoYEZWJ/R3s9E+EFAhX7PMtxj+O6zoZmZQfPLgvvNz3sJJIWhqGMZNqFE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604450796101821.4274699820485; Tue, 3 Nov 2020 16:46:36 -0800 (PST) Received: from localhost ([::1]:33564 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ka6wc-000360-Tm for importer@patchew.org; Tue, 03 Nov 2020 19:46:35 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:35472) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ka6nH-0006Q2-Kc for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:36:55 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:20295) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1ka6nD-0004qf-RQ for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:36:54 -0500 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-jDdA9ABSPEaovSoj5Byz8w-1; Tue, 03 Nov 2020 19:36:49 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2185F1016D10 for ; Wed, 4 Nov 2020 00:36:40 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-97.rdu2.redhat.com [10.10.119.97]) by smtp.corp.redhat.com (Postfix) with ESMTP id 04AE1747C6; Wed, 4 Nov 2020 00:36:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604450211; 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=Gb47x06Xv4WEjL+kSNq9tLgxvuZxDNFAxGhNTCLLNvU=; b=PVuZW2cKp5YzRngQpTQDi8khUB104OZZuucIEtcF4iUBN97v7LaPKOQMWwrlMK6pp4M/OV Kx9kg6aP77G1qnjuEbEPaLI5SSqKMdSnOnN8sfqaN8BneKzwP+iLrqiX2XDuYo52ief+OZ /oi4Wcjq6RwmUHv81dyG+wqOaZW0Z0I= X-MC-Unique: jDdA9ABSPEaovSoj5Byz8w-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v2 23/72] python/qmp: Correct type of QMPReturnValue Date: Tue, 3 Nov 2020 19:35:13 -0500 Message-Id: <20201104003602.1293560-24-jsnow@redhat.com> In-Reply-To: <20201104003602.1293560-1-jsnow@redhat.com> References: <20201104003602.1293560-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 01:02:05 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Cleber Rosa , John Snow , Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" It's only a Dict[str, Any] most of the time. It's not actually guaranteed to be anything in particular. Fix this type to be more accurate to the reality we live in. Signed-off-by: John Snow --- python/qemu/qmp/__init__.py | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/python/qemu/qmp/__init__.py b/python/qemu/qmp/__init__.py index 9606248a3d2e..7355a558796f 100644 --- a/python/qemu/qmp/__init__.py +++ b/python/qemu/qmp/__init__.py @@ -35,14 +35,19 @@ ) =20 =20 -# QMPMessage is a QMP Message of any kind. -# e.g. {'yee': 'haw'} -# -# QMPReturnValue is the inner value of return values only. -# {'return': {}} is the QMPMessage, -# {} is the QMPReturnValue. +#: QMPMessage is an entire QMP message of any kind. QMPMessage =3D Dict[str, Any] -QMPReturnValue =3D Dict[str, Any] + +#: QMPReturnValue is the 'return' value of a command. +QMPReturnValue =3D 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. +# +# {'return': {}} is a QMPMessage, +# {} is the QMPReturnValue. + =20 InternetAddrT =3D Tuple[str, str] UnixAddrT =3D str @@ -271,8 +276,8 @@ def cmd_obj(self, qmp_cmd: QMPMessage) -> QMPMessage: return resp =20 def cmd(self, name: str, - args: Optional[Dict[str, Any]] =3D None, - cmd_id: Optional[Any] =3D None) -> QMPMessage: + args: Optional[Dict[str, object]] =3D None, + cmd_id: Optional[object] =3D None) -> QMPMessage: """ Build a QMP command and send it to the QMP Monitor. =20 @@ -287,7 +292,7 @@ def cmd(self, name: str, qmp_cmd['id'] =3D cmd_id return self.cmd_obj(qmp_cmd) =20 - def command(self, cmd: str, **kwds: Any) -> QMPReturnValue: + def command(self, cmd: str, **kwds: object) -> QMPReturnValue: """ Build and send a QMP command to the monitor, report errors if any """ --=20 2.26.2 From nobody Fri May 17 07:07:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1604450912; cv=none; d=zohomail.com; s=zohoarc; b=FrfGFQ3VAKbyE57yPFL8eAAwereqqZL3z+jmXWPNNSELyyMYeQ0VIGJ7xwWIeLJYesOvWpsRo7xu3L6lWjUqOPQsv8kDyBsuF2glZ+M8HaJisd222dOKHkItK+vzmoJjK1NYBGuSIlpFcs8yjKtNhgWEonspi2dM0XxSREEwWmk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604450912; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=J1bOwRUYZLBKMVaPFoMxnDf94dgyrlB8ksOfGc+OLXM=; b=mRItwJbm82Vbhsbi9n5UVkRVow/l+0WE1dM1ji6U9/s5UjpBx1O8JxgxJfynfX23ODnv/SwzZs7ogPg0uzbhPMBumkxXSFSYijxbnUeaWkvi9/97f/WpZ1+T3CqZ27pDIeB5y6jaeYH55floaltI3vKTOyWCfWPDiuYYUqpClEs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604450912052339.1333497127838; Tue, 3 Nov 2020 16:48:32 -0800 (PST) Received: from localhost ([::1]:39328 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ka6yU-0005S0-Tz for importer@patchew.org; Tue, 03 Nov 2020 19:48:30 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:35600) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ka6nO-0006Wq-NF for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:37:02 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:28331) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1ka6nG-0004qp-9Y for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:37:02 -0500 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-19-jtcbjiIzNfShYGtSizN8zA-1; Tue, 03 Nov 2020 19:36:50 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5FA2B1018F7D for ; Wed, 4 Nov 2020 00:36:41 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-97.rdu2.redhat.com [10.10.119.97]) by smtp.corp.redhat.com (Postfix) with ESMTP id 51E2955766; Wed, 4 Nov 2020 00:36:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604450212; 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=J1bOwRUYZLBKMVaPFoMxnDf94dgyrlB8ksOfGc+OLXM=; b=TEmsIo212ogLMoxj7tVzi9IF8nK531fNe2JtXgMHJ44qa6RjycSq0Vnc9nhr53Qd/WcQtr W0lIvcanoHiIHO8uQj3i+zW37gIcYL1/3fp4TTWuQ0tIBqmc63sGik3SMXwveU3KP2o9ZO WbadpGYJZkhDW5pqEptuFubcpAGqB34= X-MC-Unique: jtcbjiIzNfShYGtSizN8zA-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v2 24/72] scripts/qmp/qemu-ga-client: add mypy type hints Date: Tue, 3 Nov 2020 19:35:14 -0500 Message-Id: <20201104003602.1293560-25-jsnow@redhat.com> In-Reply-To: <20201104003602.1293560-1-jsnow@redhat.com> References: <20201104003602.1293560-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 00:03:41 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Cleber Rosa , John Snow , Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" This script is in slightly rough shape, but it still works. A lot of care went into its initial development. In good faith, I'm updating it to the latest Python coding standards. If there is in interest in this script, though, I'll be asking for a contributor to take care of it further. Signed-off-by: John Snow --- scripts/qmp/qemu-ga-client | 89 +++++++++++++++++++++----------------- 1 file changed, 49 insertions(+), 40 deletions(-) diff --git a/scripts/qmp/qemu-ga-client b/scripts/qmp/qemu-ga-client index 59b91c78d884..3e617e7e7abe 100755 --- a/scripts/qmp/qemu-ga-client +++ b/scripts/qmp/qemu-ga-client @@ -44,10 +44,18 @@ import errno import os import random import sys +from typing import ( + Any, + Callable, + Dict, + Optional, + Sequence, +) =20 =20 sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'pytho= n')) from qemu import qmp +from qemu.qmp import SocketAddrT =20 =20 # This script has not seen many patches or careful attention in quite @@ -58,18 +66,18 @@ from qemu import qmp =20 =20 class QemuGuestAgent(qmp.QEMUMonitorProtocol): - def __getattr__(self, name): - def wrapper(**kwds): + def __getattr__(self, name: str) -> Callable[..., Any]: + def wrapper(**kwds: object) -> object: return self.command('guest-' + name.replace('_', '-'), **kwds) return wrapper =20 =20 class QemuGuestAgentClient: - def __init__(self, address): + def __init__(self, address: SocketAddrT): self.qga =3D QemuGuestAgent(address) self.qga.connect(negotiate=3DFalse) =20 - def sync(self, timeout=3D3): + def sync(self, timeout: Optional[float] =3D 3) -> None: # Avoid being blocked forever if not self.ping(timeout): raise EnvironmentError('Agent seems not alive') @@ -79,9 +87,9 @@ class QemuGuestAgentClient: if isinstance(ret, int) and int(ret) =3D=3D uid: break =20 - def __file_read_all(self, handle): + def __file_read_all(self, handle: int) -> bytes: eof =3D False - data =3D '' + data =3D b'' while not eof: ret =3D self.qga.file_read(handle=3Dhandle, count=3D1024) _data =3D base64.b64decode(ret['buf-b64']) @@ -89,7 +97,7 @@ class QemuGuestAgentClient: eof =3D ret['eof'] return data =20 - def read(self, path): + def read(self, path: str) -> bytes: handle =3D self.qga.file_open(path=3Dpath) try: data =3D self.__file_read_all(handle) @@ -97,7 +105,7 @@ class QemuGuestAgentClient: self.qga.file_close(handle=3Dhandle) return data =20 - def info(self): + def info(self) -> str: info =3D self.qga.info() =20 msgs =3D [] @@ -113,14 +121,14 @@ class QemuGuestAgentClient: return '\n'.join(msgs) =20 @classmethod - def __gen_ipv4_netmask(cls, prefixlen): + def __gen_ipv4_netmask(cls, prefixlen: int) -> str: mask =3D int('1' * prefixlen + '0' * (32 - prefixlen), 2) return '.'.join([str(mask >> 24), str((mask >> 16) & 0xff), str((mask >> 8) & 0xff), str(mask & 0xff)]) =20 - def ifconfig(self): + def ifconfig(self) -> str: nifs =3D self.qga.network_get_interfaces() =20 msgs =3D [] @@ -141,7 +149,7 @@ class QemuGuestAgentClient: =20 return '\n'.join(msgs) =20 - def ping(self, timeout): + def ping(self, timeout: Optional[float]) -> bool: self.qga.settimeout(timeout) try: self.qga.ping() @@ -149,37 +157,40 @@ class QemuGuestAgentClient: return False return True =20 - def fsfreeze(self, cmd): + def fsfreeze(self, cmd: str) -> object: if cmd not in ['status', 'freeze', 'thaw']: raise Exception('Invalid command: ' + cmd) - + # Can be int (freeze, thaw) or GuestFsfreezeStatus (status) return getattr(self.qga, 'fsfreeze' + '_' + cmd)() =20 - def fstrim(self, minimum=3D0): - return getattr(self.qga, 'fstrim')(minimum=3Dminimum) + def fstrim(self, minimum: int) -> Dict[str, object]: + # returns GuestFilesystemTrimResponse + ret =3D getattr(self.qga, 'fstrim')(minimum=3Dminimum) + assert isinstance(ret, dict) + return ret =20 - def suspend(self, mode): + def suspend(self, mode: str) -> None: if mode not in ['disk', 'ram', 'hybrid']: raise Exception('Invalid mode: ' + mode) =20 try: getattr(self.qga, 'suspend' + '_' + mode)() # On error exception will raise - except self.qga.timeout: + except TimeoutError: # On success command will timed out return =20 - def shutdown(self, mode=3D'powerdown'): + def shutdown(self, mode: str =3D 'powerdown') -> None: if mode not in ['powerdown', 'halt', 'reboot']: raise Exception('Invalid mode: ' + mode) =20 try: self.qga.shutdown(mode=3Dmode) - except self.qga.timeout: - return + except TimeoutError: + pass =20 =20 -def _cmd_cat(client, args): +def _cmd_cat(client: QemuGuestAgentClient, args: Sequence[str]) -> None: if len(args) !=3D 1: print('Invalid argument') print('Usage: cat ') @@ -187,7 +198,7 @@ def _cmd_cat(client, args): print(client.read(args[0])) =20 =20 -def _cmd_fsfreeze(client, args): +def _cmd_fsfreeze(client: QemuGuestAgentClient, args: Sequence[str]) -> No= ne: usage =3D 'Usage: fsfreeze status|freeze|thaw' if len(args) !=3D 1: print('Invalid argument') @@ -201,13 +212,14 @@ def _cmd_fsfreeze(client, args): ret =3D client.fsfreeze(cmd) if cmd =3D=3D 'status': print(ret) - elif cmd =3D=3D 'freeze': - print("%d filesystems frozen" % ret) - else: - print("%d filesystems thawed" % ret) + return =20 + assert isinstance(ret, int) + verb =3D 'frozen' if cmd =3D=3D 'freeze' else 'thawed' + print(f"{ret:d} filesystems {verb}") =20 -def _cmd_fstrim(client, args): + +def _cmd_fstrim(client: QemuGuestAgentClient, args: Sequence[str]) -> None: if len(args) =3D=3D 0: minimum =3D 0 else: @@ -215,28 +227,25 @@ def _cmd_fstrim(client, args): print(client.fstrim(minimum)) =20 =20 -def _cmd_ifconfig(client, args): +def _cmd_ifconfig(client: QemuGuestAgentClient, args: Sequence[str]) -> No= ne: assert not args print(client.ifconfig()) =20 =20 -def _cmd_info(client, args): +def _cmd_info(client: QemuGuestAgentClient, args: Sequence[str]) -> None: assert not args print(client.info()) =20 =20 -def _cmd_ping(client, args): - if len(args) =3D=3D 0: - timeout =3D 3 - else: - timeout =3D float(args[0]) +def _cmd_ping(client: QemuGuestAgentClient, args: Sequence[str]) -> None: + timeout =3D 3.0 if len(args) =3D=3D 0 else float(args[0]) alive =3D client.ping(timeout) if not alive: print("Not responded in %s sec" % args[0]) sys.exit(1) =20 =20 -def _cmd_suspend(client, args): +def _cmd_suspend(client: QemuGuestAgentClient, args: Sequence[str]) -> Non= e: usage =3D 'Usage: suspend disk|ram|hybrid' if len(args) !=3D 1: print('Less argument') @@ -249,7 +258,7 @@ def _cmd_suspend(client, args): client.suspend(args[0]) =20 =20 -def _cmd_shutdown(client, args): +def _cmd_shutdown(client: QemuGuestAgentClient, args: Sequence[str]) -> No= ne: assert not args client.shutdown() =20 @@ -257,12 +266,12 @@ def _cmd_shutdown(client, args): _cmd_powerdown =3D _cmd_shutdown =20 =20 -def _cmd_halt(client, args): +def _cmd_halt(client: QemuGuestAgentClient, args: Sequence[str]) -> None: assert not args client.shutdown('halt') =20 =20 -def _cmd_reboot(client, args): +def _cmd_reboot(client: QemuGuestAgentClient, args: Sequence[str]) -> None: assert not args client.shutdown('reboot') =20 @@ -270,7 +279,7 @@ def _cmd_reboot(client, args): commands =3D [m.replace('_cmd_', '') for m in dir() if '_cmd_' in m] =20 =20 -def send_command(address, cmd, args): +def send_command(address: str, cmd: str, args: Sequence[str]) -> None: if not os.path.exists(address): print('%s not found' % address) sys.exit(1) @@ -296,7 +305,7 @@ def send_command(address, cmd, args): globals()['_cmd_' + cmd](client, args) =20 =20 -def main(): +def main() -> None: address =3D os.environ.get('QGA_CLIENT_ADDRESS') =20 parser =3D argparse.ArgumentParser() --=20 2.26.2 From nobody Fri May 17 07:07:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1604451138; cv=none; d=zohomail.com; s=zohoarc; b=DFngM7KqW0LZW9PX0iak0JRbb5t71V+fO+piavW/23MdX5mVMM6JTNiySrnrl02eh8Ngbe4Tts3Ta9P9xpvRUI1GNG2IqbtiFa3Wy6B6dn3k/W4LdCaVAKRnnLBaioY4esSJ9yu80jiAp+u9Xkv231wxvc/8gx/8u1kS1nTdV7Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604451138; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=azWsNkEImKXAzSs0vtzelKINsN3FyUqpuERD20P/ZaM=; b=kXbXNR/juBM/sYwuRpiEBky+glazRRe65/DZje0ucLMsB6jo5D6P48+0f6BLIwsSZKNw2+qXXQJFNcoWwKEKCrl1cGPElHA3Cnz/VHGR4cgL0Z+PYlyhsaHijtsNv+deWFOlCaGf53mnyDeHW5X7b6/zDtzATTRSmVe9Ur+09gk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604451138732560.3011706673024; Tue, 3 Nov 2020 16:52:18 -0800 (PST) Received: from localhost ([::1]:56066 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ka729-0003zQ-HX for importer@patchew.org; Tue, 03 Nov 2020 19:52:17 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:35524) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ka6nJ-0006R2-T9 for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:36:58 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:38899) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1ka6nH-0004qx-Df for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:36:57 -0500 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-380-zJieXX_XP1q20TNX7lojFg-1; Tue, 03 Nov 2020 19:36:51 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8EB408BAF7C for ; Wed, 4 Nov 2020 00:36:42 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-97.rdu2.redhat.com [10.10.119.97]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8C6DE55766; Wed, 4 Nov 2020 00:36:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604450213; 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=azWsNkEImKXAzSs0vtzelKINsN3FyUqpuERD20P/ZaM=; b=aCrDn8hqfmvVZHwZw0MmOYBYZAEi+Elovql1eTcHDj8/cJimurEz5sxs+NTrx8lz8604KY 8QUFPfYt/O1uQ0Xe7LbOux7ra1jzpHtA/toDfX7LQJEnM1ZaNBFohliUSI/+VSxcel6RZ1 8NfrmQf/jjNdRVFBJv4tAKdlc7w1Upc= X-MC-Unique: zJieXX_XP1q20TNX7lojFg-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v2 25/72] scripts/qemu-ga-client: move to python/qemu/qmp/qemu_ga_client.py Date: Tue, 3 Nov 2020 19:35:15 -0500 Message-Id: <20201104003602.1293560-26-jsnow@redhat.com> In-Reply-To: <20201104003602.1293560-1-jsnow@redhat.com> References: <20201104003602.1293560-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 01:02:05 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Cleber Rosa , John Snow , Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" The script will be unavailable for a few commits before being restored. This helps move git history into the new file. To prevent linter regressions, though, we do need to immediately touch up the filename, remove the executable bit, and change the import paradigm. Signed-off-by: John Snow --- scripts/qmp/qemu-ga-client =3D> python/qemu/qmp/qemu_ga_client.py | 2 -- 1 file changed, 2 deletions(-) rename scripts/qmp/qemu-ga-client =3D> python/qemu/qmp/qemu_ga_client.py (= 99%) diff --git a/scripts/qmp/qemu-ga-client b/python/qemu/qmp/qemu_ga_client.py similarity index 99% rename from scripts/qmp/qemu-ga-client rename to python/qemu/qmp/qemu_ga_client.py index 3e617e7e7abe..43abc023c63c 100755 --- a/scripts/qmp/qemu-ga-client +++ b/python/qemu/qmp/qemu_ga_client.py @@ -52,8 +52,6 @@ Sequence, ) =20 - -sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'pytho= n')) from qemu import qmp from qemu.qmp import SocketAddrT =20 --=20 2.26.2 From nobody Fri May 17 07:07:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1604451277; cv=none; d=zohomail.com; s=zohoarc; b=m414oNRqDcCZLmFOReA9P+pFxegeEGjUROxL+8ZyTsl83si3SY3M3XNjXR5pZWR12KkATa6v8o3sVf4eViiJTeCqzvgYnKDFWefI572BnHc2q2tAUab3FHCEu5G95hw3gLk0z9P0pupB9qRGs4Nm/kKuF6qg2qMB3ivxrmvFFsY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604451277; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=cDHB7qkiQebVhRr/4xaqEBQKPrPJWBbCQEMQwjfYDfQ=; b=UNJigW6CulYiW9xZYmR9sbdFTN+dCGMsZc2xE7D4gfXwn8HCnWCOTHPTUtWcsHDyzDCiXvQlJBVh5q+K5y1HWMhEweWwLHc5ufW/Du+5AGNFb6zqrHYgSmU1/aPNe0+Yr/vw+/aNDtruzuU/2gaSuJHP1r6PUh57hlpS6T9237k= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604451277954432.3950158877876; Tue, 3 Nov 2020 16:54:37 -0800 (PST) Received: from localhost ([::1]:36220 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ka74O-0007Qd-RY for importer@patchew.org; Tue, 03 Nov 2020 19:54:36 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:35530) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ka6nK-0006S8-W4 for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:36:59 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:52608) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1ka6nH-0004r6-Ip for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:36:58 -0500 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-372-uzABpGxSMBm-OR_ZNV4GJA-1; Tue, 03 Nov 2020 19:36:53 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id AD48F192CC62 for ; Wed, 4 Nov 2020 00:36:43 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-97.rdu2.redhat.com [10.10.119.97]) by smtp.corp.redhat.com (Postfix) with ESMTP id ABCD755766; Wed, 4 Nov 2020 00:36:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604450214; 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=cDHB7qkiQebVhRr/4xaqEBQKPrPJWBbCQEMQwjfYDfQ=; b=Hg7bNL9w1jBEOlYfZ8ABM0nN0Sl7SshQedhCnPhVqk7x8BLj+xRh8NbN8BbDGtqBZmw0+1 JBdEveoFQV2mpnYYlyDRCCInIcRkys7hqhw+zX3jR7RyQzITL5Bqkpq+KDWhkLigPJHKbe sUmktOnUl44DyYKVKBNxRZCG+VvYXLY= X-MC-Unique: uzABpGxSMBm-OR_ZNV4GJA-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v2 26/72] python/qemu-ga-client: add entry point Date: Tue, 3 Nov 2020 19:35:16 -0500 Message-Id: <20201104003602.1293560-27-jsnow@redhat.com> In-Reply-To: <20201104003602.1293560-1-jsnow@redhat.com> References: <20201104003602.1293560-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 01:02:05 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Cleber Rosa , John Snow , Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Remove the shebang, and add a package-defined entry point instead. Signed-off-by: John Snow --- python/qemu/qmp/qemu_ga_client.py | 2 -- python/setup.cfg | 1 + 2 files changed, 1 insertion(+), 2 deletions(-) mode change 100755 =3D> 100644 python/qemu/qmp/qemu_ga_client.py diff --git a/python/qemu/qmp/qemu_ga_client.py b/python/qemu/qmp/qemu_ga_cl= ient.py old mode 100755 new mode 100644 index 43abc023c63c..6915e906374b --- a/python/qemu/qmp/qemu_ga_client.py +++ b/python/qemu/qmp/qemu_ga_client.py @@ -1,5 +1,3 @@ -#!/usr/bin/env python3 - # Copyright (C) 2012 Ryota Ozaki # # This work is licensed under the terms of the GNU GPL, version 2. See diff --git a/python/setup.cfg b/python/setup.cfg index 4e1c638d72d5..f2f54bcaefe8 100644 --- a/python/setup.cfg +++ b/python/setup.cfg @@ -41,6 +41,7 @@ console_scripts =3D qom-list =3D qemu.qmp.qom:QOMList.entry_point qom-tree =3D qemu.qmp.qom:QOMTree.entry_point qom-fuse =3D qemu.qmp.qom_fuse:QOMFuse.entry_point + qemu-ga-client =3D qemu.qmp.qemu_ga_client:main =20 [flake8] extend-ignore =3D E722 # Prefer pylint's bare-except checks to flake8's --=20 2.26.2 From nobody Fri May 17 07:07:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1604451177; cv=none; d=zohomail.com; s=zohoarc; b=i8puDHJMWulyA7zj2aqiylRyfvKtzSLHdXSlrSocc2w0g/XeEZVEytyCBtdpQLtU+TKf+qg19oP+vjRhM9nzg3u2Al4++WFrzw0l4CbKkH4uwtR7YVG6+xKSBIeMbgoI1jTebBb3QSUk2z4WJcNZAXi6r1JPprnWy7EAkWE2vhE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604451177; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=tjxHX3YKwPUk3/jcADiZM76gN2SNswEXWS5Hr/TDKXk=; b=A5uWVaMlIQm5S1WgIIYmAGA+xyzZGFIsd4Nfvzk5D+8++R5jgonL6O4an6MTgGyQNGWqwoTl0B/OyKEHp3KgTOl4H+NQRxaSCJkgG/y8IDR9jU9btt2HpBdzDvqyYLkVvUU/FERlsZwzOZQPSGarcHp+NBWX+8G3y6WJJ16Ibt4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604451177031998.1229193317453; Tue, 3 Nov 2020 16:52:57 -0800 (PST) Received: from localhost ([::1]:58872 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ka72l-00057t-VR for importer@patchew.org; Tue, 03 Nov 2020 19:52:55 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:35566) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ka6nM-0006Ti-UF for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:37:01 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:49406) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1ka6nI-0004rG-FU for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:36:59 -0500 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-97-5MsaW2o7NMaNvHTgDWT-7A-1; Tue, 03 Nov 2020 19:36:53 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A1A8A8030AE for ; Wed, 4 Nov 2020 00:36:44 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-97.rdu2.redhat.com [10.10.119.97]) by smtp.corp.redhat.com (Postfix) with ESMTP id BA6D381196; Wed, 4 Nov 2020 00:36:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604450215; 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=tjxHX3YKwPUk3/jcADiZM76gN2SNswEXWS5Hr/TDKXk=; b=cs+gBH3S/Na3e2cFMJ9WKzpGz6z54XSNto84lh86WcKhbfR8MauY80pZcvve4++X0/sJlP 2R76OAex9lG46ebL8r7EMRAHTLyxSA4tw0cpPsmWziTR2fjbpBKPlPFk2dVn/aN745T9iE C0UTZixIzsDtexQ6KxIWBzariTzeGSU= X-MC-Unique: 5MsaW2o7NMaNvHTgDWT-7A-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v2 27/72] scripts/qemu-ga-client: Add forwarder stub Date: Tue, 3 Nov 2020 19:35:17 -0500 Message-Id: <20201104003602.1293560-28-jsnow@redhat.com> In-Reply-To: <20201104003602.1293560-1-jsnow@redhat.com> References: <20201104003602.1293560-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 00:03:41 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Cleber Rosa , John Snow , Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Mimicking other recently moved tools: add a little forwarder stub until we are sure that everyone is comfortable understanding how to use the tools in their new location. Signed-off-by: John Snow --- scripts/qmp/qemu-ga-client | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100755 scripts/qmp/qemu-ga-client diff --git a/scripts/qmp/qemu-ga-client b/scripts/qmp/qemu-ga-client new file mode 100755 index 000000000000..102fd2cad93f --- /dev/null +++ b/scripts/qmp/qemu-ga-client @@ -0,0 +1,11 @@ +#!/usr/bin/env python3 + +import os +import sys + +sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'pytho= n')) +from qemu.qmp import qemu_ga_client + + +if __name__ =3D=3D '__main__': + sys.exit(qemu_ga_client.main()) --=20 2.26.2 From nobody Fri May 17 07:07:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1604450957; cv=none; d=zohomail.com; s=zohoarc; b=PxRDZIbtVIjv6S4m1JIICprdXDgKHj4VlNHa4fdw33ERgapu72t8y+9BVU7f81qcO07Zsli0GTVb0P6y/odLzMkrYSSRcLxcRintZUPy7vQFI+o9kccm9T49Qz1sDv3gcw9fxlDKG8QYsXS5I3NiP7q0E34ygKb5VqAYcCjSL/s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604450957; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=RC+JPFOqQIUnRgDcTjqYUvvFw2zTguxepQD7HP8jyjg=; b=AojLJSSqrAjZV3VlYV0/lloQuynHWNasd9v3K4qiuUFX3AC/+m20kb4b1/U3CnkwXAHA8Dpe/OjhYa3LMsjTdKwzrL1lVZ91IjtnfweByZzXZEwxmDf1XlF//NME98dQxWESResockqR9Bk7uOoP7/ucx3ykywvTVz2EH0HY6gU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604450957092107.00751474604829; Tue, 3 Nov 2020 16:49:17 -0800 (PST) Received: from localhost ([::1]:41952 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ka6zD-0006XJ-TZ for importer@patchew.org; Tue, 03 Nov 2020 19:49:15 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:35514) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ka6nJ-0006Qj-Jd for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:36:57 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:44899) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1ka6nH-0004r2-DX for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:36:56 -0500 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-DgWzFFGMMniH2FzD3bU9tg-1; Tue, 03 Nov 2020 19:36:52 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BB343195CC52 for ; Wed, 4 Nov 2020 00:36:45 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-97.rdu2.redhat.com [10.10.119.97]) by smtp.corp.redhat.com (Postfix) with ESMTP id CADA8747C6; Wed, 4 Nov 2020 00:36:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604450214; 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=RC+JPFOqQIUnRgDcTjqYUvvFw2zTguxepQD7HP8jyjg=; b=O430fXAjx7ZfmVm0UKg/T69WDmUpml5X6MC8EjkaUbtsE3nj8J2pWwM5D2d57rB37jqu/I kayRy1N/+MwVt/j+qOsvhBwbcBqLYNUg0NxpMcLZhk1ey52z9N/mLfnVxR5qq9KZTbH3hC 91H6J8W4o4NlPE/EtPFqhcSlEBGaJMQ= X-MC-Unique: DgWzFFGMMniH2FzD3bU9tg-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v2 28/72] scripts/qmp-shell: apply isort rules Date: Tue, 3 Nov 2020 19:35:18 -0500 Message-Id: <20201104003602.1293560-29-jsnow@redhat.com> In-Reply-To: <20201104003602.1293560-1-jsnow@redhat.com> References: <20201104003602.1293560-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 01:02:05 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Cleber Rosa , John Snow , Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" 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 b4d06096abd6..7ed45b8195b1 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 b= eing # sent to QEMU, which is useful for debugging and documentation generation. =20 -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 + =20 sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'pytho= n')) from qemu import qmp =20 + class QMPCompleter(list): def complete(self, text, state): for cmd in self: --=20 2.26.2 From nobody Fri May 17 07:07:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1604451079; cv=none; d=zohomail.com; s=zohoarc; b=WzG7LlBbLeazaqhR4G17RZGCI2BlmXvSdlzj5Kw71YcctFHjeJtSTJlKsM8qDaywLRGct2JZzm6N2mkkdDWxugajhSeWCwASkBPKQhhpImlYRLF6tDOkcYt1LceTeZsnZeLuj0KkAL5jMI31XzZ83J3BQE3IJTGS6eRefKswAoY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604451079; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=X/Nw+zSVTMnnTd7dr9G0E/CT8iXWfy8uhfEhmW0+YZw=; b=BNbt4ma0jfX48+oMZqsjeoFg1WZ+TUbgI71YrympM4jTaQeCksaN9emRoafVdNzmADuj3xzBy4jqKWNCCWc9kU4G1ZUk9C8uCdqWDTm3A5pAuBQwUyR0gY9VbXNEIXKe3QtSoB4XGg0518k8qvrC2gJb98VYIRtULNcKeurXPQ8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604451079085887.4455127580937; Tue, 3 Nov 2020 16:51:19 -0800 (PST) Received: from localhost ([::1]:50396 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ka71B-0001cA-QG for importer@patchew.org; Tue, 03 Nov 2020 19:51:17 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:35578) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ka6nN-0006Tu-B9 for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:37:01 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:33811) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1ka6nK-0004rb-LI for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:37:00 -0500 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-159-bkok5OkSNBmLC9vk0OYFVw-1; Tue, 03 Nov 2020 19:36:54 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C6EB2195D58D for ; Wed, 4 Nov 2020 00:36:46 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-97.rdu2.redhat.com [10.10.119.97]) by smtp.corp.redhat.com (Postfix) with ESMTP id F327E75128; Wed, 4 Nov 2020 00:36:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604450217; 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=X/Nw+zSVTMnnTd7dr9G0E/CT8iXWfy8uhfEhmW0+YZw=; b=Biv9/nHmk3CJjk9CiU7DM09SOPcYpehRWaKyQwqmcswVzUoTIQokAQfeUQ8F4bkoC7CdM5 aLuokxRH8ocLi9SFNuiSiV5xacm4LA9eFlb9P66DRjj3lR0hdz+sg1Uk1MgtZ1agREGFaO FnoW0e6QOd9MTvOylCMIobboSbbS4ac= X-MC-Unique: bkok5OkSNBmLC9vk0OYFVw-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v2 29/72] scripts/qmp-shell: Apply flake8 rules Date: Tue, 3 Nov 2020 19:35:19 -0500 Message-Id: <20201104003602.1293560-30-jsnow@redhat.com> In-Reply-To: <20201104003602.1293560-1-jsnow@redhat.com> References: <20201104003602.1293560-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 00:03:41 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Cleber Rosa , John Snow , Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" A lot of fiddling around to get us below 80 columns. Signed-off-by: John Snow --- scripts/qmp/qmp-shell | 68 +++++++++++++++++++++++++++++-------------- 1 file changed, 46 insertions(+), 22 deletions(-) diff --git a/scripts/qmp/qmp-shell b/scripts/qmp/qmp-shell index 7ed45b8195b1..20c420ba4251 100755 --- a/scripts/qmp/qmp-shell +++ b/scripts/qmp/qmp-shell @@ -88,12 +88,15 @@ class QMPCompleter(list): else: state -=3D 1 =20 + class QMPShellError(Exception): pass =20 + class QMPShellBadPort(QMPShellError): pass =20 + class FuzzyJSON(ast.NodeTransformer): '''This extension of ast.NodeTransformer filters literal "true/false/n= ull" values in an AST and replaces them by proper "True/False/None" values = that @@ -107,6 +110,7 @@ class FuzzyJSON(ast.NodeTransformer): node.id =3D 'None' return node =20 + # 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,7 +135,7 @@ class QMPShell(qmp.QEMUMonitorProtocol): port =3D int(addr[1]) except ValueError: raise QMPShellBadPort - return ( addr[0], port ) + return addr[0], port # socket path return arg =20 @@ -148,8 +152,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. qu= ery-), - # 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) @@ -197,7 +201,9 @@ class QMPShell(qmp.QEMUMonitorProtocol): for arg in tokens: (key, sep, val) =3D arg.partition('=3D') if sep !=3D '=3D': - raise QMPShellError("Expected a key=3Dvalue pair, got '%s'= " % arg) + raise QMPShellError( + f"Expected a key=3Dvalue pair, got '{arg!s}'" + ) =20 value =3D self.__parse_value(val) optpath =3D key.split('.') @@ -206,14 +212,16 @@ class QMPShell(qmp.QEMUMonitorProtocol): curpath.append(p) d =3D parent.get(p, {}) if type(d) is not dict: - raise QMPShellError('Cannot use "%s" as both leaf and = non-leaf key' % '.'.join(curpath)) + msg =3D 'Cannot use "{:s}" as both leaf and non-leaf k= ey' + raise QMPShellError(msg.format('.'.join(curpath))) parent[p] =3D d parent =3D 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 =3D 'Cannot use "{:s}" as both leaf and non-leaf k= ey' + raise QMPShellError(msg.format('.'.join(curpath))) else: - raise QMPShellError('Cannot set "%s" multiple times' %= key) + raise QMPShellError(f'Cannot set "{key}" multiple time= s') parent[optpath[-1]] =3D value =20 def __build_cmd(self, cmdline): @@ -223,7 +231,8 @@ class QMPShell(qmp.QEMUMonitorProtocol): =20 < command-name > [ arg-name1=3Darg1 ] ... [ arg-nameN=3DargN ] """ - cmdargs =3D re.findall(r'''(?:[^\s"']|"(?:\\.|[^"])*"|'(?:\\.|[^']= )*')+''', cmdline) + argument_regex =3D r'''(?:[^\s"']|"(?:\\.|[^"])*"|'(?:\\.|[^'])*')= +''' + cmdargs =3D re.findall(argument_regex, cmdline) =20 # Transactional CLI entry/exit: if cmdargs[0] =3D=3D 'transaction(': @@ -232,9 +241,12 @@ class QMPShell(qmp.QEMUMonitorProtocol): elif cmdargs[0] =3D=3D ')' and self._transmode: self._transmode =3D False if len(cmdargs) > 1: - raise QMPShellError("Unexpected input after close of Trans= action sub-shell") - qmpcmd =3D { 'execute': 'transaction', - 'arguments': { 'actions': self._actions } } + msg =3D 'Unexpected input after close of Transaction sub-s= hell' + raise QMPShellError(msg) + qmpcmd =3D { + 'execute': 'transaction', + 'arguments': {'actions': self._actions} + } self._actions =3D list() return qmpcmd =20 @@ -245,7 +257,7 @@ class QMPShell(qmp.QEMUMonitorProtocol): # Parse and then cache this Transactional Action if self._transmode: finalize =3D False - action =3D { 'type': cmdargs[0], 'data': {} } + action =3D {'type': cmdargs[0], 'data': {}} if cmdargs[-1] =3D=3D ')': cmdargs.pop(-1) finalize =3D True @@ -254,7 +266,7 @@ class QMPShell(qmp.QEMUMonitorProtocol): return self.__build_cmd(')') if finalize else None =20 # Standard command: parse and return it to be executed. - qmpcmd =3D { 'execute': cmdargs[0], 'arguments': {} } + qmpcmd =3D {'execute': cmdargs[0], 'arguments': {}} self.__cli_expr(cmdargs[1:], qmpcmd['arguments']) return qmpcmd =20 @@ -295,7 +307,7 @@ class QMPShell(qmp.QEMUMonitorProtocol): print('Connected') return version =3D 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(**versi= on)) =20 def get_prompt(self): if self._transmode: @@ -324,6 +336,7 @@ class QMPShell(qmp.QEMUMonitorProtocol): def set_verbosity(self, verbose): self._verbose =3D verbose =20 + class HMPShell(QMPShell): def __init__(self, address): QMPShell.__init__(self, address) @@ -332,7 +345,7 @@ class HMPShell(QMPShell): def __cmd_completion(self): for cmd in self.__cmd_passthrough('help')['return'].split('\r\n'): if cmd and cmd[0] !=3D '[' and cmd[0] !=3D '\t': - name =3D cmd.split()[0] # drop help text + name =3D cmd.split()[0] # drop help text if name =3D=3D 'info': continue if name.find('|') !=3D -1: @@ -344,7 +357,7 @@ class HMPShell(QMPShell): else: name =3D opt[0] self._completer.append(name) - self._completer.append('help ' + name) # help completion + self._completer.append('help ' + name) # help completion =20 def __info_completion(self): for cmd in self.__cmd_passthrough('info')['return'].split('\r\n'): @@ -360,17 +373,21 @@ class HMPShell(QMPShell): self.__info_completion() self.__other_completion() =20 - def __cmd_passthrough(self, cmdline, cpu_index =3D 0): - return self.cmd_obj({ 'execute': 'human-monitor-command', 'argumen= ts': - { 'command-line': cmdline, - 'cpu-index': cpu_index } }) + def __cmd_passthrough(self, cmdline, cpu_index=3D0): + return self.cmd_obj({ + 'execute': 'human-monitor-command', + 'arguments': { + 'command-line': cmdline, + 'cpu-index': cpu_index + } + }) =20 def _execute_cmd(self, cmdline): if cmdline.split()[0] =3D=3D "cpu": # trap the cpu command, it requires special setting try: idx =3D 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 =3D idx @@ -394,20 +411,26 @@ class HMPShell(QMPShell): def show_banner(self): QMPShell.show_banner(self, msg=3D'Welcome to the HMP shell!') =20 + def die(msg): sys.stderr.write('ERROR: %s\n' % msg) sys.exit(1) =20 + def fail_cmdline(option=3DNone): if option: sys.stderr.write('ERROR: bad command-line option \'%s\'\n' % optio= n) - 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) =20 + def main(): addr =3D '' qemu =3D None @@ -457,5 +480,6 @@ def main(): pass qemu.close() =20 + if __name__ =3D=3D '__main__': main() --=20 2.26.2 From nobody Fri May 17 07:07:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1604451508; cv=none; d=zohomail.com; s=zohoarc; b=OKlhDIFNSc8sgyz0YjjjIQjg8GA5KhJ9LD0z3pq1VOHgSKPFUbWTfcKHD61uW0kFZ6RP9Bdmzebsm4SzZakWm5ij+Z6/39yFULPDcFcgpH4WVr+lcKJSKtOofY6d010r/hUGAkJ1G5V04Aq1guGt3qMV9sERM2+DT6l0cG3q8B4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604451508; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=6p0SO5oHXSNKS+qK2XlouTQ4534lYn1bjRfEAh8Ppws=; b=Jvl0kOBQATjVAPeSHegmvyPMsyCbkvhlDJ2igkDH5ekC40o09GlUSk9558ZUdrJnvyueL1Sq++5da78sIHlmTrfk/DeH9P/ooty01uvCQsf+4BMKIPWQb+McyBog2WEHiaqCs2YLc3r/Ekxc22scij6a6IAMophiZZHyFiTEUTw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604451508588656.3926437871057; Tue, 3 Nov 2020 16:58:28 -0800 (PST) Received: from localhost ([::1]:53066 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ka786-0005x6-Gt for importer@patchew.org; Tue, 03 Nov 2020 19:58:26 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:35604) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ka6nP-0006Y2-3t for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:37:03 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:24576) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1ka6nL-0004rq-Dk for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:37:02 -0500 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-590-9atS6l_KPCuQVxUqcNdLVQ-1; Tue, 03 Nov 2020 19:36:57 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D9F898058DD for ; Wed, 4 Nov 2020 00:36:47 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-97.rdu2.redhat.com [10.10.119.97]) by smtp.corp.redhat.com (Postfix) with ESMTP id F030855766; Wed, 4 Nov 2020 00:36:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604450218; 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=6p0SO5oHXSNKS+qK2XlouTQ4534lYn1bjRfEAh8Ppws=; b=E/Do2b1zic4+lRnBCFb7Ni7t8kmEXyhJVAcrxn1dgRBWiv5fQVob/Y/eZrP6ifMIHnlfK1 3dV5gJfM/fmKg/8XLRXn/vD9mYr7GjvqfdLXU/l2gNXn2A0H0w87H/qeo476SMPpfnrUCQ dIcqEyfQQQmdfMDxPZVQ3YypI7/evrM= X-MC-Unique: 9atS6l_KPCuQVxUqcNdLVQ-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v2 30/72] scripts/qmp-shell: fix show_banner signature Date: Tue, 3 Nov 2020 19:35:20 -0500 Message-Id: <20201104003602.1293560-31-jsnow@redhat.com> In-Reply-To: <20201104003602.1293560-1-jsnow@redhat.com> References: <20201104003602.1293560-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 01:02:05 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Cleber Rosa , John Snow , Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" 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 20c420ba4251..e2ad979aad98 100755 --- a/scripts/qmp/qmp-shell +++ b/scripts/qmp/qmp-shell @@ -408,8 +408,8 @@ class HMPShell(QMPShell): print('%s: %s' % (resp['error']['class'], resp['error']['desc'= ])) return True =20 - def show_banner(self): - QMPShell.show_banner(self, msg=3D'Welcome to the HMP shell!') + def show_banner(self, msg=3D'Welcome to the HMP shell!'): + QMPShell.show_banner(self, msg) =20 =20 def die(msg): --=20 2.26.2 From nobody Fri May 17 07:07:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1604451328; cv=none; d=zohomail.com; s=zohoarc; b=SBbUwZjXFTdnQpxsPTRUK1HtBlGNqHhqyn5pcR8Y1nR3dY3Ez9kTGJtlrrD1vE5fTOLy9mYlEvWpLjozI2zqGNLmXMtsoTHww+LXRsxElcKeDpUNkDl8poya9Lbb0bj7b7gSGappqAJJs1Ws6fIaE6PgChNkjZ+k0hy/h+VEawg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604451328; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=kN52NtN0nPVDNW4h8Ym6yn5TAlHKdBs018ITcmMiytY=; b=I8kP/Gs79f0RLNs0NRRvzx+2zP9WvhB+ryAF3kjFcEt1rz8T7kvtflKE4wU34+4N6bwwBaIf8f/zCMhd74F1srbtBzqa1vcx/aUQUUvtuuZ+1wd1CrUF2oJBS77PUSZHmPCsujC8AVXPfT3nNpxOY/PYM37a7+DJo/uHEDpoVyc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604451328273525.6052946091951; Tue, 3 Nov 2020 16:55:28 -0800 (PST) Received: from localhost ([::1]:39066 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ka75D-00007v-6h for importer@patchew.org; Tue, 03 Nov 2020 19:55:27 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:35586) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ka6nN-0006Uc-VM for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:37:01 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:35784) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1ka6nL-0004ro-E5 for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:37:01 -0500 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-448-Mz4DFH9ENlGzlZogncL94g-1; Tue, 03 Nov 2020 19:36:56 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D346B8058DF for ; Wed, 4 Nov 2020 00:36:48 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-97.rdu2.redhat.com [10.10.119.97]) by smtp.corp.redhat.com (Postfix) with ESMTP id 13F69747C6; Wed, 4 Nov 2020 00:36:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604450218; 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=kN52NtN0nPVDNW4h8Ym6yn5TAlHKdBs018ITcmMiytY=; b=dtUkG7p6BA7OKcXg+lFZjZEgWCcAc8MsI7ejBuQY3beLjyUZ0meXbUfTipV381ez36v6rw 5xf+KvkaLQ4bHBvX7U0W7NdIJ5wdkdE2bKL6STFOxbwz09ueRFS1MCslQc+X7n3ydaxN7S V1DQvq4tTprOoy+oPOPDdXaKBZiEe4c= X-MC-Unique: Mz4DFH9ENlGzlZogncL94g-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v2 31/72] scripts/qmp-shell: fix exception handling Date: Tue, 3 Nov 2020 19:35:21 -0500 Message-Id: <20201104003602.1293560-32-jsnow@redhat.com> In-Reply-To: <20201104003602.1293560-1-jsnow@redhat.com> References: <20201104003602.1293560-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 01:02:05 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Cleber Rosa , John Snow , Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" 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 e2ad979aad98..330f8b32f9c2 100755 --- a/scripts/qmp/qmp-shell +++ b/scripts/qmp/qmp-shell @@ -471,7 +471,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) =20 qemu.show_banner() --=20 2.26.2 From nobody Fri May 17 07:07:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1604451040; cv=none; d=zohomail.com; s=zohoarc; b=EyvlQyFgWT/44RoCTpZA2qcZ03wuFpbIyyoBEGBF1YfuVXGBfLDj/EBpHhak3RAIERvbxDK4UVHP47mLASu0GWWtrRfnzfxzTSAc9k1x8hzDEEJhdyIZvjU3R9mzMyM7od73bGmfH/Td4Z3FgHwSEzsMxHKc4F1AYPuhOma0mto= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604451040; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Xk2DkEIlZ+iczJ/YzPivEFw8SkHzwnuTgTlMET5+zx8=; b=fhfqEw5EAleLBkoiT1KjWNhkJPWOXZcHDmY9oiPP0qIukb9vzf5DldWCKbikdFApyubveJ/CJnc0mBFMlawALPNN9FukhRc8mVai8aPINTSLdKiqOTRVuTHWEca3tzYQdmUG415b6l1nF3GO6erShwbMlnqTX+Wi7YQsr177taM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604451040165270.18118880204963; Tue, 3 Nov 2020 16:50:40 -0800 (PST) Received: from localhost ([::1]:47786 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ka70Y-0000Vr-WC for importer@patchew.org; Tue, 03 Nov 2020 19:50:39 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:35602) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ka6nO-0006XW-Uf for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:37:02 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:29392) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1ka6nL-0004s1-Uw for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:37:02 -0500 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-209--6B8GRSJN66AE5wYCPdUng-1; Tue, 03 Nov 2020 19:36:57 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3AF5D1054FA2 for ; Wed, 4 Nov 2020 00:36:50 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-97.rdu2.redhat.com [10.10.119.97]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0C43755766; Wed, 4 Nov 2020 00:36:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604450219; 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=Xk2DkEIlZ+iczJ/YzPivEFw8SkHzwnuTgTlMET5+zx8=; b=UrKYLltT/M9byynTDqJ/77acPN+iEOeUiqUgvF9XpK5ACJU9PGmQVKzdOFUolPSL5Lw+iV vUjCNZ3ULocCPtvtEgHTQ8NrtMDfMrCXEZTTs05GqGnjNrQw3OwtQm5czT1oyOXWB7Gv0u yqwds7MbBgOdMVRYr+dPl3nSMRFht3U= X-MC-Unique: -6B8GRSJN66AE5wYCPdUng-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v2 32/72] scripts/qmp-shell: fix connect method signature Date: Tue, 3 Nov 2020 19:35:22 -0500 Message-Id: <20201104003602.1293560-33-jsnow@redhat.com> In-Reply-To: <20201104003602.1293560-1-jsnow@redhat.com> References: <20201104003602.1293560-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 00:03:41 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Cleber Rosa , John Snow , Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" It needs to match the parent's. (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 330f8b32f9c2..27632ed5fee7 100755 --- a/scripts/qmp/qmp-shell +++ b/scripts/qmp/qmp-shell @@ -297,7 +297,7 @@ class QMPShell(qmp.QEMUMonitorProtocol): self._print(resp) return True =20 - def connect(self, negotiate): + def connect(self, negotiate: bool =3D True): self._greeting =3D super(QMPShell, self).connect(negotiate) self.__completer_setup() =20 --=20 2.26.2 From nobody Fri May 17 07:07:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1604451566; cv=none; d=zohomail.com; s=zohoarc; b=b0dDJ68f/7E1eANwtQptPAW/Bo5ogO/Ya1WVdXQSOHZwUxarvV0qPJMzNYVERSKN8glcb+Jo0IN5aPpsbeAPit81epG6iSIXRirl+wYsJSDfHlUkAH0JwwMDNEO+rlsXg8kQIfGAbMYGEKUNLTuVqTZ0KWWPohl0fq4AyIfPCfA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604451566; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=YR30SrGkrTrtliSoauF82W+kllr8v2JBPfHd2da3Fkw=; b=n+BidYMdFvplIc1MeVX4+hSfC6ATiTye+soFmQthBUSM1AywVXoma8hml18xr1rJsA3yzVP0Lm+nKO3MuBPWedl6n2z0z/kq2NwTq6dgYAiPaXakSego4yUrp7yZ3fbbAcOGj3LvA+fRUWZpiegpS0HThS28k63qdYdQE0WeQZ0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604451566251924.9612691356195; Tue, 3 Nov 2020 16:59:26 -0800 (PST) Received: from localhost ([::1]:55828 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ka793-00074z-75 for importer@patchew.org; Tue, 03 Nov 2020 19:59:25 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:35630) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ka6nQ-0006cO-NK for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:37:04 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:59174) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1ka6nP-0004tY-5O for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:37:04 -0500 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-259-n9FRtGKXNyqAxeqzxaKsVA-1; Tue, 03 Nov 2020 19:36:59 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9DBD3809DFF for ; Wed, 4 Nov 2020 00:36:51 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-97.rdu2.redhat.com [10.10.119.97]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7BA887DFFB; Wed, 4 Nov 2020 00:36:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604450222; 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=YR30SrGkrTrtliSoauF82W+kllr8v2JBPfHd2da3Fkw=; b=HE/jKFsrTNp5pimoLqzWpry+Anq675q5HoHF5H2FggtnB+L7z1uCJO1OIuFPW2ITtY4/Sy 9J39K4vPQrXqJloBfWKgcPQGoS2qgnpA55YGxE7X7tVpaDOSwkJYTCezc/CC1dLOg8Vwwr h5ET5HYZbkwOpQMd/qwxsHYsjRkbZ0c= X-MC-Unique: n9FRtGKXNyqAxeqzxaKsVA-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v2 33/72] scripts/qmp-shell: remove shadowed variable from _print() Date: Tue, 3 Nov 2020 19:35:23 -0500 Message-Id: <20201104003602.1293560-34-jsnow@redhat.com> In-Reply-To: <20201104003602.1293560-1-jsnow@redhat.com> References: <20201104003602.1293560-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 00:03:41 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, 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: Cleber Rosa , John Snow , Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" 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 27632ed5fee7..6767a01eaaed 100755 --- a/scripts/qmp/qmp-shell +++ b/scripts/qmp/qmp-shell @@ -270,11 +270,11 @@ class QMPShell(qmp.QEMUMonitorProtocol): self.__cli_expr(cmdargs[1:], qmpcmd['arguments']) return qmpcmd =20 - def _print(self, qmp): + def _print(self, qmp_message): indent =3D None if self._pretty: indent =3D 4 - jsobj =3D json.dumps(qmp, indent=3Dindent, sort_keys=3Dself._prett= y) + jsobj =3D json.dumps(qmp_message, indent=3Dindent, sort_keys=3Dsel= f._pretty) print(str(jsobj)) =20 def _execute_cmd(self, cmdline): --=20 2.26.2 From nobody Fri May 17 07:07:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1604451490; cv=none; d=zohomail.com; s=zohoarc; b=Bk7xCPBJMUVD1PXmemqh3tU5KuvToFyEjq7Jv6Gql3e7zL0yyPpuCTMuEGmeK4Um9ofQ0YvFGBN5e+V9+q9mnNejR0CFydcNxgR4XeVmzQSHsg9Zci99Q4uTRWaC1+5+q2mFMDHww3w56oi+ZvnA5WHvsdov+U6kKo3V9JSVe2c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604451490; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=bV7rjoOGdrBoWybEf7CQupU8d6G60XJruZ5XB4Mr7DU=; b=EFhWDPQBFkpPpMO4caeJYWlMxdV24GBWGKieIA9s8Hq1OfVJU2pke6O8kR/J3Ezc5twwuBO500F59kGNNPjILKhO5/F9eVo7dKK8izcxj1AAOnDPka2lVdn5I0KMePA2nZud4MC28n1LBSP7Z7tZWwCG+VAmGwAeV5wpHuvAy7E= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604451490669848.0866736493381; Tue, 3 Nov 2020 16:58:10 -0800 (PST) Received: from localhost ([::1]:52554 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ka77p-0005jK-LQ for importer@patchew.org; Tue, 03 Nov 2020 19:58:09 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:35678) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ka6nS-0006gp-9T for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:37:06 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:22076) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1ka6nP-0004to-Rx for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:37:05 -0500 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-117-rgta2XnUMMy8ew_zC0FSEQ-1; Tue, 03 Nov 2020 19:37:01 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id AE19780A1B6 for ; Wed, 4 Nov 2020 00:36:52 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-97.rdu2.redhat.com [10.10.119.97]) by smtp.corp.redhat.com (Postfix) with ESMTP id C906655766; Wed, 4 Nov 2020 00:36:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604450223; 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=bV7rjoOGdrBoWybEf7CQupU8d6G60XJruZ5XB4Mr7DU=; b=ZQi46AsIMw2ZKOKyEx9dGzEKiAEB2Fj6Zq3Sj7U0nu+L50k0GOBbVlhOzOkSGoNBgVDuGL 2h351s/9/I5DnCqdgYvFVzL8i2yPY7xkGivPl35DF8vd+5kPJTtkfYYtV/Do/8FRgg0LSk eSv8RedJC+1wg8w8U1nqXjrwPnVtR3I= X-MC-Unique: rgta2XnUMMy8ew_zC0FSEQ-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v2 34/72] scripts/qmp-shell: use @classmethod where appropriate Date: Tue, 3 Nov 2020 19:35:24 -0500 Message-Id: <20201104003602.1293560-35-jsnow@redhat.com> In-Reply-To: <20201104003602.1293560-1-jsnow@redhat.com> References: <20201104003602.1293560-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 00:03:41 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Cleber Rosa , John Snow , Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Methods with no self-use should belong to the class. Signed-off-by: John Snow --- scripts/qmp/qmp-shell | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/scripts/qmp/qmp-shell b/scripts/qmp/qmp-shell index 6767a01eaaed..69359ec8ad7f 100755 --- a/scripts/qmp/qmp-shell +++ b/scripts/qmp/qmp-shell @@ -101,7 +101,8 @@ class FuzzyJSON(ast.NodeTransformer): '''This extension of ast.NodeTransformer filters literal "true/false/n= ull" 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 =3D=3D 'true': node.id =3D 'True' if node.id =3D=3D 'false': @@ -124,7 +125,8 @@ class QMPShell(qmp.QEMUMonitorProtocol): self._histfile =3D os.path.join(os.path.expanduser('~'), '.qmp-shell_history') =20 - def __get_address(self, arg): + @classmethod + def __get_address(cls, arg): """ Figure out if the argument is in the port:host form, if it's not i= t's probably a file path. @@ -171,7 +173,8 @@ class QMPShell(qmp.QEMUMonitorProtocol): except Exception as e: print("Failed to save history file '%s'; %s" % (self._histfile= , e)) =20 - def __parse_value(self, val): + @classmethod + def __parse_value(cls, val): try: return int(val) except ValueError: --=20 2.26.2 From nobody Fri May 17 07:07:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1604451440; cv=none; d=zohomail.com; s=zohoarc; b=j1a8b/kouszEjT97Pp6+dXcJ509jS7L+bpF7mE1/me+BYp01RynQdfhVHnhvdV6qArTOwjhSS8ZL61Bbw8GtTSnTbJ4CUINKJNK9hmzTbaWzFQqhjo0tUcJyuoADvT0W61YNVTit8UUsYcu40VuazZ+z0AZl+o+LDzOm2zqUquY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604451440; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=lSvaaGwJNyTZUUmrwZxri+s5pGS41Pz/MnuVgFLqaXY=; b=M3nIMDeNbtEL5jeEjRXAhLVu1pXN4YtMA5qG3UYjgys6XkhZ/ApI/txRYDWQbJBRtEZTp+IAZq7AM3WD0/ISboduHeSDYB/7lIB+0DFwY17VlcG7BvxTc4f/trjQ0bbXdF2cbHl1ubahFOUYLV3vzDFqBd92jgAXTrhNDmJG1Kw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 160445144026715.702949590003072; Tue, 3 Nov 2020 16:57:20 -0800 (PST) Received: from localhost ([::1]:47426 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ka771-0003gF-5J for importer@patchew.org; Tue, 03 Nov 2020 19:57:19 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:35634) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ka6nQ-0006cb-NJ for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:37:04 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:58861) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1ka6nP-0004tU-08 for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:37:04 -0500 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-247-IcUReU27Mhan-a_Vl280Bw-1; Tue, 03 Nov 2020 19:36:59 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E57C010766DA for ; Wed, 4 Nov 2020 00:36:53 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-97.rdu2.redhat.com [10.10.119.97]) by smtp.corp.redhat.com (Postfix) with ESMTP id E2AC955766; Wed, 4 Nov 2020 00:36:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604450222; 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=lSvaaGwJNyTZUUmrwZxri+s5pGS41Pz/MnuVgFLqaXY=; b=G0MkQONhqSQSBnX3MNojiEsKQ9gTq8r6oqZXXlICSbmuxiZA/i7QNvBaTWgUpHy8O2t1cQ jvSVPHC/Cj70QOkZqO8TTRNtFE5euU84HmdKsJ9HzCz8BBAqPNwm8VgSkBwQSJ2D2WY6S+ uYxV9jnLXeQNABSIEa4SHaIIHWIaJnA= X-MC-Unique: IcUReU27Mhan-a_Vl280Bw-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v2 35/72] scripts/qmp-shell: Use python3-style super() Date: Tue, 3 Nov 2020 19:35:25 -0500 Message-Id: <20201104003602.1293560-36-jsnow@redhat.com> In-Reply-To: <20201104003602.1293560-1-jsnow@redhat.com> References: <20201104003602.1293560-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 00:03:41 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Cleber Rosa , John Snow , Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" 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 69359ec8ad7f..2e9ae5d59bd9 100755 --- a/scripts/qmp/qmp-shell +++ b/scripts/qmp/qmp-shell @@ -116,7 +116,7 @@ class FuzzyJSON(ast.NodeTransformer): # _execute_cmd()). Let's design a better one. class QMPShell(qmp.QEMUMonitorProtocol): def __init__(self, address, pretty=3DFalse): - super(QMPShell, self).__init__(self.__get_address(address)) + super().__init__(self.__get_address(address)) self._greeting =3D None self._completer =3D None self._pretty =3D pretty @@ -301,7 +301,7 @@ class QMPShell(qmp.QEMUMonitorProtocol): return True =20 def connect(self, negotiate: bool =3D True): - self._greeting =3D super(QMPShell, self).connect(negotiate) + self._greeting =3D super().connect(negotiate) self.__completer_setup() =20 def show_banner(self, msg=3D'Welcome to the QMP low-level shell!'): @@ -342,7 +342,7 @@ class QMPShell(qmp.QEMUMonitorProtocol): =20 class HMPShell(QMPShell): def __init__(self, address): - QMPShell.__init__(self, address) + super().__init__(address) self.__cpu_index =3D 0 =20 def __cmd_completion(self): --=20 2.26.2 From nobody Fri May 17 07:07:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1604451757; cv=none; d=zohomail.com; s=zohoarc; b=EKDe3XsU8GDx6fpTidy1A4BXkXZ95WIpfyvfsexNi5jGAViLSMPWJ9jPo0FY6j0IKyXkoIV+8rJxMCepgZSIfXy6fsfxpLtUtpbiYRj/g0GfSSM7iv9fOECuSyiF1/XS3Ry+Hp1D1N+EfkzLPPM56iRi68PYYgSMrWH5dvTek3c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604451757; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=+/oPGaxsBU1BKCm6+jfKIafG4gKrNGhUSYPGoYNADDg=; b=alwVoZWKhKNCeA5++h/iz6S/TkQ5mkp8GXcxSb7W7tQIH9KTmkmeiGpZWTMWB2FrpoH7DTl91pgQVQJbk5mClYZ+ORqyoJfPOIa4Cy8O4w5gAJmDa7lkSf7rhVOhroI1kj3uoBCoLsUrg5HAHKIyolx5Ex/mWlZVZTsrKYAe+9o= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 160445175734056.10235821987692; Tue, 3 Nov 2020 17:02:37 -0800 (PST) Received: from localhost ([::1]:35948 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ka7C8-0002Db-9e for importer@patchew.org; Tue, 03 Nov 2020 20:02:36 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:35668) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ka6nR-0006fz-V1 for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:37:05 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:57102) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1ka6nP-0004tm-P2 for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:37:05 -0500 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-369-G58_H04CPTaL_vyeC2A-iA-1; Tue, 03 Nov 2020 19:37:01 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E38D3107B272 for ; Wed, 4 Nov 2020 00:36:54 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-97.rdu2.redhat.com [10.10.119.97]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3381575121; Wed, 4 Nov 2020 00:36:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604450223; 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=+/oPGaxsBU1BKCm6+jfKIafG4gKrNGhUSYPGoYNADDg=; b=ADqDTVuywIEfX8s89LlK99dYod5sgVKg7slRIu2wskSxz99e7fpztqscj1G26evM/FEaA/ G2/W4xmr3Glh+D+TWRU/JQ2nNmb0vg/KTgs4xO1rlMh6Ab+wxlwXHv/vtypI466UFgs7ML IkEx7Wjsi0dsJoORobEipY85jPWmI6g= X-MC-Unique: G58_H04CPTaL_vyeC2A-iA-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v2 36/72] scripts/qmp-shell: declare verbose in __init__ Date: Tue, 3 Nov 2020 19:35:26 -0500 Message-Id: <20201104003602.1293560-37-jsnow@redhat.com> In-Reply-To: <20201104003602.1293560-1-jsnow@redhat.com> References: <20201104003602.1293560-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 00:03:41 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Cleber Rosa , John Snow , Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" 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 2e9ae5d59bd9..7233c4e00b89 100755 --- a/scripts/qmp/qmp-shell +++ b/scripts/qmp/qmp-shell @@ -124,6 +124,7 @@ class QMPShell(qmp.QEMUMonitorProtocol): self._actions =3D list() self._histfile =3D os.path.join(os.path.expanduser('~'), '.qmp-shell_history') + self._verbose =3D False =20 @classmethod def __get_address(cls, arg): --=20 2.26.2 From nobody Fri May 17 07:07:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1604452348; cv=none; d=zohomail.com; s=zohoarc; b=ZshDgpfCeBjNVOFNzOYx6bP+CfLOpEz6xmyLFdM0nslpjSwlRVze9Rwlz+Nt9qIqp+V/5BV1cxegdRvhf+UmefcmGitQ0KeeHbOV9Z5bk+hYcfi4/LFarmu4ZFq9JT0N/VT5hiINxaX8oZJX0zifV1TH7NfTqZJ5WFh+JXqliYM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604452348; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ak3rkzilJ13GEOSHs/1HGCstC8x92BTT/YSyHMuO5a0=; b=IRjzbCGSlpv1SF9UOAK3askGC7ulITlru6rJGrO0ubO3+QECkc5jASgyPzKO/767A4Qa/a5To5TeZwCkI6SpmmKeuljQ5OBd2bePrb20xuMRf9W0gU54WBVPWDq6MztrphBnWlnYzDSjEijSCTEzFRHpiBqwAMVyd6xL1O8DTl4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604452348455187.57465199284013; Tue, 3 Nov 2020 17:12:28 -0800 (PST) Received: from localhost ([::1]:41374 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ka7Lf-0007lM-7O for importer@patchew.org; Tue, 03 Nov 2020 20:12:27 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:35714) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ka6nT-0006l1-Qo for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:37:07 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:34651) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1ka6nR-0004uF-M3 for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:37:07 -0500 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-326-SSXZcf8NNvGczm_LkudpDA-1; Tue, 03 Nov 2020 19:37:02 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DBEC680474B for ; Wed, 4 Nov 2020 00:36:55 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-97.rdu2.redhat.com [10.10.119.97]) by smtp.corp.redhat.com (Postfix) with ESMTP id 25DD47E19C; Wed, 4 Nov 2020 00:36:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604450224; 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=ak3rkzilJ13GEOSHs/1HGCstC8x92BTT/YSyHMuO5a0=; b=facmjdaa5Jdt3dk5J010jkIibbgJAlR8kUG3MC0DgbWobbAQ76S7R8g8NM/BqRtyP3jCKB GwYyzb8HplltCoi0sZEWnDKFyWMs1uRqf9lWg40YO9nZzL5ozAOo5Aahpa4Kdel8XYj9ZN ja8KNI7e6YiWEs2EjFzEVcI70CvXskY= X-MC-Unique: SSXZcf8NNvGczm_LkudpDA-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v2 37/72] scripts/qmp-shell: use triple-double-quote docstring style Date: Tue, 3 Nov 2020 19:35:27 -0500 Message-Id: <20201104003602.1293560-38-jsnow@redhat.com> In-Reply-To: <20201104003602.1293560-1-jsnow@redhat.com> References: <20201104003602.1293560-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 01:02:05 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Cleber Rosa , John Snow , Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" (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 7233c4e00b89..73b2c099f0f0 100755 --- a/scripts/qmp/qmp-shell +++ b/scripts/qmp/qmp-shell @@ -98,9 +98,12 @@ class QMPShellBadPort(QMPShellError): =20 =20 class FuzzyJSON(ast.NodeTransformer): - '''This extension of ast.NodeTransformer filters literal "true/false/n= ull" + """ + 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 =3D=3D 'true': --=20 2.26.2 From nobody Fri May 17 07:07:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1604451279; cv=none; d=zohomail.com; s=zohoarc; b=EaA44Q36o3Z5tDTLmPmbMZziXogebRIZFa7SqNNQiDnBzf/zEWOQOady8DFPsGW3a465aDI1t7/YX51oJ/QceT7Fcx/JVMq8VK5whRB+k1zv0mQGGPIbfrLgPOIFAmvAmBuP8XvW2hP+4Fi0+eWOLTpnJxXHoUVZMe1NBC8CwWE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604451279; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ePl9uGgGQJd8ZpUc91/N3dU2eHmOACuZljeQ8+uIa3Q=; b=Iv3DLMMppct+PvN2E/MYiXOxKEkDJwWhKaT7Aj3DU0YoC/Yp/ynEL8oegBApMmUD1eVKD1JkVE3FYNTQSxn+20wBdja8s+M6o3vchZTXqMvliWNXNmHuEsVckX7ChhYBSpsYOjavKhqH3EmsDF7Plfvx+CCiO4rOARV1CSBxvs4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604451279800842.9886089037645; Tue, 3 Nov 2020 16:54:39 -0800 (PST) Received: from localhost ([::1]:36422 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ka74Q-0007VX-OY for importer@patchew.org; Tue, 03 Nov 2020 19:54:38 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:35772) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ka6nX-0006wZ-Vn for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:37:11 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:35138) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1ka6nT-0004ut-KN for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:37:11 -0500 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-421-NDBOMz4gPNeqvakzs_uF5A-1; Tue, 03 Nov 2020 19:37:04 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id CAA1456C91 for ; Wed, 4 Nov 2020 00:36:56 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-97.rdu2.redhat.com [10.10.119.97]) by smtp.corp.redhat.com (Postfix) with ESMTP id 120A955766; Wed, 4 Nov 2020 00:36:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604450226; 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=ePl9uGgGQJd8ZpUc91/N3dU2eHmOACuZljeQ8+uIa3Q=; b=HylTCZQ712w4pkHuojF6NQpfXxCnlt566XgGzTkrkeFcPZV98nllCWz2L5wjSA+Dat6MQz fsefP4XUZ+L1ayE5Bivv9yEdW9yJumpA9BcV5+bwjZrbWiJE3A28t23+haqmsyjGOj6Qfr NeyMFd3OGFOS19t1Sat8t0CjUtP0+Ro= X-MC-Unique: NDBOMz4gPNeqvakzs_uF5A-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v2 38/72] scripts/qmp-shell: ignore visit_Name name Date: Tue, 3 Nov 2020 19:35:28 -0500 Message-Id: <20201104003602.1293560-39-jsnow@redhat.com> In-Reply-To: <20201104003602.1293560-1-jsnow@redhat.com> References: <20201104003602.1293560-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 00:03:41 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Cleber Rosa , John Snow , Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" 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 73b2c099f0f0..0f03c6c89575 100755 --- a/scripts/qmp/qmp-shell +++ b/scripts/qmp/qmp-shell @@ -105,7 +105,7 @@ class FuzzyJSON(ast.NodeTransformer): """ =20 @classmethod - def visit_Name(cls, node): + def visit_Name(cls, node): # pylint: disable=3Dinvalid-name if node.id =3D=3D 'true': node.id =3D 'True' if node.id =3D=3D 'false': --=20 2.26.2 From nobody Fri May 17 07:07:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1604452062; cv=none; d=zohomail.com; s=zohoarc; b=cOM49LzSUqhyJSqfQ23CyUMtK0F8KEm/+6BVvFIss+tcSUEMDZDQVYHp+aHcJ/gQaCjrENlTxuVrQT/rQHqNtbIdefCUBU3r20x6h+GURYSb3zUxPKFpN/e4d75EdgmDojWh3ZBE7+VgrAjEKrVJdGi3Xhvm2mAuvrns62j+5uQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604452062; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=E7SZRVgT0lGFWnot1YasBuS6Z6PH9w9Mg9556lxVaLw=; b=nyFNQyYU5+3+r+oLLIcMxbN7Kb1dMePEhGxJ0nldGETnsLGU/Tf6ZrpgKtQw9WWCdwSTUjEWQgH6mAvbYLvWrcH/e99ChXcwMFHtktMIucJxuDfp0TYiDn3B7rK2/qhrVTnfkfR1xtMKjF2OOZaC4phusupRe0xsDoh9iLC2mac= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604452062442374.0380138758695; Tue, 3 Nov 2020 17:07:42 -0800 (PST) Received: from localhost ([::1]:52876 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ka7H3-0000pj-CV for importer@patchew.org; Tue, 03 Nov 2020 20:07:41 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:35704) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ka6nT-0006ji-88 for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:37:07 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:25002) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1ka6nR-0004u6-6e for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:37:06 -0500 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-294-d5HEQ7MaOaS3vzGRoi0rZA-1; Tue, 03 Nov 2020 19:37:02 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 41E81106B20E for ; Wed, 4 Nov 2020 00:36:58 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-97.rdu2.redhat.com [10.10.119.97]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1A42755766; Wed, 4 Nov 2020 00:36:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604450224; 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=E7SZRVgT0lGFWnot1YasBuS6Z6PH9w9Mg9556lxVaLw=; b=EUO+qDo2DFC5RS1dTH4dqLTXQ19wisZ4YQ1QC7TceRWAqN00dOXRlO+zPMFCSphxAPY4sm G2EMWfsT0iiBc3Ya+w0hBFoH4YJ/xAWNE5dvrCDuybSVLvAmrGeDRGpwOXqNs6OdabyyWD zRU+dibMqRobo0tTTebM/mJEOdKzgf8= X-MC-Unique: d5HEQ7MaOaS3vzGRoi0rZA-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v2 39/72] scripts/qmp-shell: make QMPCompleter returns explicit Date: Tue, 3 Nov 2020 19:35:29 -0500 Message-Id: <20201104003602.1293560-40-jsnow@redhat.com> In-Reply-To: <20201104003602.1293560-1-jsnow@redhat.com> References: <20201104003602.1293560-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 01:02:05 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Cleber Rosa , John Snow , Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" This 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 0f03c6c89575..e4163daf438d 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 =3D=3D 0: return cmd - else: - state -=3D 1 + state -=3D 1 + return None =20 =20 class QMPShellError(Exception): --=20 2.26.2 From nobody Fri May 17 07:07:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1604451919; cv=none; d=zohomail.com; s=zohoarc; b=MWeDq4B8OrH3zKM0AJ6Zsvo0L5pg9UyOmlo0Z0GppLFs0W35+VuQcyDHpw5gCF1EIY0nl1E4k1IcNJ7fpacR21d1TqmZvi7ulkzkgCJn8JRo3k+ApvFBv80Z9ylrsvKTFayKktjGO0WlCzWkwxTOo9r77Xb9WZRQ+IFikxCPpmY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604451919; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ZQxAzjyzGbRxcwuIegrUQx22TWF+Hk/vmjJukeB95vU=; b=WpcA3ORc3K/a/B4sVJv7AYBwce1S2AdtCF2wQan4743MyjQXuHf5jjf9EW7T8t/12dXllu6Z8sUB1rYlFTdmQTTvBlul4NHpzCEytlBDCMgjxqJ4bsq8e1sUMutqZWSfK16lfGioc4hQUCQtpHvdf6htp04+LdCkalvEDgqPd6U= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604451919065516.3050402995513; Tue, 3 Nov 2020 17:05:19 -0800 (PST) Received: from localhost ([::1]:44358 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ka7Ej-0005eR-Ur for importer@patchew.org; Tue, 03 Nov 2020 20:05:17 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:35706) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ka6nT-0006jt-9A for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:37:07 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:42949) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1ka6nQ-0004tu-GC for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:37:06 -0500 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-302-D3sh1EGePzSfRzFv5gpJnQ-1; Tue, 03 Nov 2020 19:37:01 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 89F7C1891E96 for ; Wed, 4 Nov 2020 00:36:59 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-97.rdu2.redhat.com [10.10.119.97]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7B4A455766; Wed, 4 Nov 2020 00:36:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604450223; 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=ZQxAzjyzGbRxcwuIegrUQx22TWF+Hk/vmjJukeB95vU=; b=RSvGL3iE1UcJ0LZU2N2TtluoE7+pl66VEnn3zgBJ2gHiBMN9VBFle4tXEN8h8Ov4AkgM5E EFUxdz5b7ZxvPUUaP0Ema52Be9xw480DO4aEfsxA0DFfS7fGfAoiBpblPKvUMEo3SzA5da FxLxsT+wNDbwQGUn8lz1jDphQGSzfZ0= X-MC-Unique: D3sh1EGePzSfRzFv5gpJnQ-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v2 40/72] scripts/qmp-shell: rename one and two-letter variables Date: Tue, 3 Nov 2020 19:35:30 -0500 Message-Id: <20201104003602.1293560-41-jsnow@redhat.com> In-Reply-To: <20201104003602.1293560-1-jsnow@redhat.com> References: <20201104003602.1293560-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 01:02:05 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Cleber Rosa , John Snow , Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" 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 e4163daf438d..2fd677e3dabd 100755 --- a/scripts/qmp/qmp-shell +++ b/scripts/qmp/qmp-shell @@ -196,8 +196,8 @@ class QMPShell(qmp.QEMUMonitorProtocol): pass # Try once again as FuzzyJSON: try: - st =3D ast.parse(val, mode=3D'eval') - return ast.literal_eval(FuzzyJSON().visit(st)) + tree =3D ast.parse(val, mode=3D'eval') + return ast.literal_eval(FuzzyJSON().visit(tree)) except SyntaxError: pass except ValueError: @@ -215,14 +215,14 @@ class QMPShell(qmp.QEMUMonitorProtocol): value =3D self.__parse_value(val) optpath =3D key.split('.') curpath =3D [] - for p in optpath[:-1]: - curpath.append(p) - d =3D parent.get(p, {}) - if type(d) is not dict: + for path in optpath[:-1]: + curpath.append(path) + obj =3D parent.get(path, {}) + if type(obj) is not dict: msg =3D 'Cannot use "{:s}" as both leaf and non-leaf k= ey' raise QMPShellError(msg.format('.'.join(curpath))) - parent[p] =3D d - parent =3D d + parent[path] =3D obj + parent =3D obj if optpath[-1] in parent: if type(parent[optpath[-1]]) is dict: msg =3D 'Cannot use "{:s}" as both leaf and non-leaf k= ey' @@ -287,8 +287,8 @@ class QMPShell(qmp.QEMUMonitorProtocol): def _execute_cmd(self, cmdline): try: qmpcmd =3D 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=3D' ') print('[arg-name1=3Darg1] ... [arg-nameN=3DargN]') return True @@ -333,8 +333,8 @@ class QMPShell(qmp.QEMUMonitorProtocol): print() return False if cmdline =3D=3D '': - for ev in self.get_events(): - print(ev) + for event in self.get_events(): + print(event) self.clear_events() return True else: --=20 2.26.2 From nobody Fri May 17 07:07:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1604452532; cv=none; d=zohomail.com; s=zohoarc; b=FXJGwi1rN+K+l0Wa3QxAR460lE+Qq8gsgZR4hlI2PI4dNZuyipFgh/W9mIjBB7+5txrr3p1xfvnkzjJqDzcw7Rf8H8eaLevf31Z252Ms1zb9rqYH9Efhe2TW3OEmwKw77UUHG/aBW21eqYh6QGTatY13CPMvMexf2IAB+d5uSWk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604452532; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=0cAfJmS8nHGdpG92H3tRvNyH/9vDEfMiaZizMi4XYh8=; b=TDuEy3gwNVHHokEzBt5mJeTx0ERUYaLcAS/UhGMnzBDnsV78wK0PsnRi+KL7jkprH5gHzTMZGyv1zEQr+omAyUkpkZ/fxuHLziYjLoi+eaXpSe/bvfRvoSJEnoKCjhTI5+h6eq4Eqf9ViNvZ0aVpCcaK8YNFsgHLrrmlGvWPP+4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604452532976993.088419951218; Tue, 3 Nov 2020 17:15:32 -0800 (PST) Received: from localhost ([::1]:49842 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ka7Od-0002mu-Ro for importer@patchew.org; Tue, 03 Nov 2020 20:15:31 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:35746) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ka6nV-0006pH-6E for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:37:09 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:43943) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1ka6nT-0004uj-Bd for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:37:08 -0500 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-37-8KZUE449PmGL09gG2reCOg-1; Tue, 03 Nov 2020 19:37:04 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8E36B5F9E3 for ; Wed, 4 Nov 2020 00:37:00 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-97.rdu2.redhat.com [10.10.119.97]) by smtp.corp.redhat.com (Postfix) with ESMTP id B69BF747C6; Wed, 4 Nov 2020 00:36:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604450226; 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=0cAfJmS8nHGdpG92H3tRvNyH/9vDEfMiaZizMi4XYh8=; b=cUva0k2D+fn4d0gm3ob7YXp7jJ0PZ9LY5Vu7Od5RYaIPv8fjNVko4qCZjHlZaH3KslZ+fx t3xTGcvaQ4tzO/docdik3Vf/q7zZ1JebZury/n2L7XXqu4Jx1+fhDUBi3O+0gNOTTly4jS eIDFQs1fwS3l5FQhEySrjjAcsVV2vXE= X-MC-Unique: 8KZUE449PmGL09gG2reCOg-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v2 41/72] scripts/qmp-shell: fix shell history exception handling Date: Tue, 3 Nov 2020 19:35:31 -0500 Message-Id: <20201104003602.1293560-42-jsnow@redhat.com> In-Reply-To: <20201104003602.1293560-1-jsnow@redhat.com> References: <20201104003602.1293560-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 00:03:41 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Cleber Rosa , John Snow , Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" 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 2fd677e3dabd..6ad9384c1804 100755 --- a/scripts/qmp/qmp-shell +++ b/scripts/qmp/qmp-shell @@ -67,7 +67,6 @@ =20 import ast import atexit -import errno import json import os import re @@ -163,19 +162,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 =3D=3D 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) =20 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= }") =20 @classmethod def __parse_value(cls, val): --=20 2.26.2 From nobody Fri May 17 07:07:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1604452209; cv=none; d=zohomail.com; s=zohoarc; b=LIftKni+hN8HEssVDJgM4WK4rRWM8QP2VOa/yEaR9AtGIAZSRliEdI1jIHi6sunlG/shptYxvlHD8xgjNiGde0lA3DNejgaIj3/TC6BbCD4k1Gwo3S3FP2yqD+cxESD7dTHsk4gG6TWsSug0GeKL3pvqD2KLSkElg+5bj6W2XRs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604452209; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=pySCMETq1QtWaiErDZTOM4dTWAaBXBhNlXBJldhFyVE=; b=lEEsxhNOFWQQOExtGaC/xwX64dYsgaaFP9eLwZX5MXMmoSGKQMNiNdCbBJNWRW0NTISx86ORXlACVnXyNYwvCwBGEcna7dT8NWpMfY36d4Rqwcl7fUKGf7SXGLaAQ0shpjBhdrBYh1SHT/3YAcNGJ+Ax0l2dB+QMngPFfoMg7c0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604452209319295.10021318898123; Tue, 3 Nov 2020 17:10:09 -0800 (PST) Received: from localhost ([::1]:33036 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ka7JQ-0004GC-A1 for importer@patchew.org; Tue, 03 Nov 2020 20:10:08 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:35710) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ka6nT-0006kJ-F5 for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:37:07 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:26234) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1ka6nR-0004uB-Eg for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:37:07 -0500 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-476-Bki5Nd_EPkatA2IraqDxyA-1; Tue, 03 Nov 2020 19:37:02 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7F393108BD07 for ; Wed, 4 Nov 2020 00:37:01 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-97.rdu2.redhat.com [10.10.119.97]) by smtp.corp.redhat.com (Postfix) with ESMTP id BA76155766; Wed, 4 Nov 2020 00:37:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604450224; 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=pySCMETq1QtWaiErDZTOM4dTWAaBXBhNlXBJldhFyVE=; b=Dx89vIXZ950WnXVbHwPQAKAwbh9b/p1ZmjvdUZdRLpGF9Ymcen2CRWGL8QSujdTy2+XVnP COMNo9iz4IKEuYKCdIs2KYE0owiJ0h9M19bzu24IBQR5Hjh4o1CHEL8i3c9+t0l8VsSQQk ABdjgIvDhq8FR2WXifwExKm2ly1f2WA= X-MC-Unique: Bki5Nd_EPkatA2IraqDxyA-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v2 42/72] scripts/qmp-shell: explicitly chain exception context Date: Tue, 3 Nov 2020 19:35:32 -0500 Message-Id: <20201104003602.1293560-43-jsnow@redhat.com> In-Reply-To: <20201104003602.1293560-1-jsnow@redhat.com> References: <20201104003602.1293560-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 01:02:05 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Cleber Rosa , John Snow , Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" 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 6ad9384c1804..b3ab735397d4 100755 --- a/scripts/qmp/qmp-shell +++ b/scripts/qmp/qmp-shell @@ -138,8 +138,8 @@ class QMPShell(qmp.QEMUMonitorProtocol): if len(addr) =3D=3D 2: try: port =3D int(addr[1]) - except ValueError: - raise QMPShellBadPort + except ValueError as err: + raise QMPShellBadPort from err return addr[0], port # socket path return arg --=20 2.26.2 From nobody Fri May 17 07:07:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1604451754; cv=none; d=zohomail.com; s=zohoarc; b=Hr7iV25vg0hpNhbiVfuKXYqHtJCV2y0GvMmry/Cdav6vkDKmrvQwHadSNaW7+K9ny1fDShi5p6ymT2HQ3jUwW4SpJZlHBwLzQjzE2h/64Nd1tFB/Epddnp1yBghV6SQ21/g2eytCncM2Zhri1l24uadQoXIN9zLo/1rc7ShjmOY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604451754; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=La8LA7rAWBOZRtdJ7hAQXXLbNavMknquY2yV0eFl5mM=; b=X+OHaeOYPsB2XjHLdfSj/OBSyPGKoyjkTziMQkY4+AhLlmjtXXPef/6q+ecuWwRn9tz/GRnMiSpW3LkCckj8L77nELwDpleto66kL8UHmEDngaYQjRdqV6+14qtRQGjdpVYR4IxuK0PSQpQknACUEohO8FZhs68g+50hs1EPPP8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604451754762463.66417549248445; Tue, 3 Nov 2020 17:02:34 -0800 (PST) Received: from localhost ([::1]:35754 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ka7C5-000293-Mq for importer@patchew.org; Tue, 03 Nov 2020 20:02:33 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:35744) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ka6nU-0006ob-Ue for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:37:08 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:40826) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1ka6nR-0004uJ-Uv for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:37:08 -0500 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-436-53BI0lz9M4SGp9hs7n25dA-1; Tue, 03 Nov 2020 19:37:03 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7139F1891E82 for ; Wed, 4 Nov 2020 00:37:02 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-97.rdu2.redhat.com [10.10.119.97]) by smtp.corp.redhat.com (Postfix) with ESMTP id AAB5055766; Wed, 4 Nov 2020 00:37:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604450224; 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=La8LA7rAWBOZRtdJ7hAQXXLbNavMknquY2yV0eFl5mM=; b=i9ZcCXTkG2FR1PsAcwfW4sLHGJxAO35e/ltzMRrPYMap+Y6NP2X1L5j4KLBSPfhLK8424A Matfh54lFQQbOosJkZnP9cj8ln3Qd64nXBJ6daqWjsfPC4N5d4AiQ4ECDqB8qQrPGncEXC 9Z3saEev7na8E+R765CcYHyp8spwPxE= X-MC-Unique: 53BI0lz9M4SGp9hs7n25dA-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v2 43/72] scripts/qmp-shell: remove if-raise-else patterns Date: Tue, 3 Nov 2020 19:35:33 -0500 Message-Id: <20201104003602.1293560-44-jsnow@redhat.com> In-Reply-To: <20201104003602.1293560-1-jsnow@redhat.com> References: <20201104003602.1293560-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 01:02:05 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Cleber Rosa , John Snow , Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" 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 b3ab735397d4..47863a604f51 100755 --- a/scripts/qmp/qmp-shell +++ b/scripts/qmp/qmp-shell @@ -224,8 +224,7 @@ class QMPShell(qmp.QEMUMonitorProtocol): if type(parent[optpath[-1]]) is dict: msg =3D 'Cannot use "{:s}" as both leaf and non-leaf k= ey' raise QMPShellError(msg.format('.'.join(curpath))) - else: - raise QMPShellError(f'Cannot set "{key}" multiple time= s') + raise QMPShellError(f'Cannot set "{key}" multiple times') parent[optpath[-1]] =3D value =20 def __build_cmd(self, cmdline): @@ -329,13 +328,14 @@ class QMPShell(qmp.QEMUMonitorProtocol): except EOFError: print() return False + if cmdline =3D=3D '': for event in self.get_events(): print(event) self.clear_events() return True - else: - return self._execute_cmd(cmdline) + + return self._execute_cmd(cmdline) =20 def set_verbosity(self, verbose): self._verbose =3D verbose --=20 2.26.2 From nobody Fri May 17 07:07:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1604451722; cv=none; d=zohomail.com; s=zohoarc; b=muBsw8KKa1hXtMknirxXm0p5K2XWVNel0yfx69KFxceSH0wirq5ZioymLF4TCFJ6BuxvHEHu8npnZi5p6lUNa6X+l3fkr5CFklKFeqRrG4T3Ym+Wa/2WM/pvOAHWsow1hPcS4YUKsmOEhRGAp8wUQoYGAuUKIYRVJsT18v3YJtA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604451722; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=zxjLjpJdipkVXuG2hbACyf4YwvY0FTbyUiG6pFbjAhk=; b=ZzosYS4/sV70PfXVw8F1pKouXz22PJ4ZAisJgoImzlw5yFksm6ehWugMCu9sq5DdgipaQidQh+DhmVaW6Ncqk3sCWWLMmqg1ckwWfDSwbwQUSKIdrF6bR3MqZ5rLX3IIHvfjTaua8Gc7JqmuGtrpJAOXQa/zFGQz7z/xwfJ9sIo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604451722414673.1764322183724; Tue, 3 Nov 2020 17:02:02 -0800 (PST) Received: from localhost ([::1]:33500 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ka7BZ-0001DH-1b for importer@patchew.org; Tue, 03 Nov 2020 20:02:01 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:35758) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ka6nV-0006rD-SC for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:37:09 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:57631) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1ka6nT-0004ue-4h for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:37:09 -0500 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-484-uN1R2NECPxSO-TJlnaZbew-1; Tue, 03 Nov 2020 19:37:04 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 90DC31891E92 for ; Wed, 4 Nov 2020 00:37:03 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-97.rdu2.redhat.com [10.10.119.97]) by smtp.corp.redhat.com (Postfix) with ESMTP id B3C9555766; Wed, 4 Nov 2020 00:37:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604450226; 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=zxjLjpJdipkVXuG2hbACyf4YwvY0FTbyUiG6pFbjAhk=; b=Gq9T5R9VJVAdGI+rjPrn88UCIBUSrAFWNyE+GbkW1Pel+yRf1Rm26cV7CPdQJkbe2YFdbK KNRMLDUnJNYQt58vhJgaEvGocne8em5uJe/pDgZEpGMDOmK9m9luRcL3df4k2lQn1RVTUJ UaARLbB3lWjxrhsk0caV+9XCZXIOz3A= X-MC-Unique: uN1R2NECPxSO-TJlnaZbew-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v2 44/72] scripts/qmp-shell: use isinstance() instead of type() Date: Tue, 3 Nov 2020 19:35:34 -0500 Message-Id: <20201104003602.1293560-45-jsnow@redhat.com> In-Reply-To: <20201104003602.1293560-1-jsnow@redhat.com> References: <20201104003602.1293560-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 01:02:05 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Cleber Rosa , John Snow , Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" 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 47863a604f51..0cd3ed7d43c7 100755 --- a/scripts/qmp/qmp-shell +++ b/scripts/qmp/qmp-shell @@ -215,13 +215,13 @@ class QMPShell(qmp.QEMUMonitorProtocol): for path in optpath[:-1]: curpath.append(path) obj =3D parent.get(path, {}) - if type(obj) is not dict: + if not isinstance(obj, dict): msg =3D 'Cannot use "{:s}" as both leaf and non-leaf k= ey' raise QMPShellError(msg.format('.'.join(curpath))) parent[path] =3D obj parent =3D obj if optpath[-1] in parent: - if type(parent[optpath[-1]]) is dict: + if isinstance(parent[optpath[-1]], dict): msg =3D 'Cannot use "{:s}" as both leaf and non-leaf k= ey' raise QMPShellError(msg.format('.'.join(curpath))) raise QMPShellError(f'Cannot set "{key}" multiple times') --=20 2.26.2 From nobody Fri May 17 07:07:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1604451140; cv=none; d=zohomail.com; s=zohoarc; b=Wh/KpPo7l/3/Ob8SJYoz0WyHGSA51vBwBXElaXCmjBNFS6ECJxoDOyGqHmKn7kp4U0ppU6Pn5DgMTe6i7Rw8dBrhPQ2Liu8xUVS584s6++qEuuHUD66MOpH8Af94yevsu0UhltMwPAG20FGkjKb9ExxUabxOdEF9Eo+jLUIu0yk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604451140; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=GMqE1AyxFYAnSfxpx9j63puyEBG10ftch/58FhUYqHA=; b=cfsUdVvFI5ry2KippPRcGAc4rcb3GrS3AWMhZxb/ipX2H9l5zt+v+r3FWmmb5lslP8VGUemStPV0jODc2I4XKE0qqH8Il+3p4OdUvZ/aF/5Lkf5+D80yn3sf96msHdvojhUhwfTiqD/0KcWadKh2FklE0JLqKT+e0CmhqATX3Uw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604451140317259.5377466727126; Tue, 3 Nov 2020 16:52:20 -0800 (PST) Received: from localhost ([::1]:56214 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ka72B-00042y-75 for importer@patchew.org; Tue, 03 Nov 2020 19:52:19 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:35768) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ka6nW-0006tD-KE for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:37:10 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:31836) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1ka6nU-0004v4-0F for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:37:10 -0500 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-589-6LG_tDASOayNRU28llR5uA-1; Tue, 03 Nov 2020 19:37:05 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B3B3980474F for ; Wed, 4 Nov 2020 00:37:04 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-97.rdu2.redhat.com [10.10.119.97]) by smtp.corp.redhat.com (Postfix) with ESMTP id BE21F747C6; Wed, 4 Nov 2020 00:37:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604450227; 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=GMqE1AyxFYAnSfxpx9j63puyEBG10ftch/58FhUYqHA=; b=OadDj5uafHYr+SfS48Siz1ZVMHaA/iETgBhNLi52ONFI/Q5i6I+ZN6o0IFhCBDXNmJMo4L kYRHN+o65XXkR0nCQQDOezVn2oleqTHkduucuRt+yyV3M84+qiRzx2+wrde+enWDdVRDBH b2vOoj8IhAO5m8gAaW53mM/tiJ/rNuE= X-MC-Unique: 6LG_tDASOayNRU28llR5uA-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v2 45/72] scripts/qmp-shell: use argparse Date: Tue, 3 Nov 2020 19:35:35 -0500 Message-Id: <20201104003602.1293560-46-jsnow@redhat.com> In-Reply-To: <20201104003602.1293560-1-jsnow@redhat.com> References: <20201104003602.1293560-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 00:03:41 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Cleber Rosa , John Snow , Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" 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 0cd3ed7d43c7..d5496aeac0bd 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 optio= ns, # which will echo back the properly formatted JSON-compliant QMP that is b= eing # sent to QEMU, which is useful for debugging and documentation generation. - +import argparse import ast import atexit import json @@ -421,65 +421,47 @@ def die(msg): sys.exit(1) =20 =20 -def fail_cmdline(option=3DNone): - if option: - sys.stderr.write('ERROR: bad command-line option \'%s\'\n' % optio= 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 =3D '' - qemu =3D None - hmp =3D False - pretty =3D False - verbose =3D False - negotiate =3D True + parser =3D argparse.ArgumentParser() + parser.add_argument('-H', '--hmp', action=3D'store_true', + help=3D'Use HMP interface') + parser.add_argument('-N', '--skip-negotiation', action=3D'store_true', + help=3D'Skip negotiate (for qemu-ga)') + parser.add_argument('-v', '--verbose', action=3D'store_true', + help=3D'Verbose (echo commands sent and received)') + parser.add_argument('-p', '--pretty', action=3D'store_true', + help=3D'Pretty-print JSON') =20 + default_server =3D os.environ.get('QMP_SOCKET') + parser.add_argument('qmp_server', action=3D'store', + default=3Ddefault_server, + help=3D'< UNIX socket path | TCP address:port >') + + args =3D 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 =3D=3D "-H": - if qemu is not None: - fail_cmdline(arg) - hmp =3D True - elif arg =3D=3D "-p": - pretty =3D True - elif arg =3D=3D "-N": - negotiate =3D False - elif arg =3D=3D "-v": - verbose =3D True - else: - if qemu is not None: - fail_cmdline(arg) - if hmp: - qemu =3D HMPShell(arg) - else: - qemu =3D QMPShell(arg, pretty) - addr =3D arg - - if qemu is None: - fail_cmdline() + if args.hmp: + qemu =3D HMPShell(args.qmp_server) + else: + qemu =3D QMPShell(args.qmp_server, args.pretty) except QMPShellBadPort: - die('bad port number in command-line') + parser.error(f"Bad port number: {args.qmp_server}") + return # pycharm doesn't know error() is noreturn =20 try: - qemu.connect(negotiate) + qemu.connect(negotiate=3Dnot 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}") =20 qemu.show_banner() - qemu.set_verbosity(verbose) + qemu.set_verbosity(args.verbose) while qemu.read_exec_command(qemu.get_prompt()): pass qemu.close() --=20 2.26.2 From nobody Fri May 17 07:07:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1604451848; cv=none; d=zohomail.com; s=zohoarc; b=T4MYUv3R7Cr+slxA7RaHVxdhofjqMBKqEWLqJB+VtnV65QPGTWc4q9hjVny4shAcx0o3Afuf/Ouw2csncqEyEKhyPWXJtMM2QpFSCzXGOM/Rndw7Ho6hbTu7tLcSRTdwrAiKTro5AUBPg5EkYokoo52Id3eBfUiyuaoTGh86dqM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604451848; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=8OIP/yQLJZUsi2soEpTbp9StYHP0czke4xPs/CZ/wFY=; b=LCyQSMNPbLlZKbRwdq6lFAyO9oX2u8rSy4MAWZYSCCbgSdLSB2guqvQ5WkE+J+Q/71sgxc5trUUZ066GAJLyzgeDNfaluPwOsbkm8eXmQP9lw57vzLJb+HMuhn3yjvV7dUiBqRlhdTyREchICyZTrwctTdwSHXGiCqvcr78cCCE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604451848508660.0830180653455; Tue, 3 Nov 2020 17:04:08 -0800 (PST) Received: from localhost ([::1]:42022 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ka7Db-0004hC-Gf for importer@patchew.org; Tue, 03 Nov 2020 20:04:07 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:35770) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ka6nX-0006um-9Y for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:37:11 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:46020) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1ka6nV-0004vI-Jl for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:37:10 -0500 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-212-EFb-lIC-Pum0RFfcMjSvDg-1; Tue, 03 Nov 2020 19:37:06 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0E8BA8015C3 for ; Wed, 4 Nov 2020 00:37:06 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-97.rdu2.redhat.com [10.10.119.97]) by smtp.corp.redhat.com (Postfix) with ESMTP id E8A39747C6; Wed, 4 Nov 2020 00:37:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604450228; 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=8OIP/yQLJZUsi2soEpTbp9StYHP0czke4xPs/CZ/wFY=; b=O0GCFwavMYmS8WBdHbPS/8e0+Obyy26QzFMe4LY2JCozs28Vz3LIaC/aZv4riPwyRvccsh DxQsSAZr4bYjnojROuvz5P8IfD0oFswtS7djcjil+56D1vGEYHoboJT7jbL5gNOUWKIAzp 5/se/pB1TsWZj9Hro58vwDDSoX0/+9c= X-MC-Unique: EFb-lIC-Pum0RFfcMjSvDg-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v2 46/72] python/qmp: Fix type of SocketAddrT Date: Tue, 3 Nov 2020 19:35:36 -0500 Message-Id: <20201104003602.1293560-47-jsnow@redhat.com> In-Reply-To: <20201104003602.1293560-1-jsnow@redhat.com> References: <20201104003602.1293560-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 01:02:05 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Cleber Rosa , John Snow , Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" This is an integer, not a string. We didn't catch this before because we have not been type checking any of the clients that use this, and it was self-consistent enough. Mypy was not introspecting into the socket() interface to realize we were passing a bad type. Fixed now. Signed-off-by: John Snow --- python/qemu/qmp/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/qemu/qmp/__init__.py b/python/qemu/qmp/__init__.py index 7355a558796f..dd211e3f6511 100644 --- a/python/qemu/qmp/__init__.py +++ b/python/qemu/qmp/__init__.py @@ -49,7 +49,7 @@ # {} is the QMPReturnValue. =20 =20 -InternetAddrT =3D Tuple[str, str] +InternetAddrT =3D Tuple[str, int] UnixAddrT =3D str SocketAddrT =3D Union[InternetAddrT, UnixAddrT] =20 --=20 2.26.2 From nobody Fri May 17 07:07:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1604452027; cv=none; d=zohomail.com; s=zohoarc; b=n34mXhxyyRKz/ABUwwok3KTDfK5cuLx2YmBNfb4KHp3GKpXD0PrXSwspm1zuJFK1iWUJVWlDXCxuaFtAwKwWbQhnpcWujYe5vgcSQluKd4EGW4zI1GahQYmAhkMT7J2NKqVbPXPpSLR5xFlj7CKqkFsA9kO6nY/IiSac4V4oztk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604452027; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=67hPomjxNLOBu5xnnDcvEm19yDZAmkXyoM6jA1VmJsY=; b=ZwoKf+IZgIoLnodRomE1KPqFd4OGujkoxDCIXSEQasmqLcywb4DFBQs3SQhqaA2ATaynHirmTxEAVrTGKmcBIQF01hh57YcdAHoXtwR7xv4WrcDUI/Geeq6eJ1nuDcxrs2c+KGq4QB9LbT24/30KmkuU2QrKB+nP3n0M83XEp/o= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604452027892910.1857338631336; Tue, 3 Nov 2020 17:07:07 -0800 (PST) Received: from localhost ([::1]:50410 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ka7GU-0008Eq-Gh for importer@patchew.org; Tue, 03 Nov 2020 20:07:06 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:35790) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ka6nc-00078i-40 for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:37:16 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:51801) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1ka6na-0004vh-6N for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:37:15 -0500 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-0xe8iIbpPAGRIsVXMv8yXg-1; Tue, 03 Nov 2020 19:37:11 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C820B8015C3 for ; Wed, 4 Nov 2020 00:37:10 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-97.rdu2.redhat.com [10.10.119.97]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5366C55766; Wed, 4 Nov 2020 00:37:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604450233; 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=67hPomjxNLOBu5xnnDcvEm19yDZAmkXyoM6jA1VmJsY=; b=EArcuoQDSav0lECru5ASNW9upmRMaatese0JPR90+EBaBT//zT9CwGAyzUIh3ED7RXK/Gz 2I/Wb4l5+JvnBvLGhkfFR0hlNq6RrCSuVI7JZwGGZMxzUw66pw/ZfmPLdSSWum6+uPLzpD Mq1GLcSbBO5Iu5phfduWDnqE3mBsKnk= X-MC-Unique: 0xe8iIbpPAGRIsVXMv8yXg-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v2 47/72] python/qmp: add parse_address classmethod Date: Tue, 3 Nov 2020 19:35:37 -0500 Message-Id: <20201104003602.1293560-48-jsnow@redhat.com> In-Reply-To: <20201104003602.1293560-1-jsnow@redhat.com> References: <20201104003602.1293560-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 01:02:05 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Cleber Rosa , John Snow , Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" This takes the place of qmp-shell's __get_address function. Signed-off-by: John Snow --- python/qemu/qmp/__init__.py | 26 ++++++++++++++++++++++++++ scripts/qmp/qmp-shell | 27 ++------------------------- 2 files changed, 28 insertions(+), 25 deletions(-) diff --git a/python/qemu/qmp/__init__.py b/python/qemu/qmp/__init__.py index dd211e3f6511..a6e1a7b85775 100644 --- a/python/qemu/qmp/__init__.py +++ b/python/qemu/qmp/__init__.py @@ -97,6 +97,12 @@ def __init__(self, reply: QMPMessage): self.reply =3D reply =20 =20 +class QMPBadPortError(QMPError): + """ + Unable to parse socket address: Port was non-numerical. + """ + + class QEMUMonitorProtocol: """ Provide an API to connect to QEMU via QEMU Monitor Protocol (QMP) and = then @@ -224,6 +230,26 @@ def __exit__(self, # Implement context manager exit function. self.close() =20 + @classmethod + def parse_address(cls, address: str) -> SocketAddrT: + """ + Parse a string into a QMP address. + + Figure out if the argument is in the port:host form. + If it's not, it's probably a file path. + """ + components =3D address.split(':') + if len(components) =3D=3D 2: + try: + port =3D int(components[1]) + except ValueError: + msg =3D f"Bad port: '{components[1]}' in '{address}'." + raise QMPBadPortError(msg) from None + return (components[0], port) + + # Treat as filepath. + return address + def connect(self, negotiate: bool =3D True) -> Optional[QMPMessage]: """ Connect to the QMP Monitor and perform capabilities negotiation. diff --git a/scripts/qmp/qmp-shell b/scripts/qmp/qmp-shell index d5496aeac0bd..5a72b9d39502 100755 --- a/scripts/qmp/qmp-shell +++ b/scripts/qmp/qmp-shell @@ -92,10 +92,6 @@ class QMPShellError(Exception): pass =20 =20 -class QMPShellBadPort(QMPShellError): - pass - - class FuzzyJSON(ast.NodeTransformer): """ This extension of ast.NodeTransformer filters literal "true/false/null" @@ -118,7 +114,7 @@ class FuzzyJSON(ast.NodeTransformer): # _execute_cmd()). Let's design a better one. class QMPShell(qmp.QEMUMonitorProtocol): def __init__(self, address, pretty=3DFalse): - super().__init__(self.__get_address(address)) + super().__init__(self.parse_address(address)) self._greeting =3D None self._completer =3D None self._pretty =3D pretty @@ -128,22 +124,6 @@ class QMPShell(qmp.QEMUMonitorProtocol): '.qmp-shell_history') self._verbose =3D False =20 - @classmethod - def __get_address(cls, arg): - """ - Figure out if the argument is in the port:host form, if it's not i= t's - probably a file path. - """ - addr =3D arg.split(':') - if len(addr) =3D=3D 2: - try: - port =3D int(addr[1]) - except ValueError as err: - raise QMPShellBadPort from err - return addr[0], port - # socket path - return arg - def _fill_completion(self): cmds =3D self.cmd('query-commands') if 'error' in cmds: @@ -337,9 +317,6 @@ class QMPShell(qmp.QEMUMonitorProtocol): =20 return self._execute_cmd(cmdline) =20 - def set_verbosity(self, verbose): - self._verbose =3D verbose - =20 class HMPShell(QMPShell): def __init__(self, address): @@ -447,7 +424,7 @@ def main(): qemu =3D HMPShell(args.qmp_server) else: qemu =3D QMPShell(args.qmp_server, args.pretty) - except QMPShellBadPort: + except qmp.QMPBadPortError: parser.error(f"Bad port number: {args.qmp_server}") return # pycharm doesn't know error() is noreturn =20 --=20 2.26.2 From nobody Fri May 17 07:07:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1604452155; cv=none; d=zohomail.com; s=zohoarc; b=ccdbWZMpMTFF7zS98MsfkSr4+bA/8r2F/uI28oRKKjKczCgf1JPBYVAD5HY0/iBuVcZSk01zRJW+qjUWj3NHK7kvJA91qSdsz7Xi07kRo1aHtZ3nyLGS8q1HVYmmDaYajFBem1XWz65gWsaKMVDD73C5/y9bL6n/RzTiamcaDUo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604452155; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=a1XHIBeG+DluaONg2ht+r/5cfSSpprDO9b+48DgbMW0=; b=QRXzk8iqaCPP4Qnv9m9GetKVxkvBAOWItHia+Wuipj1/1V9MLHuYvFace0nZQioba1ozvrcBG5o+qdfqCM7kteuAw4zGMoreBxd//z6KZ0COcw7aWzKEPTip+N5DtXIfUgAFDm2OwXZUzS5wpP9lhZkqPvt45NuoqkB5Omj7RSk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604452155478879.4559619334649; Tue, 3 Nov 2020 17:09:15 -0800 (PST) Received: from localhost ([::1]:58786 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ka7IY-0003Eq-8L for importer@patchew.org; Tue, 03 Nov 2020 20:09:14 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:35796) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ka6nd-0007B2-22 for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:37:17 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:21798) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1ka6nb-0004vm-Di for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:37:16 -0500 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-116-zDAp5zeNPue1HcQePq7_Jw-1; Tue, 03 Nov 2020 19:37:13 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 33831802B56 for ; Wed, 4 Nov 2020 00:37:12 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-97.rdu2.redhat.com [10.10.119.97]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1AA9C55766; Wed, 4 Nov 2020 00:37:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604450234; 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=a1XHIBeG+DluaONg2ht+r/5cfSSpprDO9b+48DgbMW0=; b=Z2pbJY5qODgn1YoQPodd7lsdvQlZjofXYFr0r8a8oja9K1n8U88ACEQvLG4GLtiJsL1632 KjH9gr3VOwpGWaJpc6pyPzTfZlp5zUTxxCVHskfBNX4DEzC+jKlA7tSycY4yaxB4up7fD9 kWThENCbFiv2ULkYsggsUoAmgSB9Uac= X-MC-Unique: zDAp5zeNPue1HcQePq7_Jw-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v2 48/72] scripts/qmp-shell: Add pretty attribute to HMP shell Date: Tue, 3 Nov 2020 19:35:38 -0500 Message-Id: <20201104003602.1293560-49-jsnow@redhat.com> In-Reply-To: <20201104003602.1293560-1-jsnow@redhat.com> References: <20201104003602.1293560-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 01:02:05 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Cleber Rosa , John Snow , Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" It's less useful, but it makes the initialization methods LSP consistent. 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 5a72b9d39502..ba27e9801c68 100755 --- a/scripts/qmp/qmp-shell +++ b/scripts/qmp/qmp-shell @@ -319,8 +319,8 @@ class QMPShell(qmp.QEMUMonitorProtocol): =20 =20 class HMPShell(QMPShell): - def __init__(self, address): - super().__init__(address) + def __init__(self, address, pretty=3DFalse): + super().__init__(address, pretty) self.__cpu_index =3D 0 =20 def __cmd_completion(self): @@ -418,12 +418,9 @@ def main(): if args.qmp_server is None: parser.error("QMP socket or TCP address must be specified") =20 - qemu: QMPShell + shell_class =3D HMPShell if args.hmp else QMPShell try: - if args.hmp: - qemu =3D HMPShell(args.qmp_server) - else: - qemu =3D QMPShell(args.qmp_server, args.pretty) + qemu =3D 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 --=20 2.26.2 From nobody Fri May 17 07:07:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1604451416; cv=none; d=zohomail.com; s=zohoarc; b=iI5dALcd99xnhUvJrSJSpZuJiNxZQ/riL/fC4hr1OLQM0pdWNKFk9hCwCX+zbm+NpLrfgwDOMfulBcDJ2EYArWcMC6wBwkTapDc7qXRYN6nc0pya5oVR+aqu0FUtiCKEUAbpmJPOF9DyAfdvRgXlVXccHI2nDT7KofllcpAro8A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604451416; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=pIMjZAoZPo6ny5PBtyWC0I9lcIqZo7oz/v3yVY473cQ=; b=AgwjiQ4n4Ij931QttcqIoO5QN2Zt8enK7rz351/JWBIIJn28m6jE7g9otARbdnQ14wGcQLivzBsZVPcEr16lP+IS6f4XCXbkGVkqWR5EO8yx0TbPJ/pv6vl7zHToVh3RApTVERD4ZLiWeGKFz2KVnnvgbfeaAJE+vppbLjQBrKs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604451416265717.884668869807; Tue, 3 Nov 2020 16:56:56 -0800 (PST) Received: from localhost ([::1]:44858 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ka76d-0002bi-1y for importer@patchew.org; Tue, 03 Nov 2020 19:56:55 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:35818) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ka6ne-0007CJ-NU for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:37:18 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:38968) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1ka6nc-0004vw-UN for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:37:18 -0500 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-434-oYFDkvcLNiKt-AmOUD4grw-1; Tue, 03 Nov 2020 19:37:14 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4A85964151 for ; Wed, 4 Nov 2020 00:37:13 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-97.rdu2.redhat.com [10.10.119.97]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7958B55766; Wed, 4 Nov 2020 00:37:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604450236; 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=pIMjZAoZPo6ny5PBtyWC0I9lcIqZo7oz/v3yVY473cQ=; b=gQ/CCJIbLIS9kPxO1/QnmOGHFni7vWkl8wqVYgUMyKR/GnqhRHUMY5C2RR8/9FYDMJ2FuI m+LYzsHQIEW6YICF8huIcBiDG5d3dDbeYXqg6HHSmrX3kW5l3idSSwMOm5j7CvWIqk0ZEe 88mtlv85NC03DJL4G7WnPft0gplf08Y= X-MC-Unique: oYFDkvcLNiKt-AmOUD4grw-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v2 49/72] scripts/qmp-shell: Make verbose a public attribute Date: Tue, 3 Nov 2020 19:35:39 -0500 Message-Id: <20201104003602.1293560-50-jsnow@redhat.com> In-Reply-To: <20201104003602.1293560-1-jsnow@redhat.com> References: <20201104003602.1293560-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 01:02:05 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Cleber Rosa , John Snow , Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" 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 | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/scripts/qmp/qmp-shell b/scripts/qmp/qmp-shell index ba27e9801c68..cfcefb95f9da 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=3DFalse): + def __init__(self, address, pretty=3DFalse, verbose=3DFalse): super().__init__(self.parse_address(address)) self._greeting =3D None self._completer =3D None @@ -122,7 +122,7 @@ class QMPShell(qmp.QEMUMonitorProtocol): self._actions =3D list() self._histfile =3D os.path.join(os.path.expanduser('~'), '.qmp-shell_history') - self._verbose =3D False + self.verbose =3D verbose =20 def _fill_completion(self): cmds =3D 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 =3D self.cmd_obj(qmpcmd) if resp is None: @@ -319,8 +319,8 @@ class QMPShell(qmp.QEMUMonitorProtocol): =20 =20 class HMPShell(QMPShell): - def __init__(self, address, pretty=3DFalse): - super().__init__(address, pretty) + def __init__(self, address, pretty=3DFalse, verbose=3DFalse): + super().__init__(address, pretty, verbose) self.__cpu_index =3D 0 =20 def __cmd_completion(self): @@ -420,7 +420,7 @@ def main(): =20 shell_class =3D HMPShell if args.hmp else QMPShell try: - qemu =3D shell_class(args.qmp_server, args.pretty) + qemu =3D 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 @@ -435,7 +435,6 @@ def main(): die(f"Couldn't connect to {args.qmp_server}: {err!s}") =20 qemu.show_banner() - qemu.set_verbosity(args.verbose) while qemu.read_exec_command(qemu.get_prompt()): pass qemu.close() --=20 2.26.2 From nobody Fri May 17 07:07:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1604451509; cv=none; d=zohomail.com; s=zohoarc; b=P0v7C9G/86oB9gdgP/J74LmuaJjTiXz4b1ojSdtIXLgHQtw7d3+obXkgElTuwRo2mgBwlkFgCBR+8fwicfAW7naacmltjEvlu5N4XIIpjT63QpYKsUeIt78H0vBDaTXF6d1AvqVAiE/IaiGln5FVmiiGFxaC7QTzJ/YEZqX84gU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604451509; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=l0geWX4GnzvjPC2sg3cL9qk3gkNtLddwm2qUwTAz6/I=; b=DJk/qYJWjQphYhvfIvKzt3LTICQ6rvpGf1IpHkHzzCqHYezeOMRhrUW6jBDDYDF6gQd30Z7HIw1zgIxpH97CAqpZGh69oZjXgtP+yPqmmUERGLJFf9QaagWoFVewmfwUmJ0qHaHXANU0AGn9Zy7KjdrXRJIuCI1sDmNK8oexyas= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604451509264846.8450791482251; Tue, 3 Nov 2020 16:58:29 -0800 (PST) Received: from localhost ([::1]:53312 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ka788-00063D-7p for importer@patchew.org; Tue, 03 Nov 2020 19:58:28 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:35822) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ka6nf-0007DE-Cm for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:37:19 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:55806) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1ka6nd-0004w4-Mm for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:37:19 -0500 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-ZxGpM_vVPnaViecvq_q7hw-1; Tue, 03 Nov 2020 19:37:15 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7BE9A8015C3 for ; Wed, 4 Nov 2020 00:37:14 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-97.rdu2.redhat.com [10.10.119.97]) by smtp.corp.redhat.com (Postfix) with ESMTP id 89954747C6; Wed, 4 Nov 2020 00:37:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604450237; 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=l0geWX4GnzvjPC2sg3cL9qk3gkNtLddwm2qUwTAz6/I=; b=ce4ukbwLO1au1cpTanbBUUPmE9FUbQ7/BK5PTZzOOsUgR83UNxIxy9BUJaxXiTorrMsspn zpkiQZYE5EiVjdtEyxiCIZvufug40Ck9DzDARztNa/Dbg8N1IpDyhEaYWpkWx2JJdNd52s IXwcthLTxbCjA9lN+HXg3VksHIkaVOc= X-MC-Unique: ZxGpM_vVPnaViecvq_q7hw-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v2 50/72] scripts/qmp-shell: move get_prompt() to prompt property Date: Tue, 3 Nov 2020 19:35:40 -0500 Message-Id: <20201104003602.1293560-51-jsnow@redhat.com> In-Reply-To: <20201104003602.1293560-1-jsnow@redhat.com> References: <20201104003602.1293560-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 00:03:41 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Cleber Rosa , John Snow , Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" 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 cfcefb95f9da..3b86ef7d8844 100755 --- a/scripts/qmp/qmp-shell +++ b/scripts/qmp/qmp-shell @@ -292,10 +292,11 @@ class QMPShell(qmp.QEMUMonitorProtocol): version =3D self._greeting['QMP']['version']['qemu'] print("Connected to QEMU {major}.{minor}.{micro}\n".format(**versi= on)) =20 - def get_prompt(self): + @property + def prompt(self): if self._transmode: - return "TRANS> " - return "(QEMU) " + return 'TRANS> ' + return '(QEMU) ' =20 def read_exec_command(self, prompt): """ @@ -435,7 +436,7 @@ def main(): die(f"Couldn't connect to {args.qmp_server}: {err!s}") =20 qemu.show_banner() - while qemu.read_exec_command(qemu.get_prompt()): + while qemu.read_exec_command(qemu.prompt): pass qemu.close() =20 --=20 2.26.2 From nobody Fri May 17 07:07:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1604451722; cv=none; d=zohomail.com; s=zohoarc; b=DMpFLcDmt28vFf2SB1vVJycfv71R8WpejawOb03PNBHLflIDw03xW5LsZY2r2yGq3/t6pbvYPW1G/qUNWyVCQD1Vf4njpbtH7p+NK9ivQnCCH05albauFP0SRGnirtvIHmfZTphXXnjWgFyg0f9Jlim+Bi+om2kRJKHNKgfEiqc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604451722; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=iskghmMZ9Cu+o7H8nn+qox8VkTJEOcWFJKDnEwqu+FQ=; b=hdUUxnONL53g44DV/9KNzF4qRjzt1bYQgHB+5nuGLnGx0ctHzd0JqL+kiQkCq9ncMDug/yrq/M/SXnnJpHnwqYM7ebLtYXuhuVI2eB9Mk5JroK6mOrnt7YaqKq8ucUWmnRMNPQ2G6P/WmIJYJf1f+IzxtfZABe+fNvZv+0tIJk4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604451722392251.72142131232874; Tue, 3 Nov 2020 17:02:02 -0800 (PST) Received: from localhost ([::1]:33498 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ka7BY-0001DG-TY for importer@patchew.org; Tue, 03 Nov 2020 20:02:00 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:35834) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ka6ni-0007GW-51 for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:37:23 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:43363) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1ka6ne-0004w9-R1 for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:37:21 -0500 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-113-k4vPhkd8PVKpgUT_nNwbCw-1; Tue, 03 Nov 2020 19:37:16 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B1679108E1AF for ; Wed, 4 Nov 2020 00:37:15 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-97.rdu2.redhat.com [10.10.119.97]) by smtp.corp.redhat.com (Postfix) with ESMTP id C07B055766; Wed, 4 Nov 2020 00:37:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604450238; 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=iskghmMZ9Cu+o7H8nn+qox8VkTJEOcWFJKDnEwqu+FQ=; b=QZJPviMlBHrDAkFTz0AykgDYdwMmcHpJll0F3o8A559wIaKabvxkx944P4gXkYjIlGMDZX LZIkkxcRXV+MbGfblhVRW+jIGb3eAPF95klVmQq89+FEYlZ6dZ+4GWn8/ORpN0RF9h++o+ 6VupRhKN1ygBuJsF0W5GRqx/5DPuUXU= X-MC-Unique: k4vPhkd8PVKpgUT_nNwbCw-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v2 51/72] scripts/qmp-shell: remove prompt argument from read_exec_command Date: Tue, 3 Nov 2020 19:35:41 -0500 Message-Id: <20201104003602.1293560-52-jsnow@redhat.com> In-Reply-To: <20201104003602.1293560-1-jsnow@redhat.com> References: <20201104003602.1293560-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 00:03:41 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Cleber Rosa , John Snow , Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" 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 3b86ef7d8844..31269859c4c4 100755 --- a/scripts/qmp/qmp-shell +++ b/scripts/qmp/qmp-shell @@ -298,14 +298,14 @@ class QMPShell(qmp.QEMUMonitorProtocol): return 'TRANS> ' return '(QEMU) ' =20 - def read_exec_command(self, prompt): + def read_exec_command(self): """ Read and execute a command. =20 @return True if execution was ok, return False if disconnected. """ try: - cmdline =3D input(prompt) + cmdline =3D 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}") =20 qemu.show_banner() - while qemu.read_exec_command(qemu.prompt): + while qemu.read_exec_command(): pass qemu.close() =20 --=20 2.26.2 From nobody Fri May 17 07:07:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1604451903; cv=none; d=zohomail.com; s=zohoarc; b=hetai8w6RbZzadIb4TZHm7bAX/8rt5em6dngjoP1/pWD7lw1+8rWBm+CI8LOfla1c7ZGM5Odbom74FL8WtYmtyTP8kO8LaQ/oI8Z2x8SUlyGCLdpDaTQNtMElmOYH2Zul3z0UiC6c5+4CCfX0zhbP98+LDtTwygsmvW3IdNZAqg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604451903; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=YAg08pyT30kqE06g+2YSuEIio763R2gtwKP+pBI5q70=; b=P/HfPqjzk5QVatI4QLQefiD5WCiO3BSR323fZ2ihM/FGsTMA7TSGdX9UhHM6udDHjk0i9VISHiXFwLFP8Tr8Ve29q/Dky3Vp39hQouK/Y3RE+D/alw0+oQnAKqGdHJBeWJY4zEOcMSjR/cgyAAo4+I7iTpOSq6cHpj5gbLZxWqE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604451903327286.65190706669944; Tue, 3 Nov 2020 17:05:03 -0800 (PST) Received: from localhost ([::1]:44176 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ka7EU-0005a9-6G for importer@patchew.org; Tue, 03 Nov 2020 20:05:02 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:35876) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ka6nl-0007Iq-Rm for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:37:27 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:59313) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1ka6nh-0004wM-RW for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:37:25 -0500 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-332-FIt2fiAbPGSVzV4SVrq18w-1; Tue, 03 Nov 2020 19:37:17 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C5DE36414C for ; Wed, 4 Nov 2020 00:37:16 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-97.rdu2.redhat.com [10.10.119.97]) by smtp.corp.redhat.com (Postfix) with ESMTP id DD4ED55766; Wed, 4 Nov 2020 00:37:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604450239; 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=YAg08pyT30kqE06g+2YSuEIio763R2gtwKP+pBI5q70=; b=KSKjwHxRTILSWz8RUHfzjmg0vnMkHzCYKqIStKfTJGjgUqu1SgjF8lkNOjzjECvig0sQ+v +vi+mRayAzIcwlZSGD0ev51MyaYtibSq+uUwRnj93X/0kp1iJbFgQJoWRICAxW3U0iXCP2 Zoi+miZxLj8FM9Ya/iHFTpXOUR7FlJQ= X-MC-Unique: FIt2fiAbPGSVzV4SVrq18w-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v2 52/72] scripts/qmp-shell: move the REPL functionality into QMPShell Date: Tue, 3 Nov 2020 19:35:42 -0500 Message-Id: <20201104003602.1293560-53-jsnow@redhat.com> In-Reply-To: <20201104003602.1293560-1-jsnow@redhat.com> References: <20201104003602.1293560-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 01:02:05 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Cleber Rosa , John Snow , Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Instead of doing this in main, move it into the class. 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 31269859c4c4..aa148517a864 100755 --- a/scripts/qmp/qmp-shell +++ b/scripts/qmp/qmp-shell @@ -318,6 +318,12 @@ class QMPShell(qmp.QEMUMonitorProtocol): =20 return self._execute_cmd(cmdline) =20 + def repl(self): + self.show_banner() + while self.read_exec_command(): + yield + self.close() + =20 class HMPShell(QMPShell): def __init__(self, address, pretty=3DFalse, verbose=3DFalse): @@ -435,10 +441,8 @@ def main(): except OSError as err: die(f"Couldn't connect to {args.qmp_server}: {err!s}") =20 - qemu.show_banner() - while qemu.read_exec_command(): + for _ in qemu.repl(): pass - qemu.close() =20 =20 if __name__ =3D=3D '__main__': --=20 2.26.2 From nobody Fri May 17 07:07:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1604452060; cv=none; d=zohomail.com; s=zohoarc; b=jBjWHekwpFbfTaTj/S4VcAMqgxSiYgHBLj54ZRvxjD39j4xRXGARgarmoY7/+fMVbcIklkYn9tXNPWGEQW0/Kfn7uVBvY8AasoKFnVj9j+ccDVaOgu0/Fo4qmNEi5Jfw1QFG3UK/Nda6mFW2WZqVA081bIVFz0PTI1K1XaM54wc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604452060; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=/HV2sRxuoFz1HvSs6hteE0GNcYJLYO0K0NRKl1Vz7YA=; b=O+31mUROXoy3oFDoE0UqQmpwt3v0qeg3/FmVYLAbk3+dbFQPn88b777ruEVHEx1aANZazzO2LGtnmX2rIsXWqEx3BcaajHagPqIjNbouVxAqtYT2LSI7b6DWGXj3XCFkzkjUhz+/BkguJ9/SMXQ8kwVTtXfnzm/9XddhtGX6Fr8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604452060239540.8180054464584; Tue, 3 Nov 2020 17:07:40 -0800 (PST) Received: from localhost ([::1]:52656 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ka7H1-0000k7-65 for importer@patchew.org; Tue, 03 Nov 2020 20:07:39 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:35904) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ka6nn-0007Jh-U2 for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:37:29 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:42734) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1ka6nh-0004wT-RU for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:37:26 -0500 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-335-0ytIZ5k2N52LVveGeyiUnA-1; Tue, 03 Nov 2020 19:37:19 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 236121891E84 for ; Wed, 4 Nov 2020 00:37:18 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-97.rdu2.redhat.com [10.10.119.97]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1A41955766; Wed, 4 Nov 2020 00:37:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604450241; 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=/HV2sRxuoFz1HvSs6hteE0GNcYJLYO0K0NRKl1Vz7YA=; b=cy6hZFJeBy8+4tkNSvVMT8/6ewz6aJDH7vxb7sbjAQB4WOC1z468nopeCy82NJ70qLDRnw hNNzOTSqNOnvGdMPJwhClXYgoORbm9hVhRgPHbvmokvKlsNrABdvtvzYcWbKJaGloqc9VV xV+79psfrktglHu05sFaZg6fn2qe5Js= X-MC-Unique: 0ytIZ5k2N52LVveGeyiUnA-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v2 53/72] scripts/qmp-shell: Fix "FuzzyJSON" parser Date: Tue, 3 Nov 2020 19:35:43 -0500 Message-Id: <20201104003602.1293560-54-jsnow@redhat.com> In-Reply-To: <20201104003602.1293560-1-jsnow@redhat.com> References: <20201104003602.1293560-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 00:03:41 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Cleber Rosa , John Snow , Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" 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 aa148517a864..847d34890f97 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" v= alues + that Python can properly evaluate. """ =20 @classmethod - def visit_Name(cls, node): # pylint: disable=3Dinvalid-name + def visit_Name(cls, # pylint: disable=3Dinvalid-name + node: ast.Name) -> ast.AST: if node.id =3D=3D 'true': - node.id =3D 'True' + return ast.Constant(value=3DTrue) if node.id =3D=3D 'false': - node.id =3D 'False' + return ast.Constant(value=3DFalse) if node.id =3D=3D 'null': - node.id =3D 'None' + return ast.Constant(value=3DNone) return node =20 =20 @@ -174,10 +175,9 @@ class QMPShell(qmp.QEMUMonitorProtocol): # Try once again as FuzzyJSON: try: tree =3D ast.parse(val, mode=3D'eval') - return ast.literal_eval(FuzzyJSON().visit(tree)) - except SyntaxError: - pass - except ValueError: + transformed =3D FuzzyJSON().visit(tree) + return ast.literal_eval(transformed) + except (SyntaxError, ValueError): pass return val =20 --=20 2.26.2 From nobody Fri May 17 07:07:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1604452792; cv=none; d=zohomail.com; s=zohoarc; b=VWJu0yND875fufMTLVxYaIjFnBo0RWkzCpZq1JSR1CUVhLLzj/Lk/8lRSEmdMNgZFDuQc+iBGDAQpmLA4RTQ7LlL3+LnfNMRfLLdNbI885uwx4xjgoytKUQOSiBYiIX2atuApO0Z0vTTLulOBge4KhST7U1OYm5g+m+Ei1pCL90= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604452792; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=dW8nv3mseuwyKhX4fJQG2TcuQYo/mf67EOtBCsNnqNQ=; b=VjU/BRV1AUk77BAm4bmpfc3YTFbjsj/UOOSTuZ0ApvRm/FYCKvBDtYEYaq60H2UhaGLkWTKcOE9Wme9bc+GnA+1uT4E2f+K99ayWKqpDxTNGi7OG0v90qQTec87jh7y9npyjwFE7CVcc4KGQ8t+zlUm68ajPCbBVru0mtvnl2TA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604452792033262.7061845801039; Tue, 3 Nov 2020 17:19:52 -0800 (PST) Received: from localhost ([::1]:58182 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ka7So-0006OV-TH for importer@patchew.org; Tue, 03 Nov 2020 20:19:50 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:35906) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ka6nn-0007Ji-Vt for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:37:29 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:27224) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1ka6nj-0004wa-CD for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:37:27 -0500 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-81-Zdz07CrDN_uDKHqLcttwiw-1; Tue, 03 Nov 2020 19:37:20 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 22F4A6417E for ; Wed, 4 Nov 2020 00:37:19 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-97.rdu2.redhat.com [10.10.119.97]) by smtp.corp.redhat.com (Postfix) with ESMTP id 623CC747C6; Wed, 4 Nov 2020 00:37:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604450241; 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=dW8nv3mseuwyKhX4fJQG2TcuQYo/mf67EOtBCsNnqNQ=; b=aiHi661JuY/Uo3XgMO4czscmsAan+7GVpw47pGWgdfVR1P2acb2V2nisEC+docH5Tcb17L QYKPgdAb/UOjqRgt8U0g6CGg0QBRnRdWcSrYNLn+s96jAHQos0DQ/AIw2uNTYHHHCiCU6K aEN3RHKPALr+gD9qENng9rm6W1cA1oM= X-MC-Unique: Zdz07CrDN_uDKHqLcttwiw-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v2 54/72] scripts/qmp-shell: refactor QMPCompleter Date: Tue, 3 Nov 2020 19:35:44 -0500 Message-Id: <20201104003602.1293560-55-jsnow@redhat.com> In-Reply-To: <20201104003602.1293560-1-jsnow@redhat.com> References: <20201104003602.1293560-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 00:03:41 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Cleber Rosa , John Snow , Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" 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 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 847d34890f97..73694035b203 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 =20 =20 -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] directl= y, + # but pylint as of today does not know that List[str] is simply 'list'. + def __init__(self) -> None: + self._matches: List[str] =3D [] + + 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 =3D=3D 0: return cmd --=20 2.26.2 From nobody Fri May 17 07:07:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1604453069; cv=none; d=zohomail.com; s=zohoarc; b=Sh/4anfgqKoTyDs5JG6WPzkxByEmFysjIJLS6GXGIx6rgTk3a+aSMQiH9LN1mZGkZvngzkCyZA2C1VLH67fe99HdM3cvwDJexmqvzuVyCH2w0ri16s+wIFLugdlrqktrx+BqOGOybNsKo0WnEmGZP+ECYLQQAFUgZoM2c9BlaD8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604453069; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Q+28xAGOJCZQfuhL43bq19j5d7gHdBDucvyEdTa16HY=; b=LfAQoDET+dwSDHnbo0rgoy5dV8GOnociOgCPXPZ007taeC2+v8aSPXhCWhfo1/CZEvqo+adnjb/8DyTNFXGpdbj5WcqniIliO65y7ETGN5kDZ5z/aLt4qBb9N2OeYLBQK6Katxd+fUm/bT9CwjUxyItkP9XKkzAm5sOgJij6SbA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16044530692811014.9920329569087; Tue, 3 Nov 2020 17:24:29 -0800 (PST) Received: from localhost ([::1]:42644 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ka7XH-0003Ie-Qt for importer@patchew.org; Tue, 03 Nov 2020 20:24:27 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:35976) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ka6nv-0007MK-BO for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:37:35 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:49313) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1ka6nj-0004wm-Re for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:37:33 -0500 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-o1WyM6vgMbOmq_0K7__cuA-1; Tue, 03 Nov 2020 19:37:21 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 780B0108E1A6 for ; Wed, 4 Nov 2020 00:37:20 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-97.rdu2.redhat.com [10.10.119.97]) by smtp.corp.redhat.com (Postfix) with ESMTP id 72EF255766; Wed, 4 Nov 2020 00:37:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604450243; 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=Q+28xAGOJCZQfuhL43bq19j5d7gHdBDucvyEdTa16HY=; b=Qi3rTkjSbDefWm2VAmgsgbxTBXSCaG/0jc5M4JPhWHSMboLct8JlqWnbtLRtQ5PXcJuiF5 g9G3ib8FkSTnkjMDYdR0LdE4SE3BEDe29mPMQVMIjAansLLM0vT1IwW9M1sCOo3GKc/d2y pIDDqLX7eNm7yZ4VeoFvao43E/6C+qg= X-MC-Unique: o1WyM6vgMbOmq_0K7__cuA-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v2 55/72] scripts/qmp-shell: initialize completer early Date: Tue, 3 Nov 2020 19:35:45 -0500 Message-Id: <20201104003602.1293560-56-jsnow@redhat.com> In-Reply-To: <20201104003602.1293560-1-jsnow@redhat.com> References: <20201104003602.1293560-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 00:03:41 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Cleber Rosa , John Snow , Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" 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 73694035b203..670361322c51 100755 --- a/scripts/qmp/qmp-shell +++ b/scripts/qmp/qmp-shell @@ -125,7 +125,7 @@ class QMPShell(qmp.QEMUMonitorProtocol): def __init__(self, address, pretty=3DFalse, verbose=3DFalse): super().__init__(self.parse_address(address)) self._greeting =3D None - self._completer =3D None + self._completer =3D QMPCompleter() self._pretty =3D pretty self._transmode =3D False self._actions =3D list() --=20 2.26.2 From nobody Fri May 17 07:07:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1604452957; cv=none; d=zohomail.com; s=zohoarc; b=Jin2olp3UBGPdfitDceygVN/O6qwB5IMurECko0u9urCrEA3G9pO/LZSc+ecSK2EuMpmf0mfPMfCxcQbrGN7SZv7CmqBJOJ8oZ+kelGVTiZ+8NQN9Zl+x4svC5wwvp8XAS0nN3Iu3rUnbFYIQwHof5rJq5MImJvblLr8hKTBhAE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604452957; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=08ilLdlAvTCW/NaILyV93iS4vcfYIx6F11xRdLB9EGw=; b=JBwWK8lD06ZR7GE2qAw8Y3TFiSEzsKoHhfJmkg77TpIRTakGoLJNiM7xX3OIeuBi67oXUUHKwpCZ0fTSnd3jcbVmeOTW8lEplJhyQs3ABs0D055Wh89IT70plBBlBdI7IaNR1ekxy7na1XGcjyGXLUsrz0JSebqLrhs6nGwg2Kc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604452957021451.79292774228225; Tue, 3 Nov 2020 17:22:37 -0800 (PST) Received: from localhost ([::1]:37462 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ka7VT-00019I-9T for importer@patchew.org; Tue, 03 Nov 2020 20:22:36 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:35914) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ka6np-0007KZ-Ox for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:37:31 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:49548) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1ka6nl-0004ws-I7 for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:37:29 -0500 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-472-CHVNiXagN0a7b4UFg0eX5Q-1; Tue, 03 Nov 2020 19:37:22 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A294A803F78 for ; Wed, 4 Nov 2020 00:37:21 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-97.rdu2.redhat.com [10.10.119.97]) by smtp.corp.redhat.com (Postfix) with ESMTP id C3BA255766; Wed, 4 Nov 2020 00:37:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604450244; 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=08ilLdlAvTCW/NaILyV93iS4vcfYIx6F11xRdLB9EGw=; b=TSpYNPNHR5DRlcBX5DMkrYx40SLnNNOlPCLv7InhIZM6Pa6Bfmpxer9OYkuzkZri/2vaRm E+x60agZleHrWHsHo+4SQ0orq+FDE+P+aDUYPTAj0iBN0mt6HqPvZG791n02qtztmLwNI1 sMUsO19zY2d7j1VUatOGYnxmQOceGAA= X-MC-Unique: CHVNiXagN0a7b4UFg0eX5Q-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v2 56/72] python/qmp: add QMPObject type alias Date: Tue, 3 Nov 2020 19:35:46 -0500 Message-Id: <20201104003602.1293560-57-jsnow@redhat.com> In-Reply-To: <20201104003602.1293560-1-jsnow@redhat.com> References: <20201104003602.1293560-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 01:02:05 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Cleber Rosa , John Snow , Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" This 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 a6e1a7b85775..ba0d2281d678 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 =3D object =20 +#: QMPObject is any object in a QMP message. +QMPObject =3D 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. --=20 2.26.2 From nobody Fri May 17 07:07:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1604453213; cv=none; d=zohomail.com; s=zohoarc; b=cWp5XchSSOUrIoumZczzkXzRDRKEprrARD6imU6o/FeUn7flgUuDgxaKY4dERQOPhrpME3h2F4JDKau1lqhAIFDIsecMxvIeAAryrss1HYbP22tnypM9Yggp5op3ECTO4nnwmIfct16cVEEjxLmvKBqxVLY2BAIliSezx28Qoxo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604453213; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=CLH3MBije1XSDJtFct1JQ4vpdKKI3TcUrJV5Rs/2+1g=; b=cTusLVbqzUBhP43x/9CShNdTHRAAq3ZhI9sdSpmqqf+cBOkek4QbgZp/WhC5VDmMUjqmapdrj+4dj4OHjXwKphEFHw7VxnsVu+P7CrBaCxcIZvJSo0Ot8Ai/9cjsXGNldPU0i+2F24QqQWuqYnAawxDjCLiUciYhPRFG9Iyh898= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604453213933673.8915893217053; Tue, 3 Nov 2020 17:26:53 -0800 (PST) Received: from localhost ([::1]:46930 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ka7Zc-00059a-O3 for importer@patchew.org; Tue, 03 Nov 2020 20:26:52 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:35978) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ka6nv-0007MT-E5 for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:37:35 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:44741) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1ka6nn-0004wz-Ni for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:37:35 -0500 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-506-8INIGRaCM962WlzJLTuEVA-1; Tue, 03 Nov 2020 19:37:23 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8FB231891E87 for ; Wed, 4 Nov 2020 00:37:22 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-97.rdu2.redhat.com [10.10.119.97]) by smtp.corp.redhat.com (Postfix) with ESMTP id D123655766; Wed, 4 Nov 2020 00:37:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604450245; 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=CLH3MBije1XSDJtFct1JQ4vpdKKI3TcUrJV5Rs/2+1g=; b=iUIMzYRwN3xmfH2eo4sjnAlCEy1oAfh5OvlDQDdYsIUqx31lNqLVHcoiz7jPeW9dGxyEpi tYUCoE+8FvOQh7bYqQwxrEB7C+YzuZkvS8rxlWP5OuGsKImvGKyhBQpV7UKSzCG8ZTBMXv BNYGh+Gdr2+wpS0PhWqghkVXxXbrzw8= X-MC-Unique: 8INIGRaCM962WlzJLTuEVA-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v2 57/72] scripts/qmp-shell: add mypy types Date: Tue, 3 Nov 2020 19:35:47 -0500 Message-Id: <20201104003602.1293560-58-jsnow@redhat.com> In-Reply-To: <20201104003602.1293560-1-jsnow@redhat.com> References: <20201104003602.1293560-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 01:02:05 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Cleber Rosa , John Snow , Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" 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 670361322c51..2d0e85b5f723 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, +) =20 =20 sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'pytho= n')) from qemu import qmp +from qemu.qmp import QMPMessage =20 =20 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=3DFalse, verbose=3DFalse): + def __init__(self, address: str, pretty: bool =3D False, + verbose: bool =3D False): super().__init__(self.parse_address(address)) - self._greeting =3D None + self._greeting: Optional[QMPMessage] =3D None self._completer =3D QMPCompleter() self._pretty =3D pretty self._transmode =3D False - self._actions =3D list() + self._actions: List[QMPMessage] =3D [] self._histfile =3D os.path.join(os.path.expanduser('~'), '.qmp-shell_history') self.verbose =3D verbose =20 - def _fill_completion(self): + def _fill_completion(self) -> None: cmds =3D self.cmd('query-commands') if 'error' in cmds: return for cmd in cmds['return']: self._completer.append(cmd['name']) =20 - def __completer_setup(self): + def __completer_setup(self) -> None: self._completer =3D 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) =20 - 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= }") =20 @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 =20 - def __cli_expr(self, tokens, parent): + def __cli_expr(self, + tokens: Sequence[str], + parent: qmp.QMPObject) -> None: for arg in tokens: (key, sep, val) =3D arg.partition('=3D') if sep !=3D '=3D': @@ -215,7 +226,7 @@ class QMPShell(qmp.QEMUMonitorProtocol): raise QMPShellError(f'Cannot set "{key}" multiple times') parent[optpath[-1]] =3D value =20 - 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 =3D r'''(?:[^\s"']|"(?:\\.|[^"])*"|'(?:\\.|[^'])*')= +''' cmdargs =3D re.findall(argument_regex, cmdline) + qmpcmd: QMPMessage =20 # Transactional CLI entry/exit: if cmdargs[0] =3D=3D 'transaction(': @@ -261,14 +273,14 @@ class QMPShell(qmp.QEMUMonitorProtocol): self.__cli_expr(cmdargs[1:], qmpcmd['arguments']) return qmpcmd =20 - def _print(self, qmp_message): + def _print(self, qmp_message: object) -> None: indent =3D None if self._pretty: indent =3D 4 jsobj =3D json.dumps(qmp_message, indent=3Dindent, sort_keys=3Dsel= f._pretty) print(str(jsobj)) =20 - def _execute_cmd(self, cmdline): + def _execute_cmd(self, cmdline: str) -> bool: try: qmpcmd =3D self.__build_cmd(cmdline) except Exception as err: @@ -288,11 +300,12 @@ class QMPShell(qmp.QEMUMonitorProtocol): self._print(resp) return True =20 - def connect(self, negotiate: bool =3D True): + def connect(self, negotiate: bool =3D True) -> None: self._greeting =3D super().connect(negotiate) self.__completer_setup() =20 - def show_banner(self, msg=3D'Welcome to the QMP low-level shell!'): + def show_banner(self, + msg: str =3D '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(**versi= on)) =20 @property - def prompt(self): + def prompt(self) -> str: if self._transmode: return 'TRANS> ' return '(QEMU) ' =20 - def read_exec_command(self): + def read_exec_command(self) -> bool: """ Read and execute a command. =20 @@ -326,7 +339,7 @@ class QMPShell(qmp.QEMUMonitorProtocol): =20 return self._execute_cmd(cmdline) =20 - 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): =20 =20 class HMPShell(QMPShell): - def __init__(self, address, pretty=3DFalse, verbose=3DFalse): + def __init__(self, address: str, + pretty: bool =3D False, verbose: bool =3D False): super().__init__(address, pretty, verbose) self.__cpu_index =3D 0 =20 - 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] !=3D '[' and cmd[0] !=3D '\t': name =3D cmd.split()[0] # drop help text @@ -355,21 +369,22 @@ class HMPShell(QMPShell): self._completer.append(name) self._completer.append('help ' + name) # help completion =20 - 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]) =20 - def __other_completion(self): + def __other_completion(self) -> None: # special cases self._completer.append('help info') =20 - def _fill_completion(self): + def _fill_completion(self) -> None: self.__cmd_completion() self.__info_completion() self.__other_completion() =20 - def __cmd_passthrough(self, cmdline, cpu_index=3D0): + def __cmd_passthrough(self, cmdline: str, + cpu_index: int =3D 0) -> QMPMessage: return self.cmd_obj({ 'execute': 'human-monitor-command', 'arguments': { @@ -378,7 +393,7 @@ class HMPShell(QMPShell): } }) =20 - def _execute_cmd(self, cmdline): + def _execute_cmd(self, cmdline: str) -> bool: if cmdline.split()[0] =3D=3D "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 =20 - def show_banner(self, msg=3D'Welcome to the HMP shell!'): + def show_banner(self, msg: str =3D 'Welcome to the HMP shell!') -> Non= e: QMPShell.show_banner(self, msg) =20 =20 -def die(msg): +def die(msg: str) -> NoReturn: sys.stderr.write('ERROR: %s\n' % msg) sys.exit(1) =20 =20 -def main(): +def main() -> None: parser =3D argparse.ArgumentParser() parser.add_argument('-H', '--hmp', action=3D'store_true', help=3D'Use HMP interface') --=20 2.26.2 From nobody Fri May 17 07:07:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1604452206; cv=none; d=zohomail.com; s=zohoarc; b=Iu3YIu0nv88Y5x+HqebCcrBrv9RznULXVjR3HPBUCWFmsig+XM8tI9qnRzrqJQR9jlof93cBEHDar/StDwnrbkHZvMzdwdzuWdQLiMQ9KlD64fNAZ2vDLnx7E/YfntfONoVTee16IU2SNqSJ1MLz4uPio/stzLm0MbQk9N9NH3k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604452206; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=W2iHjqkIKG0cOWnHmRr1gY05wStFxbfX6F6YUEQDMNg=; b=OkEl1VIR+sP52EsYFgajTJKjqpr13dXLVeadVnbNEyR/XrvFRHjg4Ri9miS9HOmYuaWt274Aje7xNoZ37l47VlCvu51Np59Tkplz/Oa7t3iNJ3yfoJWpI+IsJ3EPgpz8zII5WmqiRKuIZKBLALibaVqdMtGbB1tvIUUk7nQ2GjY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16044522065277.82396052616491; Tue, 3 Nov 2020 17:10:06 -0800 (PST) Received: from localhost ([::1]:32830 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ka7JN-0004As-Ah for importer@patchew.org; Tue, 03 Nov 2020 20:10:05 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:35956) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ka6nt-0007Lv-In for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:37:34 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:46837) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1ka6np-0004xG-Fd for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:37:33 -0500 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-572-Co7zQxJaPVawPMw0uyVL-g-1; Tue, 03 Nov 2020 19:37:25 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2AAA18030B1 for ; Wed, 4 Nov 2020 00:37:24 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-97.rdu2.redhat.com [10.10.119.97]) by smtp.corp.redhat.com (Postfix) with ESMTP id C976F55766; Wed, 4 Nov 2020 00:37:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604450246; 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=W2iHjqkIKG0cOWnHmRr1gY05wStFxbfX6F6YUEQDMNg=; b=Iiemx1/n1ABYKFexztEC52s6chDUD9YwQxuTi22pZkkgIQh00Fjkn8P9p4LehYYVixk7o8 fw/JwjRjtk/JLxdHe28KZPNbzUVsSI8V0Khl9BOScMiPCQ44M3/0TRrPkiR7xByfFGCv8Y bfzN/rs+m5a1qM3gq9eWGCyvFq87p3E= X-MC-Unique: Co7zQxJaPVawPMw0uyVL-g-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v2 58/72] scripts/qmp-shell: Accept SocketAddrT instead of string Date: Tue, 3 Nov 2020 19:35:48 -0500 Message-Id: <20201104003602.1293560-59-jsnow@redhat.com> In-Reply-To: <20201104003602.1293560-1-jsnow@redhat.com> References: <20201104003602.1293560-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 01:02:05 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Cleber Rosa , John Snow , Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Don't extend QEMUMonitorProtocol but change the argument types; move the string parsing just outside of the class. 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 2d0e85b5f723..b465c7f9e2d6 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 =3D False, - verbose: bool =3D False): - super().__init__(self.parse_address(address)) + def __init__(self, address: qmp.SocketAddrT, + pretty: bool =3D False, verbose: bool =3D False): + super().__init__(address) self._greeting: Optional[QMPMessage] =3D None self._completer =3D QMPCompleter() self._pretty =3D pretty @@ -347,7 +347,7 @@ class QMPShell(qmp.QEMUMonitorProtocol): =20 =20 class HMPShell(QMPShell): - def __init__(self, address: str, + def __init__(self, address: qmp.SocketAddrT, pretty: bool =3D False, verbose: bool =3D False): super().__init__(address, pretty, verbose) self.__cpu_index =3D 0 @@ -450,11 +450,13 @@ def main() -> None: =20 shell_class =3D HMPShell if args.hmp else QMPShell try: - qemu =3D shell_class(args.qmp_server, args.pretty, args.verbose) + address =3D 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 =20 + qemu =3D shell_class(address, args.pretty, args.verbose) + try: qemu.connect(negotiate=3Dnot args.skip_negotiation) except qmp.QMPConnectError: --=20 2.26.2 From nobody Fri May 17 07:07:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1604451847; cv=none; d=zohomail.com; s=zohoarc; b=bJr1W/rTcEyPfSC/BZOtOAPZjUdjZ73UDwHqGb5dzounZkkVj2KYj4YP6TmW0SQsM3asEQDU3jhPoeT5QVWTpJhS2LxmOdnHtERy8VsPs8njq3+IooQ7m8q5ujaJpDK4Xi+gJTdGpEmTGWLSBEzlic3rmDIr5oCVaVN4FiJ7TKc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604451847; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=tyMp/WUkbkDPOvDMuuseh09FZ8+pmQhhXtOyGTRegsI=; b=Kf+jaO1kKgbg9BR6iCo3mS0ueDqjD8CTJQZHitm9vNpIMcfRagWowYEHPDSKKvOazbcCiHQYFA42Ll9f9I3F/fW2U8nSY8onXoyrXVPie6EWVpQcoYZnZq6wIFJ3pZ9I9hBZEHolTLZEuRmovBXIZN4hHQcqJAxQp4mMncY+nMM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604451847300737.8553795231935; Tue, 3 Nov 2020 17:04:07 -0800 (PST) Received: from localhost ([::1]:41954 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ka7DZ-0004fk-LF for importer@patchew.org; Tue, 03 Nov 2020 20:04:06 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:35942) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ka6nr-0007Km-EU for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:37:33 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:34414) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1ka6np-0004xS-Ew for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:37:31 -0500 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-L0qAOpe1OOiH19s5zOqXWQ-1; Tue, 03 Nov 2020 19:37:26 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8F28F1009E26 for ; Wed, 4 Nov 2020 00:37:25 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-97.rdu2.redhat.com [10.10.119.97]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7562F55766; Wed, 4 Nov 2020 00:37:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604450248; 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=tyMp/WUkbkDPOvDMuuseh09FZ8+pmQhhXtOyGTRegsI=; b=NLKsDd5jxChADc2Dp+BRRaEHHsP4XU3oVgTvRpic8HqwupdNpJR751P1uGz6pB5x45ev/Q VXYh1ApOYcwkyBgWGJYcQ1YxQ/0VY9zE9Rq45HQGLMQDEvTmF+44qouGM8ioTcFmRLX3F8 jqXLBokaMTHba8AWrzhj+4cRvCoiK1M= X-MC-Unique: L0qAOpe1OOiH19s5zOqXWQ-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v2 59/72] scripts/qmp-shell: unprivatize 'pretty' property Date: Tue, 3 Nov 2020 19:35:49 -0500 Message-Id: <20201104003602.1293560-60-jsnow@redhat.com> In-Reply-To: <20201104003602.1293560-1-jsnow@redhat.com> References: <20201104003602.1293560-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 00:03:41 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Cleber Rosa , John Snow , Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" 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 b465c7f9e2d6..f14fe211cca4 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] =3D None self._completer =3D QMPCompleter() - self._pretty =3D pretty self._transmode =3D False self._actions: List[QMPMessage] =3D [] self._histfile =3D os.path.join(os.path.expanduser('~'), '.qmp-shell_history') + self.pretty =3D pretty self.verbose =3D verbose =20 def _fill_completion(self) -> None: @@ -274,10 +274,9 @@ class QMPShell(qmp.QEMUMonitorProtocol): return qmpcmd =20 def _print(self, qmp_message: object) -> None: - indent =3D None - if self._pretty: - indent =3D 4 - jsobj =3D json.dumps(qmp_message, indent=3Dindent, sort_keys=3Dsel= f._pretty) + jsobj =3D json.dumps(qmp_message, + indent=3D4 if self.pretty else None, + sort_keys=3Dself.pretty) print(str(jsobj)) =20 def _execute_cmd(self, cmdline: str) -> bool: --=20 2.26.2 From nobody Fri May 17 07:07:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1604452326; cv=none; d=zohomail.com; s=zohoarc; b=UeafPaqQGSoDIZaL9MI7NbNfIM69jF1MgerGQcz8jovRiizHaVHV81+lHG3IJVMlmw5+BLRal19Y8rFGw9CVTRti4GGJgcBbgEl0atPNsoET6MihJvt7gUUsq7Ym1pQLqHlGLzgJFUNglR5dQ/MLnM/TKbCdyO6cmwy0dQj3KFI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604452326; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=BjOVoF9IAQEpgMWUVUzthZy3hghyNPSDDg5CUOiAI4c=; b=Bhpoc0gEeVg0OU7cYAXlQy+2XCvHVtaWBxQ5q6zieuxKOYZPbNAG/pSDMN0zpW3E4qo0hgr/ubUqP7wshET8hGyoJD+awC5jRmbQGP/CE1H8NBCenEuesVdAs5QplkCLir8CoX4RPgJbEszuqU389PBvW9ucfnTEhp4GNffthIk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 160445232612432.8347107603588; Tue, 3 Nov 2020 17:12:06 -0800 (PST) Received: from localhost ([::1]:39026 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ka7LJ-0006ng-0B for importer@patchew.org; Tue, 03 Nov 2020 20:12:05 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:35992) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ka6nw-0007OD-2s for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:37:36 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:59972) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1ka6nr-0004xa-3p for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:37:35 -0500 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-JKMZM7EgMEapCK6iTthzug-1; Tue, 03 Nov 2020 19:37:28 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 894958030DF for ; Wed, 4 Nov 2020 00:37:27 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-97.rdu2.redhat.com [10.10.119.97]) by smtp.corp.redhat.com (Postfix) with ESMTP id 435D355766; Wed, 4 Nov 2020 00:37:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604450250; 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=BjOVoF9IAQEpgMWUVUzthZy3hghyNPSDDg5CUOiAI4c=; b=KGBfX/Bqg6adGF0Xwmth6zbHEPl3J4IAkiUb5CbVFZwvFrpllepwda0yE/ABp6h3z0OG7h TsdZiHNSUbips5IHzw8gzmxrgdGJRaPXFYAmRhy4bxj1p1V1hkevQrlxyQKlZ+s+fSHPW8 TXPESC7ZM7zQZFaluZUX2w2JYXkFSl4= X-MC-Unique: JKMZM7EgMEapCK6iTthzug-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v2 60/72] python/qmp: return generic type from context manager Date: Tue, 3 Nov 2020 19:35:50 -0500 Message-Id: <20201104003602.1293560-61-jsnow@redhat.com> In-Reply-To: <20201104003602.1293560-1-jsnow@redhat.com> References: <20201104003602.1293560-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 00:03:41 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Cleber Rosa , John Snow , Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" __enter__ can be invoked from a subclass, so it needs a more specific 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 ba0d2281d678..376954cb6d27 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] =3D Fal= se) -> None: if ret is None: raise QMPConnectError("Error while reading from socket") =20 - def __enter__(self) -> 'QEMUMonitorProtocol': + T =3D TypeVar('T') + + def __enter__(self: T) -> T: # Implement context manager enter function. return self =20 --=20 2.26.2 From nobody Fri May 17 07:07:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1604452532; cv=none; d=zohomail.com; s=zohoarc; b=V1qPU5bvppaI4P83kVBG51C14KDc0DX+hLHsEFVSv0ZkPckKe+CpX0AHX+3cUJn5J6ouaWrOMBCFMCnhKUowbnwcOv0alHJH1ZktwcapzG81FgzapATkAKSpL1IMmUecqQXtI6XBXt77B2EpD97Wf0Q8c31ZPsOW8/a2xgPaVPU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604452532; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=B9FRDK9RDXP1gvYcLKnDz5U4uhB4JEcP2LMYKIEAfCM=; b=Id8AE+zdyeK7weGkGeRRB1LAnNhGk5GTwhXKYAilDO7eDitWUiyz8RstFkhrfVm2wf+IadmSC0qT2oLIv0drnEjUM+WKUzMZEyM2qrt/d9jnbUZ5FdDix9OmwQzR0Zh+45855gkB7xfAVewUcWGHAm1QV7uDErQ+lK+9eQokXrI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604452532024423.6655611291334; Tue, 3 Nov 2020 17:15:32 -0800 (PST) Received: from localhost ([::1]:49688 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ka7OX-0002jB-BD for importer@patchew.org; Tue, 03 Nov 2020 20:15:29 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:35996) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ka6nw-0007P3-DD for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:37:36 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:26386) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1ka6nt-0004xk-9m for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:37:35 -0500 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-358-noO3gqbbOrWcxtyHMvo6gg-1; Tue, 03 Nov 2020 19:37:29 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EA075108E1A8 for ; Wed, 4 Nov 2020 00:37:28 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-97.rdu2.redhat.com [10.10.119.97]) by smtp.corp.redhat.com (Postfix) with ESMTP id 00CD855766; Wed, 4 Nov 2020 00:37:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604450251; 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=B9FRDK9RDXP1gvYcLKnDz5U4uhB4JEcP2LMYKIEAfCM=; b=I7tuQP2qUJQaLHe58S5shN6iNyL48a4aNiQdQtrO8jAXyfRoVhAE9i2MSFv9qbiMqFBP37 dzj8KnJZKc+hKXQNSb7wx5ykv85xIfwdxQkvVKXafKeZkACtg6Bd4AIQxuRr70z2fyqj+o m27A+mEgELc4s9Np5NUmler+jmTArHw= X-MC-Unique: noO3gqbbOrWcxtyHMvo6gg-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v2 61/72] scripts/qmp-shell: Use context manager instead of atexit Date: Tue, 3 Nov 2020 19:35:51 -0500 Message-Id: <20201104003602.1293560-62-jsnow@redhat.com> In-Reply-To: <20201104003602.1293560-1-jsnow@redhat.com> References: <20201104003602.1293560-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 01:02:05 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Cleber Rosa , John Snow , Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" 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 f14fe211cca4..ec028d662e8e 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 =3D pretty self.verbose =3D verbose =20 + 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 =3D 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) =20 - 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") =20 shell_class =3D HMPShell if args.hmp else QMPShell + try: address =3D 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 =20 - qemu =3D shell_class(address, args.pretty, args.verbose) + with shell_class(address, args.pretty, args.verbose) as qemu: + try: + qemu.connect(negotiate=3Dnot 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}") =20 - try: - qemu.connect(negotiate=3Dnot 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 =20 =20 if __name__ =3D=3D '__main__': --=20 2.26.2 From nobody Fri May 17 07:07:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1604452348; cv=none; d=zohomail.com; s=zohoarc; b=hgxg6EtxEvQEH2Fcm/JlV4EX2FTcRM7xBMvXMfqbqdE/CdpPZPBqSkOJ2qLRT0Gc+wd2DP1S77lH93M3wz2qFvhADRE37eHdCDjUjNC1MVWHZR0IDLcxaWLj//ef0SIDJ0eZyFXTwwmcnDj67JyhXD2M2oL/mNQVRFtWaYfKuJ4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604452348; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=TIFuMouv3BevsTrVSomuc/EthhkE99OcgJhVE2XMzY8=; b=FhbE9VxszCqH+Vut9qSRvZVTEJ/X4L2gKy5d+HTPmouAqWccd+ddRJuhkID//dXpe6C8647P2O6LaFs00sOSsz6q4efszq5uScr7g3XFtiEkRmBfC4dXT2Kk/47FkbU09tNVeag7Vs+Tsfoo4EwxTkywpZDFOINrkcvkgijJImY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604452348938988.7299560389396; Tue, 3 Nov 2020 17:12:28 -0800 (PST) Received: from localhost ([::1]:41268 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ka7Ld-0007ir-Pf for importer@patchew.org; Tue, 03 Nov 2020 20:12:25 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:35986) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ka6nv-0007NR-Pc for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:37:35 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:26687) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1ka6nt-0004xp-9u for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:37:35 -0500 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-343-qEaK0t9-Peei9aKrMiv0tg-1; Tue, 03 Nov 2020 19:37:31 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 29E301009E26 for ; Wed, 4 Nov 2020 00:37:30 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-97.rdu2.redhat.com [10.10.119.97]) by smtp.corp.redhat.com (Postfix) with ESMTP id 36C7E55766; Wed, 4 Nov 2020 00:37:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604450252; 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=TIFuMouv3BevsTrVSomuc/EthhkE99OcgJhVE2XMzY8=; b=IvRImPQvAHmzTxlHhwT8QN0hfiomj2uDij75/m8vn4bpT4hTSVhJh2CUv71xyNkNMng+qb c8MSup/zoYTny8nYlHABAfCY9Yqg8XVFSbirmZFPpA8DIhhSGTF/AQDCgimSrqqwxSpxDG wGBEfGjFzTQuRF7SC+zSmSILuXE0jJY= X-MC-Unique: qEaK0t9-Peei9aKrMiv0tg-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v2 62/72] scripts/qmp-shell: use logging to show warnings Date: Tue, 3 Nov 2020 19:35:52 -0500 Message-Id: <20201104003602.1293560-63-jsnow@redhat.com> In-Reply-To: <20201104003602.1293560-1-jsnow@redhat.com> References: <20201104003602.1293560-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 00:03:41 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Cleber Rosa , John Snow , Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" 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 ec028d662e8e..0199a13a3428 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 =20 =20 +LOG =3D logging.getLogger(__name__) + + class QMPCompleter: # NB: Python 3.9+ will probably allow us to subclass list[str] directl= y, # 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 =3D f"Failed to read history '{self._histfile}': {err!s}" + LOG.warning(msg) =20 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 =3D f"Failed to save history file '{self._histfile}': {err= !s}" + LOG.warning(msg) =20 @classmethod def __parse_value(cls, val: str) -> object: --=20 2.26.2 From nobody Fri May 17 07:07:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1604452792; cv=none; d=zohomail.com; s=zohoarc; b=UqgIGrXDPAR3YV8gZs4t+e3spbUXFbTBtriaisCT/otaJRPNXDqy9JZYR5eZYhkCvLgtAKhKy8tFg8LGll0lEVm1EyStJqy+auG+ZGnx9YHOTfwCVRFg83LIM37rQzK0z7VD6VkFJJIau9SSoz/1smfYzk75qOy7DCVk5Wb6SfU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604452792; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=YhQxOEX3MpAK3NV9j1/EgLWzuYfEtOEcMpjIm7W0Vck=; b=ASveRnAg169cYYsdYWp6riF05gzR5mkE14zn8nV8gYuCxFTHb3nhp7oo8W6c5XjdLcZTVUUnf9fYxEZabpra8JMzx6nyXUIYxkg8hrfxVdwuCEZo//uE7u1xt2Y9IIknFicRUx8PnV5D8toc03VjTva0LJm+xEOsaHGwoSKgyNk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604452792072372.1574674366519; Tue, 3 Nov 2020 17:19:52 -0800 (PST) Received: from localhost ([::1]:58206 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ka7Sp-0006P1-0d for importer@patchew.org; Tue, 03 Nov 2020 20:19:51 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36004) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ka6nw-0007QX-PW for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:37:36 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:26746) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1ka6nv-0004xx-25 for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:37:36 -0500 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-421-xDIuIumZMGauO18wwFQG4A-1; Tue, 03 Nov 2020 19:37:32 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 598721009E27 for ; Wed, 4 Nov 2020 00:37:31 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-97.rdu2.redhat.com [10.10.119.97]) by smtp.corp.redhat.com (Postfix) with ESMTP id 585EF55766; Wed, 4 Nov 2020 00:37:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604450254; 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=YhQxOEX3MpAK3NV9j1/EgLWzuYfEtOEcMpjIm7W0Vck=; b=QBTV7zFsLF7YXPschc5AAnPLCy3VH8ArpzsWhOttNaNRqa84NYwuOYp5/PcBfsqy+oepiN O2r3X1D+LuMfuK4UWkLAVjzq1nQo1ZM0zZWCyhWXrz0+NHnPG0yoRO5zWGEZq3a/7R0VsT JBQBxennKqHusvKpGFKUORLM/yDdG/A= X-MC-Unique: xDIuIumZMGauO18wwFQG4A-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v2 63/72] scripts/qmp-shell: remove TODO Date: Tue, 3 Nov 2020 19:35:53 -0500 Message-Id: <20201104003602.1293560-64-jsnow@redhat.com> In-Reply-To: <20201104003602.1293560-1-jsnow@redhat.com> References: <20201104003602.1293560-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 00:03:41 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Cleber Rosa , John Snow , Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" 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 0199a13a3428..3c32b576a37d 100755 --- a/scripts/qmp/qmp-shell +++ b/scripts/qmp/qmp-shell @@ -130,8 +130,6 @@ class FuzzyJSON(ast.NodeTransformer): return node =20 =20 -# 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 =3D False, verbose: bool =3D False): --=20 2.26.2 From nobody Fri May 17 07:07:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1604452459; cv=none; d=zohomail.com; s=zohoarc; b=UUzO3JCfKNST5FS0Ypa/2RGAixqxq5TwAAST0JRv/NYUJks4IWMklfPXCnRgtLA55BZ6kbY9SuauTWdN3Pz3DhVk/M8pvWpuUnOHySr29A5UXvT/pBXTDyJEu0PT01WYPSPhp1eOGtybbvnVEVoZ62MoZxkBugTY1Pg0M3GGYpY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604452459; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=wzRB4cjrp4u7lt1vcXzG7IhYHDqdOiEuFhG6Dq+h9EY=; b=kx17LXpPXRs/YthjcDvuONYLLX/Kh1uXieIaVELQdBAAdOEyH3kciJjd4d02ShEzVJOIRIt7VCINoiUMZsfVRfu2/4ZZbav6CJYoWux5daLKi3FVLHMiKDWDV8E+WksMqc0Yxz1FI9wrfySXjSSAGgzg9rUGCLLY9/HftJAH774= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604452459415253.62866297562493; Tue, 3 Nov 2020 17:14:19 -0800 (PST) Received: from localhost ([::1]:47454 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ka7NS-0001oS-6M for importer@patchew.org; Tue, 03 Nov 2020 20:14:18 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36010) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ka6nx-0007SP-DG for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:37:37 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:56554) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1ka6nv-0004y2-Iu for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:37:37 -0500 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-443-MblLetRpM7a0Ve_uZxc5qA-1; Tue, 03 Nov 2020 19:37:33 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3ED7A6D243 for ; Wed, 4 Nov 2020 00:37:32 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-97.rdu2.redhat.com [10.10.119.97]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8255E747C6; Wed, 4 Nov 2020 00:37:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604450254; 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=wzRB4cjrp4u7lt1vcXzG7IhYHDqdOiEuFhG6Dq+h9EY=; b=RwdlGnD0f+k8MZ7ry2fWLiCflv2kMb7ma4vQX+8xbtHoqOI9mTXiICcMoyJqBL/bcbd+9p MVrGCzJNPaubTmB4Lhanwx4RQme4zE/iaZrtbiaeulkUI/bmwwIhV0mNNQjq1r9YKfQvJP ZJTkVXTjH8Sjo/bhyHbofiTXTfLTx0I= X-MC-Unique: MblLetRpM7a0Ve_uZxc5qA-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v2 64/72] scripts/qmp-shell: Fix empty-transaction invocation Date: Tue, 3 Nov 2020 19:35:54 -0500 Message-Id: <20201104003602.1293560-65-jsnow@redhat.com> In-Reply-To: <20201104003602.1293560-1-jsnow@redhat.com> References: <20201104003602.1293560-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 00:03:41 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Cleber Rosa , John Snow , Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" 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 3c32b576a37d..78e4eae00754 100755 --- a/scripts/qmp/qmp-shell +++ b/scripts/qmp/qmp-shell @@ -244,11 +244,14 @@ class QMPShell(qmp.QEMUMonitorProtocol): cmdargs =3D re.findall(argument_regex, cmdline) qmpcmd: QMPMessage =20 - # Transactional CLI entry/exit: - if cmdargs[0] =3D=3D 'transaction(': + # Transactional CLI entry: + if cmdargs and cmdargs[0] =3D=3D 'transaction(': self._transmode =3D True + self._actions =3D [] cmdargs.pop(0) - elif cmdargs[0] =3D=3D ')' and self._transmode: + + # Transactional CLI exit: + if cmdargs and cmdargs[0] =3D=3D ')' and self._transmode: self._transmode =3D False if len(cmdargs) > 1: msg =3D 'Unexpected input after close of Transaction sub-s= hell' @@ -257,15 +260,14 @@ class QMPShell(qmp.QEMUMonitorProtocol): 'execute': 'transaction', 'arguments': {'actions': self._actions} } - self._actions =3D list() return qmpcmd =20 - # Nothing to process? + # No args, or no args remaining if not cmdargs: return None =20 - # Parse and then cache this Transactional Action if self._transmode: + # Parse and cache this Transactional Action finalize =3D False action =3D {'type': cmdargs[0], 'data': {}} if cmdargs[-1] =3D=3D ')': --=20 2.26.2 From nobody Fri May 17 07:07:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1604452028; cv=none; d=zohomail.com; s=zohoarc; b=Ti3mE9+Vi0vgmOYNgTyDrLoOag5MzhYsLkg/i7sLyhxqedusvSbmkfXMrc8AG9EMgcCarS5HJI+MicJJExM0lLj2SXPlE3ZbHIGWGxLVZmjgOe/MAH7TsHHw8eV/l+dw9E/QMvKK6vp9y8aheHy6uM/IHjq2YzDpniOKI/HT4DY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604452028; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=MguaJi7qsX+yMjl4mE0Iu+XWpMdwiaBCv2zhtIeLKwI=; b=DvKfUL3NCsr6/9HRV/WTuZ7ZBdS+LR4aESJMM/n69ublhBrRln+zwVtsCKrLZtYLNzQ1pps7YhJ7eV0CgbSMrsxKnrpKtMYOLZn6FvBUgmM4DxJDlIGBMLlTgYnpQHIqLLSBx9y2V+PgUk3OhEUfAmmEWj/7ECixPOBwoJD55XM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604452028544866.5710024888124; Tue, 3 Nov 2020 17:07:08 -0800 (PST) Received: from localhost ([::1]:50432 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ka7GV-0008FJ-9I for importer@patchew.org; Tue, 03 Nov 2020 20:07:07 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36038) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ka6ny-0007VM-JH for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:37:38 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:56491) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1ka6nw-0004yL-Sn for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:37:38 -0500 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-72-8Jv4MU0iN-OwIV9VYZzd6g-1; Tue, 03 Nov 2020 19:37:34 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 45BAA6D240 for ; Wed, 4 Nov 2020 00:37:33 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-97.rdu2.redhat.com [10.10.119.97]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6A19855766; Wed, 4 Nov 2020 00:37:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604450255; 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=MguaJi7qsX+yMjl4mE0Iu+XWpMdwiaBCv2zhtIeLKwI=; b=abjMoJEsCUn7hrLW7CfJzKcJsiBcNEFpEoehDVsx+uL4iB6X9Go2GzQhjRiyPN/klke/0D vOoa2G8N/7AFvzCz+CiGAayxfF5CbQy8ilnY2Ww//PA37uKwU2kURpiaimDnNhQ8cA0yew ffDlWqCb20X66zYElKeRkw3RBOZEDgA= X-MC-Unique: 8Jv4MU0iN-OwIV9VYZzd6g-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v2 65/72] scripts/qmp-shell: Remove too-broad-exception Date: Tue, 3 Nov 2020 19:35:55 -0500 Message-Id: <20201104003602.1293560-66-jsnow@redhat.com> In-Reply-To: <20201104003602.1293560-1-jsnow@redhat.com> References: <20201104003602.1293560-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 01:02:05 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Cleber Rosa , John Snow , Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" 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 78e4eae00754..8d5845ab4815 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 =3D self.__build_cmd(cmdline) - except Exception as err: - print('Error while parsing command line: %s' % err) - print('command format: ', end=3D' ') - print('[arg-name1=3Darg1] ... [arg-nameN=3DargN]') + except QMPShellError as err: + print( + f"Error while parsing command line: {err!s}\n" + "command format: " + "[arg-name1=3Darg1] ... [arg-nameN=3DargN", + file=3Dsys.stderr + ) return True # For transaction mode, we may have just cached the action: if qmpcmd is None: --=20 2.26.2 From nobody Fri May 17 07:07:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1604452747; cv=none; d=zohomail.com; s=zohoarc; b=KmJBDka7y1+cGzxvh8buZRNrlIeLR8QxqYoKKvoJH8CLpDymohh/yQz8/rDu3ST4MT+/A1q6pQzaR4WmLMRGkygGjJOcwspdit3rBJ+ul5A+KiX0/z952sg3Ux7zdrZy09JpB/ySW0fgV3hcER3C6HSCwAOGBs9vAvvOSLd0Pyw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604452747; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=r5RN8S6BJ12v6o3a7OQWEM4M5IcdBBkgErIERMbrEj8=; b=OH7PtTnM6gojoz7DiKJXbg6+wfO33TjiA/kNolO8xAMs9JfShDr+38sm6kSxkfyVcl3PzIb3WIF7XLos3qYt3iOqVZssBRgRIBo3/Yj0mvzllYALLqymbtrtosjgoeC3mayKh1byOFASW7AEyNlSalcz1f3H9QfSVKLiFAa6vhk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604452747234204.83232556796486; Tue, 3 Nov 2020 17:19:07 -0800 (PST) Received: from localhost ([::1]:56118 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ka7Rz-0005XK-QK for importer@patchew.org; Tue, 03 Nov 2020 20:19:01 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36052) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ka6nz-0007Y6-I5 for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:37:39 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:35849) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1ka6nx-0004yX-JV for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:37:39 -0500 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-523-Yxo1hrUCMii8rjTm09aNfQ-1; Tue, 03 Nov 2020 19:37:35 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 463BC108E1A6 for ; Wed, 4 Nov 2020 00:37:34 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-97.rdu2.redhat.com [10.10.119.97]) by smtp.corp.redhat.com (Postfix) with ESMTP id 71ADE55766; Wed, 4 Nov 2020 00:37:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604450257; 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=r5RN8S6BJ12v6o3a7OQWEM4M5IcdBBkgErIERMbrEj8=; b=MUTT3F3Ce/7rLHG4QsLiP7by3qfIFlH4MGnCMakRDkAIjPT9twQ04ieWeo89GsS+NlRrxk 915QNDpXF6Cc3Ob8A95nKvm8rsA6LBD5OW58EopZwuCPWx9qoEjRMLgRr/pB1dx2w6WTYj Q/RWgmV3KviyPrKnqKgZNqidjk3VLCo= X-MC-Unique: Yxo1hrUCMii8rjTm09aNfQ-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v2 66/72] scripts/qmp-shell: convert usage comment to docstring Date: Tue, 3 Nov 2020 19:35:56 -0500 Message-Id: <20201104003602.1293560-67-jsnow@redhat.com> In-Reply-To: <20201104003602.1293560-1-jsnow@redhat.com> References: <20201104003602.1293560-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 00:03:41 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Cleber Rosa , John Snow , Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" 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 8d5845ab4815..82fe16cff820 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=3Darg1 ] ... [ arg-nameN=3DargN ] -# -# For example: -# -# (QEMU) device_add driver=3De1000 id=3Dnet1 -# {u'return': {}} -# (QEMU) -# -# key=3Dvalue pairs also support Python or JSON object literal subset nota= tions, -# without spaces. Dictionaries/objects {} are supported as are arrays []. -# -# example-command arg-name1=3D{'key':'value','obj'=3D{'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=3Darg1 ] ... [arg-nameN=3DargN ] -# ... -# action-nameN [ arg-name1=3Darg1 ] ... [arg-nameN=3DargN ] -# ) -# -# One line transactions are also supported: -# -# transaction( action-name1 ... ) -# -# For example: -# -# (QEMU) transaction( -# TRANS> block-dirty-bitmap-add node=3Ddrive0 name=3Dbitmap1 -# TRANS> block-dirty-bitmap-clear node=3Ddrive0 name=3Dbitmap0 -# TRANS> ) -# {"return": {}} -# (QEMU) -# -# Use the -v and -p options to activate the verbose and pretty-print optio= ns, -# which will echo back the properly formatted JSON-compliant QMP that is b= eing -# 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=3Darg1 ] ... [ arg-nameN=3DargN ] + +For example: + +(QEMU) device_add driver=3De1000 id=3Dnet1 +{'return': {}} +(QEMU) + +key=3Dvalue pairs also support Python or JSON object literal subset notati= ons, +without spaces. Dictionaries/objects {} are supported as are arrays []. + + example-command arg-name1=3D{'key':'value','obj'=3D{'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=3Darg1 ] ... [arg-nameN=3DargN ] + ... + action-nameN [ arg-name1=3Darg1 ] ... [arg-nameN=3DargN ] + ) + +One line transactions are also supported: + + transaction( action-name1 ... ) + +For example: + + (QEMU) transaction( + TRANS> block-dirty-bitmap-add node=3Ddrive0 name=3Dbitmap1 + TRANS> block-dirty-bitmap-clear node=3Ddrive0 name=3Dbitmap0 + 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 bei= ng +sent to QEMU, which is useful for debugging and documentation generation. +""" + import argparse import ast import json --=20 2.26.2 From nobody Fri May 17 07:07:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1604452163; cv=none; d=zohomail.com; s=zohoarc; b=TIrcUwMkmWZ21x6sIR9K5E1oTvAkDv7SLswKU6lycGyxTnvShXvBiuGL2SZbchgBCGINv1Q+yWyWQVHWX+GkAeimIPCMLBn/tZs13BRw1ue+oa/Spw5MVBa1B8xJobTWCQEmjvjRtwJZuz4mZjzlzHvAypfnK5m/t21Z9VZolVM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604452163; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=78jL6/OaCghfIdn9yhVtvUgPfPribGKLhjg9bPI806Y=; b=KO+24P/U1hgAgznoePdOo/bo9y5e0cSNC4rpRFA09E/jRo+SmRY2224VxVsVNbSqw69Dluoo1RW41bkguYq+BUlUCtxCNo08cqIPLwSGMPYWa+zFiCuMziwcHZPm0oq9SEvNfhkfyrltDNMLOuCNAtCN4VL2HNnF9YhVECNdCVw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 160445216393062.12061440942318; Tue, 3 Nov 2020 17:09:23 -0800 (PST) Received: from localhost ([::1]:58916 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ka7Ig-0003I0-UM for importer@patchew.org; Tue, 03 Nov 2020 20:09:22 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36064) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ka6o0-0007Zs-Bi for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:37:40 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:35438) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1ka6ny-0004yh-97 for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:37:39 -0500 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-589-FbBq82JjMISjrOc-V7aaEA-1; Tue, 03 Nov 2020 19:37:36 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 32E5C6D242 for ; Wed, 4 Nov 2020 00:37:35 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-97.rdu2.redhat.com [10.10.119.97]) by smtp.corp.redhat.com (Postfix) with ESMTP id 74E296266E; Wed, 4 Nov 2020 00:37:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604450257; 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=78jL6/OaCghfIdn9yhVtvUgPfPribGKLhjg9bPI806Y=; b=SgOGhdarFhb2LK3WrGu7V0JL1X+dabRwx/VVtG68tHATFcCrThYk56/BtFlkSDM4Mgsn+O QB0IaY1pjQa2Ld2nnQD93qK0TD4kmvJSwI9NETtRSTMqudMBkpnhLpdb5wdXJvY877N0Dt DXBxkpKbHakWBM98htvZXhIrCr4ugKw= X-MC-Unique: FbBq82JjMISjrOc-V7aaEA-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v2 67/72] scripts/qmp-shell: remove double-underscores Date: Tue, 3 Nov 2020 19:35:57 -0500 Message-Id: <20201104003602.1293560-68-jsnow@redhat.com> In-Reply-To: <20201104003602.1293560-1-jsnow@redhat.com> References: <20201104003602.1293560-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 00:03:41 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Cleber Rosa , John Snow , Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" 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 82fe16cff820..40ff9e0a82bd 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']) =20 - def __completer_setup(self) -> None: + def _completer_setup(self) -> None: self._completer =3D QMPCompleter() self._fill_completion() readline.set_history_length(1024) @@ -196,7 +196,7 @@ class QMPShell(qmp.QEMUMonitorProtocol): LOG.warning(msg) =20 @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 =20 - 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) =3D arg.partition('=3D') if sep !=3D '=3D': @@ -231,7 +231,7 @@ class QMPShell(qmp.QEMUMonitorProtocol): f"Expected a key=3Dvalue pair, got '{arg!s}'" ) =20 - value =3D self.__parse_value(val) + value =3D self._parse_value(val) optpath =3D key.split('.') curpath =3D [] for path in optpath[:-1]: @@ -249,7 +249,7 @@ class QMPShell(qmp.QEMUMonitorProtocol): raise QMPShellError(f'Cannot set "{key}" multiple times') parent[optpath[-1]] =3D value =20 - 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] =3D=3D ')': cmdargs.pop(-1) finalize =3D 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 =20 # Standard command: parse and return it to be executed. qmpcmd =3D {'execute': cmdargs[0], 'arguments': {}} - self.__cli_expr(cmdargs[1:], qmpcmd['arguments']) + self._cli_expr(cmdargs[1:], qmpcmd['arguments']) return qmpcmd =20 def _print(self, qmp_message: object) -> None: @@ -306,7 +306,7 @@ class QMPShell(qmp.QEMUMonitorProtocol): =20 def _execute_cmd(self, cmdline: str) -> bool: try: - qmpcmd =3D self.__build_cmd(cmdline) + qmpcmd =3D 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): =20 def connect(self, negotiate: bool =3D True) -> None: self._greeting =3D super().connect(negotiate) - self.__completer_setup() + self._completer_setup() =20 def show_banner(self, msg: str =3D 'Welcome to the QMP low-level shell!') ->= None: @@ -377,10 +377,10 @@ class HMPShell(QMPShell): def __init__(self, address: qmp.SocketAddrT, pretty: bool =3D False, verbose: bool =3D False): super().__init__(address, pretty, verbose) - self.__cpu_index =3D 0 + self._cpu_index =3D 0 =20 - 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] !=3D '[' and cmd[0] !=3D '\t': name =3D cmd.split()[0] # drop help text if name =3D=3D 'info': @@ -396,22 +396,22 @@ class HMPShell(QMPShell): self._completer.append(name) self._completer.append('help ' + name) # help completion =20 - 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]) =20 - def __other_completion(self) -> None: + def _other_completion(self) -> None: # special cases self._completer.append('help info') =20 def _fill_completion(self) -> None: - self.__cmd_completion() - self.__info_completion() - self.__other_completion() + self._cmd_completion() + self._info_completion() + self._other_completion() =20 - def __cmd_passthrough(self, cmdline: str, - cpu_index: int =3D 0) -> QMPMessage: + def _cmd_passthrough(self, cmdline: str, + cpu_index: int =3D 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 =3D int(cmdline.split()[1]) - if 'return' not in self.__cmd_passthrough('info version', = idx): + if 'return' not in self._cmd_passthrough('info version', i= dx): print('bad CPU index') return True - self.__cpu_index =3D idx + self._cpu_index =3D idx except ValueError: print('cpu command takes an integer argument') return True - resp =3D self.__cmd_passthrough(cmdline, self.__cpu_index) + resp =3D self._cmd_passthrough(cmdline, self._cpu_index) if resp is None: print('Disconnected') return False --=20 2.26.2 From nobody Fri May 17 07:07:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1604453386; cv=none; d=zohomail.com; s=zohoarc; b=aVkvznmxPMcUGmBp5mtW0mGX17l9jAzstxNpwWwi4woMg3E0yvv2oLUsRbAGcDkJz/Ue9jKeX6qrR/4TjTVVyn6mPX9hxd9IaCPHVOHXLEdTZUeVTayaFgNmqyTpOqzSNT3G9Ctsd00Hngnu7EG9hPk7wkJb+YcPnXhLPetC5XE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604453386; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=9yzPsQt0eiaVQ5VaBtLTKYEsbKBliZF87O4/Y2R/1PA=; b=aHbCAuZ8CrtabBSmDhiFWz0ftDBs+OgV/eW1gSuBe45l+waOR0OAFbtodhjcxQY/gNKbX5WhKd+XqgW4PGx1uFPnkTBT2mbAAZqIOyD1C7LLZWXzkYgQdJE1Fp6xpIIxRAXpmeJiHARiGK8w4kCUZvbR8tggOJGadUMJ86Uie5U= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604453386749702.6401562693976; Tue, 3 Nov 2020 17:29:46 -0800 (PST) Received: from localhost ([::1]:52894 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ka7cP-0007fA-8Z for importer@patchew.org; Tue, 03 Nov 2020 20:29:45 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36068) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ka6o1-0007bl-7p for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:37:41 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:32716) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1ka6nz-0004ys-Fy for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:37:40 -0500 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-17-cmbCj18YOyCcZTjdd_yMSw-1; Tue, 03 Nov 2020 19:37:37 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4DA8D835B8D for ; Wed, 4 Nov 2020 00:37:36 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-97.rdu2.redhat.com [10.10.119.97]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5E96F55766; Wed, 4 Nov 2020 00:37:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604450258; 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=9yzPsQt0eiaVQ5VaBtLTKYEsbKBliZF87O4/Y2R/1PA=; b=WotMD6TmOfhsonf/DcCVyKaJzne/Wh1N5dbp92g8ib4esHLNGq/2q0+ddqwvoMAbYlNMO8 liqdQQl3QHESMAyE9vk8xYp85o9/c3bdV0oQELIIc4mRciSEyALFPTGew9nUEtx+zb6bsL GsPgn5fkKMTGTpl3D9U9yMH1jzy4FBI= X-MC-Unique: cmbCj18YOyCcZTjdd_yMSw-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v2 68/72] scripts/qmp-shell: make QMPShellError inherit QMPError Date: Tue, 3 Nov 2020 19:35:58 -0500 Message-Id: <20201104003602.1293560-69-jsnow@redhat.com> In-Reply-To: <20201104003602.1293560-1-jsnow@redhat.com> References: <20201104003602.1293560-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 00:03:41 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Cleber Rosa , John Snow , Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" This way, all exceptions from the qemu.qmp namespace 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 40ff9e0a82bd..1a8a4ba18ab4 100755 --- a/scripts/qmp/qmp-shell +++ b/scripts/qmp/qmp-shell @@ -123,7 +123,7 @@ class QMPCompleter: return None =20 =20 -class QMPShellError(Exception): +class QMPShellError(qmp.QMPError): pass =20 =20 --=20 2.26.2 From nobody Fri May 17 07:07:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1604453469; cv=none; d=zohomail.com; s=zohoarc; b=MkpqZWz6PQKLz6eRBBYqdKLSK9SBtlfF3l8DhsML6ZkCHNrgjLf/QtTFvNAVkADEIP006RHtfFMZpZrdLGye5FKrGKyeaFGUOA4mff3hYtdOgkxYW/LT1OGaLcwb9UcNBTkx6JwhVjSg0VxypSditO+KDR44D3+axWfT+dAE9rk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604453469; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=6Q7qh9uMxQEd1ERc+PLZ2ut7YmMhXW1F3j7R0pQeAnU=; b=cePMv/2AU0rBm5tr5nW5vUQzORdKDS3w6ndAQOcy787xke+c7lvr8dG4RrEzvZ2yFBLLoUbbX1Iq3x+pajIu8pya8Iycm+bKoWxTNk72K4rzB02jyvXZwSa/BXnZf+Uh2PQc4zLOYAYbfkwXHo3rhWSzOPJfWnFyqogZItur+Ck= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604453469286216.41108652597143; Tue, 3 Nov 2020 17:31:09 -0800 (PST) Received: from localhost ([::1]:56876 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ka7dk-0000ul-1K for importer@patchew.org; Tue, 03 Nov 2020 20:31:08 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36098) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ka6o5-0007ef-LM for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:37:45 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:36167) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1ka6o0-0004z6-Kd for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:37:43 -0500 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-446-0rnVFqecMruZCXMFDwzIrA-1; Tue, 03 Nov 2020 19:37:38 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1468F835B8C for ; Wed, 4 Nov 2020 00:37:37 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-97.rdu2.redhat.com [10.10.119.97]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4B35575127; Wed, 4 Nov 2020 00:37:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604450259; 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=6Q7qh9uMxQEd1ERc+PLZ2ut7YmMhXW1F3j7R0pQeAnU=; b=EAjmUQNbN4iZ+D347YGge2iZPvu0jS3bgKaJ5cegY4+8XyXmKQeOG06a0qUAPiHSvASJjh +0xOZGBwZWCApxpYgCm0GD1+XMGerIzr33nSKipToJGdY3AMHxUU6FehVDKzZjHeiP2RyJ IZ2+USjcpWUmTMFIK+xNFYe1dpx6EVc= X-MC-Unique: 0rnVFqecMruZCXMFDwzIrA-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v2 69/72] scripts/qmp-shell: add docstrings Date: Tue, 3 Nov 2020 19:35:59 -0500 Message-Id: <20201104003602.1293560-70-jsnow@redhat.com> In-Reply-To: <20201104003602.1293560-1-jsnow@redhat.com> References: <20201104003602.1293560-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 01:02:05 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Cleber Rosa , John Snow , Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" 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 1a8a4ba18ab4..15aedb80c2af 100755 --- a/scripts/qmp/qmp-shell +++ b/scripts/qmp/qmp-shell @@ -106,15 +106,20 @@ LOG =3D logging.getLogger(__name__) =20 =20 class QMPCompleter: + """ + QMPCompleter provides a readline library tab-complete behavior. + """ # NB: Python 3.9+ will probably allow us to subclass list[str] directl= y, # but pylint as of today does not know that List[str] is simply 'list'. def __init__(self) -> None: self._matches: List[str] =3D [] =20 def append(self, value: str) -> None: + """Append a new valid completion to the list of possibilities.""" return self._matches.append(value) =20 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 =3D=3D 0: @@ -124,7 +129,9 @@ class QMPCompleter: =20 =20 class QMPShellError(qmp.QMPError): - pass + """ + QMP Shell Base error class. + """ =20 =20 class FuzzyJSON(ast.NodeTransformer): @@ -137,6 +144,9 @@ class FuzzyJSON(ast.NodeTransformer): @classmethod def visit_Name(cls, # pylint: disable=3Dinvalid-name node: ast.Name) -> ast.AST: + """ + Transform Name nodes with certain values into Constant (keyword) n= odes. + """ if node.id =3D=3D 'true': return ast.Constant(value=3DTrue) if node.id =3D=3D 'false': @@ -147,6 +157,13 @@ class FuzzyJSON(ast.NodeTransformer): =20 =20 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 =3D False, verbose: bool =3D False): super().__init__(address) @@ -333,6 +350,9 @@ class QMPShell(qmp.QEMUMonitorProtocol): =20 def show_banner(self, msg: str =3D '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): =20 @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) =20 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): =20 =20 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 =3D False, verbose: bool =3D False): super().__init__(address, pretty, verbose) @@ -451,11 +484,15 @@ class HMPShell(QMPShell): =20 =20 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) =20 =20 def main() -> None: + """ + qmp-shell entry point: parse command line arguments and start the REPL. + """ parser =3D argparse.ArgumentParser() parser.add_argument('-H', '--hmp', action=3D'store_true', help=3D'Use HMP interface') --=20 2.26.2 From nobody Fri May 17 07:07:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1604453557; cv=none; d=zohomail.com; s=zohoarc; b=jbiPnPsJppS0GynrC9Jo9jXQN29GXUdpoEd+jwO9Ws2qCcZkf0dMWWUD+CzIPB48X4xLCTla1CNzwbSbl2YcwByBz03hho/1uqsIClbn114VsN5O4BdIhLH//TUdG5Hq/Bl6Y0vfZW2GyG2+3yVojsa7WquEglTFHjPMRIf2Vd4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604453557; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=4YnOAzercV1xIfq73DlkplazlGkduPLwRDwqOGs3CQA=; b=lwuj+BiBoni0K4Je/uvsVLu5x3AZQWqZTX4lrDvBTn7/xfdAun90Ln+bl5ZeR3+h9eOwnrP0o4odPOkb86bt61dmimGJX0FpR2Nznd7UPUd35Aps6KBMFs5BHKGPGTYRWv+QvRyPJLniFa/wB+mVKV5K1hJEf8X629sL2wNp6QA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604453557390684.8579231634085; Tue, 3 Nov 2020 17:32:37 -0800 (PST) Received: from localhost ([::1]:59048 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ka7fA-0001sr-6d for importer@patchew.org; Tue, 03 Nov 2020 20:32:36 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36102) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ka6o6-0007f5-06 for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:37:46 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:27032) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1ka6o1-0004zG-IR for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:37:45 -0500 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-570-uogC_avfMlafE_IE0Wneyw-1; Tue, 03 Nov 2020 19:37:39 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1552E1891E84 for ; Wed, 4 Nov 2020 00:37:38 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-97.rdu2.redhat.com [10.10.119.97]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4026355766; Wed, 4 Nov 2020 00:37:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604450260; 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=4YnOAzercV1xIfq73DlkplazlGkduPLwRDwqOGs3CQA=; b=c4M9Ui14eAXuaAj7K/4Ku2VvHOlg/A+B12W01QfbsAe0y7q3xFhl73IpTevm+Gm663USHR vJhszoHkK1J6/aewKuXvuBOhqMmC5aKV//7O9Id03ySZp2RSvJFkLagv04SQlXmtLwvLGn qkTFI0eaik148jWAajYrqwLqK/Re4tU= X-MC-Unique: uogC_avfMlafE_IE0Wneyw-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v2 70/72] scripts/qmp-shell: move to python/qemu/qmp/qmp_shell.py Date: Tue, 3 Nov 2020 19:36:00 -0500 Message-Id: <20201104003602.1293560-71-jsnow@redhat.com> In-Reply-To: <20201104003602.1293560-1-jsnow@redhat.com> References: <20201104003602.1293560-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 01:02:05 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Cleber Rosa , John Snow , Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" 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. Signed-off-by: John Snow --- scripts/qmp/qmp-shell =3D> python/qemu/qmp/qmp_shell.py | 3 --- 1 file changed, 3 deletions(-) rename scripts/qmp/qmp-shell =3D> python/qemu/qmp/qmp_shell.py (99%) mode change 100755 =3D> 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 15aedb80c2af..337acfce2d26 --- 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, ) =20 - -sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'pytho= n')) from qemu import qmp from qemu.qmp import QMPMessage =20 --=20 2.26.2 From nobody Fri May 17 07:07:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1604452328; cv=none; d=zohomail.com; s=zohoarc; b=E+tBf+rbOhpCFScmdsqZZf+k1IWAZ6eWIMduzEx+9GWIffS9ev0U8qBENXQtyYBOXICQo6hIMf0xq15F3+Rr9HmIJsIW5XpPS0nyvtaEJ4Waby9Zym+AGgsnAhVjPnvSxlZ1+mhJLqQ99AMHKAW1NJhR2CdC6kFp+xwQZrJTCDk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604452328; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=H30on+FLWG6ibSTrgV/1k06Ld3pxmvIt0XZbcJ6B/NI=; b=FG8Wn/o26EKnAFAvvo+PxLV43SrXdb9JiZhTAIgPZtZ2ASvziJHIycyItUXLN8D9QJJOI2tiM29m/hSfjWP9XEjFjhuqKnDG63KjPzJEi5KH60sUKKfGo1pKeJ5c75CD3CtWY1UJDN79++DFRmqk14GsWPxBNWEcV8zPGCdu9lI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604452328017874.8725080984599; Tue, 3 Nov 2020 17:12:08 -0800 (PST) Received: from localhost ([::1]:39206 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ka7LK-0006sF-S2 for importer@patchew.org; Tue, 03 Nov 2020 20:12:06 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36114) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ka6o8-0007gH-0v for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:37:48 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:37479) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1ka6o3-0004zN-54 for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:37:47 -0500 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-584-GTdfkn5RNLu9_4LVp43E5Q-1; Tue, 03 Nov 2020 19:37:39 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EE9DD108E1A5 for ; Wed, 4 Nov 2020 00:37:38 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-97.rdu2.redhat.com [10.10.119.97]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4199355766; Wed, 4 Nov 2020 00:37:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604450261; 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=H30on+FLWG6ibSTrgV/1k06Ld3pxmvIt0XZbcJ6B/NI=; b=HasBv9Db1o5MbjsOu6l2z6ynuGJJ9D4CMKItt5II39wB2a6f3hRoxlAI/uOIMS5ghLN2qn wyhalxcxgrXZSK4SomtRREbm1FYOgXu4fz6OqHbqGa1BxLo6zPuGb3gb7XEEkT3DYbdR6c Z2t+glKAIKpoAiElksa3EiwO86tsfXs= X-MC-Unique: GTdfkn5RNLu9_4LVp43E5Q-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v2 71/72] python: add qmp-shell entry point Date: Tue, 3 Nov 2020 19:36:01 -0500 Message-Id: <20201104003602.1293560-72-jsnow@redhat.com> In-Reply-To: <20201104003602.1293560-1-jsnow@redhat.com> References: <20201104003602.1293560-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 01:02:05 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Cleber Rosa , John Snow , Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" 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 f2f54bcaefe8..230fd870ea91 100644 --- a/python/setup.cfg +++ b/python/setup.cfg @@ -42,6 +42,7 @@ console_scripts =3D qom-tree =3D qemu.qmp.qom:QOMTree.entry_point qom-fuse =3D qemu.qmp.qom_fuse:QOMFuse.entry_point qemu-ga-client =3D qemu.qmp.qemu_ga_client:main + qmp-shell =3D qemu.qmp.qmp_shell:main =20 [flake8] extend-ignore =3D E722 # Prefer pylint's bare-except checks to flake8's --=20 2.26.2 From nobody Fri May 17 07:07:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1604452461; cv=none; d=zohomail.com; s=zohoarc; b=lETpP2P21BAQEBRVqilA3u39RNlAZlVhTicvMUYenddXobmTvpJ40CLasqyCtbuDlQFkDE9EwNxDckVleetyCjxRljKxMkA7n1LAw9s20Dh3aN635opIe2HwTPvBWDbOSvKXbpt0p7KeJ5HwZyHg7YVTYYNTxfvg2j14tlhFk/I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604452461; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=UlAPtAaJSVZh+LhqAYKaB/Hw5RIE2CVk1F6sGrFXOwE=; b=QUUwC1R9sO5AjnwQDwmG2QZbo0qBq+H8JDma8Z3pPPLQHFYC0ErhncUltcmetUtaE5HOkH488fEjLAnjHYtxT3a2V3nCQR4Xl9FVIF4ENKVPxUHXljrxfd6GNh5C8Vk2msVSFIkLQNzFBBnNH5AWw9rd6l/27Ky2hZphD1snPsA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604452461508939.6463765626319; Tue, 3 Nov 2020 17:14:21 -0800 (PST) Received: from localhost ([::1]:47674 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ka7NU-0001u6-8O for importer@patchew.org; Tue, 03 Nov 2020 20:14:20 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36118) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ka6o9-0007h2-UJ for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:37:49 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:50230) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1ka6o5-0004zV-Dn for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:37:49 -0500 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-133-ugdUgRzNO06ksrwYLxX9CA-1; Tue, 03 Nov 2020 19:37:40 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D765F6D243 for ; Wed, 4 Nov 2020 00:37:39 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-97.rdu2.redhat.com [10.10.119.97]) by smtp.corp.redhat.com (Postfix) with ESMTP id 27246747C6; Wed, 4 Nov 2020 00:37:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604450262; 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=UlAPtAaJSVZh+LhqAYKaB/Hw5RIE2CVk1F6sGrFXOwE=; b=gA0C4duLwIXK0S/OvxBWUcyNw9NOaHJ1JmdV4X+4EKRCJGKzHJw9KSdjsTqMWRQnaRSfxy UNZ1wZjSpk4yFSs5OPNIQAIA1UJ6iekiEDX3vd+L4fYxzcS9rxcHOPjuYACgFTOuQp5rgy ZPGWmvMI3xmHhBWEGm/uJ0ePhZFCx0Y= X-MC-Unique: ugdUgRzNO06ksrwYLxX9CA-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v2 72/72] scripts/qmp-shell: add redirection shim Date: Tue, 3 Nov 2020 19:36:02 -0500 Message-Id: <20201104003602.1293560-73-jsnow@redhat.com> In-Reply-To: <20201104003602.1293560-1-jsnow@redhat.com> References: <20201104003602.1293560-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 00:03:41 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Cleber Rosa , John Snow , Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" 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 000000000000..4a20f97db708 --- /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__), '..', '..', 'pytho= n')) +from qemu.qmp import qmp_shell + + +if __name__ =3D=3D '__main__': + qmp_shell.main() --=20 2.26.2