From: John Snow <jsnow@redhat.com>
To: qemu-devel@nongnu.org
Cc: Eduardo Habkost <eduardo@habkost.net>,
Kevin Wolf <kwolf@redhat.com>,
Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>,
Daniel Berrange <berrange@redhat.com>,
Beraldo Leal <bleal@redhat.com>,
qemu-block@nongnu.org, Andrea Bolognani <abologna@redhat.com>,
Wainer Moschetta <wainersm@redhat.com>,
Markus Armbruster <armbru@redhat.com>,
Hanna Reitz <hreitz@redhat.com>,
Gerd Hoffmann <kraxel@redhat.com>, Cleber Rosa <crosa@redhat.com>,
John Snow <jsnow@redhat.com>
Subject: [PATCH v2 20/25] python/aqmp: take QMPBadPortError and parse_address from qemu.qmp
Date: Wed, 15 Dec 2021 14:39:34 -0500 [thread overview]
Message-ID: <20211215193939.3768033-21-jsnow@redhat.com> (raw)
In-Reply-To: <20211215193939.3768033-1-jsnow@redhat.com>
Shift these definitions over from the qmp package to the async qmp
package.
Signed-off-by: John Snow <jsnow@redhat.com>
---
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
-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 0890f95b16..76b09671cc 100644
--- a/python/qemu/aqmp/legacy.py
+++ b/python/qemu/aqmp/legacy.py
@@ -22,9 +22,6 @@
from .qmp_client import QMPClient
-# (Temporarily) Re-export QMPBadPortError
-QMPBadPortError = qemu.qmp.QMPBadPortError
-
#: QMPMessage is an entire QMP message of any kind.
QMPMessage = Dict[str, Any]
@@ -45,6 +42,12 @@
# pylint: disable=missing-docstring
+class QMPBadPortError(QMPError):
+ """
+ Unable to parse socket address: Port was non-numerical.
+ """
+
+
class QEMUMonitorProtocol(qemu.qmp.QEMUMonitorProtocol):
def __init__(self, address: SocketAddrT,
server: bool = False,
@@ -72,7 +75,26 @@ def _get_greeting(self) -> Optional[QMPMessage]:
return None
# __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 = address.split(':')
+ if len(components) == 2:
+ try:
+ port = int(components[1])
+ except ValueError:
+ msg = 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 = True) -> Optional[QMPMessage]:
self._aqmp.await_greeting = 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 = reply
-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()
- @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 = address.split(':')
- if len(components) == 2:
- try:
- port = int(components[1])
- except ValueError:
- msg = 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 = True) -> Optional[QMPMessage]:
"""
Connect to the QMP Monitor and perform capabilities negotiation.
--
2.31.1
next prev parent reply other threads:[~2021-12-15 20:04 UTC|newest]
Thread overview: 87+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-15 19:39 [PATCH v2 00/25] Python: delete synchronous qemu.qmp package John Snow
2021-12-15 19:39 ` [PATCH v2 01/25] python/aqmp: add __del__ method to legacy interface John Snow
2021-12-16 9:31 ` Vladimir Sementsov-Ogievskiy
2021-12-16 17:09 ` John Snow
2021-12-16 12:26 ` Beraldo Leal
2021-12-15 19:39 ` [PATCH v2 02/25] python/aqmp: handle asyncio.TimeoutError on execute() John Snow
2021-12-16 9:51 ` Vladimir Sementsov-Ogievskiy
2021-12-16 17:22 ` John Snow
2021-12-16 17:59 ` Vladimir Sementsov-Ogievskiy
2021-12-16 12:39 ` Beraldo Leal
2021-12-16 17:26 ` John Snow
2021-12-15 19:39 ` [PATCH v2 03/25] python/aqmp: copy type definitions from qmp John Snow
2021-12-16 10:00 ` Vladimir Sementsov-Ogievskiy
2021-12-16 10:19 ` Daniel P. Berrangé
2021-12-16 17:31 ` John Snow
2021-12-15 19:39 ` [PATCH v2 04/25] python/aqmp: add SocketAddrT to package root John Snow
2021-12-16 10:01 ` Vladimir Sementsov-Ogievskiy
2021-12-16 13:16 ` Beraldo Leal
2021-12-15 19:39 ` [PATCH v2 05/25] python/aqmp: rename AQMPError to QMPError John Snow
2021-12-16 10:08 ` Vladimir Sementsov-Ogievskiy
2021-12-16 17:01 ` John Snow
2021-12-15 19:39 ` [PATCH v2 06/25] python/qemu-ga-client: update instructions to newer CLI syntax John Snow
2021-12-16 10:14 ` Vladimir Sementsov-Ogievskiy
2021-12-16 17:36 ` John Snow
2021-12-16 10:16 ` Daniel P. Berrangé
2021-12-15 19:39 ` [PATCH v2 07/25] python/qmp: switch qemu-ga-client to AQMP John Snow
2021-12-16 10:31 ` Vladimir Sementsov-Ogievskiy
2021-12-16 17:43 ` John Snow
2021-12-16 13:21 ` Beraldo Leal
2021-12-15 19:39 ` [PATCH v2 08/25] python/qmp: switch qom tools " John Snow
2021-12-16 10:43 ` Vladimir Sementsov-Ogievskiy
2021-12-16 13:26 ` Beraldo Leal
2021-12-15 19:39 ` [PATCH v2 09/25] python/qmp: switch qmp-shell " John Snow
2021-12-16 10:45 ` Vladimir Sementsov-Ogievskiy
2021-12-15 19:39 ` [PATCH v2 10/25] python: move qmp utilities to python/qemu/utils John Snow
2021-12-16 10:48 ` Vladimir Sementsov-Ogievskiy
2021-12-15 19:39 ` [PATCH v2 11/25] python: move qmp-shell under the AQMP package John Snow
2021-12-16 10:49 ` Vladimir Sementsov-Ogievskiy
2021-12-16 13:31 ` Beraldo Leal
2021-12-15 19:39 ` [PATCH v2 12/25] python/machine: permanently switch to AQMP John Snow
2021-12-16 10:51 ` Vladimir Sementsov-Ogievskiy
2021-12-16 17:49 ` John Snow
2021-12-16 13:33 ` Beraldo Leal
2021-12-15 19:39 ` [PATCH v2 13/25] scripts/cpu-x86-uarch-abi: fix CLI parsing John Snow
2021-12-16 10:13 ` Daniel P. Berrangé
2021-12-16 10:55 ` Vladimir Sementsov-Ogievskiy
2021-12-15 19:39 ` [PATCH v2 14/25] scripts/cpu-x86-uarch-abi: switch to AQMP John Snow
2021-12-16 10:14 ` Daniel P. Berrangé
2021-12-16 10:56 ` Vladimir Sementsov-Ogievskiy
2021-12-16 13:46 ` Beraldo Leal
2021-12-15 19:39 ` [PATCH v2 15/25] scripts/render-block-graph: " John Snow
2021-12-16 10:57 ` Vladimir Sementsov-Ogievskiy
2021-12-16 20:48 ` John Snow
2021-12-16 13:47 ` Beraldo Leal
2021-12-15 19:39 ` [PATCH v2 16/25] scripts/bench-block-job: " John Snow
2021-12-16 10:58 ` Vladimir Sementsov-Ogievskiy
2021-12-16 13:49 ` Beraldo Leal
2021-12-15 19:39 ` [PATCH v2 17/25] iotests/mirror-top-perms: " John Snow
2021-12-16 11:01 ` Vladimir Sementsov-Ogievskiy
2021-12-16 13:50 ` Beraldo Leal
2021-12-15 19:39 ` [PATCH v2 18/25] iotests: " John Snow
2021-12-16 11:02 ` Vladimir Sementsov-Ogievskiy
2021-12-16 13:55 ` Beraldo Leal
2021-12-15 19:39 ` [PATCH v2 19/25] python: temporarily silence pylint duplicate-code warnings John Snow
2021-12-16 11:02 ` Vladimir Sementsov-Ogievskiy
2021-12-15 19:39 ` John Snow [this message]
2021-12-16 11:05 ` [PATCH v2 20/25] python/aqmp: take QMPBadPortError and parse_address from qemu.qmp Vladimir Sementsov-Ogievskiy
2021-12-16 14:03 ` Beraldo Leal
2021-12-15 19:39 ` [PATCH v2 21/25] python/aqmp: fully separate from qmp.QEMUMonitorProtocol John Snow
2021-12-16 11:11 ` Vladimir Sementsov-Ogievskiy
2021-12-16 14:11 ` Beraldo Leal
2021-12-15 19:39 ` [PATCH v2 22/25] python/aqmp: copy qmp docstrings to qemu.aqmp.legacy John Snow
2021-12-16 11:28 ` Vladimir Sementsov-Ogievskiy
2021-12-16 14:15 ` Beraldo Leal
2021-12-15 19:39 ` [PATCH v2 23/25] python: remove the old QMP package John Snow
2021-12-16 11:30 ` Vladimir Sementsov-Ogievskiy
2021-12-16 14:17 ` Beraldo Leal
2021-12-15 19:39 ` [PATCH v2 24/25] python: re-enable pylint duplicate-code warnings John Snow
2021-12-16 11:31 ` Vladimir Sementsov-Ogievskiy
2021-12-16 14:18 ` Beraldo Leal
2021-12-15 19:39 ` [PATCH v2 25/25] python: rename qemu.aqmp to qemu.qmp John Snow
2021-12-16 11:41 ` Vladimir Sementsov-Ogievskiy
2021-12-16 21:10 ` John Snow
2021-12-17 7:39 ` Vladimir Sementsov-Ogievskiy
2021-12-17 16:28 ` John Snow
2021-12-16 10:50 ` [PATCH v2 00/25] Python: delete synchronous qemu.qmp package Daniel P. Berrangé
2021-12-16 16:27 ` 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=20211215193939.3768033-21-jsnow@redhat.com \
--to=jsnow@redhat.com \
--cc=abologna@redhat.com \
--cc=armbru@redhat.com \
--cc=berrange@redhat.com \
--cc=bleal@redhat.com \
--cc=crosa@redhat.com \
--cc=eduardo@habkost.net \
--cc=hreitz@redhat.com \
--cc=kraxel@redhat.com \
--cc=kwolf@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=vsementsov@virtuozzo.com \
--cc=wainersm@redhat.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).