From nobody Mon Feb 9 01:03:31 2026 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1648661399418131.08094070043285; Wed, 30 Mar 2022 10:29:59 -0700 (PDT) Received: from localhost ([::1]:57308 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nZc8s-0008WK-8L for importer@patchew.org; Wed, 30 Mar 2022 13:29:58 -0400 Received: from eggs.gnu.org ([209.51.188.92]:34744) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nZc7P-0005oP-W8 for qemu-devel@nongnu.org; Wed, 30 Mar 2022 13:28:28 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:55944) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nZc7O-0003LN-JI for qemu-devel@nongnu.org; Wed, 30 Mar 2022 13:28:27 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-584-l0Gfq4PeOn-E2fsMayjC9A-1; Wed, 30 Mar 2022 13:28:22 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1EBA03C14CE2; Wed, 30 Mar 2022 17:28:17 +0000 (UTC) Received: from scv.redhat.com (unknown [10.22.35.177]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6FEDB40CFD0D; Wed, 30 Mar 2022 17:28:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1648661306; 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=GAMl+6/LeK+TiN1y4IaDH+o1SkOvjXC8Is0Sq5BINJc=; b=KZQ6xXwpjjbvKs0sKGtOn6xjnT1Iuv+tKtkwZRs31UTa/dnPtbSVeQ7Td43HiNdhdYuLeT PUx/S9FLAt+xDj3JIFVHvqzZTP57nEU4S2vAL4cN/ixctrgZ7yBr99zwDkhSUq28k4325P aJmahRdiKw8YgBVsERZLD1M59I+3cyk= X-MC-Unique: l0Gfq4PeOn-E2fsMayjC9A-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v2 1/9] python: temporarily silence pylint duplicate-code warnings Date: Wed, 30 Mar 2022 13:28:04 -0400 Message-Id: <20220330172812.3427355-2-jsnow@redhat.com> In-Reply-To: <20220330172812.3427355-1-jsnow@redhat.com> References: <20220330172812.3427355-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 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=170.10.133.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Vladimir Sementsov-Ogievskiy , Beraldo Leal , qemu-block@nongnu.org, Markus Armbruster , Hanna Reitz , Vladimir Sementsov-Ogievskiy , Cleber Rosa , John Snow Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1648661401934100001 Content-Type: text/plain; charset="utf-8"; x-default="true" The next several commits copy some code from qemu.qmp to qemu.aqmp, then delete qemu.qmp. In the interim, to prevent test failures, the duplicate code detection needs to be silenced to prevent bisect problems with CI testing. Signed-off-by: John Snow Reviewed-by: Vladimir Sementsov-Ogievskiy --- python/setup.cfg | 1 + 1 file changed, 1 insertion(+) diff --git a/python/setup.cfg b/python/setup.cfg index 241f243e8b9..cdeced44d2b 100644 --- a/python/setup.cfg +++ b/python/setup.cfg @@ -119,6 +119,7 @@ disable=3Dconsider-using-f-string, too-many-function-args, # mypy handles this with less false posit= ives. too-many-instance-attributes, no-member, # mypy also handles this better. + duplicate-code, # To be removed by the end of this patch series. =20 [pylint.basic] # Good variable names which should always be accepted, separated by a comm= a. --=20 2.34.1 From nobody Mon Feb 9 01:03:31 2026 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1648661551628330.6775462784635; Wed, 30 Mar 2022 10:32:31 -0700 (PDT) Received: from localhost ([::1]:35662 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nZcBK-0005Sm-Kr for importer@patchew.org; Wed, 30 Mar 2022 13:32:30 -0400 Received: from eggs.gnu.org ([209.51.188.92]:34778) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nZc7T-0005wM-B5 for qemu-devel@nongnu.org; Wed, 30 Mar 2022 13:28:31 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:33029) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nZc7R-0003Le-FZ for qemu-devel@nongnu.org; Wed, 30 Mar 2022 13:28:31 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-379-aDiyQ2NuNo6S1ErgIZGZiQ-1; Wed, 30 Mar 2022 13:28:27 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 52DE2899EE7; Wed, 30 Mar 2022 17:28:21 +0000 (UTC) Received: from scv.redhat.com (unknown [10.22.35.177]) by smtp.corp.redhat.com (Postfix) with ESMTP id 726BD40CFD22; Wed, 30 Mar 2022 17:28:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1648661308; 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/lbW38Dac4FP2QCfnPFGoUNhpMgEiZ/GraSrqfBdQQ=; b=NP1b9848mEbdGBnpiURFoZi9pYoYcCVPgCveSddJ8xPhK3b7pXj83xAS8YxoyeX+/B5TUy bIpJJCwVQP1N37TUqrIQ0kI4+GJQQ+ywk2Fq9rxs/wnv+52y9kopdgWLW6VxJP5AHFsvov FB0T78WBvp2tnEEYo76IM6c0IbTLqTk= X-MC-Unique: aDiyQ2NuNo6S1ErgIZGZiQ-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v2 2/9] python/aqmp: take QMPBadPortError and parse_address from qemu.qmp Date: Wed, 30 Mar 2022 13:28:05 -0400 Message-Id: <20220330172812.3427355-3-jsnow@redhat.com> In-Reply-To: <20220330172812.3427355-1-jsnow@redhat.com> References: <20220330172812.3427355-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 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=170.10.129.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Vladimir Sementsov-Ogievskiy , Beraldo Leal , qemu-block@nongnu.org, Markus Armbruster , Hanna Reitz , Vladimir Sementsov-Ogievskiy , Cleber Rosa , John Snow Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1648661553148100003 Content-Type: text/plain; charset="utf-8"; x-default="true" Shift these definitions over from the qmp package to the async qmp package. (Licensing: this is a lateral move, from GPLv2 (only) to GPLv2 (only)) Signed-off-by: John Snow Reviewed-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Beraldo Leal --- python/qemu/aqmp/aqmp_tui.py | 3 +-- python/qemu/aqmp/legacy.py | 30 ++++++++++++++++++++++++++---- python/qemu/qmp/__init__.py | 26 -------------------------- 3 files changed, 27 insertions(+), 32 deletions(-) diff --git a/python/qemu/aqmp/aqmp_tui.py b/python/qemu/aqmp/aqmp_tui.py index 946ba9af24e..59d3036be38 100644 --- a/python/qemu/aqmp/aqmp_tui.py +++ b/python/qemu/aqmp/aqmp_tui.py @@ -35,9 +35,8 @@ import urwid import urwid_readline =20 -from qemu.qmp import QEMUMonitorProtocol, QMPBadPortError - from .error import ProtocolError +from .legacy import QEMUMonitorProtocol, QMPBadPortError from .message import DeserializationError, Message, UnexpectedTypeError from .protocol import ConnectError, Runstate from .qmp_client import ExecInterruptedError, QMPClient diff --git a/python/qemu/aqmp/legacy.py b/python/qemu/aqmp/legacy.py index f86cb298049..f0262749491 100644 --- a/python/qemu/aqmp/legacy.py +++ b/python/qemu/aqmp/legacy.py @@ -33,9 +33,6 @@ from .qmp_client import QMPClient =20 =20 -# (Temporarily) Re-export QMPBadPortError -QMPBadPortError =3D qemu.qmp.QMPBadPortError - #: QMPMessage is an entire QMP message of any kind. QMPMessage =3D Dict[str, Any] =20 @@ -56,6 +53,12 @@ # pylint: disable=3Dmissing-docstring =20 =20 +class QMPBadPortError(QMPError): + """ + Unable to parse socket address: Port was non-numerical. + """ + + class QEMUMonitorProtocol(qemu.qmp.QEMUMonitorProtocol): def __init__(self, address: SocketAddrT, server: bool =3D False, @@ -86,7 +89,26 @@ def _get_greeting(self) -> Optional[QMPMessage]: return None =20 # __enter__ and __exit__ need no changes - # parse_address needs no changes + + @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 =20 def connect(self, negotiate: bool =3D True) -> Optional[QMPMessage]: self._aqmp.await_greeting =3D negotiate diff --git a/python/qemu/qmp/__init__.py b/python/qemu/qmp/__init__.py index 358c0971d06..4e086411544 100644 --- a/python/qemu/qmp/__init__.py +++ b/python/qemu/qmp/__init__.py @@ -102,12 +102,6 @@ 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 @@ -237,26 +231,6 @@ 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. --=20 2.34.1 From nobody Mon Feb 9 01:03:31 2026 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1648661895490134.97153390124583; Wed, 30 Mar 2022 10:38:15 -0700 (PDT) Received: from localhost ([::1]:46742 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nZcGr-0004Zc-2F for importer@patchew.org; Wed, 30 Mar 2022 13:38:14 -0400 Received: from eggs.gnu.org ([209.51.188.92]:34990) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nZc7Z-0006IA-6H for qemu-devel@nongnu.org; Wed, 30 Mar 2022 13:28:37 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:36111) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nZc7V-0003NR-Pd for qemu-devel@nongnu.org; Wed, 30 Mar 2022 13:28:36 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-622-f8_3ZaN3PBSiJD2iavgYww-1; Wed, 30 Mar 2022 13:28:28 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4DFF1185A794; Wed, 30 Mar 2022 17:28:22 +0000 (UTC) Received: from scv.redhat.com (unknown [10.22.35.177]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3955540D016E; Wed, 30 Mar 2022 17:28:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1648661313; 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=hHGmrv4Y9uCgO0ysuxE2y2ShX2y4tSVHHD8tR4hVhb0=; b=RPJs5nwt9yTfRTGbZILpG2pJvMC04UuYcdAZ/L/m9oDSuTaetZ0/XU+qthV2Z/uNHDJCpz F8vxaJsUUilQ9rE/KDx+5pnJGWtJR6J9VoRAi77HVFKW0ie+VdPf1fo6ottMtVh3y/M9ZX e3NDAkhMGvXFFKdOxVgQJQP3jV/ldk8= X-MC-Unique: f8_3ZaN3PBSiJD2iavgYww-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v2 3/9] python/aqmp: fully separate from qmp.QEMUMonitorProtocol Date: Wed, 30 Mar 2022 13:28:06 -0400 Message-Id: <20220330172812.3427355-4-jsnow@redhat.com> In-Reply-To: <20220330172812.3427355-1-jsnow@redhat.com> References: <20220330172812.3427355-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 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=170.10.133.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Vladimir Sementsov-Ogievskiy , Beraldo Leal , qemu-block@nongnu.org, Markus Armbruster , Hanna Reitz , Vladimir Sementsov-Ogievskiy , Cleber Rosa , John Snow Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1648661895786100001 Content-Type: text/plain; charset="utf-8"; x-default="true" After this patch, qemu.aqmp.legacy.QEMUMonitorProtocol no longer inherits from qemu.qmp.QEMUMonitorProtocol. To do this, several inherited methods need to be explicitly re-defined. (Licensing: This is copying and modifying GPLv2-only code into a GPLv2-only file.) Signed-off-by: John Snow Reviewed-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Beraldo Leal --- python/qemu/aqmp/legacy.py | 37 +++++++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/python/qemu/aqmp/legacy.py b/python/qemu/aqmp/legacy.py index f0262749491..10c7c99c4f0 100644 --- a/python/qemu/aqmp/legacy.py +++ b/python/qemu/aqmp/legacy.py @@ -16,18 +16,18 @@ # =20 import asyncio +from types import TracebackType from typing import ( Any, Awaitable, Dict, List, Optional, + Type, TypeVar, Union, ) =20 -import qemu.qmp - from .error import QMPError from .protocol import Runstate, SocketAddrT from .qmp_client import QMPClient @@ -59,12 +59,11 @@ class QMPBadPortError(QMPError): """ =20 =20 -class QEMUMonitorProtocol(qemu.qmp.QEMUMonitorProtocol): +class QEMUMonitorProtocol: def __init__(self, address: SocketAddrT, server: bool =3D False, nickname: Optional[str] =3D None): =20 - # pylint: disable=3Dsuper-init-not-called self._aqmp =3D QMPClient(nickname) self._aloop =3D asyncio.get_event_loop() self._address =3D address @@ -88,7 +87,18 @@ def _get_greeting(self) -> Optional[QMPMessage]: return self._aqmp.greeting._asdict() return None =20 - # __enter__ and __exit__ need no changes + def __enter__(self: _T) -> _T: + # Implement context manager enter function. + return self + + def __exit__(self, + # pylint: disable=3Dduplicate-code + # see https://github.com/PyCQA/pylint/issues/3619 + exc_type: Optional[Type[BaseException]], + exc_val: Optional[BaseException], + exc_tb: Optional[TracebackType]) -> None: + # Implement context manager exit function. + self.close() =20 @classmethod def parse_address(cls, address: str) -> SocketAddrT: @@ -142,7 +152,22 @@ def cmd_obj(self, qmp_cmd: QMPMessage) -> QMPMessage: ) ) =20 - # Default impl of cmd() delegates to cmd_obj + def cmd(self, name: str, + 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. + + @param name: command name (string) + @param args: command arguments (dict) + @param cmd_id: command id (dict, list, string or int) + """ + qmp_cmd: QMPMessage =3D {'execute': name} + if args: + qmp_cmd['arguments'] =3D args + if cmd_id: + qmp_cmd['id'] =3D cmd_id + return self.cmd_obj(qmp_cmd) =20 def command(self, cmd: str, **kwds: object) -> QMPReturnValue: return self._sync( --=20 2.34.1 From nobody Mon Feb 9 01:03:31 2026 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1648661419825303.183149306098; Wed, 30 Mar 2022 10:30:19 -0700 (PDT) Received: from localhost ([::1]:58710 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nZc9C-000190-IO for importer@patchew.org; Wed, 30 Mar 2022 13:30:18 -0400 Received: from eggs.gnu.org ([209.51.188.92]:34882) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nZc7V-00063Y-Hg for qemu-devel@nongnu.org; Wed, 30 Mar 2022 13:28:33 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:34099) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nZc7T-0003Lz-Fb for qemu-devel@nongnu.org; Wed, 30 Mar 2022 13:28:33 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-393-uAJWdsvaOm2QKyqIKiIFgA-1; Wed, 30 Mar 2022 13:28:27 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 71CED811E9B; Wed, 30 Mar 2022 17:28:27 +0000 (UTC) Received: from scv.redhat.com (unknown [10.22.35.177]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2567E40CF91D; Wed, 30 Mar 2022 17:28:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1648661310; 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=y6q7OFJm4PAE8cOrBWZ6IJUVrtKYnBLPMNe5xmw5bFw=; b=aaNj0uCJrxbd+cygvYZgVpzaxZwIXjTEV0qOsdUbX/auUCfwzKaakfFakFQEIw8CjCO1qb TECDKPQSvhR6juBGDghkmCAugVRCrMNqvnxs3yuPPyxeqOeA2ItomNc1zc/mEeWtAbUfvm ALVTJxypoJZjV+XdIs4K21/+1jK9x8A= X-MC-Unique: uAJWdsvaOm2QKyqIKiIFgA-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v2 4/9] python/aqmp: copy qmp docstrings to qemu.aqmp.legacy Date: Wed, 30 Mar 2022 13:28:07 -0400 Message-Id: <20220330172812.3427355-5-jsnow@redhat.com> In-Reply-To: <20220330172812.3427355-1-jsnow@redhat.com> References: <20220330172812.3427355-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 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=170.10.129.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Vladimir Sementsov-Ogievskiy , Beraldo Leal , qemu-block@nongnu.org, Markus Armbruster , Hanna Reitz , Vladimir Sementsov-Ogievskiy , Cleber Rosa , John Snow Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1648661422093100001 Content-Type: text/plain; charset="utf-8"; x-default="true" Copy the docstrings out of qemu.qmp, adjusting them as necessary to more accurately reflect the current state of this class. (Licensing: This is copying and modifying GPLv2-only licensed docstrings into a GPLv2-only file.) Signed-off-by: John Snow Reviewed-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Beraldo Leal --- python/qemu/aqmp/legacy.py | 98 ++++++++++++++++++++++++++++++++++---- 1 file changed, 90 insertions(+), 8 deletions(-) diff --git a/python/qemu/aqmp/legacy.py b/python/qemu/aqmp/legacy.py index 10c7c99c4f0..dfcd20bbd23 100644 --- a/python/qemu/aqmp/legacy.py +++ b/python/qemu/aqmp/legacy.py @@ -1,7 +1,13 @@ """ -Sync QMP Wrapper +(Legacy) Sync QMP Wrapper =20 -This class pretends to be qemu.qmp.QEMUMonitorProtocol. +This module provides the `QEMUMonitorProtocol` class, which is a +synchronous wrapper around `QMPClient`. + +Its design closely resembles that of the original QEMUMonitorProtocol +class, originally written by Luiz Capitulino. It is provided here for +compatibility with scripts inside the QEMU source tree that expect the +old interface. """ =20 # @@ -50,9 +56,6 @@ # {} is the QMPReturnValue. =20 =20 -# pylint: disable=3Dmissing-docstring - - class QMPBadPortError(QMPError): """ Unable to parse socket address: Port was non-numerical. @@ -60,6 +63,17 @@ class QMPBadPortError(QMPError): =20 =20 class QEMUMonitorProtocol: + """ + Provide an API to connect to QEMU via QEMU Monitor Protocol (QMP) + and then allow to handle commands and events. + + :param address: QEMU address, can be either a unix socket path (strin= g) + or a tuple in the form ( address, port ) for a TCP + connection + :param server: Act as the socket server. (See 'accept') + :param nickname: Optional nickname used for logging. + """ + def __init__(self, address: SocketAddrT, server: bool =3D False, nickname: Optional[str] =3D None): @@ -121,6 +135,12 @@ def parse_address(cls, address: str) -> SocketAddrT: return address =20 def connect(self, negotiate: bool =3D True) -> Optional[QMPMessage]: + """ + Connect to the QMP Monitor and perform capabilities negotiation. + + :return: QMP greeting dict, or None if negotiate is false + :raise ConnectError: on connection errors + """ self._aqmp.await_greeting =3D negotiate self._aqmp.negotiate =3D negotiate =20 @@ -130,6 +150,16 @@ def connect(self, negotiate: bool =3D True) -> Optiona= l[QMPMessage]: return self._get_greeting() =20 def accept(self, timeout: Optional[float] =3D 15.0) -> QMPMessage: + """ + Await connection from QMP Monitor and perform capabilities negotia= tion. + + :param timeout: + timeout in seconds (nonnegative float number, or None). + If None, there is no timeout, and this may block forever. + + :return: QMP greeting dict + :raise ConnectError: on connection errors + """ self._aqmp.await_greeting =3D True self._aqmp.negotiate =3D True =20 @@ -140,6 +170,12 @@ def accept(self, timeout: Optional[float] =3D 15.0) ->= QMPMessage: return ret =20 def cmd_obj(self, qmp_cmd: QMPMessage) -> QMPMessage: + """ + Send a QMP command to the QMP Monitor. + + :param qmp_cmd: QMP command to be sent as a Python dict + :return: QMP response as a Python dict + """ return dict( self._sync( # pylint: disable=3Dprotected-access @@ -158,9 +194,9 @@ def cmd(self, name: str, """ Build a QMP command and send it to the QMP Monitor. =20 - @param name: command name (string) - @param args: command arguments (dict) - @param cmd_id: command id (dict, list, string or int) + :param name: command name (string) + :param args: command arguments (dict) + :param cmd_id: command id (dict, list, string or int) """ qmp_cmd: QMPMessage =3D {'execute': name} if args: @@ -170,6 +206,9 @@ def cmd(self, name: str, return self.cmd_obj(qmp_cmd) =20 def command(self, cmd: str, **kwds: object) -> QMPReturnValue: + """ + Build and send a QMP command to the monitor, report errors if any + """ return self._sync( self._aqmp.execute(cmd, kwds), self._timeout @@ -177,6 +216,19 @@ def command(self, cmd: str, **kwds: object) -> QMPRetu= rnValue: =20 def pull_event(self, wait: Union[bool, float] =3D False) -> Optional[QMPMess= age]: + """ + Pulls a single event. + + :param wait: + If False or 0, do not wait. Return None if no events ready. + If True, wait forever until the next event. + Otherwise, wait for the specified number of seconds. + + :raise asyncio.TimeoutError: + When a timeout is requested and the timeout period elapses. + + :return: The first available QMP event, or None. + """ if not wait: # wait is False/0: "do not wait, do not except." if self._aqmp.events.empty(): @@ -197,6 +249,20 @@ def pull_event(self, ) =20 def get_events(self, wait: Union[bool, float] =3D False) -> List[QMPMe= ssage]: + """ + Get a list of QMP events and clear all pending events. + + :param wait: + If False or 0, do not wait. Return None if no events ready. + If True, wait until we have at least one event. + Otherwise, wait for up to the specified number of seconds for = at + least one event. + + :raise asyncio.TimeoutError: + When a timeout is requested and the timeout period elapses. + + :return: A list of QMP events. + """ events =3D [dict(x) for x in self._aqmp.events.clear()] if events: return events @@ -205,17 +271,33 @@ def get_events(self, wait: Union[bool, float] =3D Fal= se) -> List[QMPMessage]: return [event] if event is not None else [] =20 def clear_events(self) -> None: + """Clear current list of pending events.""" self._aqmp.events.clear() =20 def close(self) -> None: + """Close the connection.""" self._sync( self._aqmp.disconnect() ) =20 def settimeout(self, timeout: Optional[float]) -> None: + """ + Set the timeout for QMP RPC execution. + + This timeout affects the `cmd`, `cmd_obj`, and `command` methods. + The `accept`, `pull_event` and `get_event` methods have their + own configurable timeouts. + + :param timeout: + timeout in seconds, or None. + None will wait indefinitely. + """ self._timeout =3D timeout =20 def send_fd_scm(self, fd: int) -> None: + """ + Send a file descriptor to the remote via SCM_RIGHTS. + """ self._aqmp.send_fd_scm(fd) =20 def __del__(self) -> None: --=20 2.34.1 From nobody Mon Feb 9 01:03:31 2026 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1648662377780867.2212444327643; Wed, 30 Mar 2022 10:46:17 -0700 (PDT) Received: from localhost ([::1]:52482 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nZcOe-0000FZ-AK for importer@patchew.org; Wed, 30 Mar 2022 13:46:16 -0400 Received: from eggs.gnu.org ([209.51.188.92]:35030) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nZc7a-0006MA-3t for qemu-devel@nongnu.org; Wed, 30 Mar 2022 13:28:38 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:56631) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nZc7W-0003Nc-77 for qemu-devel@nongnu.org; Wed, 30 Mar 2022 13:28:37 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-624-12uqQ-1cOwCy04Ive2Ywdw-1; Wed, 30 Mar 2022 13:28:30 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B45E638009ED; Wed, 30 Mar 2022 17:28:29 +0000 (UTC) Received: from scv.redhat.com (unknown [10.22.35.177]) by smtp.corp.redhat.com (Postfix) with ESMTP id 68F1840CFD22; Wed, 30 Mar 2022 17:28:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1648661313; 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=GmILQO47okUNr7/jttI2zDqoIhR/yfe3kh+iSN8kVkc=; b=I3Sb7gL2e/2CHo7TgHECul3LkGxyFdc+6j7EjVjaOV2ijQyueuLLRF9cFry+iuZgI2Accx t/fegQPYb/gnM4Bw6vt1m/VZpzubeSmlp0HhAmttmPS1uVx1onRkRwHrKJ0CpkOeXvBneR C0smXyoldnd4eK08P2RWncS5KJXlyKI= X-MC-Unique: 12uqQ-1cOwCy04Ive2Ywdw-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v2 5/9] python: remove the old QMP package Date: Wed, 30 Mar 2022 13:28:08 -0400 Message-Id: <20220330172812.3427355-6-jsnow@redhat.com> In-Reply-To: <20220330172812.3427355-1-jsnow@redhat.com> References: <20220330172812.3427355-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 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=170.10.133.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Vladimir Sementsov-Ogievskiy , Beraldo Leal , qemu-block@nongnu.org, Markus Armbruster , Hanna Reitz , Vladimir Sementsov-Ogievskiy , Cleber Rosa , John Snow Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1648662378731100001 Content-Type: text/plain; charset="utf-8"; x-default="true" Thank you for your service! Signed-off-by: John Snow Reviewed-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Beraldo Leal --- python/PACKAGE.rst | 4 +- python/README.rst | 2 +- python/qemu/qmp/README.rst | 9 - python/qemu/qmp/__init__.py | 396 ------------------------------------ python/qemu/qmp/py.typed | 0 python/setup.cfg | 3 +- 6 files changed, 4 insertions(+), 410 deletions(-) delete mode 100644 python/qemu/qmp/README.rst delete mode 100644 python/qemu/qmp/__init__.py delete mode 100644 python/qemu/qmp/py.typed diff --git a/python/PACKAGE.rst b/python/PACKAGE.rst index b0b86cc4c31..ddfa9ba3f59 100644 --- a/python/PACKAGE.rst +++ b/python/PACKAGE.rst @@ -8,11 +8,11 @@ to change at any time. Usage ----- =20 -The ``qemu.qmp`` subpackage provides a library for communicating with +The ``qemu.aqmp`` subpackage provides a library for communicating with QMP servers. The ``qemu.machine`` subpackage offers rudimentary facilities for launching and managing QEMU processes. Refer to each package's documentation -(``>>> help(qemu.qmp)``, ``>>> help(qemu.machine)``) +(``>>> help(qemu.aqmp)``, ``>>> help(qemu.machine)``) for more information. =20 Contributing diff --git a/python/README.rst b/python/README.rst index fcf74f69eae..eb5213337d2 100644 --- a/python/README.rst +++ b/python/README.rst @@ -3,7 +3,7 @@ QEMU Python Tooling =20 This directory houses Python tooling used by the QEMU project to build, configure, and test QEMU. It is organized by namespace (``qemu``), and -then by package (e.g. ``qemu/machine``, ``qemu/qmp``, etc). +then by package (e.g. ``qemu/machine``, ``qemu/aqmp``, etc). =20 ``setup.py`` is used by ``pip`` to install this tooling to the current environment. ``setup.cfg`` provides the packaging configuration used by diff --git a/python/qemu/qmp/README.rst b/python/qemu/qmp/README.rst deleted file mode 100644 index 5bfb82535f8..00000000000 --- a/python/qemu/qmp/README.rst +++ /dev/null @@ -1,9 +0,0 @@ -qemu.qmp package -=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D - -This package provides a library used for connecting to and communicating -with QMP servers. It is used extensively by iotests, vm tests, -avocado tests, and other utilities in the ./scripts directory. It is -not a fully-fledged SDK and is subject to change at any time. - -See the documentation in ``__init__.py`` for more information. diff --git a/python/qemu/qmp/__init__.py b/python/qemu/qmp/__init__.py deleted file mode 100644 index 4e086411544..00000000000 --- a/python/qemu/qmp/__init__.py +++ /dev/null @@ -1,396 +0,0 @@ -""" -QEMU Monitor Protocol (QMP) development library & tooling. - -This package provides a fairly low-level class for communicating to QMP -protocol servers, as implemented by QEMU, the QEMU Guest Agent, and the -QEMU Storage Daemon. This library is not intended for production use. - -`QEMUMonitorProtocol` is the primary class of interest, and all errors -raised derive from `QMPError`. -""" - -# Copyright (C) 2009, 2010 Red Hat Inc. -# -# Authors: -# Luiz Capitulino -# -# This work is licensed under the terms of the GNU GPL, version 2. See -# the COPYING file in the top-level directory. - -import errno -import json -import logging -import socket -import struct -from types import TracebackType -from typing import ( - Any, - Dict, - List, - Optional, - TextIO, - Tuple, - Type, - TypeVar, - Union, - cast, -) - - -#: QMPMessage is an entire QMP message of any kind. -QMPMessage =3D Dict[str, Any] - -#: QMPReturnValue is the 'return' value of a command. -QMPReturnValue =3D object - -#: 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. -# -# {'return': {}} is a QMPMessage, -# {} is the QMPReturnValue. - - -InternetAddrT =3D Tuple[str, int] -UnixAddrT =3D str -SocketAddrT =3D Union[InternetAddrT, UnixAddrT] - - -class QMPError(Exception): - """ - QMP base exception - """ - - -class QMPConnectError(QMPError): - """ - QMP connection exception - """ - - -class QMPCapabilitiesError(QMPError): - """ - QMP negotiate capabilities exception - """ - - -class QMPTimeoutError(QMPError): - """ - QMP timeout exception - """ - - -class QMPProtocolError(QMPError): - """ - QMP protocol error; unexpected response - """ - - -class QMPResponseError(QMPError): - """ - Represents erroneous QMP monitor reply - """ - def __init__(self, reply: QMPMessage): - try: - desc =3D reply['error']['desc'] - except KeyError: - desc =3D reply - super().__init__(desc) - self.reply =3D reply - - -class QEMUMonitorProtocol: - """ - Provide an API to connect to QEMU via QEMU Monitor Protocol (QMP) and = then - allow to handle commands and events. - """ - - #: Logger object for debugging messages - logger =3D logging.getLogger('QMP') - - def __init__(self, address: SocketAddrT, - server: bool =3D False, - nickname: Optional[str] =3D None): - """ - Create a QEMUMonitorProtocol class. - - @param address: QEMU address, can be either a unix socket path (st= ring) - or a tuple in the form ( address, port ) for a TCP - connection - @param server: server mode listens on the socket (bool) - @raise OSError on socket connection errors - @note No connection is established, this is done by the connect() = or - accept() methods - """ - self.__events: List[QMPMessage] =3D [] - self.__address =3D address - self.__sock =3D self.__get_sock() - self.__sockfile: Optional[TextIO] =3D None - self._nickname =3D nickname - if self._nickname: - self.logger =3D logging.getLogger('QMP').getChild(self._nickna= me) - if server: - self.__sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR,= 1) - self.__sock.bind(self.__address) - self.__sock.listen(1) - - def __get_sock(self) -> socket.socket: - if isinstance(self.__address, tuple): - family =3D socket.AF_INET - else: - family =3D socket.AF_UNIX - return socket.socket(family, socket.SOCK_STREAM) - - def __negotiate_capabilities(self) -> QMPMessage: - greeting =3D self.__json_read() - if greeting is None or "QMP" not in greeting: - raise QMPConnectError - # Greeting seems ok, negotiate capabilities - resp =3D self.cmd('qmp_capabilities') - if resp and "return" in resp: - return greeting - raise QMPCapabilitiesError - - def __json_read(self, only_event: bool =3D False) -> Optional[QMPMessa= ge]: - assert self.__sockfile is not None - while True: - data =3D self.__sockfile.readline() - if not data: - return None - # By definition, any JSON received from QMP is a QMPMessage, - # and we are asserting only at static analysis time that it - # has a particular shape. - resp: QMPMessage =3D json.loads(data) - if 'event' in resp: - self.logger.debug("<<< %s", resp) - self.__events.append(resp) - if not only_event: - continue - return resp - - def __get_events(self, wait: Union[bool, float] =3D False) -> None: - """ - Check for new events in the stream and cache them in __events. - - @param wait (bool): block until an event is available. - @param wait (float): If wait is a float, treat it as a timeout val= ue. - - @raise QMPTimeoutError: If a timeout float is provided and the tim= eout - period elapses. - @raise QMPConnectError: If wait is True but no events could be - retrieved or if some other error occurred. - """ - - # Current timeout and blocking status - current_timeout =3D self.__sock.gettimeout() - - # Check for new events regardless and pull them into the cache: - self.__sock.settimeout(0) # i.e. setblocking(False) - try: - self.__json_read() - except OSError as err: - # EAGAIN: No data available; not critical - if err.errno !=3D errno.EAGAIN: - raise - finally: - self.__sock.settimeout(current_timeout) - - # Wait for new events, if needed. - # if wait is 0.0, this means "no wait" and is also implicitly fals= e. - if not self.__events and wait: - if isinstance(wait, float): - self.__sock.settimeout(wait) - try: - ret =3D self.__json_read(only_event=3DTrue) - except socket.timeout as err: - raise QMPTimeoutError("Timeout waiting for event") from err - except Exception as err: - msg =3D "Error while reading from socket" - raise QMPConnectError(msg) from err - finally: - self.__sock.settimeout(current_timeout) - - if ret is None: - raise QMPConnectError("Error while reading from socket") - - T =3D TypeVar('T') - - def __enter__(self: T) -> T: - # Implement context manager enter function. - return self - - def __exit__(self, - # pylint: disable=3Dduplicate-code - # see https://github.com/PyCQA/pylint/issues/3619 - exc_type: Optional[Type[BaseException]], - exc_val: Optional[BaseException], - exc_tb: Optional[TracebackType]) -> None: - # Implement context manager exit function. - self.close() - - def connect(self, negotiate: bool =3D True) -> Optional[QMPMessage]: - """ - Connect to the QMP Monitor and perform capabilities negotiation. - - @return QMP greeting dict, or None if negotiate is false - @raise OSError on socket connection errors - @raise QMPConnectError if the greeting is not received - @raise QMPCapabilitiesError if fails to negotiate capabilities - """ - self.__sock.connect(self.__address) - self.__sockfile =3D self.__sock.makefile(mode=3D'r') - if negotiate: - return self.__negotiate_capabilities() - return None - - def accept(self, timeout: Optional[float] =3D 15.0) -> QMPMessage: - """ - Await connection from QMP Monitor and perform capabilities negotia= tion. - - @param timeout: timeout in seconds (nonnegative float number, or - None). The value passed will set the behavior of t= he - underneath QMP socket as described in [1]. - Default value is set to 15.0. - - @return QMP greeting dict - @raise OSError on socket connection errors - @raise QMPConnectError if the greeting is not received - @raise QMPCapabilitiesError if fails to negotiate capabilities - - [1] - https://docs.python.org/3/library/socket.html#socket.socket.settim= eout - """ - self.__sock.settimeout(timeout) - self.__sock, _ =3D self.__sock.accept() - self.__sockfile =3D self.__sock.makefile(mode=3D'r') - return self.__negotiate_capabilities() - - def cmd_obj(self, qmp_cmd: QMPMessage) -> QMPMessage: - """ - Send a QMP command to the QMP Monitor. - - @param qmp_cmd: QMP command to be sent as a Python dict - @return QMP response as a Python dict - """ - self.logger.debug(">>> %s", qmp_cmd) - self.__sock.sendall(json.dumps(qmp_cmd).encode('utf-8')) - resp =3D self.__json_read() - if resp is None: - raise QMPConnectError("Unexpected empty reply from server") - self.logger.debug("<<< %s", resp) - return resp - - def cmd(self, name: str, - 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. - - @param name: command name (string) - @param args: command arguments (dict) - @param cmd_id: command id (dict, list, string or int) - """ - qmp_cmd: QMPMessage =3D {'execute': name} - if args: - qmp_cmd['arguments'] =3D args - if cmd_id: - qmp_cmd['id'] =3D cmd_id - return self.cmd_obj(qmp_cmd) - - def command(self, cmd: str, **kwds: object) -> QMPReturnValue: - """ - Build and send a QMP command to the monitor, report errors if any - """ - ret =3D self.cmd(cmd, kwds) - if 'error' in ret: - raise QMPResponseError(ret) - if 'return' not in ret: - raise QMPProtocolError( - "'return' key not found in QMP response '{}'".format(str(r= et)) - ) - return cast(QMPReturnValue, ret['return']) - - def pull_event(self, - wait: Union[bool, float] =3D False) -> Optional[QMPMess= age]: - """ - Pulls a single event. - - @param wait (bool): block until an event is available. - @param wait (float): If wait is a float, treat it as a timeout val= ue. - - @raise QMPTimeoutError: If a timeout float is provided and the tim= eout - period elapses. - @raise QMPConnectError: If wait is True but no events could be - retrieved or if some other error occurred. - - @return The first available QMP event, or None. - """ - self.__get_events(wait) - - if self.__events: - return self.__events.pop(0) - return None - - def get_events(self, wait: bool =3D False) -> List[QMPMessage]: - """ - Get a list of available QMP events and clear all pending events. - - @param wait (bool): block until an event is available. - @param wait (float): If wait is a float, treat it as a timeout val= ue. - - @raise QMPTimeoutError: If a timeout float is provided and the tim= eout - period elapses. - @raise QMPConnectError: If wait is True but no events could be - retrieved or if some other error occurred. - - @return The list of available QMP events. - """ - self.__get_events(wait) - events =3D self.__events - self.__events =3D [] - return events - - def clear_events(self) -> None: - """ - Clear current list of pending events. - """ - self.__events =3D [] - - def close(self) -> None: - """ - Close the socket and socket file. - """ - if self.__sock: - self.__sock.close() - if self.__sockfile: - self.__sockfile.close() - - def settimeout(self, timeout: Optional[float]) -> None: - """ - Set the socket timeout. - - @param timeout (float): timeout in seconds (non-zero), or None. - @note This is a wrap around socket.settimeout - - @raise ValueError: if timeout was set to 0. - """ - if timeout =3D=3D 0: - msg =3D "timeout cannot be 0; this engages non-blocking mode." - msg +=3D " Use 'None' instead to disable timeouts." - raise ValueError(msg) - self.__sock.settimeout(timeout) - - def send_fd_scm(self, fd: int) -> None: - """ - Send a file descriptor to the remote via SCM_RIGHTS. - """ - if self.__sock.family !=3D socket.AF_UNIX: - raise RuntimeError("Can't use SCM_RIGHTS on non-AF_UNIX socket= .") - - self.__sock.sendmsg( - [b' '], - [(socket.SOL_SOCKET, socket.SCM_RIGHTS, struct.pack('@i', fd))] - ) diff --git a/python/qemu/qmp/py.typed b/python/qemu/qmp/py.typed deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/python/setup.cfg b/python/setup.cfg index cdeced44d2b..4340c29a24f 100644 --- a/python/setup.cfg +++ b/python/setup.cfg @@ -24,10 +24,9 @@ classifiers =3D [options] python_requires =3D >=3D 3.6 packages =3D - qemu.qmp + qemu.aqmp qemu.machine qemu.utils - qemu.aqmp =20 [options.package_data] * =3D py.typed --=20 2.34.1 From nobody Mon Feb 9 01:03:31 2026 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1648661744157257.31153847418113; Wed, 30 Mar 2022 10:35:44 -0700 (PDT) Received: from localhost ([::1]:42266 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nZcER-0001T9-4n for importer@patchew.org; Wed, 30 Mar 2022 13:35:43 -0400 Received: from eggs.gnu.org ([209.51.188.92]:34906) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nZc7W-00065p-6y for qemu-devel@nongnu.org; Wed, 30 Mar 2022 13:28:34 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:52460) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nZc7T-0003MH-Tb for qemu-devel@nongnu.org; Wed, 30 Mar 2022 13:28:33 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-632-0n3YPG-mM6Gut-k4oDgZkQ-1; Wed, 30 Mar 2022 13:28:27 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 71CB5100BAC7; Wed, 30 Mar 2022 17:28:27 +0000 (UTC) Received: from scv.redhat.com (unknown [10.22.35.177]) by smtp.corp.redhat.com (Postfix) with ESMTP id AA84240CF917; Wed, 30 Mar 2022 17:28:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1648661311; 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=t1PlnvwHej4FRrM9bignyFOvB2KT9e6LAQg11TLuok4=; b=aRIgbZXHcZFhs1gPfGjw8umou/QXeyNq+Hu+YnSeupqbxmHRkWIE7JN7Bwn0JwkHuvLnZc IQ5ZapcXQJFrXaz5vvhZBBwOTm2gvovNGlqoYy21Dier+Cd529TBs/tzD1SLTiBQCcq1S6 SBbKrkb9TxjACahRiBTqVthb6fcYK5I= X-MC-Unique: 0n3YPG-mM6Gut-k4oDgZkQ-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v2 6/9] python: re-enable pylint duplicate-code warnings Date: Wed, 30 Mar 2022 13:28:09 -0400 Message-Id: <20220330172812.3427355-7-jsnow@redhat.com> In-Reply-To: <20220330172812.3427355-1-jsnow@redhat.com> References: <20220330172812.3427355-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 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=170.10.133.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Vladimir Sementsov-Ogievskiy , Beraldo Leal , qemu-block@nongnu.org, Markus Armbruster , Hanna Reitz , Vladimir Sementsov-Ogievskiy , Cleber Rosa , John Snow Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1648661744767100001 Content-Type: text/plain; charset="utf-8"; x-default="true" With the old library gone, there's nothing duplicated in the tree, so the warning suppression can be removed. Signed-off-by: John Snow Reviewed-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Beraldo Leal --- python/setup.cfg | 1 - 1 file changed, 1 deletion(-) diff --git a/python/setup.cfg b/python/setup.cfg index 4340c29a24f..49e3c285f19 100644 --- a/python/setup.cfg +++ b/python/setup.cfg @@ -118,7 +118,6 @@ disable=3Dconsider-using-f-string, too-many-function-args, # mypy handles this with less false posit= ives. too-many-instance-attributes, no-member, # mypy also handles this better. - duplicate-code, # To be removed by the end of this patch series. =20 [pylint.basic] # Good variable names which should always be accepted, separated by a comm= a. --=20 2.34.1 From nobody Mon Feb 9 01:03:31 2026 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1648662004958712.2777371632338; Wed, 30 Mar 2022 10:40:04 -0700 (PDT) Received: from localhost ([::1]:47426 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nZcIc-00051o-JV for importer@patchew.org; Wed, 30 Mar 2022 13:40:02 -0400 Received: from eggs.gnu.org ([209.51.188.92]:35022) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nZc7a-0006Lo-13 for qemu-devel@nongnu.org; Wed, 30 Mar 2022 13:28:38 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:29803) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nZc7V-0003NB-BH for qemu-devel@nongnu.org; Wed, 30 Mar 2022 13:28:37 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-592-ffJ7OdniMPyQG5psczs_Dg-1; Wed, 30 Mar 2022 13:28:28 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E9453803CB8; Wed, 30 Mar 2022 17:28:27 +0000 (UTC) Received: from scv.redhat.com (unknown [10.22.35.177]) by smtp.corp.redhat.com (Postfix) with ESMTP id 82F9740CFD02; Wed, 30 Mar 2022 17:28:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1648661312; 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=ykXqsjbywL06YRvC5GpxkZ4OLYr8grci1crY+okBYkc=; b=SriIXJolwGjpH6uJtCeIRCIcSFS/4Fc1kJmG7+NIkP4P2/Xaqj9Xp+4WIPFu4b8NAZRzHk 0ubO02iI7mbkqa/P+mVv4WxBgOd0mGce8XqPaIHgoxEWg2YFzWLgjheGyzmIEe+bMiy4tT RDG41acAln+xSc7XBB26sSfr/1Uu21Y= X-MC-Unique: ffJ7OdniMPyQG5psczs_Dg-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v2 7/9] python: rename qemu.aqmp to qemu.qmp Date: Wed, 30 Mar 2022 13:28:10 -0400 Message-Id: <20220330172812.3427355-8-jsnow@redhat.com> In-Reply-To: <20220330172812.3427355-1-jsnow@redhat.com> References: <20220330172812.3427355-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 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=170.10.133.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Vladimir Sementsov-Ogievskiy , Beraldo Leal , qemu-block@nongnu.org, Markus Armbruster , Hanna Reitz , Cleber Rosa , John Snow Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1648662005942100001 Content-Type: text/plain; charset="utf-8"; x-default="true" Now that we are fully switched over to the new QMP library, move it back over the old namespace. This is being done primarily so that we may upload this package simply as "qemu.qmp" without introducing confusion over whether or not "aqmp" is a new protocol or not. The trade-off is increased confusion inside the QEMU developer tree. Sorry! Note: the 'private' member "_aqmp" in legacy.py also changes to "_qmp"; not out of necessity, but just to remove any traces of the "aqmp" name. Signed-off-by: John Snow Reviewed-by: Beraldo Leal Acked-by: Hanna Reitz Reviewed-by: Vladimir Sementsov-Ogievskiy --- python/PACKAGE.rst | 4 +-- python/README.rst | 4 +-- python/qemu/machine/machine.py | 4 +-- python/qemu/machine/qtest.py | 2 +- python/qemu/{aqmp =3D> qmp}/__init__.py | 6 ++-- python/qemu/{aqmp =3D> qmp}/aqmp_tui.py | 0 python/qemu/{aqmp =3D> qmp}/error.py | 0 python/qemu/{aqmp =3D> qmp}/events.py | 2 +- python/qemu/{aqmp =3D> qmp}/legacy.py | 38 +++++++++++------------ python/qemu/{aqmp =3D> qmp}/message.py | 0 python/qemu/{aqmp =3D> qmp}/models.py | 0 python/qemu/{aqmp =3D> qmp}/protocol.py | 4 +-- python/qemu/{aqmp =3D> qmp}/py.typed | 0 python/qemu/{aqmp =3D> qmp}/qmp_client.py | 16 +++++----- python/qemu/{aqmp =3D> qmp}/qmp_shell.py | 4 +-- python/qemu/{aqmp =3D> qmp}/util.py | 0 python/qemu/utils/qemu_ga_client.py | 4 +-- python/qemu/utils/qom.py | 2 +- python/qemu/utils/qom_common.py | 4 +-- python/qemu/utils/qom_fuse.py | 2 +- python/setup.cfg | 10 +++--- python/tests/protocol.py | 14 ++++----- scripts/cpu-x86-uarch-abi.py | 2 +- scripts/device-crash-test | 4 +-- scripts/qmp/qmp-shell | 2 +- scripts/qmp/qmp-shell-wrap | 2 +- scripts/render_block_graph.py | 4 +-- scripts/simplebench/bench_block_job.py | 2 +- tests/qemu-iotests/iotests.py | 2 +- tests/qemu-iotests/tests/mirror-top-perms | 4 +-- 30 files changed, 71 insertions(+), 71 deletions(-) rename python/qemu/{aqmp =3D> qmp}/__init__.py (87%) rename python/qemu/{aqmp =3D> qmp}/aqmp_tui.py (100%) rename python/qemu/{aqmp =3D> qmp}/error.py (100%) rename python/qemu/{aqmp =3D> qmp}/events.py (99%) rename python/qemu/{aqmp =3D> qmp}/legacy.py (91%) rename python/qemu/{aqmp =3D> qmp}/message.py (100%) rename python/qemu/{aqmp =3D> qmp}/models.py (100%) rename python/qemu/{aqmp =3D> qmp}/protocol.py (99%) rename python/qemu/{aqmp =3D> qmp}/py.typed (100%) rename python/qemu/{aqmp =3D> qmp}/qmp_client.py (97%) rename python/qemu/{aqmp =3D> qmp}/qmp_shell.py (99%) rename python/qemu/{aqmp =3D> qmp}/util.py (100%) diff --git a/python/PACKAGE.rst b/python/PACKAGE.rst index ddfa9ba3f59..b0b86cc4c31 100644 --- a/python/PACKAGE.rst +++ b/python/PACKAGE.rst @@ -8,11 +8,11 @@ to change at any time. Usage ----- =20 -The ``qemu.aqmp`` subpackage provides a library for communicating with +The ``qemu.qmp`` subpackage provides a library for communicating with QMP servers. The ``qemu.machine`` subpackage offers rudimentary facilities for launching and managing QEMU processes. Refer to each package's documentation -(``>>> help(qemu.aqmp)``, ``>>> help(qemu.machine)``) +(``>>> help(qemu.qmp)``, ``>>> help(qemu.machine)``) for more information. =20 Contributing diff --git a/python/README.rst b/python/README.rst index eb5213337d2..9c1fceaee73 100644 --- a/python/README.rst +++ b/python/README.rst @@ -3,7 +3,7 @@ QEMU Python Tooling =20 This directory houses Python tooling used by the QEMU project to build, configure, and test QEMU. It is organized by namespace (``qemu``), and -then by package (e.g. ``qemu/machine``, ``qemu/aqmp``, etc). +then by package (e.g. ``qemu/machine``, ``qemu/qmp``, etc). =20 ``setup.py`` is used by ``pip`` to install this tooling to the current environment. ``setup.cfg`` provides the packaging configuration used by @@ -59,7 +59,7 @@ Package installation also normally provides executable co= nsole scripts, so that tools like ``qmp-shell`` are always available via $PATH. To invoke them without installation, you can invoke e.g.: =20 -``> PYTHONPATH=3D~/src/qemu/python python3 -m qemu.aqmp.qmp_shell`` +``> PYTHONPATH=3D~/src/qemu/python python3 -m qemu.qmp.qmp_shell`` =20 The mappings between console script name and python module path can be found in ``setup.cfg``. diff --git a/python/qemu/machine/machine.py b/python/qemu/machine/machine.py index 41be025ac7b..07ac5a710be 100644 --- a/python/qemu/machine/machine.py +++ b/python/qemu/machine/machine.py @@ -40,8 +40,8 @@ TypeVar, ) =20 -from qemu.aqmp import SocketAddrT -from qemu.aqmp.legacy import ( +from qemu.qmp import SocketAddrT +from qemu.qmp.legacy import ( QEMUMonitorProtocol, QMPMessage, QMPReturnValue, diff --git a/python/qemu/machine/qtest.py b/python/qemu/machine/qtest.py index 13e0aaff846..1a1fc6c9b08 100644 --- a/python/qemu/machine/qtest.py +++ b/python/qemu/machine/qtest.py @@ -26,7 +26,7 @@ TextIO, ) =20 -from qemu.aqmp import SocketAddrT +from qemu.qmp import SocketAddrT =20 from .machine import QEMUMachine =20 diff --git a/python/qemu/aqmp/__init__.py b/python/qemu/qmp/__init__.py similarity index 87% rename from python/qemu/aqmp/__init__.py rename to python/qemu/qmp/__init__.py index 2b69b264f4f..69190d057a5 100644 --- a/python/qemu/aqmp/__init__.py +++ b/python/qemu/qmp/__init__.py @@ -6,8 +6,8 @@ QEMU Guest Agent, and the QEMU Storage Daemon. =20 `QMPClient` provides the main functionality of this package. All errors -raised by this library derive from `QMPError`, see `aqmp.error` for -additional detail. See `aqmp.events` for an in-depth tutorial on +raised by this library derive from `QMPError`, see `qmp.error` for +additional detail. See `qmp.events` for an in-depth tutorial on managing QMP events. """ =20 @@ -36,7 +36,7 @@ =20 =20 # Suppress logging unless an application engages it. -logging.getLogger('qemu.aqmp').addHandler(logging.NullHandler()) +logging.getLogger('qemu.qmp').addHandler(logging.NullHandler()) =20 =20 # The order of these fields impact the Sphinx documentation order. diff --git a/python/qemu/aqmp/aqmp_tui.py b/python/qemu/qmp/aqmp_tui.py similarity index 100% rename from python/qemu/aqmp/aqmp_tui.py rename to python/qemu/qmp/aqmp_tui.py diff --git a/python/qemu/aqmp/error.py b/python/qemu/qmp/error.py similarity index 100% rename from python/qemu/aqmp/error.py rename to python/qemu/qmp/error.py diff --git a/python/qemu/aqmp/events.py b/python/qemu/qmp/events.py similarity index 99% rename from python/qemu/aqmp/events.py rename to python/qemu/qmp/events.py index f3d4e2b5e85..6199776cc66 100644 --- a/python/qemu/aqmp/events.py +++ b/python/qemu/qmp/events.py @@ -1,5 +1,5 @@ """ -AQMP Events and EventListeners +QMP Events and EventListeners =20 Asynchronous QMP uses `EventListener` objects to listen for events. An `EventListener` is a FIFO event queue that can be pre-filtered to listen diff --git a/python/qemu/aqmp/legacy.py b/python/qemu/qmp/legacy.py similarity index 91% rename from python/qemu/aqmp/legacy.py rename to python/qemu/qmp/legacy.py index dfcd20bbd23..a8629b44dff 100644 --- a/python/qemu/aqmp/legacy.py +++ b/python/qemu/qmp/legacy.py @@ -78,13 +78,13 @@ def __init__(self, address: SocketAddrT, server: bool =3D False, nickname: Optional[str] =3D None): =20 - self._aqmp =3D QMPClient(nickname) + self._qmp =3D QMPClient(nickname) self._aloop =3D asyncio.get_event_loop() self._address =3D address self._timeout: Optional[float] =3D None =20 if server: - self._sync(self._aqmp.start_server(self._address)) + self._sync(self._qmp.start_server(self._address)) =20 _T =3D TypeVar('_T') =20 @@ -96,9 +96,9 @@ def _sync( ) =20 def _get_greeting(self) -> Optional[QMPMessage]: - if self._aqmp.greeting is not None: + if self._qmp.greeting is not None: # pylint: disable=3Dprotected-access - return self._aqmp.greeting._asdict() + return self._qmp.greeting._asdict() return None =20 def __enter__(self: _T) -> _T: @@ -141,11 +141,11 @@ def connect(self, negotiate: bool =3D True) -> Option= al[QMPMessage]: :return: QMP greeting dict, or None if negotiate is false :raise ConnectError: on connection errors """ - self._aqmp.await_greeting =3D negotiate - self._aqmp.negotiate =3D negotiate + self._qmp.await_greeting =3D negotiate + self._qmp.negotiate =3D negotiate =20 self._sync( - self._aqmp.connect(self._address) + self._qmp.connect(self._address) ) return self._get_greeting() =20 @@ -160,10 +160,10 @@ def accept(self, timeout: Optional[float] =3D 15.0) -= > QMPMessage: :return: QMP greeting dict :raise ConnectError: on connection errors """ - self._aqmp.await_greeting =3D True - self._aqmp.negotiate =3D True + self._qmp.await_greeting =3D True + self._qmp.negotiate =3D True =20 - self._sync(self._aqmp.accept(), timeout) + self._sync(self._qmp.accept(), timeout) =20 ret =3D self._get_greeting() assert ret is not None @@ -183,7 +183,7 @@ def cmd_obj(self, qmp_cmd: QMPMessage) -> QMPMessage: # _raw() isn't a public API, because turning off # automatic ID assignment is discouraged. For # compatibility with iotests *only*, do it anyway. - self._aqmp._raw(qmp_cmd, assign_id=3DFalse), + self._qmp._raw(qmp_cmd, assign_id=3DFalse), self._timeout ) ) @@ -210,7 +210,7 @@ def command(self, cmd: str, **kwds: object) -> QMPRetur= nValue: Build and send a QMP command to the monitor, report errors if any """ return self._sync( - self._aqmp.execute(cmd, kwds), + self._qmp.execute(cmd, kwds), self._timeout ) =20 @@ -231,7 +231,7 @@ def pull_event(self, """ if not wait: # wait is False/0: "do not wait, do not except." - if self._aqmp.events.empty(): + if self._qmp.events.empty(): return None =20 # If wait is 'True', wait forever. If wait is False/0, the events @@ -243,7 +243,7 @@ def pull_event(self, =20 return dict( self._sync( - self._aqmp.events.get(), + self._qmp.events.get(), timeout ) ) @@ -263,7 +263,7 @@ def get_events(self, wait: Union[bool, float] =3D False= ) -> List[QMPMessage]: =20 :return: A list of QMP events. """ - events =3D [dict(x) for x in self._aqmp.events.clear()] + events =3D [dict(x) for x in self._qmp.events.clear()] if events: return events =20 @@ -272,12 +272,12 @@ def get_events(self, wait: Union[bool, float] =3D Fal= se) -> List[QMPMessage]: =20 def clear_events(self) -> None: """Clear current list of pending events.""" - self._aqmp.events.clear() + self._qmp.events.clear() =20 def close(self) -> None: """Close the connection.""" self._sync( - self._aqmp.disconnect() + self._qmp.disconnect() ) =20 def settimeout(self, timeout: Optional[float]) -> None: @@ -298,10 +298,10 @@ def send_fd_scm(self, fd: int) -> None: """ Send a file descriptor to the remote via SCM_RIGHTS. """ - self._aqmp.send_fd_scm(fd) + self._qmp.send_fd_scm(fd) =20 def __del__(self) -> None: - if self._aqmp.runstate =3D=3D Runstate.IDLE: + if self._qmp.runstate =3D=3D Runstate.IDLE: return =20 if not self._aloop.is_running(): diff --git a/python/qemu/aqmp/message.py b/python/qemu/qmp/message.py similarity index 100% rename from python/qemu/aqmp/message.py rename to python/qemu/qmp/message.py diff --git a/python/qemu/aqmp/models.py b/python/qemu/qmp/models.py similarity index 100% rename from python/qemu/aqmp/models.py rename to python/qemu/qmp/models.py diff --git a/python/qemu/aqmp/protocol.py b/python/qemu/qmp/protocol.py similarity index 99% rename from python/qemu/aqmp/protocol.py rename to python/qemu/qmp/protocol.py index 36fae57f277..6ea86650ad2 100644 --- a/python/qemu/aqmp/protocol.py +++ b/python/qemu/qmp/protocol.py @@ -196,9 +196,9 @@ class AsyncProtocol(Generic[T]): =20 :param name: Name used for logging messages, if any. By default, messages - will log to 'qemu.aqmp.protocol', but each individual connection + will log to 'qemu.qmp.protocol', but each individual connection can be given its own logger by giving it a name; messages will - then log to 'qemu.aqmp.protocol.${name}'. + then log to 'qemu.qmp.protocol.${name}'. """ # pylint: disable=3Dtoo-many-instance-attributes =20 diff --git a/python/qemu/aqmp/py.typed b/python/qemu/qmp/py.typed similarity index 100% rename from python/qemu/aqmp/py.typed rename to python/qemu/qmp/py.typed diff --git a/python/qemu/aqmp/qmp_client.py b/python/qemu/qmp/qmp_client.py similarity index 97% rename from python/qemu/aqmp/qmp_client.py rename to python/qemu/qmp/qmp_client.py index 90a8737f03a..5dcda04a756 100644 --- a/python/qemu/aqmp/qmp_client.py +++ b/python/qemu/qmp/qmp_client.py @@ -192,7 +192,7 @@ async def run(self, address=3D'/tmp/qemu.socket'): await self.qmp.runstate_changed.wait() await self.disconnect() =20 - See `aqmp.events` for more detail on event handling patterns. + See `qmp.events` for more detail on event handling patterns. """ #: Logger object used for debugging messages. logger =3D logging.getLogger(__name__) @@ -416,7 +416,7 @@ def _do_send(self, msg: Message) -> None: =20 @upper_half def _get_exec_id(self) -> str: - exec_id =3D f"__aqmp#{self._execute_id:05d}" + exec_id =3D f"__qmp#{self._execute_id:05d}" self._execute_id +=3D 1 return exec_id =20 @@ -476,7 +476,7 @@ async def _execute(self, msg: Message, assign_id: bool = =3D True) -> Message: An execution ID will be assigned if assign_id is `True`. It can be disabled, but this requires that an ID is manually assigned instead. For manually assigned IDs, you must not use the string - '__aqmp#' anywhere in the ID. + '__qmp#' anywhere in the ID. =20 :param msg: The QMP `Message` to execute. :param assign_id: If True, assign a new execution ID. @@ -490,7 +490,7 @@ async def _execute(self, msg: Message, assign_id: bool = =3D True) -> Message: msg['id'] =3D self._get_exec_id() elif 'id' in msg: assert isinstance(msg['id'], str) - assert '__aqmp#' not in msg['id'] + assert '__qmp#' not in msg['id'] =20 exec_id =3D await self._issue(msg) return await self._reply(exec_id) @@ -512,7 +512,7 @@ async def _raw( Assign an arbitrary execution ID to this message. If `False`, the existing id must either be absent (and no other such pending execution may omit an ID) or a string. If it is - a string, it must not start with '__aqmp#' and no other such + a string, it must not start with '__qmp#' and no other such pending execution may currently be using that ID. =20 :return: Execution reply from the server. @@ -524,7 +524,7 @@ async def _raw( When assign_id is `False`, an ID is given, and it is not a str= ing. :raise ValueError: When assign_id is `False`, but the ID is not usable; - Either because it starts with '__aqmp#' or it is already in-us= e. + Either because it starts with '__qmp#' or it is already in-use. """ # 1. convert generic Mapping or bytes to a QMP Message # 2. copy Message objects so that we assign an ID only to the copy. @@ -534,9 +534,9 @@ async def _raw( if not assign_id and 'id' in msg: if not isinstance(exec_id, str): raise TypeError(f"ID ('{exec_id}') must be a string.") - if exec_id.startswith('__aqmp#'): + if exec_id.startswith('__qmp#'): raise ValueError( - f"ID ('{exec_id}') must not start with '__aqmp#'." + f"ID ('{exec_id}') must not start with '__qmp#'." ) =20 if not assign_id and exec_id in self._pending: diff --git a/python/qemu/aqmp/qmp_shell.py b/python/qemu/qmp/qmp_shell.py similarity index 99% rename from python/qemu/aqmp/qmp_shell.py rename to python/qemu/qmp/qmp_shell.py index c23f1b19280..619ab42cedd 100644 --- a/python/qemu/aqmp/qmp_shell.py +++ b/python/qemu/qmp/qmp_shell.py @@ -98,8 +98,8 @@ Sequence, ) =20 -from qemu.aqmp import ConnectError, QMPError, SocketAddrT -from qemu.aqmp.legacy import ( +from qemu.qmp import ConnectError, QMPError, SocketAddrT +from qemu.qmp.legacy import ( QEMUMonitorProtocol, QMPBadPortError, QMPMessage, diff --git a/python/qemu/aqmp/util.py b/python/qemu/qmp/util.py similarity index 100% rename from python/qemu/aqmp/util.py rename to python/qemu/qmp/util.py diff --git a/python/qemu/utils/qemu_ga_client.py b/python/qemu/utils/qemu_g= a_client.py index 15ed430c618..8c38a7ac9c0 100644 --- a/python/qemu/utils/qemu_ga_client.py +++ b/python/qemu/utils/qemu_ga_client.py @@ -50,8 +50,8 @@ Sequence, ) =20 -from qemu.aqmp import ConnectError, SocketAddrT -from qemu.aqmp.legacy import QEMUMonitorProtocol +from qemu.qmp import ConnectError, SocketAddrT +from qemu.qmp.legacy import QEMUMonitorProtocol =20 =20 # This script has not seen many patches or careful attention in quite diff --git a/python/qemu/utils/qom.py b/python/qemu/utils/qom.py index bb5d1a78f59..bcf192f4774 100644 --- a/python/qemu/utils/qom.py +++ b/python/qemu/utils/qom.py @@ -32,7 +32,7 @@ =20 import argparse =20 -from qemu.aqmp import ExecuteError +from qemu.qmp import ExecuteError =20 from .qom_common import QOMCommand =20 diff --git a/python/qemu/utils/qom_common.py b/python/qemu/utils/qom_common= .py index e034a6f2476..80da1b23041 100644 --- a/python/qemu/utils/qom_common.py +++ b/python/qemu/utils/qom_common.py @@ -27,8 +27,8 @@ TypeVar, ) =20 -from qemu.aqmp import QMPError -from qemu.aqmp.legacy import QEMUMonitorProtocol +from qemu.qmp import QMPError +from qemu.qmp.legacy import QEMUMonitorProtocol =20 =20 class ObjectPropertyInfo: diff --git a/python/qemu/utils/qom_fuse.py b/python/qemu/utils/qom_fuse.py index 653a76b93b9..8dcd59fcde6 100644 --- a/python/qemu/utils/qom_fuse.py +++ b/python/qemu/utils/qom_fuse.py @@ -48,7 +48,7 @@ import fuse from fuse import FUSE, FuseOSError, Operations =20 -from qemu.aqmp import ExecuteError +from qemu.qmp import ExecuteError =20 from .qom_common import QOMCommand =20 diff --git a/python/setup.cfg b/python/setup.cfg index 49e3c285f19..773e51b34e7 100644 --- a/python/setup.cfg +++ b/python/setup.cfg @@ -24,7 +24,7 @@ classifiers =3D [options] python_requires =3D >=3D 3.6 packages =3D - qemu.aqmp + qemu.qmp qemu.machine qemu.utils =20 @@ -66,9 +66,9 @@ console_scripts =3D qom-tree =3D qemu.utils.qom:QOMTree.entry_point qom-fuse =3D qemu.utils.qom_fuse:QOMFuse.entry_point [fuse] qemu-ga-client =3D qemu.utils.qemu_ga_client:main - qmp-shell =3D qemu.aqmp.qmp_shell:main - qmp-shell-wrap =3D qemu.aqmp.qmp_shell:main_wrap - aqmp-tui =3D qemu.aqmp.aqmp_tui:main [tui] + qmp-shell =3D qemu.qmp.qmp_shell:main + qmp-shell-wrap =3D qemu.qmp.qmp_shell:main_wrap + aqmp-tui =3D qemu.qmp.aqmp_tui:main [tui] =20 [flake8] extend-ignore =3D E722 # Prefer pylint's bare-except checks to flake8's @@ -84,7 +84,7 @@ namespace_packages =3D True # fusepy has no type stubs: allow_subclassing_any =3D True =20 -[mypy-qemu.aqmp.aqmp_tui] +[mypy-qemu.qmp.aqmp_tui] # urwid and urwid_readline have no type stubs: allow_subclassing_any =3D True =20 diff --git a/python/tests/protocol.py b/python/tests/protocol.py index d6849ad3062..56c4d441f9c 100644 --- a/python/tests/protocol.py +++ b/python/tests/protocol.py @@ -6,9 +6,9 @@ =20 import avocado =20 -from qemu.aqmp import ConnectError, Runstate -from qemu.aqmp.protocol import AsyncProtocol, StateError -from qemu.aqmp.util import asyncio_run, create_task +from qemu.qmp import ConnectError, Runstate +from qemu.qmp.protocol import AsyncProtocol, StateError +from qemu.qmp.util import asyncio_run, create_task =20 =20 class NullProtocol(AsyncProtocol[None]): @@ -183,7 +183,7 @@ def testDefaultName(self): def testLogger(self): self.assertEqual( self.proto.logger.name, - 'qemu.aqmp.protocol' + 'qemu.qmp.protocol' ) =20 def testName(self): @@ -196,7 +196,7 @@ def testName(self): =20 self.assertEqual( self.proto.logger.name, - 'qemu.aqmp.protocol.Steve' + 'qemu.qmp.protocol.Steve' ) =20 self.assertEqual( @@ -431,7 +431,7 @@ async def _bad_connection(self, family: str): await self.proto.start_server_and_accept('/dev/null') =20 async def _hanging_connection(self): - with TemporaryDirectory(suffix=3D'.aqmp') as tmpdir: + with TemporaryDirectory(suffix=3D'.qmp') as tmpdir: sock =3D os.path.join(tmpdir, type(self.proto).__name__ + ".so= ck") await self.proto.start_server_and_accept(sock) =20 @@ -587,7 +587,7 @@ async def _asyncTearDown(self): =20 @TestBase.async_test async def testSmoke(self): - with TemporaryDirectory(suffix=3D'.aqmp') as tmpdir: + with TemporaryDirectory(suffix=3D'.qmp') as tmpdir: sock =3D os.path.join(tmpdir, type(self.proto).__name__ + ".so= ck") server_task =3D create_task(self.server.start_server_and_accep= t(sock)) =20 diff --git a/scripts/cpu-x86-uarch-abi.py b/scripts/cpu-x86-uarch-abi.py index c262d2f0277..82ff07582f8 100644 --- a/scripts/cpu-x86-uarch-abi.py +++ b/scripts/cpu-x86-uarch-abi.py @@ -6,7 +6,7 @@ # compatibility levels for each CPU model. # =20 -from qemu.aqmp.legacy import QEMUMonitorProtocol +from qemu.qmp.legacy import QEMUMonitorProtocol import sys =20 if len(sys.argv) !=3D 2: diff --git a/scripts/device-crash-test b/scripts/device-crash-test index 7fbd99158be..4bfc68c0087 100755 --- a/scripts/device-crash-test +++ b/scripts/device-crash-test @@ -36,7 +36,7 @@ from itertools import chain =20 sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'python')) from qemu.machine import QEMUMachine -from qemu.aqmp import ConnectError +from qemu.qmp import ConnectError =20 logger =3D logging.getLogger('device-crash-test') dbg =3D logger.debug @@ -517,7 +517,7 @@ def main(): # Async QMP, when in use, is chatty about connection failures. # This script knowingly generates a ton of connection errors. # Silence this logger. - logging.getLogger('qemu.aqmp.qmp_client').setLevel(logging.CRITICA= L) + logging.getLogger('qemu.qmp.qmp_client').setLevel(logging.CRITICAL) =20 fatal_failures =3D [] wl_stats =3D {} diff --git a/scripts/qmp/qmp-shell b/scripts/qmp/qmp-shell index 31b19d73e22..4a20f97db70 100755 --- a/scripts/qmp/qmp-shell +++ b/scripts/qmp/qmp-shell @@ -4,7 +4,7 @@ import os import sys =20 sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'pytho= n')) -from qemu.aqmp import qmp_shell +from qemu.qmp import qmp_shell =20 =20 if __name__ =3D=3D '__main__': diff --git a/scripts/qmp/qmp-shell-wrap b/scripts/qmp/qmp-shell-wrap index 66846e36d1f..9e94da114f5 100755 --- a/scripts/qmp/qmp-shell-wrap +++ b/scripts/qmp/qmp-shell-wrap @@ -4,7 +4,7 @@ import os import sys =20 sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'pytho= n')) -from qemu.aqmp import qmp_shell +from qemu.qmp import qmp_shell =20 =20 if __name__ =3D=3D '__main__': diff --git a/scripts/render_block_graph.py b/scripts/render_block_graph.py index b33fb70d5ee..8f731a5cfe1 100755 --- a/scripts/render_block_graph.py +++ b/scripts/render_block_graph.py @@ -25,8 +25,8 @@ from graphviz import Digraph =20 sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'python')) -from qemu.aqmp import QMPError -from qemu.aqmp.legacy import QEMUMonitorProtocol +from qemu.qmp import QMPError +from qemu.qmp.legacy import QEMUMonitorProtocol =20 =20 def perm(arr): diff --git a/scripts/simplebench/bench_block_job.py b/scripts/simplebench/b= ench_block_job.py index af9d1646a46..56191db44b2 100755 --- a/scripts/simplebench/bench_block_job.py +++ b/scripts/simplebench/bench_block_job.py @@ -27,7 +27,7 @@ =20 sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'pytho= n')) from qemu.machine import QEMUMachine -from qemu.aqmp import ConnectError +from qemu.qmp import ConnectError =20 =20 def bench_block_job(cmd, cmd_args, qemu_args): diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index 56cbad244f9..87eb5f542f5 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -37,8 +37,8 @@ =20 from contextlib import contextmanager =20 -from qemu.aqmp.legacy import QMPMessage, QEMUMonitorProtocol from qemu.machine import qtest +from qemu.qmp.legacy import QMPMessage, QEMUMonitorProtocol from qemu.utils import VerboseProcessError =20 # Use this logger for logging messages directly from the iotests module diff --git a/tests/qemu-iotests/tests/mirror-top-perms b/tests/qemu-iotests= /tests/mirror-top-perms index a9f275cd7f2..8bca5927089 100755 --- a/tests/qemu-iotests/tests/mirror-top-perms +++ b/tests/qemu-iotests/tests/mirror-top-perms @@ -97,8 +97,8 @@ class TestMirrorTopPerms(iotests.QMPTestCase): self.vm_b.add_blockdev(f'file,node-name=3Ddrive0,filename=3D{sourc= e}') self.vm_b.add_device('virtio-blk,drive=3Ddrive0,share-rw=3Don') try: - # Silence AQMP logging errors temporarily. - with change_log_level('qemu.aqmp'): + # Silence QMP logging errors temporarily. + with change_log_level('qemu.qmp'): self.vm_b.launch() print('ERROR: VM B launched successfully, ' 'this should not have happened') --=20 2.34.1 From nobody Mon Feb 9 01:03:31 2026 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1648661550478933.7594889161411; Wed, 30 Mar 2022 10:32:30 -0700 (PDT) Received: from localhost ([::1]:35570 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nZcBJ-0005PD-6L for importer@patchew.org; Wed, 30 Mar 2022 13:32:29 -0400 Received: from eggs.gnu.org ([209.51.188.92]:34852) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nZc7U-00061P-T4 for qemu-devel@nongnu.org; Wed, 30 Mar 2022 13:28:32 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:27090) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nZc7S-0003Lo-So for qemu-devel@nongnu.org; Wed, 30 Mar 2022 13:28:32 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-381--GMWzKeCP9Ct4D3MucWIkg-1; Wed, 30 Mar 2022 13:28:28 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5C4C083395F; Wed, 30 Mar 2022 17:28:28 +0000 (UTC) Received: from scv.redhat.com (unknown [10.22.35.177]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0220D40CFD02; Wed, 30 Mar 2022 17:28:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1648661310; 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=wIedATEMbLm8tOZpNi+wLoXYeYnw8oOQd+pHDx0T0lY=; b=K2pSHY+QitP0I0jvIx/k7p7s8Y+LAGlBTcB4UNPLv/8/YyEsC7DDmvvL7D3M1oduvCPWI5 F9EHcl7J+oqJSs+qnsCTgj0qJ5FvabU9CgMBjz8iDehEneQxguHEK3iciIYlEU+gQOIkmb ziuBAAsvKJyPnF6aYzlDYkP/jXOwRqs= X-MC-Unique: -GMWzKeCP9Ct4D3MucWIkg-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v2 8/9] python: rename 'aqmp-tui' to 'qmp-tui' Date: Wed, 30 Mar 2022 13:28:11 -0400 Message-Id: <20220330172812.3427355-9-jsnow@redhat.com> In-Reply-To: <20220330172812.3427355-1-jsnow@redhat.com> References: <20220330172812.3427355-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 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=170.10.129.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Vladimir Sementsov-Ogievskiy , Beraldo Leal , qemu-block@nongnu.org, Markus Armbruster , Hanna Reitz , Cleber Rosa , John Snow Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1648661551144100001 Content-Type: text/plain; charset="utf-8"; x-default="true" This is the last vestige of the "aqmp" moniker surviving in the tree; remov= e it. Signed-off-by: John Snow Reviewed-by: Beraldo Leal Reviewed-by: Vladimir Sementsov-Ogievskiy --- python/qemu/qmp/{aqmp_tui.py =3D> qmp_tui.py} | 12 ++++++------ python/setup.cfg | 6 +++--- 2 files changed, 9 insertions(+), 9 deletions(-) rename python/qemu/qmp/{aqmp_tui.py =3D> qmp_tui.py} (98%) diff --git a/python/qemu/qmp/aqmp_tui.py b/python/qemu/qmp/qmp_tui.py similarity index 98% rename from python/qemu/qmp/aqmp_tui.py rename to python/qemu/qmp/qmp_tui.py index 59d3036be38..ce239d8979b 100644 --- a/python/qemu/qmp/aqmp_tui.py +++ b/python/qemu/qmp/qmp_tui.py @@ -6,13 +6,13 @@ # This work is licensed under the terms of the GNU LGPL, version 2 or # later. See the COPYING file in the top-level directory. """ -AQMP TUI +QMP TUI =20 -AQMP TUI is an asynchronous interface built on top the of the AQMP library. +QMP TUI is an asynchronous interface built on top the of the QMP library. It is the successor of QMP-shell and is bought-in as a replacement for it. =20 -Example Usage: aqmp-tui -Full Usage: aqmp-tui --help +Example Usage: qmp-tui +Full Usage: qmp-tui --help """ =20 import argparse @@ -129,7 +129,7 @@ def has_handler_type(logger: logging.Logger, =20 class App(QMPClient): """ - Implements the AQMP TUI. + Implements the QMP TUI. =20 Initializes the widgets and starts the urwid event loop. =20 @@ -612,7 +612,7 @@ def main() -> None: Driver of the whole script, parses arguments, initialize the TUI and the logger. """ - parser =3D argparse.ArgumentParser(description=3D'AQMP TUI') + parser =3D argparse.ArgumentParser(description=3D'QMP TUI') parser.add_argument('qmp_server', help=3D'Address of the QMP server. ' 'Format ') parser.add_argument('--num-retries', type=3Dint, default=3D10, diff --git a/python/setup.cfg b/python/setup.cfg index 773e51b34e7..e877ea56475 100644 --- a/python/setup.cfg +++ b/python/setup.cfg @@ -51,7 +51,7 @@ devel =3D fuse =3D fusepy >=3D 2.0.4 =20 -# AQMP TUI dependencies +# QMP TUI dependencies tui =3D urwid >=3D 2.1.2 urwid-readline >=3D 0.13 @@ -68,7 +68,7 @@ console_scripts =3D qemu-ga-client =3D qemu.utils.qemu_ga_client:main qmp-shell =3D qemu.qmp.qmp_shell:main qmp-shell-wrap =3D qemu.qmp.qmp_shell:main_wrap - aqmp-tui =3D qemu.qmp.aqmp_tui:main [tui] + qmp-tui =3D qemu.qmp.qmp_tui:main [tui] =20 [flake8] extend-ignore =3D E722 # Prefer pylint's bare-except checks to flake8's @@ -84,7 +84,7 @@ namespace_packages =3D True # fusepy has no type stubs: allow_subclassing_any =3D True =20 -[mypy-qemu.qmp.aqmp_tui] +[mypy-qemu.qmp.qmp_tui] # urwid and urwid_readline have no type stubs: allow_subclassing_any =3D True =20 --=20 2.34.1 From nobody Mon Feb 9 01:03:31 2026 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1648661748676859.7888040342189; Wed, 30 Mar 2022 10:35:48 -0700 (PDT) Received: from localhost ([::1]:42672 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nZcEV-0001jP-BE for importer@patchew.org; Wed, 30 Mar 2022 13:35:47 -0400 Received: from eggs.gnu.org ([209.51.188.92]:34952) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nZc7X-0006Aq-Hp for qemu-devel@nongnu.org; Wed, 30 Mar 2022 13:28:35 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:27704) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nZc7U-0003Md-Ij for qemu-devel@nongnu.org; Wed, 30 Mar 2022 13:28:35 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-654-KtR45MCUOq-59mASGJu9pw-1; Wed, 30 Mar 2022 13:28:29 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C3633280095B; Wed, 30 Mar 2022 17:28:28 +0000 (UTC) Received: from scv.redhat.com (unknown [10.22.35.177]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6981C40CFD02; Wed, 30 Mar 2022 17:28:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1648661311; 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=30h2wKwFCaxWQFIbjK2JOUua867dKxcgSGTl31iyfsw=; b=WdWnp7C9Up7zvzlUH7HXGQwtRhSpMNj7VPMbAAeaIW/OgrXGYjJwHOUcx1kUbO8F/WOIpT rnHIGphnl8Hemdw90nxDO711wwXLQzdIP/F+VL0hQ92mysDm5lj2jLjua12F97s35wVEjI 2qFXjjulCWGFmnYRWYPm6XvCGLzF3KA= X-MC-Unique: KtR45MCUOq-59mASGJu9pw-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v2 9/9] python/qmp: remove pylint workaround from legacy.py Date: Wed, 30 Mar 2022 13:28:12 -0400 Message-Id: <20220330172812.3427355-10-jsnow@redhat.com> In-Reply-To: <20220330172812.3427355-1-jsnow@redhat.com> References: <20220330172812.3427355-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 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=170.10.133.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Vladimir Sementsov-Ogievskiy , Beraldo Leal , qemu-block@nongnu.org, Markus Armbruster , Hanna Reitz , Cleber Rosa , John Snow Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1648661750715100001 Content-Type: text/plain; charset="utf-8"; x-default="true" Pylint upgraded recently (2.13.z) and having a pylint: disable comment in the middle of an argument field causes it some grief (It appears to stop parsing when it encounters it, causing some syntax problems). Since the duplicate line threshold was bumped up in 22305c2a081b, we don't need this workaround anymore. Drop it. Signed-off-by: John Snow Reviewed-by: Vladimir Sementsov-Ogievskiy --- python/qemu/qmp/legacy.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/python/qemu/qmp/legacy.py b/python/qemu/qmp/legacy.py index a8629b44dff..03b5574618f 100644 --- a/python/qemu/qmp/legacy.py +++ b/python/qemu/qmp/legacy.py @@ -106,8 +106,6 @@ def __enter__(self: _T) -> _T: return self =20 def __exit__(self, - # pylint: disable=3Dduplicate-code - # see https://github.com/PyCQA/pylint/issues/3619 exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType]) -> None: --=20 2.34.1