From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A2961C433EF for ; Thu, 16 Dec 2021 17:51:52 +0000 (UTC) Received: from localhost ([::1]:55946 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mxuv1-0006Tp-Bp for qemu-devel@archiver.kernel.org; Thu, 16 Dec 2021 12:51:51 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52012) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mxutT-0004Y8-0f for qemu-devel@nongnu.org; Thu, 16 Dec 2021 12:50:15 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:34356) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mxutQ-0006UD-Pu for qemu-devel@nongnu.org; Thu, 16 Dec 2021 12:50:14 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639677011; 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: in-reply-to:in-reply-to:references:references; bh=Pni6e7XQALE8DvLVRdpELabg49TtWZDxO3UHNc5Qcsc=; b=IZtrasC6ypJjmktm5Xpz2E47sVe5sePrQIdM4tc9llldDuSyAh+PKzjuSEKWNRrEGAfK4E 8MhHZQFO3OIj5DPbkCBvwL1eXBTFW2a7MQREW5ReEb1WJapCf288PwMKX4kVNzpZOdEHRV mlL14VsVJ1PrfRSphiPLI409nLQlkDg= Received: from mail-ua1-f72.google.com (mail-ua1-f72.google.com [209.85.222.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-586-1wDPZa7oOkCvla7vPLar-g-1; Thu, 16 Dec 2021 12:50:09 -0500 X-MC-Unique: 1wDPZa7oOkCvla7vPLar-g-1 Received: by mail-ua1-f72.google.com with SMTP id 99-20020a9f246c000000b002f5cf140d32so4529596uaq.10 for ; Thu, 16 Dec 2021 09:50:09 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Pni6e7XQALE8DvLVRdpELabg49TtWZDxO3UHNc5Qcsc=; b=fihUkA7oeJ6DS7EdcXvdy34ZlmJN/FdD/7ZceetIE2jIvJsPYsevP79847BYAd9Ic+ rZCU0OBz9MhLC7Us9wU0BIGlpsOICHXrEJ0GjQR7Jw2jskCW9qhltt/55QZc666gKSy2 PcH9MjVhQE03nnBP3pMbnAIV/Y0pyGns1T/Pqz8L7IlpkKUwSrVz3nC1WqMZDNIoW6yx elwXOV83wXCHIhZ67Qs8YzI4ePd315DIoGZGOD0MFlewaKj4Ejxh6a+cjfXujDFcL3cH y7JdgC0tPGOseWLnmGI+d0rio6KHoNSl7802nkT994//WBKXvy9f1Cby5fFCQT7L6Kx8 oO+g== X-Gm-Message-State: AOAM532Plf7yylTBzkgydQDgN3Kxqg6DwOoN8ABVy21eQssv/Cm6G0zU bhCuIG8Ykk7/nEj7r+ES8n2P7hjtVZrkeNvcu+s3HqkRKtMuJC8rhbRGXGHPYgNCNQVOV//HzP8 zH5JUA0phfdIyuz1zFRjY75+toJ+BJA0= X-Received: by 2002:a05:6122:2158:: with SMTP id m24mr7285423vkd.1.1639677009275; Thu, 16 Dec 2021 09:50:09 -0800 (PST) X-Google-Smtp-Source: ABdhPJw9rUTMAEvOawWvMh7YKgx2MUZalvIJaawu3sJXwTK7Nnx6OSGCqLbFt4sQkTedbVGzNqsd2cfWaO9KDPjhrds= X-Received: by 2002:a05:6122:2158:: with SMTP id m24mr7285401vkd.1.1639677009003; Thu, 16 Dec 2021 09:50:09 -0800 (PST) MIME-Version: 1.0 References: <20211215193939.3768033-1-jsnow@redhat.com> <20211215193939.3768033-13-jsnow@redhat.com> <1cfdbd81-810e-05e6-57cd-a63e9cb8bddb@virtuozzo.com> In-Reply-To: <1cfdbd81-810e-05e6-57cd-a63e9cb8bddb@virtuozzo.com> From: John Snow Date: Thu, 16 Dec 2021 12:49:58 -0500 Message-ID: Subject: Re: [PATCH v2 12/25] python/machine: permanently switch to AQMP To: Vladimir Sementsov-Ogievskiy Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: multipart/alternative; boundary="000000000000ab1c1d05d3470d1f" 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.718, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, HTML_MESSAGE=0.001, 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: Eduardo Habkost , Kevin Wolf , Daniel Berrange , Beraldo Leal , Qemu-block , Markus Armbruster , qemu-devel , Wainer Moschetta , Andrea Bolognani , Hanna Reitz , Gerd Hoffmann , Cleber Rosa Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" --000000000000ab1c1d05d3470d1f Content-Type: text/plain; charset="UTF-8" On Thu, Dec 16, 2021 at 5:52 AM Vladimir Sementsov-Ogievskiy < vsementsov@virtuozzo.com> wrote: > 15.12.2021 22:39, John Snow wrote: > > 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, > > ) > > > > -from qemu.qmp import ( # pylint: disable=import-error > > +from qemu.aqmp import SocketAddrT > > +from qemu.aqmp.legacy import ( > > + QEMUMonitorProtocol, > > QMPMessage, > > QMPReturnValue, > > - SocketAddrT, > > ) > > > > from . import console_socket > > > > > > -if os.environ.get('QEMU_PYTHON_LEGACY_QMP'): > > - from qemu.qmp import QEMUMonitorProtocol > > -else: > > - from qemu.aqmp.legacy import QEMUMonitorProtocol > > - > > - > > LOG = logging.getLogger(__name__) > > > > > > @@ -710,8 +705,9 @@ def events_wait(self, > > :param timeout: Optional timeout, in seconds. > > See QEMUMonitorProtocol.pull_event. > > > > - :raise QMPTimeoutError: If timeout was non-zero and no matching > events > > - 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 = self._qmp.pull_event(wait=timeout) > > 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, > > ) > > > > -from qemu.qmp import SocketAddrT # pylint: disable=import-error > > +from qemu.aqmp.protocol import SocketAddrT > > You can also import it simply from qemu.aqmp > > Guess what order those patches got written in :) You're right, I'll update this. > > > > from .machine import QEMUMachine > > > > > > Reviewed-by: Vladimir Sementsov-Ogievskiy > > Thanks --000000000000ab1c1d05d3470d1f Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


=
On Thu, Dec 16, 2021 at 5:52 AM Vladi= mir Sementsov-Ogievskiy <vse= mentsov@virtuozzo.com> wrote:
15.12.2021 22:39, John Snow wrote:
> Remove the QEMU_PYTHON_LEGACY_QMP environment variable, making the
> switch permanent. Update Exceptions and import paths as necessary.
>
> Signed-off-by: John Snow <jsnow@redhat.com>
> ---
>=C2=A0 =C2=A0python/qemu/machine/machine.py | 18 +++++++-----------
>=C2=A0 =C2=A0python/qemu/machine/qtest.py=C2=A0 =C2=A0|=C2=A0 2 +-
>=C2=A0 =C2=A02 files changed, 8 insertions(+), 12 deletions(-)
>
> diff --git a/python/qemu/machine/machine.py b/python/qemu/machine/mach= ine.py
> index 67ab06ca2b..21fb4a4f30 100644
> --- a/python/qemu/machine/machine.py
> +++ b/python/qemu/machine/machine.py
> @@ -40,21 +40,16 @@
>=C2=A0 =C2=A0 =C2=A0 =C2=A0TypeVar,
>=C2=A0 =C2=A0)
>=C2=A0 =C2=A0
> -from qemu.qmp import (=C2=A0 # pylint: disable=3Dimport-error
> +from qemu.aqmp import SocketAddrT
> +from qemu.aqmp.legacy import (
> +=C2=A0 =C2=A0 QEMUMonitorProtocol,
>=C2=A0 =C2=A0 =C2=A0 =C2=A0QMPMessage,
>=C2=A0 =C2=A0 =C2=A0 =C2=A0QMPReturnValue,
> -=C2=A0 =C2=A0 SocketAddrT,
>=C2=A0 =C2=A0)
>=C2=A0 =C2=A0
>=C2=A0 =C2=A0from . import console_socket
>=C2=A0 =C2=A0
>=C2=A0 =C2=A0
> -if os.environ.get('QEMU_PYTHON_LEGACY_QMP'):
> -=C2=A0 =C2=A0 from qemu.qmp import QEMUMonitorProtocol
> -else:
> -=C2=A0 =C2=A0 from qemu.aqmp.legacy import QEMUMonitorProtocol
> -
> -
>=C2=A0 =C2=A0LOG =3D logging.getLogger(__name__)
>=C2=A0 =C2=A0
>=C2=A0 =C2=A0
> @@ -710,8 +705,9 @@ def events_wait(self,
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0:param timeout: Optional timeo= ut, in seconds.
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0See QEMUMonitorProtocol.pull_event.
>=C2=A0 =C2=A0
> -=C2=A0 =C2=A0 =C2=A0 =C2=A0 :raise QMPTimeoutError: If timeout was no= n-zero and no matching events
> -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 were found.
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 :raise asyncio.TimeoutError:
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 If timeout was non-zero and= no matching events were found.
> +
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0:return: A QMP event matching = the filter criteria.
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 I= f timeout was 0 and no event matched, None.
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0"""
> @@ -734,7 +730,7 @@ def _match(event: QMPMessage) -> bool:
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0event =3D self._= qmp.pull_event(wait=3Dtimeout)
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if event is None= :
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0# = NB: None is only returned when timeout is false-ish.
> -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 # Timeouts ra= ise QMPTimeoutError instead!
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 # Timeouts ra= ise asyncio.TimeoutError instead!
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0br= eak
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if _match(event)= :
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0re= turn 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 @@
>=C2=A0 =C2=A0 =C2=A0 =C2=A0TextIO,
>=C2=A0 =C2=A0)
>=C2=A0 =C2=A0
> -from qemu.qmp import SocketAddrT=C2=A0 # pylint: disable=3Dimport-err= or
> +from qemu.aqmp.protocol import SocketAddrT

You can also import it simply from qemu.aqmp


Guess what order those patches got wri= tten in :)

You're right, I'll update this.=
=C2=A0
vsementsov@virtuozzo.com>


Thanks
--000000000000ab1c1d05d3470d1f--