On Tue, Aug 03, 2021 at 02:29:25PM -0400, John Snow wrote:
> It's a little messier than connect, because it wasn't designed to accept
> *precisely one* connection. Such is life.
>
> Signed-off-by: John Snow <jsnow@redhat.com>
> ---
> python/qemu/aqmp/protocol.py | 89 ++++++++++++++++++++++++++++++++++--
> 1 file changed, 85 insertions(+), 4 deletions(-)
>
> diff --git a/python/qemu/aqmp/protocol.py b/python/qemu/aqmp/protocol.py
> index 77b330627b3..7eca65aa265 100644
> --- a/python/qemu/aqmp/protocol.py
> +++ b/python/qemu/aqmp/protocol.py
> @@ -243,6 +243,24 @@ async def runstate_changed(self) -> Runstate:
> await self._runstate_event.wait()
> return self.runstate
>
> + @upper_half
> + @require(Runstate.IDLE)
> + async def accept(self, address: Union[str, Tuple[str, int]],
> + ssl: Optional[SSLContext] = None) -> None:
> + """
> + Accept a connection and begin processing message queues.
> +
> + If this call fails, `runstate` is guaranteed to be set back to `IDLE`.
> +
> + :param address:
> + Address to listen to; UNIX socket path or TCP address/port.
Can't TCP use a well-known port name instead of an int? But limiting
clients to just int port for now isn't fatal to the patch.
The old QMP library didn't support this, and I used the old library as my template here. I'm willing to change the address format and types to be more comprehensive, but I was thinking that it should probably try to match or adhere to some standard; de-facto or otherwise. I wasn't sure which to pick, and we use a few different ones in QEMU itself. Any recommendations for me?
> + :param ssl: SSL context to use, if any.
> +
> + :raise StateError: When the `Runstate` is not `IDLE`.
> + :raise ConnectError: If a connection could not be accepted.
> + """
> + await self._new_session(address, ssl, accept=True)
> +
Reviewed-by: Eric Blake <eblake@redhat.com>
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization: qemu.org | libvirt.org