From nobody Sat Apr 27 02:46:16 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1637782186968183.26511032607505; Wed, 24 Nov 2021 11:29:46 -0800 (PST) Received: from localhost ([::1]:42036 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mpxxf-0006RL-El for importer@patchew.org; Wed, 24 Nov 2021 14:29:43 -0500 Received: from eggs.gnu.org ([209.51.188.92]:35460) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mpxuz-0003Pm-SD for qemu-devel@nongnu.org; Wed, 24 Nov 2021 14:26:57 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:46202) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mpxux-0007Zv-9r for qemu-devel@nongnu.org; Wed, 24 Nov 2021 14:26:56 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-429-h1cw6esbOeSaSESYrGH4QA-1; Wed, 24 Nov 2021 14:26:51 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 56D9687A842; Wed, 24 Nov 2021 19:26:48 +0000 (UTC) Received: from scv.redhat.com (unknown [10.22.9.79]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5608F7DE58; Wed, 24 Nov 2021 19:26:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1637782012; 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=4S9SIOCySwJsiETo45OdWYDFRUqMH9u8CfVImMkxZNY=; b=D7kbOjon08rj3+QUgfHejqMPZAJ/Js6r0idAnFYHrCAanI0c9B2iZTavIjVK3DVkCIJc9b TwmNhxyXmmPGm5vw0SewjYhHJYXqXUgPvZe3jCbnNNyqDomsXvXFZ+JyckHkLm/pBe2kXk Yi7HWcztswMou5NQjvFvfBTgNMk8IRQ= X-MC-Unique: h1cw6esbOeSaSESYrGH4QA-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH 01/23] python/aqmp: add __del__ method to legacy interface Date: Wed, 24 Nov 2021 14:25:55 -0500 Message-Id: <20211124192617.3396403-2-jsnow@redhat.com> In-Reply-To: <20211124192617.3396403-1-jsnow@redhat.com> References: <20211124192617.3396403-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=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: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.7, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Vladimir Sementsov-Ogievskiy , Eduardo Habkost , qemu-block@nongnu.org, Markus Armbruster , Hanna Reitz , Gerd Hoffmann , 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: 1637782189858100001 Content-Type: text/plain; charset="utf-8" asyncio can complain *very* loudly if you forget to back out of things gracefully before the garbage collector starts destroying objects that contain live references to asyncio Tasks. The usual fix is just to remember to call aqmp.disconnect(), but for the sake of the legacy wrapper and quick, one-off scripts where a graceful shutdown is not necessarily of paramount imporance, add a courtesy cleanup that will trigger prior to seeing screenfuls of confusing asyncio tracebacks. Note that we can't *always* save you from yourself; depending on when the GC runs, you might just seriously be out of luck. The best we can do in this case is to gently remind you to clean up after yourself. (Still much better than multiple pages of incomprehensible python warnings for the crime of forgetting to put your toys away.) Signed-off-by: John Snow --- python/qemu/aqmp/legacy.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/python/qemu/aqmp/legacy.py b/python/qemu/aqmp/legacy.py index 9e7b9fb80b..2ccb136b02 100644 --- a/python/qemu/aqmp/legacy.py +++ b/python/qemu/aqmp/legacy.py @@ -16,6 +16,8 @@ import qemu.qmp from qemu.qmp import QMPMessage, QMPReturnValue, SocketAddrT =20 +from .error import AQMPError +from .protocol import Runstate from .qmp_client import QMPClient =20 =20 @@ -136,3 +138,19 @@ def settimeout(self, timeout: Optional[float]) -> None: =20 def send_fd_scm(self, fd: int) -> None: self._aqmp.send_fd_scm(fd) + + def __del__(self) -> None: + if self._aqmp.runstate =3D=3D Runstate.IDLE: + return + + if not self._aloop.is_running(): + self.close() + else: + # Garbage collection ran while the event loop was running. + # Nothing we can do about it now, but if we don't raise our + # own error, the user will be treated to a lot of traceback + # they might not understand. + raise AQMPError( + "QEMUMonitorProtocol.close()" + " was not called before object was garbage collected" + ) --=20 2.31.1 From nobody Sat Apr 27 02:46:16 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1637782219943933.3423674462501; Wed, 24 Nov 2021 11:30:19 -0800 (PST) Received: from localhost ([::1]:42808 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mpxyD-0006wN-UC for importer@patchew.org; Wed, 24 Nov 2021 14:30:17 -0500 Received: from eggs.gnu.org ([209.51.188.92]:35500) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mpxv0-0003Q0-5F for qemu-devel@nongnu.org; Wed, 24 Nov 2021 14:27:01 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:46189) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mpxuy-0007aC-I2 for qemu-devel@nongnu.org; Wed, 24 Nov 2021 14:26:57 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-497-bXPmIAgDOOSgpvrteCQCKA-1; Wed, 24 Nov 2021 14:26:52 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id AA2A510557D5; Wed, 24 Nov 2021 19:26:49 +0000 (UTC) Received: from scv.redhat.com (unknown [10.22.9.79]) by smtp.corp.redhat.com (Postfix) with ESMTP id 744687DE5B; Wed, 24 Nov 2021 19:26:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1637782016; 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=mTPg9OlYaEtMoVYo4OhIjZOaYBewhMFH9YhQB2XHl64=; b=MZKOWxlKAgJe4sUJdBHmhS3eQCrNo9sdVVRHpE+CR9azSxMzNYCi9sOf5O79UjhCN5232c 673qQ/A76gyNB3rPtHUmm89QEaDt3/v33MbZFXjKQGa1Pr5B/8rXB+aWxz4y00VP4zvOCg YSLW7sKoVbNKZpu0GtievWf4eZODu8Q= X-MC-Unique: bXPmIAgDOOSgpvrteCQCKA-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH 02/23] python/aqmp: handle asyncio.TimeoutError on execute() Date: Wed, 24 Nov 2021 14:25:56 -0500 Message-Id: <20211124192617.3396403-3-jsnow@redhat.com> In-Reply-To: <20211124192617.3396403-1-jsnow@redhat.com> References: <20211124192617.3396403-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=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: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.7, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Vladimir Sementsov-Ogievskiy , Eduardo Habkost , qemu-block@nongnu.org, Markus Armbruster , Hanna Reitz , Gerd Hoffmann , 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: 1637782221958100001 Content-Type: text/plain; charset="utf-8" This exception can be injected into any await statement. If we are canceled via timeout, we want to clear the pending execution record on our way out. Signed-off-by: John Snow --- python/qemu/aqmp/qmp_client.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/python/qemu/aqmp/qmp_client.py b/python/qemu/aqmp/qmp_client.py index 8105e29fa8..6a985ffe30 100644 --- a/python/qemu/aqmp/qmp_client.py +++ b/python/qemu/aqmp/qmp_client.py @@ -435,7 +435,11 @@ async def _issue(self, msg: Message) -> Union[None, st= r]: msg_id =3D msg['id'] =20 self._pending[msg_id] =3D asyncio.Queue(maxsize=3D1) - await self._outgoing.put(msg) + try: + await self._outgoing.put(msg) + except: + del self._pending[msg_id] + raise =20 return msg_id =20 @@ -452,9 +456,9 @@ async def _reply(self, msg_id: Union[str, None]) -> Mes= sage: was lost, or some other problem. """ queue =3D self._pending[msg_id] - result =3D await queue.get() =20 try: + result =3D await queue.get() if isinstance(result, ExecInterruptedError): raise result return result --=20 2.31.1 From nobody Sat Apr 27 02:46:16 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1637782476996996.6720076474462; Wed, 24 Nov 2021 11:34:36 -0800 (PST) Received: from localhost ([::1]:51760 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mpy2M-0004k7-Rm for importer@patchew.org; Wed, 24 Nov 2021 14:34:34 -0500 Received: from eggs.gnu.org ([209.51.188.92]:35526) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mpxv1-0003QX-3r for qemu-devel@nongnu.org; Wed, 24 Nov 2021 14:27:01 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:36432) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mpxuz-0007aN-DM for qemu-devel@nongnu.org; Wed, 24 Nov 2021 14:26:58 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-270-gLWGUde8PUOYVrJT47upFA-1; Wed, 24 Nov 2021 14:26:54 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id CFDF4101D61F; Wed, 24 Nov 2021 19:26:50 +0000 (UTC) Received: from scv.redhat.com (unknown [10.22.9.79]) by smtp.corp.redhat.com (Postfix) with ESMTP id CEC0E79C53; Wed, 24 Nov 2021 19:26:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1637782016; 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=zOfDKqXxhoCUTexfpJWO4hRlK2KV3C8drQlDp+KAl3E=; b=cpCJxwE1itPEgUCVhd7FZ4fp2w31oBjpybOkoDJK4qFTh36TfHNniveN2PavLUdF4VfzB2 3cQWKSAodNGdTiI+9S7yzPT/tsSFsyc7lhdhDFF2daRMK3WN8VBIyUWZteJ7lwgE8tgFUA X+l1K5N5xpEDkosXk2hqHHazNc2LnzE= X-MC-Unique: gLWGUde8PUOYVrJT47upFA-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH 03/23] python/aqmp: copy type definitions from qmp Date: Wed, 24 Nov 2021 14:25:57 -0500 Message-Id: <20211124192617.3396403-4-jsnow@redhat.com> In-Reply-To: <20211124192617.3396403-1-jsnow@redhat.com> References: <20211124192617.3396403-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=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: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.7, 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_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Vladimir Sementsov-Ogievskiy , Eduardo Habkost , qemu-block@nongnu.org, Markus Armbruster , Hanna Reitz , Gerd Hoffmann , 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: 1637782477731100001 Content-Type: text/plain; charset="utf-8" Copy the remaining type definitions from QMP into the qemu.aqmp.legacy module. Now, most users don't need to import anything else but qemu.aqmp.legacy. Signed-off-by: John Snow --- python/qemu/aqmp/legacy.py | 22 ++++++++++++++++++++-- python/qemu/aqmp/protocol.py | 16 ++++++++++------ 2 files changed, 30 insertions(+), 8 deletions(-) diff --git a/python/qemu/aqmp/legacy.py b/python/qemu/aqmp/legacy.py index 2ccb136b02..9431fe9330 100644 --- a/python/qemu/aqmp/legacy.py +++ b/python/qemu/aqmp/legacy.py @@ -6,7 +6,9 @@ =20 import asyncio from typing import ( + Any, Awaitable, + Dict, List, Optional, TypeVar, @@ -14,13 +16,29 @@ ) =20 import qemu.qmp -from qemu.qmp import QMPMessage, QMPReturnValue, SocketAddrT =20 from .error import AQMPError -from .protocol import Runstate +from .protocol import Runstate, SocketAddrT from .qmp_client import QMPClient =20 =20 +#: 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. + + # pylint: disable=3Dmissing-docstring =20 =20 diff --git a/python/qemu/aqmp/protocol.py b/python/qemu/aqmp/protocol.py index 5190b33b13..42a897e2fe 100644 --- a/python/qemu/aqmp/protocol.py +++ b/python/qemu/aqmp/protocol.py @@ -46,6 +46,10 @@ _TaskFN =3D Callable[[], Awaitable[None]] # aka ``async def func() -> Non= e`` _FutureT =3D TypeVar('_FutureT', bound=3DOptional['asyncio.Future[Any]']) =20 +InternetAddrT =3D Tuple[str, int] +UnixAddrT =3D str +SocketAddrT =3D Union[UnixAddrT, InternetAddrT] + =20 class Runstate(Enum): """Protocol session runstate.""" @@ -257,7 +261,7 @@ async def runstate_changed(self) -> Runstate: =20 @upper_half @require(Runstate.IDLE) - async def accept(self, address: Union[str, Tuple[str, int]], + async def accept(self, address: SocketAddrT, ssl: Optional[SSLContext] =3D None) -> None: """ Accept a connection and begin processing message queues. @@ -275,7 +279,7 @@ async def accept(self, address: Union[str, Tuple[str, i= nt]], =20 @upper_half @require(Runstate.IDLE) - async def connect(self, address: Union[str, Tuple[str, int]], + async def connect(self, address: SocketAddrT, ssl: Optional[SSLContext] =3D None) -> None: """ Connect to the server and begin processing message queues. @@ -337,7 +341,7 @@ def _set_state(self, state: Runstate) -> None: =20 @upper_half async def _new_session(self, - address: Union[str, Tuple[str, int]], + address: SocketAddrT, ssl: Optional[SSLContext] =3D None, accept: bool =3D False) -> None: """ @@ -397,7 +401,7 @@ async def _new_session(self, @upper_half async def _establish_connection( self, - address: Union[str, Tuple[str, int]], + address: SocketAddrT, ssl: Optional[SSLContext] =3D None, accept: bool =3D False ) -> None: @@ -424,7 +428,7 @@ async def _establish_connection( await self._do_connect(address, ssl) =20 @upper_half - async def _do_accept(self, address: Union[str, Tuple[str, int]], + async def _do_accept(self, address: SocketAddrT, ssl: Optional[SSLContext] =3D None) -> None: """ Acting as the transport server, accept a single connection. @@ -482,7 +486,7 @@ async def _client_connected_cb(reader: asyncio.StreamRe= ader, self.logger.debug("Connection accepted.") =20 @upper_half - async def _do_connect(self, address: Union[str, Tuple[str, int]], + async def _do_connect(self, address: SocketAddrT, ssl: Optional[SSLContext] =3D None) -> None: """ Acting as the transport client, initiate a connection to a server. --=20 2.31.1 From nobody Sat Apr 27 02:46:16 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1637782470763642.90066947637; Wed, 24 Nov 2021 11:34:30 -0800 (PST) Received: from localhost ([::1]:51554 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mpy2F-0004al-NM for importer@patchew.org; Wed, 24 Nov 2021 14:34:27 -0500 Received: from eggs.gnu.org ([209.51.188.92]:35542) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mpxv2-0003QZ-9g for qemu-devel@nongnu.org; Wed, 24 Nov 2021 14:27:01 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:54722) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mpxuz-0007ac-R7 for qemu-devel@nongnu.org; Wed, 24 Nov 2021 14:26:58 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-307-DB4dMt8uPma95kdbo9PlNw-1; Wed, 24 Nov 2021 14:26:56 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0E794193F58B; Wed, 24 Nov 2021 19:26:52 +0000 (UTC) Received: from scv.redhat.com (unknown [10.22.9.79]) by smtp.corp.redhat.com (Postfix) with ESMTP id F3A196C352; Wed, 24 Nov 2021 19:26:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1637782017; 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=MiilU32l9qViD/3YblCdYLylKpNf5B/qdJ+hyjphUbk=; b=BszD+CSu+rF536Ivkrgf0oHqkSjJMlyod/vnq4YFfaGIcO/MtbQCz9HldgVU3IANWyJ53/ fjWhJbH4ILtPQp7PZ7Y9rH/dyalzwv6SYepw7XpEAlBznvu5eEVjWNE+WBcn5z2czFlOCB gmjLgDbORhXOdzhYYNrffGLfEZ4eiHg= X-MC-Unique: DB4dMt8uPma95kdbo9PlNw-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH 04/23] python/aqmp: add SocketAddrT to package root Date: Wed, 24 Nov 2021 14:25:58 -0500 Message-Id: <20211124192617.3396403-5-jsnow@redhat.com> In-Reply-To: <20211124192617.3396403-1-jsnow@redhat.com> References: <20211124192617.3396403-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=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: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.7, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Vladimir Sementsov-Ogievskiy , Eduardo Habkost , qemu-block@nongnu.org, Markus Armbruster , Hanna Reitz , Gerd Hoffmann , 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: 1637782472423100001 Content-Type: text/plain; charset="utf-8" It's a commonly needed definition, it can be re-exported by the root. Signed-off-by: John Snow --- python/qemu/aqmp/__init__.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/python/qemu/aqmp/__init__.py b/python/qemu/aqmp/__init__.py index 880d5b6fa7..c6fa2dda58 100644 --- a/python/qemu/aqmp/__init__.py +++ b/python/qemu/aqmp/__init__.py @@ -26,7 +26,12 @@ from .error import AQMPError from .events import EventListener from .message import Message -from .protocol import ConnectError, Runstate, StateError +from .protocol import ( + ConnectError, + Runstate, + SocketAddrT, + StateError, +) from .qmp_client import ExecInterruptedError, ExecuteError, QMPClient =20 =20 @@ -48,4 +53,7 @@ 'ConnectError', 'ExecuteError', 'ExecInterruptedError', + + # Type aliases + 'SocketAddrT', ) --=20 2.31.1 From nobody Sat Apr 27 02:46:16 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1637782189836367.56539253990036; Wed, 24 Nov 2021 11:29:49 -0800 (PST) Received: from localhost ([::1]:42324 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mpxxj-0006dG-KL for importer@patchew.org; Wed, 24 Nov 2021 14:29:47 -0500 Received: from eggs.gnu.org ([209.51.188.92]:35610) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mpxv6-0003S2-JR for qemu-devel@nongnu.org; Wed, 24 Nov 2021 14:27:07 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:51869) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mpxv4-0007bS-Oq for qemu-devel@nongnu.org; Wed, 24 Nov 2021 14:27:04 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-42-uKRenrfkMhiApUhOC5a5pg-1; Wed, 24 Nov 2021 14:26:57 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1C2A685B68E; Wed, 24 Nov 2021 19:26:53 +0000 (UTC) Received: from scv.redhat.com (unknown [10.22.9.79]) by smtp.corp.redhat.com (Postfix) with ESMTP id 196087E656; Wed, 24 Nov 2021 19:26:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1637782020; 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=8fkM3RzKN38Ml/3hwMhJ0HBNIBPBNdszQjmOJHoSID4=; b=EJ3El0hecyo3gpTeNEP2S97VPPICtJoUVOH/fCCm8aWw3s34ehI0/OLzmgcAL/dtdYziPn piGG1Dalm6ahPZU2cDHLMyCVlEO6vcth0mTPMdOIgxz25XzEZin98ER2t5Z3n67eHERk/S 3ucSAQOBDiPZ7y7aTMAC0t1YTv8jOoE= X-MC-Unique: uKRenrfkMhiApUhOC5a5pg-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH 05/23] python/qemu-ga-client: update instructions to newer CLI syntax Date: Wed, 24 Nov 2021 14:25:59 -0500 Message-Id: <20211124192617.3396403-6-jsnow@redhat.com> In-Reply-To: <20211124192617.3396403-1-jsnow@redhat.com> References: <20211124192617.3396403-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=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: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.7, 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_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Vladimir Sementsov-Ogievskiy , Eduardo Habkost , qemu-block@nongnu.org, Markus Armbruster , Hanna Reitz , Gerd Hoffmann , 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: 1637782191909100003 Content-Type: text/plain; charset="utf-8" Signed-off-by: John Snow --- python/qemu/qmp/qemu_ga_client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/qemu/qmp/qemu_ga_client.py b/python/qemu/qmp/qemu_ga_cl= ient.py index 67ac0b4211..b3e1d98c9e 100644 --- a/python/qemu/qmp/qemu_ga_client.py +++ b/python/qemu/qmp/qemu_ga_client.py @@ -5,7 +5,7 @@ =20 Start QEMU with: =20 -# qemu [...] -chardev socket,path=3D/tmp/qga.sock,server,wait=3Doff,id=3Dq= ga0 \ +# qemu [...] -chardev socket,path=3D/tmp/qga.sock,server=3Don,wait=3Doff,i= d=3Dqga0 \ -device virtio-serial \ -device virtserialport,chardev=3Dqga0,name=3Dorg.qemu.guest_agent.0 =20 --=20 2.31.1 From nobody Sat Apr 27 02:46:16 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1637782740896615.117799754996; Wed, 24 Nov 2021 11:39:00 -0800 (PST) Received: from localhost ([::1]:60968 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mpy6c-0002ce-I9 for importer@patchew.org; Wed, 24 Nov 2021 14:38:58 -0500 Received: from eggs.gnu.org ([209.51.188.92]:35604) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mpxv6-0003S1-Dx for qemu-devel@nongnu.org; Wed, 24 Nov 2021 14:27:07 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:32841) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mpxv3-0007bQ-4j for qemu-devel@nongnu.org; Wed, 24 Nov 2021 14:27:03 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-240-8r2BpKtoMHSIIa0cWMNLyg-1; Wed, 24 Nov 2021 14:26:59 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 35E57A0CB8; Wed, 24 Nov 2021 19:26:54 +0000 (UTC) Received: from scv.redhat.com (unknown [10.22.9.79]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3E87E7AD1F; Wed, 24 Nov 2021 19:26:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1637782020; 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=vLFhR7ZJ7BWeCLyQJFXmxjzGjmcX2i8VzFRc8cNrtAM=; b=VIFqDTrH1Qk0qHVE0xwl1n+rKZIO77jNfuBJ+8/eLJ6wydsVBuA9A77LuSrBr7zen60/A9 bZoNFsC+fv/LhpcBfry3Ki1Wz1SzHaE1j+I/eZg2PYtfjaSL/Qj9QTQJ70/D6t+sBsfBO4 TD6mY2QpJ6QtDSykq12nQeXFpJnNiyc= X-MC-Unique: 8r2BpKtoMHSIIa0cWMNLyg-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH 06/23] python/qmp: switch qemu-ga-client to AQMP Date: Wed, 24 Nov 2021 14:26:00 -0500 Message-Id: <20211124192617.3396403-7-jsnow@redhat.com> In-Reply-To: <20211124192617.3396403-1-jsnow@redhat.com> References: <20211124192617.3396403-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=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: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.7, 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_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Vladimir Sementsov-Ogievskiy , Eduardo Habkost , qemu-block@nongnu.org, Markus Armbruster , Hanna Reitz , Gerd Hoffmann , 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: 1637782742016100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: John Snow --- python/qemu/qmp/qemu_ga_client.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/python/qemu/qmp/qemu_ga_client.py b/python/qemu/qmp/qemu_ga_cl= ient.py index b3e1d98c9e..15ed430c61 100644 --- a/python/qemu/qmp/qemu_ga_client.py +++ b/python/qemu/qmp/qemu_ga_client.py @@ -37,8 +37,8 @@ # the COPYING file in the top-level directory. =20 import argparse +import asyncio import base64 -import errno import os import random import sys @@ -50,8 +50,8 @@ Sequence, ) =20 -from qemu import qmp -from qemu.qmp import SocketAddrT +from qemu.aqmp import ConnectError, SocketAddrT +from qemu.aqmp.legacy import QEMUMonitorProtocol =20 =20 # This script has not seen many patches or careful attention in quite @@ -61,7 +61,7 @@ # pylint: disable=3Dmissing-docstring =20 =20 -class QemuGuestAgent(qmp.QEMUMonitorProtocol): +class QemuGuestAgent(QEMUMonitorProtocol): def __getattr__(self, name: str) -> Callable[..., Any]: def wrapper(**kwds: object) -> object: return self.command('guest-' + name.replace('_', '-'), **kwds) @@ -149,7 +149,7 @@ def ping(self, timeout: Optional[float]) -> bool: self.qga.settimeout(timeout) try: self.qga.ping() - except TimeoutError: + except asyncio.TimeoutError: return False return True =20 @@ -172,7 +172,7 @@ def suspend(self, mode: str) -> None: try: getattr(self.qga, 'suspend' + '_' + mode)() # On error exception will raise - except TimeoutError: + except asyncio.TimeoutError: # On success command will timed out return =20 @@ -182,7 +182,7 @@ def shutdown(self, mode: str =3D 'powerdown') -> None: =20 try: self.qga.shutdown(mode=3Dmode) - except TimeoutError: + except asyncio.TimeoutError: pass =20 =20 @@ -277,7 +277,7 @@ def _cmd_reboot(client: QemuGuestAgentClient, args: Seq= uence[str]) -> None: =20 def send_command(address: str, cmd: str, args: Sequence[str]) -> None: if not os.path.exists(address): - print('%s not found' % address) + print(f"'{address}' not found. (Is QEMU running?)") sys.exit(1) =20 if cmd not in commands: @@ -287,10 +287,10 @@ def send_command(address: str, cmd: str, args: Sequen= ce[str]) -> None: =20 try: client =3D QemuGuestAgentClient(address) - except OSError as err: + except ConnectError as err: print(err) - if err.errno =3D=3D errno.ECONNREFUSED: - print('Hint: qemu is not running?') + if isinstance(err.exc, ConnectionError): + print('(Is QEMU running?)') sys.exit(1) =20 if cmd =3D=3D 'fsfreeze' and args[0] =3D=3D 'freeze': --=20 2.31.1 From nobody Sat Apr 27 02:46:16 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1637782969739894.8702431156794; Wed, 24 Nov 2021 11:42:49 -0800 (PST) Received: from localhost ([::1]:41180 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mpyAJ-0008UU-AP for importer@patchew.org; Wed, 24 Nov 2021 14:42:47 -0500 Received: from eggs.gnu.org ([209.51.188.92]:35680) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mpxv9-0003S6-0F for qemu-devel@nongnu.org; Wed, 24 Nov 2021 14:27:07 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:55689) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mpxv7-0007cK-A4 for qemu-devel@nongnu.org; Wed, 24 Nov 2021 14:27:06 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-287-h1mwpDSPNWGNmQhXEJ9MWA-1; Wed, 24 Nov 2021 14:27:01 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5A9F7185302D; Wed, 24 Nov 2021 19:26:55 +0000 (UTC) Received: from scv.redhat.com (unknown [10.22.9.79]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5BA657E409; Wed, 24 Nov 2021 19:26:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1637782024; 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=X4ZiRgWWEWlRgT9nSkzfENvUilfS82DKfyqj+wTJiw4=; b=EseOZozBLkalVJhHLLbHfpBsmKh7N9vtIPFc3vK9BMXAcESMq0mTIDGEHvKfoYfRMo9clH 52ZMSAxUIZEMPu+C9uHw7DvDNQ61XczEvunJ9CLE25KFc+7aS4QdmYi1jbnmMvd/B9Jjv8 DKXoDwg5WNA0X0Kcs41A4NmqsqaZQsE= X-MC-Unique: h1mwpDSPNWGNmQhXEJ9MWA-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH 07/23] python/qmp: switch qom tools to AQMP Date: Wed, 24 Nov 2021 14:26:01 -0500 Message-Id: <20211124192617.3396403-8-jsnow@redhat.com> In-Reply-To: <20211124192617.3396403-1-jsnow@redhat.com> References: <20211124192617.3396403-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=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: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.7, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Vladimir Sementsov-Ogievskiy , Eduardo Habkost , qemu-block@nongnu.org, Markus Armbruster , Hanna Reitz , Gerd Hoffmann , 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: 1637782971270100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: John Snow --- python/qemu/qmp/qom.py | 5 +++-- python/qemu/qmp/qom_common.py | 7 ++++--- python/qemu/qmp/qom_fuse.py | 11 ++++++----- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/python/qemu/qmp/qom.py b/python/qemu/qmp/qom.py index 8ff28a8343..bb5d1a78f5 100644 --- a/python/qemu/qmp/qom.py +++ b/python/qemu/qmp/qom.py @@ -32,7 +32,8 @@ =20 import argparse =20 -from . import QMPResponseError +from qemu.aqmp import ExecuteError + from .qom_common import QOMCommand =20 =20 @@ -233,7 +234,7 @@ def _list_node(self, path: str) -> None: rsp =3D self.qmp.command('qom-get', path=3Dpath, property=3Ditem.name) print(f" {item.name}: {rsp} ({item.type})") - except QMPResponseError as err: + except ExecuteError as err: print(f" {item.name}: ({item.type})") print('') for item in items: diff --git a/python/qemu/qmp/qom_common.py b/python/qemu/qmp/qom_common.py index a59ae1a2a1..b145157258 100644 --- a/python/qemu/qmp/qom_common.py +++ b/python/qemu/qmp/qom_common.py @@ -27,7 +27,8 @@ TypeVar, ) =20 -from . import QEMUMonitorProtocol, QMPError +from qemu.aqmp import AQMPError +from qemu.aqmp.legacy import QEMUMonitorProtocol =20 =20 # The following is needed only for a type alias. @@ -82,7 +83,7 @@ class QOMCommand: =20 def __init__(self, args: argparse.Namespace): if args.socket is None: - raise QMPError("No QMP socket path or address given") + raise AQMPError("No QMP socket path or address given") self.qmp =3D QEMUMonitorProtocol( QEMUMonitorProtocol.parse_address(args.socket) ) @@ -161,7 +162,7 @@ def command_runner( try: cmd =3D cls(args) return cmd.run() - except QMPError as err: + except AQMPError as err: print(f"{type(err).__name__}: {err!s}", file=3Dsys.stderr) return -1 =20 diff --git a/python/qemu/qmp/qom_fuse.py b/python/qemu/qmp/qom_fuse.py index 43f4671fdb..653a76b93b 100644 --- a/python/qemu/qmp/qom_fuse.py +++ b/python/qemu/qmp/qom_fuse.py @@ -48,7 +48,8 @@ import fuse from fuse import FUSE, FuseOSError, Operations =20 -from . import QMPResponseError +from qemu.aqmp import ExecuteError + from .qom_common import QOMCommand =20 =20 @@ -99,7 +100,7 @@ def is_object(self, path: str) -> bool: try: self.qom_list(path) return True - except QMPResponseError: + except ExecuteError: return False =20 def is_property(self, path: str) -> bool: @@ -112,7 +113,7 @@ def is_property(self, path: str) -> bool: if item.name =3D=3D prop: return True return False - except QMPResponseError: + except ExecuteError: return False =20 def is_link(self, path: str) -> bool: @@ -125,7 +126,7 @@ def is_link(self, path: str) -> bool: if item.name =3D=3D prop and item.link: return True return False - except QMPResponseError: + except ExecuteError: return False =20 def read(self, path: str, size: int, offset: int, fh: IO[bytes]) -> by= tes: @@ -138,7 +139,7 @@ def read(self, path: str, size: int, offset: int, fh: I= O[bytes]) -> bytes: try: data =3D str(self.qmp.command('qom-get', path=3Dpath, property= =3Dprop)) data +=3D '\n' # make values shell friendly - except QMPResponseError as err: + except ExecuteError as err: raise FuseOSError(EPERM) from err =20 if offset > len(data): --=20 2.31.1 From nobody Sat Apr 27 02:46:16 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1637783218691815.6768654683287; Wed, 24 Nov 2021 11:46:58 -0800 (PST) Received: from localhost ([::1]:49566 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mpyEK-0005jV-Gp for importer@patchew.org; Wed, 24 Nov 2021 14:46:56 -0500 Received: from eggs.gnu.org ([209.51.188.92]:35724) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mpxvB-0003TD-4g for qemu-devel@nongnu.org; Wed, 24 Nov 2021 14:27:09 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:39136) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mpxv8-0007cq-JY for qemu-devel@nongnu.org; Wed, 24 Nov 2021 14:27:08 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-558-xMFC7Ao6NLGSf26F70qGJg-1; Wed, 24 Nov 2021 14:27:02 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8A6B080F051; Wed, 24 Nov 2021 19:26:56 +0000 (UTC) Received: from scv.redhat.com (unknown [10.22.9.79]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7F0252B178; Wed, 24 Nov 2021 19:26:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1637782025; 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=7nu3wISZgyH4rIz4CD8Pwamst4jQqGzOKhrf8q9W8DY=; b=JAINeoLUcz6mSQp+b7+BWcyHuzaPvPkCA3ySshpLuhJNCvrx1zmwU+Bwr6la9kO1gdWoT1 HzLwAaHmVmDXRqJcTa9Rz7+PYbaa7cPMaMQV1KRxboca9SbCp6o9XBUoRH9Kec75GdDHj3 HrhSfVMLPmHAgHdFpdapCzKV3gEBhM0= X-MC-Unique: xMFC7Ao6NLGSf26F70qGJg-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH 08/23] python/qmp: switch qmp-shell to AQMP Date: Wed, 24 Nov 2021 14:26:02 -0500 Message-Id: <20211124192617.3396403-9-jsnow@redhat.com> In-Reply-To: <20211124192617.3396403-1-jsnow@redhat.com> References: <20211124192617.3396403-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=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: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.7, 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_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Vladimir Sementsov-Ogievskiy , Eduardo Habkost , qemu-block@nongnu.org, Markus Armbruster , Hanna Reitz , Gerd Hoffmann , 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: 1637783219159100001 Content-Type: text/plain; charset="utf-8" We have a replacement for async QMP, but it doesn't have feature parity yet. For now, then, port the old tool onto the new backend. Signed-off-by: John Snow --- python/qemu/aqmp/legacy.py | 3 +++ python/qemu/qmp/qmp_shell.py | 31 +++++++++++++++++-------------- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/python/qemu/aqmp/legacy.py b/python/qemu/aqmp/legacy.py index 9431fe9330..5d358d63db 100644 --- a/python/qemu/aqmp/legacy.py +++ b/python/qemu/aqmp/legacy.py @@ -22,6 +22,9 @@ 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 diff --git a/python/qemu/qmp/qmp_shell.py b/python/qemu/qmp/qmp_shell.py index e7d7eb18f1..2260ae016e 100644 --- a/python/qemu/qmp/qmp_shell.py +++ b/python/qemu/qmp/qmp_shell.py @@ -95,8 +95,13 @@ Sequence, ) =20 -from qemu import qmp -from qemu.qmp import QMPMessage +from qemu.aqmp import AQMPError, ConnectError, SocketAddrT +from qemu.aqmp.legacy import ( + QEMUMonitorProtocol, + QMPBadPortError, + QMPMessage, + QMPObject, +) =20 =20 LOG =3D logging.getLogger(__name__) @@ -125,7 +130,7 @@ def complete(self, text: str, state: int) -> Optional[s= tr]: return None =20 =20 -class QMPShellError(qmp.QMPError): +class QMPShellError(AQMPError): """ QMP Shell Base error class. """ @@ -153,7 +158,7 @@ def visit_Name(cls, # pylint: disable=3Dinvalid-name return node =20 =20 -class QMPShell(qmp.QEMUMonitorProtocol): +class QMPShell(QEMUMonitorProtocol): """ QMPShell provides a basic readline-based QMP shell. =20 @@ -161,7 +166,7 @@ class QMPShell(qmp.QEMUMonitorProtocol): :param pretty: Pretty-print QMP messages. :param verbose: Echo outgoing QMP messages to console. """ - def __init__(self, address: qmp.SocketAddrT, + def __init__(self, address: SocketAddrT, pretty: bool =3D False, verbose: bool =3D False): super().__init__(address) self._greeting: Optional[QMPMessage] =3D None @@ -237,7 +242,7 @@ def _parse_value(cls, val: str) -> object: =20 def _cli_expr(self, tokens: Sequence[str], - parent: qmp.QMPObject) -> None: + parent: QMPObject) -> None: for arg in tokens: (key, sep, val) =3D arg.partition('=3D') if sep !=3D '=3D': @@ -403,7 +408,7 @@ class HMPShell(QMPShell): :param pretty: Pretty-print QMP messages. :param verbose: Echo outgoing QMP messages to console. """ - def __init__(self, address: qmp.SocketAddrT, + def __init__(self, address: SocketAddrT, pretty: bool =3D False, verbose: bool =3D False): super().__init__(address, pretty, verbose) self._cpu_index =3D 0 @@ -512,19 +517,17 @@ def main() -> None: =20 try: address =3D shell_class.parse_address(args.qmp_server) - except qmp.QMPBadPortError: + except QMPBadPortError: parser.error(f"Bad port number: {args.qmp_server}") return # pycharm doesn't know error() is noreturn =20 with shell_class(address, args.pretty, args.verbose) as qemu: try: qemu.connect(negotiate=3Dnot args.skip_negotiation) - except qmp.QMPConnectError: - die("Didn't get QMP greeting message") - except qmp.QMPCapabilitiesError: - die("Couldn't negotiate capabilities") - except OSError as err: - die(f"Couldn't connect to {args.qmp_server}: {err!s}") + except ConnectError as err: + if isinstance(err.exc, OSError): + die(f"Couldn't connect to {args.qmp_server}: {err!s}") + die(str(err)) =20 for _ in qemu.repl(): pass --=20 2.31.1 From nobody Sat Apr 27 02:46:16 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1637783026346343.36876522625414; Wed, 24 Nov 2021 11:43:46 -0800 (PST) Received: from localhost ([::1]:42596 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mpyBE-00012B-2t for importer@patchew.org; Wed, 24 Nov 2021 14:43:44 -0500 Received: from eggs.gnu.org ([209.51.188.92]:35872) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mpxvE-0003dC-Ao for qemu-devel@nongnu.org; Wed, 24 Nov 2021 14:27:12 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:41773) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mpxvA-0007ds-TD for qemu-devel@nongnu.org; Wed, 24 Nov 2021 14:27:12 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-17-jiNP0eZAPjGWbnwynKx40Q-1; Wed, 24 Nov 2021 14:27:04 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id AADC310247A9; Wed, 24 Nov 2021 19:26:57 +0000 (UTC) Received: from scv.redhat.com (unknown [10.22.9.79]) by smtp.corp.redhat.com (Postfix) with ESMTP id AA2A872FA4; Wed, 24 Nov 2021 19:26:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1637782028; 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=GHTs3dVM5hFbGiBs6bsJhoICZNDKvIQeHP9OLCa4kXo=; b=UQ47RCCIJPRK4GDkjtstPC/4Q5BseDV4pJdcLIqqxtny3q4m9BnAcHF0oMjErkmcATEFU6 xjdnmL2KnZELjb0cQx9mCfKeN2HdeYZwnJnVXeIEdqErKnuzKaNolsRMyRY3W83YfRZrDM B1W1WAe2CalQWjik2PHn0YGlCLheWDE= X-MC-Unique: jiNP0eZAPjGWbnwynKx40Q-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH 09/23] python: move qmp utilities to python/qemu/utils Date: Wed, 24 Nov 2021 14:26:03 -0500 Message-Id: <20211124192617.3396403-10-jsnow@redhat.com> In-Reply-To: <20211124192617.3396403-1-jsnow@redhat.com> References: <20211124192617.3396403-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=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: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.7, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Vladimir Sementsov-Ogievskiy , Eduardo Habkost , qemu-block@nongnu.org, Markus Armbruster , Hanna Reitz , Gerd Hoffmann , 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: 1637783027908100001 Content-Type: text/plain; charset="utf-8" In order to upload a QMP package to PyPI, I want to remove any scripts that I am not 100% confident I want to support upstream, beyond our castle walls. Move most of our QMP utilities into the utils package so we can split them out from the PyPI upload. Signed-off-by: John Snow --- python/qemu/{qmp =3D> utils}/qemu_ga_client.py | 0 python/qemu/{qmp =3D> utils}/qom.py | 0 python/qemu/{qmp =3D> utils}/qom_common.py | 0 python/qemu/{qmp =3D> utils}/qom_fuse.py | 0 python/setup.cfg | 16 ++++++++-------- scripts/qmp/qemu-ga-client | 2 +- scripts/qmp/qom-fuse | 2 +- scripts/qmp/qom-get | 2 +- scripts/qmp/qom-list | 2 +- scripts/qmp/qom-set | 2 +- scripts/qmp/qom-tree | 2 +- 11 files changed, 14 insertions(+), 14 deletions(-) rename python/qemu/{qmp =3D> utils}/qemu_ga_client.py (100%) rename python/qemu/{qmp =3D> utils}/qom.py (100%) rename python/qemu/{qmp =3D> utils}/qom_common.py (100%) rename python/qemu/{qmp =3D> utils}/qom_fuse.py (100%) diff --git a/python/qemu/qmp/qemu_ga_client.py b/python/qemu/utils/qemu_ga_= client.py similarity index 100% rename from python/qemu/qmp/qemu_ga_client.py rename to python/qemu/utils/qemu_ga_client.py diff --git a/python/qemu/qmp/qom.py b/python/qemu/utils/qom.py similarity index 100% rename from python/qemu/qmp/qom.py rename to python/qemu/utils/qom.py diff --git a/python/qemu/qmp/qom_common.py b/python/qemu/utils/qom_common.py similarity index 100% rename from python/qemu/qmp/qom_common.py rename to python/qemu/utils/qom_common.py diff --git a/python/qemu/qmp/qom_fuse.py b/python/qemu/utils/qom_fuse.py similarity index 100% rename from python/qemu/qmp/qom_fuse.py rename to python/qemu/utils/qom_fuse.py diff --git a/python/setup.cfg b/python/setup.cfg index 417e937839..78421411d2 100644 --- a/python/setup.cfg +++ b/python/setup.cfg @@ -60,13 +60,13 @@ tui =3D =20 [options.entry_points] console_scripts =3D - qom =3D qemu.qmp.qom:main - qom-set =3D qemu.qmp.qom:QOMSet.entry_point - qom-get =3D qemu.qmp.qom:QOMGet.entry_point - qom-list =3D qemu.qmp.qom:QOMList.entry_point - qom-tree =3D qemu.qmp.qom:QOMTree.entry_point - qom-fuse =3D qemu.qmp.qom_fuse:QOMFuse.entry_point [fuse] - qemu-ga-client =3D qemu.qmp.qemu_ga_client:main + qom =3D qemu.utils.qom:main + qom-set =3D qemu.utils.qom:QOMSet.entry_point + qom-get =3D qemu.utils.qom:QOMGet.entry_point + qom-list =3D qemu.utils.qom:QOMList.entry_point + 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.qmp.qmp_shell:main aqmp-tui =3D qemu.aqmp.aqmp_tui:main [tui] =20 @@ -80,7 +80,7 @@ python_version =3D 3.6 warn_unused_configs =3D True namespace_packages =3D True =20 -[mypy-qemu.qmp.qom_fuse] +[mypy-qemu.utils.qom_fuse] # fusepy has no type stubs: allow_subclassing_any =3D True =20 diff --git a/scripts/qmp/qemu-ga-client b/scripts/qmp/qemu-ga-client index 102fd2cad9..56edd0234a 100755 --- a/scripts/qmp/qemu-ga-client +++ b/scripts/qmp/qemu-ga-client @@ -4,7 +4,7 @@ import os import sys =20 sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'pytho= n')) -from qemu.qmp import qemu_ga_client +from qemu.utils import qemu_ga_client =20 =20 if __name__ =3D=3D '__main__': diff --git a/scripts/qmp/qom-fuse b/scripts/qmp/qom-fuse index a58c8ef979..d453807b27 100755 --- a/scripts/qmp/qom-fuse +++ b/scripts/qmp/qom-fuse @@ -4,7 +4,7 @@ import os import sys =20 sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'pytho= n')) -from qemu.qmp.qom_fuse import QOMFuse +from qemu.utils.qom_fuse import QOMFuse =20 =20 if __name__ =3D=3D '__main__': diff --git a/scripts/qmp/qom-get b/scripts/qmp/qom-get index e4f3e0c013..04ebe052e8 100755 --- a/scripts/qmp/qom-get +++ b/scripts/qmp/qom-get @@ -4,7 +4,7 @@ import os import sys =20 sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'pytho= n')) -from qemu.qmp.qom import QOMGet +from qemu.utils.qom import QOMGet =20 =20 if __name__ =3D=3D '__main__': diff --git a/scripts/qmp/qom-list b/scripts/qmp/qom-list index 7a071a54e1..853b85a8d3 100755 --- a/scripts/qmp/qom-list +++ b/scripts/qmp/qom-list @@ -4,7 +4,7 @@ import os import sys =20 sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'pytho= n')) -from qemu.qmp.qom import QOMList +from qemu.utils.qom import QOMList =20 =20 if __name__ =3D=3D '__main__': diff --git a/scripts/qmp/qom-set b/scripts/qmp/qom-set index 9ca9e2ba10..06820feec4 100755 --- a/scripts/qmp/qom-set +++ b/scripts/qmp/qom-set @@ -4,7 +4,7 @@ import os import sys =20 sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'pytho= n')) -from qemu.qmp.qom import QOMSet +from qemu.utils.qom import QOMSet =20 =20 if __name__ =3D=3D '__main__': diff --git a/scripts/qmp/qom-tree b/scripts/qmp/qom-tree index 7d0ccca3a4..760e172277 100755 --- a/scripts/qmp/qom-tree +++ b/scripts/qmp/qom-tree @@ -4,7 +4,7 @@ import os import sys =20 sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'pytho= n')) -from qemu.qmp.qom import QOMTree +from qemu.utils.qom import QOMTree =20 =20 if __name__ =3D=3D '__main__': --=20 2.31.1 From nobody Sat Apr 27 02:46:16 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1637782563655984.9314686950258; Wed, 24 Nov 2021 11:36:03 -0800 (PST) Received: from localhost ([::1]:53660 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mpy3l-00061u-KL for importer@patchew.org; Wed, 24 Nov 2021 14:36:01 -0500 Received: from eggs.gnu.org ([209.51.188.92]:35770) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mpxvC-0003VW-Dy for qemu-devel@nongnu.org; Wed, 24 Nov 2021 14:27:10 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:21644) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mpxvA-0007dP-SW for qemu-devel@nongnu.org; Wed, 24 Nov 2021 14:27:10 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-44-UMe7T4kSPxaSJywGdudO_Q-1; Wed, 24 Nov 2021 14:27:06 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D1F68EC1D9; Wed, 24 Nov 2021 19:26:58 +0000 (UTC) Received: from scv.redhat.com (unknown [10.22.9.79]) by smtp.corp.redhat.com (Postfix) with ESMTP id CCEC65B826; Wed, 24 Nov 2021 19:26:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1637782027; 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=o/D/PEB9EDF7yYxBFFSKnfUT785DfwIux93dqCYu8qA=; b=ihasMqDfQQmMo+VnkkrekLz31oksW3AJjMyc6N5SJIkW12De1c0Of0emhitv4QwXlg1Acn EiMKg6ur9iXnfKrRjMH+Uj/LMUMpqPZ/mmcMnAFihgXA+aCwl+qgjP3a0wmz2oJVBUheSK KK+/Ve32jKz7NPhzR0vkRRCiA/xGWCs= X-MC-Unique: UMe7T4kSPxaSJywGdudO_Q-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH 10/23] python: move qmp-shell under the AQMP package Date: Wed, 24 Nov 2021 14:26:04 -0500 Message-Id: <20211124192617.3396403-11-jsnow@redhat.com> In-Reply-To: <20211124192617.3396403-1-jsnow@redhat.com> References: <20211124192617.3396403-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=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: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.7, 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_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Vladimir Sementsov-Ogievskiy , Eduardo Habkost , qemu-block@nongnu.org, Markus Armbruster , Hanna Reitz , Gerd Hoffmann , 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: 1637782564754100003 Content-Type: text/plain; charset="utf-8" Signed-off-by: John Snow --- python/README.rst | 2 +- python/qemu/{qmp =3D> aqmp}/qmp_shell.py | 0 python/setup.cfg | 2 +- scripts/qmp/qmp-shell | 2 +- 4 files changed, 3 insertions(+), 3 deletions(-) rename python/qemu/{qmp =3D> aqmp}/qmp_shell.py (100%) diff --git a/python/README.rst b/python/README.rst index 9c1fceaee7..fcf74f69ea 100644 --- a/python/README.rst +++ b/python/README.rst @@ -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.qmp.qmp_shell`` +``> PYTHONPATH=3D~/src/qemu/python python3 -m qemu.aqmp.qmp_shell`` =20 The mappings between console script name and python module path can be found in ``setup.cfg``. diff --git a/python/qemu/qmp/qmp_shell.py b/python/qemu/aqmp/qmp_shell.py similarity index 100% rename from python/qemu/qmp/qmp_shell.py rename to python/qemu/aqmp/qmp_shell.py diff --git a/python/setup.cfg b/python/setup.cfg index 78421411d2..168a79c867 100644 --- a/python/setup.cfg +++ b/python/setup.cfg @@ -67,7 +67,7 @@ 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.qmp.qmp_shell:main + qmp-shell =3D qemu.aqmp.qmp_shell:main aqmp-tui =3D qemu.aqmp.aqmp_tui:main [tui] =20 [flake8] diff --git a/scripts/qmp/qmp-shell b/scripts/qmp/qmp-shell index 4a20f97db7..31b19d73e2 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.qmp import qmp_shell +from qemu.aqmp import qmp_shell =20 =20 if __name__ =3D=3D '__main__': --=20 2.31.1 From nobody Sat Apr 27 02:46:16 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1637782522599962.3004112057241; Wed, 24 Nov 2021 11:35:22 -0800 (PST) Received: from localhost ([::1]:52430 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mpy35-0005CM-0U for importer@patchew.org; Wed, 24 Nov 2021 14:35:20 -0500 Received: from eggs.gnu.org ([209.51.188.92]:35906) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mpxvE-0003fv-Ud for qemu-devel@nongnu.org; Wed, 24 Nov 2021 14:27:12 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:56655) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mpxvA-0007dU-T0 for qemu-devel@nongnu.org; Wed, 24 Nov 2021 14:27:12 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-574-xvrVO2J5NkSrGY095lMC1A-1; Wed, 24 Nov 2021 14:27:06 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 25848190A7A6; Wed, 24 Nov 2021 19:27:00 +0000 (UTC) Received: from scv.redhat.com (unknown [10.22.9.79]) by smtp.corp.redhat.com (Postfix) with ESMTP id 00EC367842; Wed, 24 Nov 2021 19:26:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1637782027; 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=pdCv53NqcC/gHhN4IgKau9iSfhdUIeYYu37PK97CXuY=; b=YavIFtP4L3+I6cslWUBBw4KE6UemOie2E48SRE5T4NI0vScObQ1y7t9cCQVW1NxsjuTJ46 2AqtcVzqOiKx0wLviX+6JDfIoRmWd/HRemJPUAw085q8pR0KvBhoixusE1gab6QNmIJ45s yzXLttcBhCeW3q/Df3Hx63FzZ375GeA= X-MC-Unique: xvrVO2J5NkSrGY095lMC1A-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH 11/23] python/machine: permanently switch to AQMP Date: Wed, 24 Nov 2021 14:26:05 -0500 Message-Id: <20211124192617.3396403-12-jsnow@redhat.com> In-Reply-To: <20211124192617.3396403-1-jsnow@redhat.com> References: <20211124192617.3396403-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=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: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.7, 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_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Vladimir Sementsov-Ogievskiy , Eduardo Habkost , qemu-block@nongnu.org, Markus Armbruster , Hanna Reitz , Gerd Hoffmann , 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: 1637782524652100001 Content-Type: text/plain; charset="utf-8" Remove the QEMU_PYTHON_LEGACY_QMP environment variable, making the switch permanent. Update Exceptions and import paths as necessary. Signed-off-by: John Snow --- python/qemu/machine/machine.py | 18 +++++++----------- python/qemu/machine/qtest.py | 2 +- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/python/qemu/machine/machine.py b/python/qemu/machine/machine.py index 67ab06ca2b..21fb4a4f30 100644 --- a/python/qemu/machine/machine.py +++ b/python/qemu/machine/machine.py @@ -40,21 +40,16 @@ TypeVar, ) =20 -from qemu.qmp import ( # pylint: disable=3Dimport-error +from qemu.aqmp import SocketAddrT +from qemu.aqmp.legacy import ( + QEMUMonitorProtocol, QMPMessage, QMPReturnValue, - SocketAddrT, ) =20 from . import console_socket =20 =20 -if os.environ.get('QEMU_PYTHON_LEGACY_QMP'): - from qemu.qmp import QEMUMonitorProtocol -else: - from qemu.aqmp.legacy import QEMUMonitorProtocol - - LOG =3D logging.getLogger(__name__) =20 =20 @@ -710,8 +705,9 @@ def events_wait(self, :param timeout: Optional timeout, in seconds. See QEMUMonitorProtocol.pull_event. =20 - :raise QMPTimeoutError: If timeout was non-zero and no matching ev= ents - were found. + :raise asyncio.TimeoutError: + If timeout was non-zero and no matching events were found. + :return: A QMP event matching the filter criteria. If timeout was 0 and no event matched, None. """ @@ -734,7 +730,7 @@ def _match(event: QMPMessage) -> bool: event =3D self._qmp.pull_event(wait=3Dtimeout) if event is None: # NB: None is only returned when timeout is false-ish. - # Timeouts raise QMPTimeoutError instead! + # Timeouts raise asyncio.TimeoutError instead! break if _match(event): return event diff --git a/python/qemu/machine/qtest.py b/python/qemu/machine/qtest.py index f2f9aaa5e5..817c8a5425 100644 --- a/python/qemu/machine/qtest.py +++ b/python/qemu/machine/qtest.py @@ -26,7 +26,7 @@ TextIO, ) =20 -from qemu.qmp import SocketAddrT # pylint: disable=3Dimport-error +from qemu.aqmp.protocol import SocketAddrT =20 from .machine import QEMUMachine =20 --=20 2.31.1 From nobody Sat Apr 27 02:46:16 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1637782742828103.15882812242558; Wed, 24 Nov 2021 11:39:02 -0800 (PST) Received: from localhost ([::1]:32910 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mpy6e-0002jW-P5 for importer@patchew.org; Wed, 24 Nov 2021 14:39:00 -0500 Received: from eggs.gnu.org ([209.51.188.92]:35912) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mpxvF-0003g6-3D for qemu-devel@nongnu.org; Wed, 24 Nov 2021 14:27:13 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:36148) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mpxvB-0007e8-Q8 for qemu-devel@nongnu.org; Wed, 24 Nov 2021 14:27:12 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-35-PUKEbZRBNzCEe97XLFYg4g-1; Wed, 24 Nov 2021 14:27:05 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 435C8102C8D8; Wed, 24 Nov 2021 19:27:01 +0000 (UTC) Received: from scv.redhat.com (unknown [10.22.9.79]) by smtp.corp.redhat.com (Postfix) with ESMTP id 47A4F4180; Wed, 24 Nov 2021 19:27:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1637782028; 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=lAgGbxVCeyTmIDeyZ+YWYCMIvjAwkEcRBPiUwRdN2bQ=; b=RCBvIb7vJKQuweydyO3wEM+Ww+84SOhdncivzIfS3eYaGjErQRsjG+5CW5975JyiHw3ep0 PSo8jSSfu/FLiIvL8rQfDn0gVFzZGskLn5I6AJ91P+o+gGdqoFCxZOauQgbhT5/LFg8/ky 4KEeqmmjUDKgGwblryuwsrXJ5KHVmI8= X-MC-Unique: PUKEbZRBNzCEe97XLFYg4g-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH 12/23] scripts/cpu-x86-uarch-abi: fix CLI parsing Date: Wed, 24 Nov 2021 14:26:06 -0500 Message-Id: <20211124192617.3396403-13-jsnow@redhat.com> In-Reply-To: <20211124192617.3396403-1-jsnow@redhat.com> References: <20211124192617.3396403-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=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: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.7, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Vladimir Sementsov-Ogievskiy , Eduardo Habkost , qemu-block@nongnu.org, Markus Armbruster , Hanna Reitz , Gerd Hoffmann , 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: 1637782744222100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: John Snow --- scripts/cpu-x86-uarch-abi.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/cpu-x86-uarch-abi.py b/scripts/cpu-x86-uarch-abi.py index 08acc52a81..8963d90f0b 100644 --- a/scripts/cpu-x86-uarch-abi.py +++ b/scripts/cpu-x86-uarch-abi.py @@ -9,7 +9,7 @@ from qemu import qmp import sys =20 -if len(sys.argv) !=3D 1: +if len(sys.argv) !=3D 2: print("syntax: %s QMP-SOCK\n\n" % __file__ + "Where QMP-SOCK points to a QEMU process such as\n\n" + " # qemu-system-x86_64 -qmp unix:/tmp/qmp,server,nowait " + @@ -66,7 +66,6 @@ =20 =20 sock =3D sys.argv[1] -cmd =3D sys.argv[2] shell =3D qmp.QEMUMonitorProtocol(sock) shell.connect() =20 --=20 2.31.1 From nobody Sat Apr 27 02:46:16 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1637783347279430.71949493796274; Wed, 24 Nov 2021 11:49:07 -0800 (PST) Received: from localhost ([::1]:56178 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mpyGP-0001mr-8x for importer@patchew.org; Wed, 24 Nov 2021 14:49:05 -0500 Received: from eggs.gnu.org ([209.51.188.92]:35836) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mpxvD-0003ad-Nz for qemu-devel@nongnu.org; Wed, 24 Nov 2021 14:27:11 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:45602) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mpxvA-0007dm-TA for qemu-devel@nongnu.org; Wed, 24 Nov 2021 14:27:11 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-400-GX5zAORlOjexYgL41kMl6Q-1; Wed, 24 Nov 2021 14:27:07 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5AEE0835E4D; Wed, 24 Nov 2021 19:27:02 +0000 (UTC) Received: from scv.redhat.com (unknown [10.22.9.79]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6571667840; Wed, 24 Nov 2021 19:27:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1637782028; 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=EOSe0Y+PecUkVn3R8Oja7L9B2QiH1oXEL9mkbdeM1p4=; b=C3gepcBsIAKswH2bl++MXyhYYcrbA4+s0IOGOFIX0CCI/VV7tUI7TR0YVSzSAoGg8b3YS9 JGr4anippPsjxYcb/J8GBhsr49KXp8DUeCH/KPf2l3vhJVw1OWFoIWSqTaCBO6hrkhb/4W TmNmK1GJSPB9KL8/LaCbNdfoH7TBqpM= X-MC-Unique: GX5zAORlOjexYgL41kMl6Q-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH 13/23] scripts/cpu-x86-uarch-abi: switch to AQMP Date: Wed, 24 Nov 2021 14:26:07 -0500 Message-Id: <20211124192617.3396403-14-jsnow@redhat.com> In-Reply-To: <20211124192617.3396403-1-jsnow@redhat.com> References: <20211124192617.3396403-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=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: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.7, 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_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Vladimir Sementsov-Ogievskiy , Eduardo Habkost , qemu-block@nongnu.org, Markus Armbruster , Hanna Reitz , Gerd Hoffmann , 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: 1637783349417100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: John Snow --- scripts/cpu-x86-uarch-abi.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/cpu-x86-uarch-abi.py b/scripts/cpu-x86-uarch-abi.py index 8963d90f0b..c262d2f027 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 import qmp +from qemu.aqmp.legacy import QEMUMonitorProtocol import sys =20 if len(sys.argv) !=3D 2: @@ -66,7 +66,7 @@ =20 =20 sock =3D sys.argv[1] -shell =3D qmp.QEMUMonitorProtocol(sock) +shell =3D QEMUMonitorProtocol(sock) shell.connect() =20 models =3D shell.cmd("query-cpu-definitions") --=20 2.31.1 From nobody Sat Apr 27 02:46:16 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1637783234526439.28889928854744; Wed, 24 Nov 2021 11:47:14 -0800 (PST) Received: from localhost ([::1]:50776 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mpyEa-0006du-KN for importer@patchew.org; Wed, 24 Nov 2021 14:47:12 -0500 Received: from eggs.gnu.org ([209.51.188.92]:35886) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mpxvE-0003dv-I4 for qemu-devel@nongnu.org; Wed, 24 Nov 2021 14:27:12 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:28218) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mpxvA-0007do-TZ for qemu-devel@nongnu.org; Wed, 24 Nov 2021 14:27:12 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-432-IB0G3q3mNLeDvLyEwadwKA-1; Wed, 24 Nov 2021 14:27:07 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6D3DE8042E1; Wed, 24 Nov 2021 19:27:03 +0000 (UTC) Received: from scv.redhat.com (unknown [10.22.9.79]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7CA986C336; Wed, 24 Nov 2021 19:27:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1637782028; 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=Ln1iF3R/Saap+dvmbiTu+4xhne6Gp5Lto4kYEgUfVpY=; b=XVljtLctT+slkdavGKJSr6lI1A3OD1IyQpo7uPm8KvoTa6VaKu0S3/5ibrAr7Q06Gygt1N RkbWYDYfVyLiY2U5mk1oCNzxL8m7TPOTzJsEF/jXqKd4uy8Kp0LDuIsGU2U+e7Qa6AkinD jttRnLs8uQGHm6ZxlwSVngzxUrgIlvo= X-MC-Unique: IB0G3q3mNLeDvLyEwadwKA-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH 14/23] scripts/render-block-graph: switch to AQMP Date: Wed, 24 Nov 2021 14:26:08 -0500 Message-Id: <20211124192617.3396403-15-jsnow@redhat.com> In-Reply-To: <20211124192617.3396403-1-jsnow@redhat.com> References: <20211124192617.3396403-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=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: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.7, 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_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Vladimir Sementsov-Ogievskiy , Eduardo Habkost , qemu-block@nongnu.org, Markus Armbruster , Hanna Reitz , Gerd Hoffmann , 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: 1637783235530100001 Content-Type: text/plain; charset="utf-8" Creating an instance of qemu.aqmp.ExecuteError is too involved here, so just drop the specificity down to a generic AQMPError. Signed-off-by: John Snow --- scripts/render_block_graph.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/scripts/render_block_graph.py b/scripts/render_block_graph.py index da6acf050d..d2f3a72348 100755 --- a/scripts/render_block_graph.py +++ b/scripts/render_block_graph.py @@ -25,10 +25,8 @@ from graphviz import Digraph =20 sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'python')) -from qemu.qmp import ( - QEMUMonitorProtocol, - QMPResponseError, -) +from qemu.aqmp import AQMPError +from qemu.aqmp.legacy import QEMUMonitorProtocol =20 =20 def perm(arr): @@ -105,7 +103,7 @@ def command(self, cmd): reply =3D json.loads(subprocess.check_output(ar)) =20 if 'error' in reply: - raise QMPResponseError(reply) + raise AQMPError(reply) =20 return reply['return'] =20 --=20 2.31.1 From nobody Sat Apr 27 02:46:16 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1637782770955506.1447748843233; Wed, 24 Nov 2021 11:39:30 -0800 (PST) Received: from localhost ([::1]:33988 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mpy76-0003Tc-S4 for importer@patchew.org; Wed, 24 Nov 2021 14:39:28 -0500 Received: from eggs.gnu.org ([209.51.188.92]:35838) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mpxvD-0003ae-OZ for qemu-devel@nongnu.org; Wed, 24 Nov 2021 14:27:11 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:31636) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mpxvA-0007dv-TR for qemu-devel@nongnu.org; Wed, 24 Nov 2021 14:27:11 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-364-vZ8R_FrcPQK1IRvpIY1bAA-1; Wed, 24 Nov 2021 14:27:07 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8D77480574C; Wed, 24 Nov 2021 19:27:04 +0000 (UTC) Received: from scv.redhat.com (unknown [10.22.9.79]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8F2D767840; Wed, 24 Nov 2021 19:27:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1637782028; 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=ldOdmNQi+cFFOo6YYoDgU5P4D37dC1TVNC1M6WbkmMQ=; b=CBvoCGwCH4rL1/kWG1bKfyb1aK6peohzbt+iIxIbeOfhv2OmVFlgvd20R9Sw1EaLQgL6+u 3mrl4uexcz2D/ESHhkaJMe4N1pbUhM35/KRVSWoWbhantLY92vJVR36ZRTRsXT5nA/m7qX tLk7cRcOcy8ccLkDVDcfH86I20WKbR4= X-MC-Unique: vZ8R_FrcPQK1IRvpIY1bAA-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH 15/23] scripts/bench-block-job: switch to AQMP Date: Wed, 24 Nov 2021 14:26:09 -0500 Message-Id: <20211124192617.3396403-16-jsnow@redhat.com> In-Reply-To: <20211124192617.3396403-1-jsnow@redhat.com> References: <20211124192617.3396403-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=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: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.7, 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_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Vladimir Sementsov-Ogievskiy , Eduardo Habkost , qemu-block@nongnu.org, Markus Armbruster , Hanna Reitz , Gerd Hoffmann , 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: 1637782771641100001 Content-Type: text/plain; charset="utf-8" For this commit, we only need to remove accommodations for the synchronous QMP library. Signed-off-by: John Snow --- scripts/simplebench/bench_block_job.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/simplebench/bench_block_job.py b/scripts/simplebench/b= ench_block_job.py index a403c35b08..af9d1646a4 100755 --- a/scripts/simplebench/bench_block_job.py +++ b/scripts/simplebench/bench_block_job.py @@ -27,7 +27,6 @@ =20 sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'pytho= n')) from qemu.machine import QEMUMachine -from qemu.qmp import QMPConnectError from qemu.aqmp import ConnectError =20 =20 @@ -50,7 +49,7 @@ def bench_block_job(cmd, cmd_args, qemu_args): vm.launch() except OSError as e: return {'error': 'popen failed: ' + str(e)} - except (QMPConnectError, ConnectError, socket.timeout): + except (ConnectError, socket.timeout): return {'error': 'qemu failed: ' + str(vm.get_log())} =20 try: --=20 2.31.1 From nobody Sat Apr 27 02:46:16 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 163778279688167.10103681528278; Wed, 24 Nov 2021 11:39:56 -0800 (PST) Received: from localhost ([::1]:35098 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mpy7T-0004EK-15 for importer@patchew.org; Wed, 24 Nov 2021 14:39:54 -0500 Received: from eggs.gnu.org ([209.51.188.92]:35972) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mpxvG-0003lb-7I for qemu-devel@nongnu.org; Wed, 24 Nov 2021 14:27:14 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:38878) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mpxvC-0007ej-I0 for qemu-devel@nongnu.org; Wed, 24 Nov 2021 14:27:13 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-167-3vV3_pRlNVyn-by-sJ985w-1; Wed, 24 Nov 2021 14:27:06 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A52DB102C81F; Wed, 24 Nov 2021 19:27:05 +0000 (UTC) Received: from scv.redhat.com (unknown [10.22.9.79]) by smtp.corp.redhat.com (Postfix) with ESMTP id AF05B6C337; Wed, 24 Nov 2021 19:27:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1637782030; 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=fbR8cLUOu5n6ohejSdT7hbIEAZvI5H8CnJy9U6sbFHY=; b=NCsMetmP6T3tgrtxuYBBB0ydNEn/ns/uUEY8BoIjyAqXYkgU3lDpLgMTx3zdzsTOvXWMYR E2ZvGUbwX1by8YSkiAD0kbFbMKPbeYX3rJClbyhq/Syk7MWGjgXpDRkGLvV65wdZk3LE7T X41ocu4rRTIubJFb7DYAFXTfxkCajd0= X-MC-Unique: 3vV3_pRlNVyn-by-sJ985w-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH 16/23] iotests/mirror-top-perms: switch to AQMP Date: Wed, 24 Nov 2021 14:26:10 -0500 Message-Id: <20211124192617.3396403-17-jsnow@redhat.com> In-Reply-To: <20211124192617.3396403-1-jsnow@redhat.com> References: <20211124192617.3396403-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=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: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.7, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Vladimir Sementsov-Ogievskiy , Eduardo Habkost , qemu-block@nongnu.org, Markus Armbruster , Hanna Reitz , Gerd Hoffmann , 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: 1637782798236100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: John Snow --- Note: I still need to adjust the logging. The problem now is that the logging messages include the PID of the test process, so they need to be filtered out. I'll investigate that for a follow-up, or for v2. I could just add yet another filtering function somewhere, but I think it's getting out of hand with how many filters and loggers there are, so I want to give it a slightly more serious treatment instead of a hackjob. Signed-off-by: John Snow --- tests/qemu-iotests/tests/mirror-top-perms | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tests/qemu-iotests/tests/mirror-top-perms b/tests/qemu-iotests= /tests/mirror-top-perms index 0a51a613f3..f394931a00 100755 --- a/tests/qemu-iotests/tests/mirror-top-perms +++ b/tests/qemu-iotests/tests/mirror-top-perms @@ -23,7 +23,6 @@ import os =20 from qemu.aqmp import ConnectError from qemu.machine import machine -from qemu.qmp import QMPConnectError =20 import iotests from iotests import change_log_level, qemu_img @@ -101,13 +100,13 @@ class TestMirrorTopPerms(iotests.QMPTestCase): self.vm_b.add_device('virtio-blk,drive=3Ddrive0,share-rw=3Don') try: # Silence AQMP errors temporarily. - # TODO: Remove this and just allow the errors to be logged when - # AQMP fully replaces QMP. + # TODO: Remove change_log_level and allow the errors to be log= ged. + # This necessitates a PID filter on *all* logging output. with change_log_level('qemu.aqmp'): self.vm_b.launch() print('ERROR: VM B launched successfully, ' 'this should not have happened') - except (QMPConnectError, ConnectError): + except ConnectError: assert 'Is another process using the image' in self.vm_b.get_l= og() =20 result =3D self.vm.qmp('block-job-cancel', --=20 2.31.1 From nobody Sat Apr 27 02:46:16 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1637782978930488.20790494724986; Wed, 24 Nov 2021 11:42:58 -0800 (PST) Received: from localhost ([::1]:41474 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mpyAS-0000Ff-S4 for importer@patchew.org; Wed, 24 Nov 2021 14:42:56 -0500 Received: from eggs.gnu.org ([209.51.188.92]:35938) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mpxvF-0003ic-In for qemu-devel@nongnu.org; Wed, 24 Nov 2021 14:27:13 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:37679) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mpxvB-0007eR-QR for qemu-devel@nongnu.org; Wed, 24 Nov 2021 14:27:13 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-425-ZNTr0VP0OF2ipaXS_G8GIw-1; Wed, 24 Nov 2021 14:27:07 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BEC27190A7D3; Wed, 24 Nov 2021 19:27:06 +0000 (UTC) Received: from scv.redhat.com (unknown [10.22.9.79]) by smtp.corp.redhat.com (Postfix) with ESMTP id C759E2B179; Wed, 24 Nov 2021 19:27:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1637782028; 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=ZxlToBL8uM12CzsCFv+FxFOBKJYX2wgHcwzRPGN+2Go=; b=Cz1JsLlljOL8n1OM3ajCtTxkt9GhkeGkWr6yUJRPUb/QEE+KumTh7PoSYIqx8GAPDTE8KJ ibepaEpqyFX24N7h5SuV9s/jo7Dx145oeYWtiJvh4laV8b8Nmfl589kU8GEjt6djJ+YYY3 PTwAWQDObKn3IPon4JFyaAxJBO8arZ0= X-MC-Unique: ZNTr0VP0OF2ipaXS_G8GIw-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH 17/23] iotests: switch to AQMP Date: Wed, 24 Nov 2021 14:26:11 -0500 Message-Id: <20211124192617.3396403-18-jsnow@redhat.com> In-Reply-To: <20211124192617.3396403-1-jsnow@redhat.com> References: <20211124192617.3396403-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=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: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.7, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Vladimir Sementsov-Ogievskiy , Eduardo Habkost , qemu-block@nongnu.org, Markus Armbruster , Hanna Reitz , Gerd Hoffmann , 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: 1637782980197100001 Content-Type: text/plain; charset="utf-8" Simply import the type defition from the new location. Signed-off-by: John Snow --- tests/qemu-iotests/iotests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index 83bfedb902..cb21aebe36 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -37,7 +37,7 @@ from contextlib import contextmanager =20 from qemu.machine import qtest -from qemu.qmp import QMPMessage +from qemu.aqmp.legacy import QMPMessage =20 # Use this logger for logging messages directly from the iotests module logger =3D logging.getLogger('qemu.iotests') --=20 2.31.1 From nobody Sat Apr 27 02:46:16 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1637783376745837.0745391635912; Wed, 24 Nov 2021 11:49:36 -0800 (PST) Received: from localhost ([::1]:57138 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mpyGs-0002Pr-Qo for importer@patchew.org; Wed, 24 Nov 2021 14:49:34 -0500 Received: from eggs.gnu.org ([209.51.188.92]:35980) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mpxvG-0003mL-DH for qemu-devel@nongnu.org; Wed, 24 Nov 2021 14:27:14 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:44476) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mpxvC-0007eh-KS for qemu-devel@nongnu.org; Wed, 24 Nov 2021 14:27:14 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-523-u93TwnFcPB2Lillh9KLT7A-1; Wed, 24 Nov 2021 14:27:08 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D97C71054F91; Wed, 24 Nov 2021 19:27:07 +0000 (UTC) Received: from scv.redhat.com (unknown [10.22.9.79]) by smtp.corp.redhat.com (Postfix) with ESMTP id E1B2C67840; Wed, 24 Nov 2021 19:27:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1637782030; 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=39pJWh8RGfbFeVB98pUJd96r5gL4/HEBTqQOwDEQMzM=; b=NxeyTFHukHg7RLIhvjmyi48GwB4+QQbtWh4L2tmlP2d8WNwKHap/qbWWpdftvckXzFZlVn vWUzwj3O8QdzX6Sx7EGKfyDMYwUAFJ5oO6OGVLCwPmAalyfYV6R9Q7OolN+w/aPMsqAdwV 5li7WwvMOvZK/nlUKtV+yx19akIf5Co= X-MC-Unique: u93TwnFcPB2Lillh9KLT7A-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH 18/23] python: temporarily silence pylint duplicate-code warnings Date: Wed, 24 Nov 2021 14:26:12 -0500 Message-Id: <20211124192617.3396403-19-jsnow@redhat.com> In-Reply-To: <20211124192617.3396403-1-jsnow@redhat.com> References: <20211124192617.3396403-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=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: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.7, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Vladimir Sementsov-Ogievskiy , Eduardo Habkost , qemu-block@nongnu.org, Markus Armbruster , Hanna Reitz , Gerd Hoffmann , 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: 1637783377048100001 Content-Type: text/plain; charset="utf-8" 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 --- python/setup.cfg | 1 + 1 file changed, 1 insertion(+) diff --git a/python/setup.cfg b/python/setup.cfg index 168a79c867..510df23698 100644 --- a/python/setup.cfg +++ b/python/setup.cfg @@ -115,6 +115,7 @@ ignore_missing_imports =3D True disable=3Dconsider-using-f-string, too-many-function-args, # mypy handles this with less false posit= ives. 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.31.1 From nobody Sat Apr 27 02:46:16 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1637783541588433.96055936331925; Wed, 24 Nov 2021 11:52:21 -0800 (PST) Received: from localhost ([::1]:37296 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mpyJX-00083i-KA for importer@patchew.org; Wed, 24 Nov 2021 14:52:19 -0500 Received: from eggs.gnu.org ([209.51.188.92]:36120) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mpxvJ-0003yZ-G4 for qemu-devel@nongnu.org; Wed, 24 Nov 2021 14:27:17 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:40145) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mpxvF-0007hk-KI for qemu-devel@nongnu.org; Wed, 24 Nov 2021 14:27:17 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-193-ikIDWUb_NtiZau2OAjVsJg-1; Wed, 24 Nov 2021 14:27:10 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EBF70102ABE5; Wed, 24 Nov 2021 19:27:08 +0000 (UTC) Received: from scv.redhat.com (unknown [10.22.9.79]) by smtp.corp.redhat.com (Postfix) with ESMTP id 071226C336; Wed, 24 Nov 2021 19:27:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1637782033; 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=UIGpVd+G0TGJmPBoybxAUYyqPZihySlMnB+UDF+G+2U=; b=EPhCFlFJYXPlb/RGm4dgP9wnXyZ2agMLJL5kXxRpyB2oWecQUT7FYZKN8Iuo8sKly798pE kCOyiUsZv5yfnkpJtrbbsbfwlimyiEaZROGLg9+q3YaxCXnk4iA4c0v2+TkbG9Hlg0DsSd bqVkBMiEiU4+lmPU7n4FZVs0baa+XZA= X-MC-Unique: ikIDWUb_NtiZau2OAjVsJg-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH 19/23] python/aqmp: take QMPBadPortError and parse_address from qemu.qmp Date: Wed, 24 Nov 2021 14:26:13 -0500 Message-Id: <20211124192617.3396403-20-jsnow@redhat.com> In-Reply-To: <20211124192617.3396403-1-jsnow@redhat.com> References: <20211124192617.3396403-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=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: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.7, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Vladimir Sementsov-Ogievskiy , Eduardo Habkost , qemu-block@nongnu.org, Markus Armbruster , Hanna Reitz , Gerd Hoffmann , 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: 1637783542625100001 Content-Type: text/plain; charset="utf-8" Shift these definitions over from the qmp package to the async qmp package. Signed-off-by: John Snow --- python/qemu/aqmp/aqmp_tui.py | 2 +- python/qemu/aqmp/legacy.py | 30 ++++++++++++++++++++++++++---- python/qemu/qmp/__init__.py | 26 -------------------------- 3 files changed, 27 insertions(+), 31 deletions(-) diff --git a/python/qemu/aqmp/aqmp_tui.py b/python/qemu/aqmp/aqmp_tui.py index a2929f771c..184a3e4690 100644 --- a/python/qemu/aqmp/aqmp_tui.py +++ b/python/qemu/aqmp/aqmp_tui.py @@ -35,8 +35,8 @@ import urwid import urwid_readline =20 -from ..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 5d358d63db..c8183de19a 100644 --- a/python/qemu/aqmp/legacy.py +++ b/python/qemu/aqmp/legacy.py @@ -22,9 +22,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 @@ -45,6 +42,12 @@ # pylint: disable=3Dmissing-docstring =20 =20 +class QMPBadPortError(AQMPError): + """ + Unable to parse socket address: Port was non-numerical. + """ + + class QEMUMonitorProtocol(qemu.qmp.QEMUMonitorProtocol): def __init__(self, address: SocketAddrT, server: bool =3D False, @@ -72,7 +75,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 358c0971d0..4e08641154 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.31.1 From nobody Sat Apr 27 02:46:16 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 163778308607688.1410788983502; Wed, 24 Nov 2021 11:44:46 -0800 (PST) Received: from localhost ([::1]:45872 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mpyCB-0003E2-PW for importer@patchew.org; Wed, 24 Nov 2021 14:44:43 -0500 Received: from eggs.gnu.org ([209.51.188.92]:36180) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mpxvL-00048I-8v for qemu-devel@nongnu.org; Wed, 24 Nov 2021 14:27:19 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:29010) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mpxvH-0007iV-4n for qemu-devel@nongnu.org; Wed, 24 Nov 2021 14:27:18 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-264-MHlAYz-OMGmObFwAnvAGcw-1; Wed, 24 Nov 2021 14:27:11 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 191AC1800D41; Wed, 24 Nov 2021 19:27:10 +0000 (UTC) Received: from scv.redhat.com (unknown [10.22.9.79]) by smtp.corp.redhat.com (Postfix) with ESMTP id 19FFF67840; Wed, 24 Nov 2021 19:27:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1637782034; 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=OWMnQTSKoUxcRE4rHmCpOut0hwsKX2RMqMpsEOBKbYA=; b=eum36Zt0Yw12DX56MUCGtSyFmwpOgmG1OUR79OhMSRpGadK5xrll8B/o3kJumw76d6N0+0 k0EZ3iqOnVrRdgBziEm+OGap+uZLTHsxPokCg8SyNeqOwXdOvhC1Yx3cxWIeQ6eyx4D4HO rd6yQfkoqrYkyiVLAhr+U01PFfNToR8= X-MC-Unique: MHlAYz-OMGmObFwAnvAGcw-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH 20/23] python/aqmp: fully separate from qmp.QEMUMonitorProtocol Date: Wed, 24 Nov 2021 14:26:14 -0500 Message-Id: <20211124192617.3396403-21-jsnow@redhat.com> In-Reply-To: <20211124192617.3396403-1-jsnow@redhat.com> References: <20211124192617.3396403-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=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: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.7, 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_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Vladimir Sementsov-Ogievskiy , Eduardo Habkost , qemu-block@nongnu.org, Markus Armbruster , Hanna Reitz , Gerd Hoffmann , 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: 1637783087360100001 Content-Type: text/plain; charset="utf-8" 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. Signed-off-by: John Snow --- python/qemu/aqmp/legacy.py | 38 ++++++++++++++++++++++++++++++++------ 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/python/qemu/aqmp/legacy.py b/python/qemu/aqmp/legacy.py index c8183de19a..71f3d378db 100644 --- a/python/qemu/aqmp/legacy.py +++ b/python/qemu/aqmp/legacy.py @@ -5,18 +5,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 AQMPError from .protocol import Runstate, SocketAddrT from .qmp_client import QMPClient @@ -48,9 +48,9 @@ class QMPBadPortError(AQMPError): """ =20 =20 -class QEMUMonitorProtocol(qemu.qmp.QEMUMonitorProtocol): +class QEMUMonitorProtocol: def __init__(self, address: SocketAddrT, - server: bool =3D False, + server: bool =3D False, # pylint: disable=3Dunused-argum= ent nickname: Optional[str] =3D None): =20 # pylint: disable=3Dsuper-init-not-called @@ -74,7 +74,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: @@ -131,7 +142,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.31.1 From nobody Sat Apr 27 02:46:16 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1637783501530373.48768443571396; Wed, 24 Nov 2021 11:51:41 -0800 (PST) Received: from localhost ([::1]:36410 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mpyIt-0007Rh-9P for importer@patchew.org; Wed, 24 Nov 2021 14:51:39 -0500 Received: from eggs.gnu.org ([209.51.188.92]:36134) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mpxvK-00041G-15 for qemu-devel@nongnu.org; Wed, 24 Nov 2021 14:27:18 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:54934) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mpxvG-0007i2-1h for qemu-devel@nongnu.org; Wed, 24 Nov 2021 14:27:17 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-321-M097iStVOKW-wZdhs44y7g-1; Wed, 24 Nov 2021 14:27:12 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 349141054F90; Wed, 24 Nov 2021 19:27:11 +0000 (UTC) Received: from scv.redhat.com (unknown [10.22.9.79]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3B17E18A50; Wed, 24 Nov 2021 19:27:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1637782033; 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=NJpYRiSgqmgAc1rt1DcL1/Uwq82ddUzsIxWqnFHuKBg=; b=JFKyElRrJULsexSeFne11/UCN3rGM7A3ZvlZOLK7xSijfo6BG5zrDzgNuZl1bID4VhckWi /zHwazP7EzcrEnB0lE00AeDenE+wyXSahLPbk5X4KQfDCySHKRYaJ/YqoCsi8zXu2DfW9Z mEZsdmh63DaSS8WdGMsEHbZk8FDEYtc= X-MC-Unique: M097iStVOKW-wZdhs44y7g-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH 21/23] python/aqmp: copy qmp docstrings to qemu.aqmp.legacy Date: Wed, 24 Nov 2021 14:26:15 -0500 Message-Id: <20211124192617.3396403-22-jsnow@redhat.com> In-Reply-To: <20211124192617.3396403-1-jsnow@redhat.com> References: <20211124192617.3396403-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=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: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.7, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Vladimir Sementsov-Ogievskiy , Eduardo Habkost , qemu-block@nongnu.org, Markus Armbruster , Hanna Reitz , Gerd Hoffmann , 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: 1637783502057100001 Content-Type: text/plain; charset="utf-8" Copy the docstrings out of qemu.qmp, adjusting them as necessary to more accurately reflect the current state of this class. Signed-off-by: John Snow --- python/qemu/aqmp/legacy.py | 110 ++++++++++++++++++++++++++++++++++--- 1 file changed, 102 insertions(+), 8 deletions(-) diff --git a/python/qemu/aqmp/legacy.py b/python/qemu/aqmp/legacy.py index 71f3d378db..5f7955ac5d 100644 --- a/python/qemu/aqmp/legacy.py +++ b/python/qemu/aqmp/legacy.py @@ -1,9 +1,23 @@ """ -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. """ =20 +# Copyright (C) 2009, 2010, 2021 Red Hat Inc. +# +# Authors: +# Luiz Capitulino +# John Snow +# +# This work is licensed under the terms of the GNU GPL, version 2. +# See the COPYING file in the top-level directory. + + import asyncio from types import TracebackType from typing import ( @@ -39,9 +53,6 @@ # {} is the QMPReturnValue. =20 =20 -# pylint: disable=3Dmissing-docstring - - class QMPBadPortError(AQMPError): """ Unable to parse socket address: Port was non-numerical. @@ -49,6 +60,21 @@ class QMPBadPortError(AQMPError): =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: Deprecated, ignored. (See 'accept') + :param nickname: Optional nickname used for logging. + + ..note:: + No connection is established during `__init__`, this is done by + the `connect()` or `accept()` methods. + """ + def __init__(self, address: SocketAddrT, server: bool =3D False, # pylint: disable=3Dunused-argum= ent nickname: Optional[str] =3D None): @@ -108,6 +134,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 @@ -117,6 +149,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 @@ -130,6 +172,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 @@ -148,9 +196,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: @@ -160,6 +208,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 @@ -167,6 +218,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(): @@ -187,6 +251,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 @@ -195,17 +273,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.31.1 From nobody Sat Apr 27 02:46:16 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1637783876664868.651746249504; Wed, 24 Nov 2021 11:57:56 -0800 (PST) Received: from localhost ([::1]:52750 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mpyOw-0001nt-Bu for importer@patchew.org; Wed, 24 Nov 2021 14:57:54 -0500 Received: from eggs.gnu.org ([209.51.188.92]:36212) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mpxvM-0004Dw-DO for qemu-devel@nongnu.org; Wed, 24 Nov 2021 14:27:20 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:34628) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mpxvI-0007j6-E0 for qemu-devel@nongnu.org; Wed, 24 Nov 2021 14:27:20 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-444-zJKi5bHjONiE487Wq6Hc2g-1; Wed, 24 Nov 2021 14:27:13 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 74E9180A5F7; Wed, 24 Nov 2021 19:27:12 +0000 (UTC) Received: from scv.redhat.com (unknown [10.22.9.79]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5597667840; Wed, 24 Nov 2021 19:27:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1637782035; 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=ZZwa1mX4YRq0vgVxI4TWWloUUhZpDz5osaOtoQ8t8H0=; b=PaUz3/SsiuhJokx4AQpsv2y3jL1V+pR5d0bhDWUOWwAuBx1ON2V31UqdNkwhDXcaGV193v oNOqKWUlhVlgztr43mQlwDXJq7HU1zjAKkiS/tjsXN+4TFJpd1ZYuN8nuwzR37x21WE25g UE3CYAGwYNBlq0LkHXFi5KFCl5zENGo= X-MC-Unique: zJKi5bHjONiE487Wq6Hc2g-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH 22/23] python: remove the old QMP package Date: Wed, 24 Nov 2021 14:26:16 -0500 Message-Id: <20211124192617.3396403-23-jsnow@redhat.com> In-Reply-To: <20211124192617.3396403-1-jsnow@redhat.com> References: <20211124192617.3396403-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=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: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.7, 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_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Vladimir Sementsov-Ogievskiy , Eduardo Habkost , qemu-block@nongnu.org, Markus Armbruster , Hanna Reitz , Gerd Hoffmann , 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: 1637783877736100001 Content-Type: text/plain; charset="utf-8" Thank you for your service! Signed-off-by: John Snow --- 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 b0b86cc4c3..ddfa9ba3f5 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 fcf74f69ea..eb5213337d 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 5bfb82535f..0000000000 --- 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 4e08641154..0000000000 --- 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 e69de29bb2..0000000000 diff --git a/python/setup.cfg b/python/setup.cfg index 510df23698..5140a5b322 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.31.1 From nobody Sat Apr 27 02:46:16 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1637783736307745.9033935019654; Wed, 24 Nov 2021 11:55:36 -0800 (PST) Received: from localhost ([::1]:45538 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mpyMg-0005Fy-8y for importer@patchew.org; Wed, 24 Nov 2021 14:55:34 -0500 Received: from eggs.gnu.org ([209.51.188.92]:36202) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mpxvL-0004B0-OC for qemu-devel@nongnu.org; Wed, 24 Nov 2021 14:27:19 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:37841) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mpxvK-0007k4-9J for qemu-devel@nongnu.org; Wed, 24 Nov 2021 14:27:19 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-46-BfF4uI93OQGocHwy_7Zqqw-1; Wed, 24 Nov 2021 14:27:14 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8A3541054F90; Wed, 24 Nov 2021 19:27:13 +0000 (UTC) Received: from scv.redhat.com (unknown [10.22.9.79]) by smtp.corp.redhat.com (Postfix) with ESMTP id 970762B179; Wed, 24 Nov 2021 19:27:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1637782037; 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=yON4DkVybRlJ8QrAOwHh2Nzza9xYE+03aFOFuEjoQoQ=; b=bwZOcisosHVVJlAGAiaR+Z1Grty3b0WJHz/7dr4EAUPV2D3c0/FTtzXeoeAi9AwN1yvKbQ c65efVgkSbHcqeCrRgCAYcelkBWVl2ftXpLRc90TUjDxGqJhvXDOpknh29Vop2sFHSxTJU P5Bv1eUmenEtpaolG4cL2yqvYbt+mDk= X-MC-Unique: BfF4uI93OQGocHwy_7Zqqw-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH 23/23] python: re-enable pylint duplicate-code warnings Date: Wed, 24 Nov 2021 14:26:17 -0500 Message-Id: <20211124192617.3396403-24-jsnow@redhat.com> In-Reply-To: <20211124192617.3396403-1-jsnow@redhat.com> References: <20211124192617.3396403-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=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: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.7, 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_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Vladimir Sementsov-Ogievskiy , Eduardo Habkost , qemu-block@nongnu.org, Markus Armbruster , Hanna Reitz , Gerd Hoffmann , 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: 1637783738350100001 Content-Type: text/plain; charset="utf-8" With the old library gone, there's nothing duplicated in the tree, so the warning suppression can be removed. Signed-off-by: John Snow --- python/setup.cfg | 1 - 1 file changed, 1 deletion(-) diff --git a/python/setup.cfg b/python/setup.cfg index 5140a5b322..c341e922c2 100644 --- a/python/setup.cfg +++ b/python/setup.cfg @@ -114,7 +114,6 @@ ignore_missing_imports =3D True disable=3Dconsider-using-f-string, too-many-function-args, # mypy handles this with less false posit= ives. 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.31.1