All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: John Snow <jsnow@redhat.com>
Cc: Eduardo Habkost <eduardo@habkost.net>,
	Peter Maydell <peter.maydell@linaro.org>,
	Beraldo Leal <bleal@redhat.com>,
	qemu-block@nongnu.org, Markus Armbruster <armbru@redhat.com>,
	qemu-devel@nongnu.org, Hanna Reitz <hreitz@redhat.com>,
	Cleber Rosa <crosa@redhat.com>
Subject: Re: [PATCH v4 4/4] python/aqmp: add socket bind step to legacy.py
Date: Tue, 1 Feb 2022 14:21:05 +0100	[thread overview]
Message-ID: <YfkzwdbIaGF5TcVZ@redhat.com> (raw)
In-Reply-To: <20220201041134.1237016-5-jsnow@redhat.com>

Am 01.02.2022 um 05:11 hat John Snow geschrieben:
> The synchronous QMP library would bind to the server address during
> __init__(). The new library delays this to the accept() call, because
> binding occurs inside of the call to start_[unix_]server(), which is an
> async method -- so it cannot happen during __init__ anymore.
> 
> Python 3.7+ adds the ability to create the server (and thus the bind()
> call) and begin the active listening in separate steps, but we don't
> have that functionality in 3.6, our current minimum.
> 
> Therefore ... Add a temporary workaround that allows the synchronous
> version of the client to bind the socket in advance, guaranteeing that
> there will be a UNIX socket in the filesystem ready for the QEMU client
> to connect to without a race condition.
> 
> (Yes, it's a bit ugly. Fixing it more nicely will have to wait until our
> minimum Python version is 3.7+.)
> 
> Signed-off-by: John Snow <jsnow@redhat.com>
> ---
>  python/qemu/aqmp/legacy.py   |  3 +++
>  python/qemu/aqmp/protocol.py | 41 +++++++++++++++++++++++++++++++++---
>  2 files changed, 41 insertions(+), 3 deletions(-)
> 
> diff --git a/python/qemu/aqmp/legacy.py b/python/qemu/aqmp/legacy.py
> index 0890f95b16..6baa5f3409 100644
> --- a/python/qemu/aqmp/legacy.py
> +++ b/python/qemu/aqmp/legacy.py
> @@ -56,6 +56,9 @@ def __init__(self, address: SocketAddrT,
>          self._address = address
>          self._timeout: Optional[float] = None
>  
> +        if server:
> +            self._aqmp._bind_hack(address)  # pylint: disable=protected-access

I feel that this is the only part that really makes it ugly. Do you
really think this way is so bad that we can't make it an official public
interface in the library?

Kevin



  reply	other threads:[~2022-02-01 17:27 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-01  4:11 [PATCH v4 0/4] Python: Improvements for iotest 040,041 John Snow
2022-02-01  4:11 ` [PATCH v4 1/4] python/aqmp: Fix negotiation with pre-"oob" QEMU John Snow
2022-02-01 12:59   ` Kevin Wolf
2022-02-01 18:33     ` John Snow
2022-02-01  4:11 ` [PATCH v4 2/4] python/machine: raise VMLaunchFailure exception from launch() John Snow
2022-02-01  4:11 ` [PATCH v4 3/4] python: upgrade mypy to 0.780 John Snow
2022-02-01  4:11 ` [PATCH v4 4/4] python/aqmp: add socket bind step to legacy.py John Snow
2022-02-01 13:21   ` Kevin Wolf [this message]
2022-02-01 18:32     ` John Snow
2022-02-01 19:46       ` Kevin Wolf
2022-02-02 19:08         ` John Snow
2022-02-03  9:19           ` Kevin Wolf
2022-02-04 21:23             ` John Snow
2022-02-03  9:38           ` Daniel P. Berrangé
2022-02-04  0:25             ` John Snow
2022-02-01 13:28 ` [PATCH v4 0/4] Python: Improvements for iotest 040,041 Kevin Wolf
2022-02-01 18:16   ` John Snow

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YfkzwdbIaGF5TcVZ@redhat.com \
    --to=kwolf@redhat.com \
    --cc=armbru@redhat.com \
    --cc=bleal@redhat.com \
    --cc=crosa@redhat.com \
    --cc=eduardo@habkost.net \
    --cc=hreitz@redhat.com \
    --cc=jsnow@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.