• R/O
  • HTTP
  • SSH
  • HTTPS

コミット

タグ
未設定

よく使われているワード(クリックで追加)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

コミットメタ情報

リビジョンf3efd12930f34b9724e15d8fd2ff56a97b67219d (tree)
日時2022-01-22 06:01:31
作者John Snow <jsnow@redh...>
コミッターJohn Snow

ログメッセージ

python/qmp: switch qmp-shell to AQMP

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 <jsnow@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>

変更サマリ

差分

--- a/python/qemu/aqmp/legacy.py
+++ b/python/qemu/aqmp/legacy.py
@@ -22,6 +22,9 @@ from .protocol import Runstate, SocketAddrT
2222 from .qmp_client import QMPClient
2323
2424
25+# (Temporarily) Re-export QMPBadPortError
26+QMPBadPortError = qemu.qmp.QMPBadPortError
27+
2528 #: QMPMessage is an entire QMP message of any kind.
2629 QMPMessage = Dict[str, Any]
2730
--- a/python/qemu/qmp/qmp_shell.py
+++ b/python/qemu/qmp/qmp_shell.py
@@ -95,8 +95,13 @@ from typing import (
9595 Sequence,
9696 )
9797
98-from qemu import qmp
99-from qemu.qmp import QMPMessage
98+from qemu.aqmp import ConnectError, QMPError, SocketAddrT
99+from qemu.aqmp.legacy import (
100+ QEMUMonitorProtocol,
101+ QMPBadPortError,
102+ QMPMessage,
103+ QMPObject,
104+)
100105
101106
102107 LOG = logging.getLogger(__name__)
@@ -125,7 +130,7 @@ class QMPCompleter:
125130 return None
126131
127132
128-class QMPShellError(qmp.QMPError):
133+class QMPShellError(QMPError):
129134 """
130135 QMP Shell Base error class.
131136 """
@@ -153,7 +158,7 @@ class FuzzyJSON(ast.NodeTransformer):
153158 return node
154159
155160
156-class QMPShell(qmp.QEMUMonitorProtocol):
161+class QMPShell(QEMUMonitorProtocol):
157162 """
158163 QMPShell provides a basic readline-based QMP shell.
159164
@@ -161,7 +166,7 @@ class QMPShell(qmp.QEMUMonitorProtocol):
161166 :param pretty: Pretty-print QMP messages.
162167 :param verbose: Echo outgoing QMP messages to console.
163168 """
164- def __init__(self, address: qmp.SocketAddrT,
169+ def __init__(self, address: SocketAddrT,
165170 pretty: bool = False, verbose: bool = False):
166171 super().__init__(address)
167172 self._greeting: Optional[QMPMessage] = None
@@ -237,7 +242,7 @@ class QMPShell(qmp.QEMUMonitorProtocol):
237242
238243 def _cli_expr(self,
239244 tokens: Sequence[str],
240- parent: qmp.QMPObject) -> None:
245+ parent: QMPObject) -> None:
241246 for arg in tokens:
242247 (key, sep, val) = arg.partition('=')
243248 if sep != '=':
@@ -403,7 +408,7 @@ class HMPShell(QMPShell):
403408 :param pretty: Pretty-print QMP messages.
404409 :param verbose: Echo outgoing QMP messages to console.
405410 """
406- def __init__(self, address: qmp.SocketAddrT,
411+ def __init__(self, address: SocketAddrT,
407412 pretty: bool = False, verbose: bool = False):
408413 super().__init__(address, pretty, verbose)
409414 self._cpu_index = 0
@@ -512,19 +517,17 @@ def main() -> None:
512517
513518 try:
514519 address = shell_class.parse_address(args.qmp_server)
515- except qmp.QMPBadPortError:
520+ except QMPBadPortError:
516521 parser.error(f"Bad port number: {args.qmp_server}")
517522 return # pycharm doesn't know error() is noreturn
518523
519524 with shell_class(address, args.pretty, args.verbose) as qemu:
520525 try:
521526 qemu.connect(negotiate=not args.skip_negotiation)
522- except qmp.QMPConnectError:
523- die("Didn't get QMP greeting message")
524- except qmp.QMPCapabilitiesError:
525- die("Couldn't negotiate capabilities")
526- except OSError as err:
527- die(f"Couldn't connect to {args.qmp_server}: {err!s}")
527+ except ConnectError as err:
528+ if isinstance(err.exc, OSError):
529+ die(f"Couldn't connect to {args.qmp_server}: {err!s}")
530+ die(str(err))
528531
529532 for _ in qemu.repl():
530533 pass