QAPI patches patches for 2023-05-17
The following changes since commit f9d58e0ca53b3f470b84725a7b5e47fcf446a2ea:
Merge tag 'pull-9p-20230516' of https://github.com/cschoenebeck/qemu into staging (2023-05-16 10:21:44 -0700)
are available in the Git repository at:
https://repo.or.cz/qemu/armbru.git tags/pull-qapi-2023-05-17
for you to fetch changes up to 28d2a4f620db2bc327dbd3443b777890d39a0bf6:
qapi/parser: Drop two bad type hints for now (2023-05-17 15:49:22 +0200)
----------------------------------------------------------------
QAPI patches patches for 2023-05-17
----------------------------------------------------------------
Markus Armbruster (2):
qapi: Improve error message for description following section qapi/parser: Drop two bad type hints for now
Peter Maydell (3):
docs/interop: Convert qmp-spec.txt to rST docs/interop/qmp-spec: Update error description for parsing errors docs/interop: Delete qmp-intro.txt
docs/devel/qapi-code-gen.rst | 3 +-
docs/interop/index.rst | 1 +
docs/interop/qmp-intro.txt | 88 -------
docs/interop/{qmp-spec.txt => qmp-spec.rst} | 337 ++++++++++++++------------
qapi/control.json | 4 +-
qapi/qapi-schema.json | 3 +-
qobject/json-lexer.c | 2 +-
python/qemu/qmp/models.py | 8 +-
python/qemu/qmp/qmp_client.py | 4 +-
qemu-options.hx | 28 ++-
scripts/qapi/parser.py | 8 +-
tests/qapi-schema/doc-interleaved-section.err | 2 +-
12 files changed, 226 insertions(+), 262 deletions(-)
delete mode 100644 docs/interop/qmp-intro.txt
rename docs/interop/{qmp-spec.txt => qmp-spec.rst} (55%)Signature · 1 line
2.39.2
[PULL 1/5] qapi: Improve error message for description following section
The error message is bad when the section is untagged. For instance, test case doc-interleaved-section produces "'@foobar:' can't follow 'Note' section", which is okay, but if we drop the "Note:" tag, we get "'@foobar:' can't follow 'None' section, which is bad.
Change the error message to "description of '@foobar:' follows a section".
Message-Id: <[email protected]>
--- scripts/qapi/parser.py | 4 ++-- tests/qapi-schema/doc-interleaved-section.err | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
scripts/qapi/parser.py +2 -2
@@ -675,8 +675,8 @@ def _append_various_line(self, line: str) -> None: match = self._match_at_name_colon(line) if match: raise QAPIParseError(self._parser, - "'@%s:' can't follow '%s' section" - % (match.group(1), self.sections[0].name)) + "description of '@%s:' follows a section" + % match.group(1)) match = self._match_section_tag(line) if match: line = line[match.end():]
tests/qapi-schema/doc-interleaved-section.err +1 -1
@@ -1 +1 @@ -doc-interleaved-section.json:15:1: '@foobar:' can't follow 'Note' section +doc-interleaved-section.json:15:1: description of '@foobar:' follows a section
Signature · 1 line
2.39.2
PATCH 1/1 qapi/parser: Drop two bad type hints for now
In reply to Markus ArmbrusterTwo type hints fail centos-stream-8-x86_64 CI. They are actually broken. Changing them to Optional[re.Match[str]] fixes them locally for me, but then CI fails differently. Drop them for now.
--- scripts/qapi/parser.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
scripts/qapi/parser.py +2 -2
@@ -563,11 +563,11 @@ def end_comment(self) -> None: self._switch_section(QAPIDoc.NullSection(self._parser)) @staticmethod - def _match_at_name_colon(string: str) -> re.Match: + def _match_at_name_colon(string: str): return re.match(r'@([^:]*): *', string) @staticmethod - def _match_section_tag(string: str) -> re.Match: + def _match_section_tag(string: str): return re.match(r'(Returns|Since|Notes?|Examples?|TODO): *', string) def _append_body_line(self, line: str) -> None:
Signature · 1 line
2.39.2
[PULL 4/5] docs/interop: Delete qmp-intro.txt
In reply to Markus ArmbrusterFrom: Peter Maydell <[email protected]>
qmp-intro.txt is quite small and provides very little information that isn't already in the documentation elsewhere. Fold the example command lines into qemu-options.hx, and delete the now-unneeded plain text document.
While we're touching the qemu-options.hx documentation text, wordsmith it a little bit and improve the rST formatting.
Message-Id: <[email protected]>
--- docs/interop/qmp-intro.txt | 88 -------------------------------------- qemu-options.hx | 28 +++++++++--- 2 files changed, 22 insertions(+), 94 deletions(-) delete mode 100644 docs/interop/qmp-intro.txt
docs/interop/qmp-intro.txt deleted +0 -88
@@ -1,88 +0,0 @@ - QEMU Machine Protocol - ===================== - -Introduction ------------- - -The QEMU Machine Protocol (QMP) allows applications to operate a -QEMU instance. - -QMP is JSON[1] based and features the following: - -- Lightweight, text-based, easy to parse data format -- Asynchronous messages support (ie. events) -- Capabilities Negotiation - -For detailed information on QMP's usage, please, refer to the following files: - -o qmp-spec.txt QEMU Machine Protocol current specification -o qemu-qmp-ref.html QEMU QMP commands and events (auto-generated at build-time) - -[1] https://www.json.org - -Usage ------ - -You can use the -qmp option to enable QMP. For example, the following -makes QMP available on localhost port 4444: - -$ qemu [...] -qmp tcp:localhost:4444,server=on,wait=off - -However, for more flexibility and to make use of more options, the -mon -command-line option should be used. For instance, the following example -creates one HMP instance (human monitor) on stdio and one QMP instance -on localhost port 4444: - -$ qemu [...] -chardev stdio,id=mon0 -mon chardev=mon0,mode=readline \ - -chardev socket,id=mon1,host=localhost,port=4444,server=on,wait=off \ - -mon chardev=mon1,mode=control,pretty=on - -Please, refer to QEMU's manpage for more information. - -Simple Testing --------------- - -To manually test QMP one can connect with telnet and issue commands by hand: - -$ telnet localhost 4444 -Trying 127.0.0.1... -Connected to localhost. -Escape character is '^]'. -{ - "QMP": { - "version": { - "qemu": { - "micro": 0, - "minor": 0, - "major": 3 - }, - "package": "v3.0.0" - }, - "capabilities": [ - "oob" - ] - } -} - -{ "execute": "qmp_capabilities" } -{ - "return": { - } -} - -{ "execute": "query-status" } -{ - "return": { - "status": "prelaunch", - "singlestep": false, - "running": false - } -} - -Please refer to docs/interop/qemu-qmp-ref.* for a complete command -reference, generated from qapi/qapi-schema.json. - -QMP wiki page -------------- - -https://wiki.qemu.org/QMP
qemu-options.hx +22 -6
@@ -4170,26 +4170,42 @@ DEF("qmp", HAS_ARG, QEMU_OPTION_qmp, \ QEMU_ARCH_ALL) SRST ``-qmp dev`` - Like -monitor but opens in 'control' mode. + Like ``-monitor`` but opens in 'control' mode. For example, to make + QMP available on localhost port 4444:: + + -qmp tcp:localhost:4444,server=on,wait=off + + Not all options are configurable via this syntax; for maximum + flexibility use the ``-mon`` option and an accompanying ``-chardev``. + ERST DEF("qmp-pretty", HAS_ARG, QEMU_OPTION_qmp_pretty, \ "-qmp-pretty dev like -qmp but uses pretty JSON formatting\n", QEMU_ARCH_ALL) SRST ``-qmp-pretty dev`` - Like -qmp but uses pretty JSON formatting. + Like ``-qmp`` but uses pretty JSON formatting. ERST DEF("mon", HAS_ARG, QEMU_OPTION_mon, \ "-mon [chardev=]name[,mode=readline|control][,pretty[=on|off]]\n", QEMU_ARCH_ALL) SRST ``-mon [chardev=]name[,mode=readline|control][,pretty[=on|off]]`` - Setup monitor on chardev name. ``mode=control`` configures - a QMP monitor (a JSON RPC-style protocol) and it is not the - same as HMP, the human monitor that has a "(qemu)" prompt. - ``pretty`` is only valid when ``mode=control``, + Set up a monitor connected to the chardev ``name``. + QEMU supports two monitors: the Human Monitor Protocol + (HMP; for human interaction), and the QEMU Monitor Protocol + (QMP; a JSON RPC-style protocol). + The default is HMP; ``mode=control`` selects QMP instead. + ``pretty`` is only valid when ``mode=control``, turning on JSON pretty printing to ease human reading and debugging. + + For example:: + + -chardev socket,id=mon1,host=localhost,port=4444,server=on,wait=off \ + -mon chardev=mon1,mode=control,pretty=on + + enables the QMP monitor on localhost port 4444 with pretty-printing. ERST DEF("debugcon", HAS_ARG, QEMU_OPTION_debugcon, \
Signature · 1 line
2.39.2
[PULL 3/5] docs/interop/qmp-spec: Update error description for parsing errors
In reply to Markus ArmbrusterFrom: Peter Maydell <[email protected]>
The description text for a parsing error has changed since the spec doc was first written; update the example in the docs.
Message-Id: <[email protected]>
--- docs/interop/qmp-spec.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
docs/interop/qmp-spec.rst +1 -1
@@ -307,7 +307,7 @@ This section provides some examples of real QMP usage, in all of them .. code-block:: QMP -> { "execute": } - <- { "error": { "class": "GenericError", "desc": "Invalid JSON syntax" } } + <- { "error": { "class": "GenericError", "desc": "JSON parse error, expecting value" } } .. admonition:: Example
Signature · 1 line
2.39.2
[PULL 2/5] docs/interop: Convert qmp-spec.txt to rST
In reply to Markus ArmbrusterFrom: Peter Maydell <[email protected]>
Convert the qmp-spec.txt document to restructuredText. Notable points about the conversion:
* numbers at the start of section headings are removed, to match the style of the rest of the manual
* cross-references to other sections or documents are hyperlinked
* various formatting tweaks (notably the examples, which need the -> and <- prefixed so the QMP code-block lexer will accept them)
* English prose fixed in a few places
Message-Id: <[email protected]>
---
docs/devel/qapi-code-gen.rst | 3 +-
docs/interop/index.rst | 1 +
docs/interop/{qmp-spec.txt => qmp-spec.rst} | 337 +++++++++++---------
qapi/control.json | 4 +-
qapi/qapi-schema.json | 3 +-
qobject/json-lexer.c | 2 +-
python/qemu/qmp/models.py | 8 +-
python/qemu/qmp/qmp_client.py | 4 +-
8 files changed, 199 insertions(+), 163 deletions(-)
rename docs/interop/{qmp-spec.txt => qmp-spec.rst} (55%)docs/devel/qapi-code-gen.rst +2 -1
@@ -545,7 +545,8 @@ Member 'allow-oob' declares whether the command supports out-of-band { 'command': 'migrate_recover', 'data': { 'uri': 'str' }, 'allow-oob': true } -See qmp-spec.txt for out-of-band execution syntax and semantics. +See the :doc:`/interop/qmp-spec` for out-of-band execution syntax +and semantics. Commands supporting out-of-band execution can still be executed in-band.
docs/interop/index.rst +1 -0
@@ -15,6 +15,7 @@ are useful for making QEMU interoperate with other software. dbus-display live-block-operations pr-helper + qmp-spec qemu-ga qemu-ga-ref qemu-qmp-ref
docs/interop/qmp-spec.rst renamed from docs/interop/qmp-spec.txt +185 -152
539 lines not on this page · raw message
qapi/control.json +2 -2
@@ -27,7 +27,7 @@ # Notes: This command is valid exactly when first connecting: it must # be issued before any other command will be accepted, and will # fail once the monitor is accepting other commands. (see qemu -# docs/interop/qmp-spec.txt) +# docs/interop/qmp-spec.rst) # # The QMP client needs to explicitly enable QMP capabilities, # otherwise all the QMP capabilities will be turned off by
@@ -46,7 +46,7 @@ # connection, used for agreeing on particular QMP extension behaviors. # # @oob: QMP ability to support out-of-band requests. (Please refer to -# qmp-spec.txt for more information on OOB) +# qmp-spec.rst for more information on OOB) # # Since: 2.12 ##
qapi/qapi-schema.json +2 -1
@@ -29,7 +29,8 @@ # -> data issued by the Client # <- Server data response # -# Please, refer to the QMP specification (docs/interop/qmp-spec.txt) +# Please refer to the +# :doc:`QEMU Machine Protocol Specification </interop/qmp-spec>` # for detailed information on the Server command and response formats. ##
qobject/json-lexer.c +1 -1
@@ -139,7 +139,7 @@ static const uint8_t json_lexer[][256] = {* bytes '\xFE', '\xFF'. Structural characters and line * endings are promising resynchronization points. Clients * may use the others to force the JSON parser into known-good -* state; see docs/interop/qmp-spec.txt. +* state; see docs/interop/qmp-spec.rst. */ [0 ... 0x1F] = IN_START | LOOKAHEAD, [0x20 ... 0xFD] = IN_RECOVERY,
python/qemu/qmp/models.py +4 -4
@@ -54,7 +54,7 @@ def __repr__(self) -> str: class Greeting(Model): """ - Defined in qmp-spec.txt, section 2.2, "Server Greeting". + Defined in qmp-spec.rst, section "Server Greeting". :param raw: The raw Greeting object. :raise KeyError: If any required fields are absent.
@@ -82,7 +82,7 @@ def _asdict(self) -> Dict[str, object]: class QMPGreeting(Model): """ - Defined in qmp-spec.txt, section 2.2, "Server Greeting". + Defined in qmp-spec.rst, section "Server Greeting". :param raw: The raw QMPGreeting object. :raise KeyError: If any required fields are absent.
@@ -104,7 +104,7 @@ def __init__(self, raw: Mapping[str, Any]): class ErrorResponse(Model): """ - Defined in qmp-spec.txt, section 2.4.2, "error". + Defined in qmp-spec.rst, section "Error". :param raw: The raw ErrorResponse object. :raise KeyError: If any required fields are absent.
@@ -126,7 +126,7 @@ def __init__(self, raw: Mapping[str, Any]): class ErrorInfo(Model): """ - Defined in qmp-spec.txt, section 2.4.2, "error". + Defined in qmp-spec.rst, section "Error". :param raw: The raw ErrorInfo object. :raise KeyError: If any required fields are absent.
python/qemu/qmp/qmp_client.py +2 -2
@@ -369,7 +369,7 @@ async def _on_message(self, msg: Message) -> None: # This is very likely a server parsing error. # It doesn't inherently belong to any pending execution. # Instead of performing clever recovery, just terminate. - # See "NOTE" in qmp-spec.txt, section 2.4.2 + # See "NOTE" in qmp-spec.rst, section "Error". raise ServerParseError( ("Server sent an error response without an ID, " "but there are no ID-less executions pending. "
@@ -377,7 +377,7 @@ async def _on_message(self, msg: Message) -> None: msg ) - # qmp-spec.txt, section 2.4: + # qmp-spec.rst, section "Commands Responses": # 'Clients should drop all the responses # that have an unknown "id" field.' self.logger.log(
Signature · 1 line
2.39.2
[PULL 5/5] qapi/parser: Drop two bad type hints for now
In reply to Markus ArmbrusterTwo type hints fail centos-stream-8-x86_64 CI. They are actually broken. Changing them to Optional[re.Match[str]] fixes them locally for me, but then CI fails differently. Drop them for now.
Message-Id: <[email protected]>
--- scripts/qapi/parser.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
scripts/qapi/parser.py +2 -2
@@ -563,11 +563,11 @@ def end_comment(self) -> None: self._switch_section(QAPIDoc.NullSection(self._parser)) @staticmethod - def _match_at_name_colon(string: str) -> re.Match: + def _match_at_name_colon(string: str): return re.match(r'@([^:]*): *', string) @staticmethod - def _match_section_tag(string: str) -> re.Match: + def _match_section_tag(string: str): return re.match(r'(Returns|Since|Notes?|Examples?|TODO): *', string) def _append_body_line(self, line: str) -> None:
Signature · 1 line
2.39.2
Re: [PULL 5/5] qapi/parser: Drop two bad type hints for now
Quoted 21 lines · Markus Armbruster
Two type hints fail centos-stream-8-x86_64 CI. They are actually broken. Changing them to Optional[re.Match[str]] fixes them locally for me, but then CI fails differently. Drop them for now.
Fixes 3e32dca3f0d1 (qapi: Rewrite parsing of doc comment section symbols and tags)Signed-off-by Markus Armbruster <[email protected]>Message-Id: <[email protected]>
Reviewed-by Richard Henderson <[email protected]>Tested-by Igor Mammedov <[email protected]>--- scripts/qapi/parser.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)scripts/qapi/parser.py +0
-0@@ -563,11 +563,11 @@ def end_comment(self) -> None: self._switch_section(QAPIDoc.NullSection(self._parser)) @staticmethod
scripts/qapi/parser.py def end_comment(self) -> None: · line 573
Quoted 10 lines
scripts/qapi/parser.py +2
-2- def _match_at_name_colon(string: str) -> re.Match: + def _match_at_name_colon(string: str): return re.match(r'@([^:]*): *', string) @staticmethod - def _match_section_tag(string: str) -> re.Match: + def _match_section_tag(string: str): return re.match(r'(Returns|Since|Notes?|Examples?|TODO): *', string) def _append_body_line(self, line: str) -> None:
I am going to cherry-pick this patch into master, since the build did succeed sufficiently to show that it fixes the centos-8-stream job.
r~
Quoted 6 lines · Markus Armbruster
The following changes since commit
f9d58e0ca53b3f470b84725a7b5e47fcf446a2ea:Merge tag 'pull-9p-20230516' of https://github.com/cschoenebeck/qemu into staging (2023-05-16 10:21:44 -0700)are available in the Git repository at:
Quoted 8 lines
https://repo.or.cz/qemu/armbru.git tags/pull-qapi-2023-05-17for you to fetch changes up to
28d2a4f620db2bc327dbd3443b777890d39a0bf6:qapi/parser: Drop two bad type hints for now (2023-05-17 15:49:22 +0200)
----------------------------------------------------------------
QAPI patches patches for 2023-05-17
Multiple failures:
https://gitlab.com/qemu-project/qemu/-/jobs/4303506112#L4674
▶ 2/61 /x86_64/migration/multifd/tcp/tls/x509/default-host - ERROR:../tests/qtest/migration-helpers.c:180:check_migration_status: assertion failed (current_status != "failed"): ("failed" != "failed") FAIL
https://gitlab.com/qemu-project/qemu/-/jobs/4303506102#L3766
https://gitlab.com/qemu-project/qemu/-/jobs/4303506050#L5856
https://gitlab.com/qemu-project/qemu/-/jobs/4303506047#L3654
/home/gitlab-runner/builds/Jpwtyaz7/0/qemu-project/qemu/docs/interop/qmp-spec.rst:71:Error in "code-block" directive:
1 argument(s) required, 0 supplied.
.. code-block::
{ "QMP": { "version": json-object, "capabilities": json-array } }
r~
Quoted 9 lines · Richard Henderson
https://gitlab.com/qemu-project/qemu/-/jobs/4303506102#L3766
https://gitlab.com/qemu-project/qemu/-/jobs/4303506050#L5856
https://gitlab.com/qemu-project/qemu/-/jobs/4303506047#L3654/home/gitlab-runner/builds/Jpwtyaz7/0/qemu-project/qemu/docs/interop/qmp-spec.rst:71:Error in "code-block" directive:
1 argument(s) required, 0 supplied.
.. code-block::{ "QMP": { "version": json-object, "capabilities": json-array } }
Looks like whatever version of Sphinx this is enforces that code-block comments specify a language. The system I tested on didn't care.
In theory these blocks should be ".. code-block:: json", you might think, but for me that results in
Warning, treated as error:
/mnt/nvmedisk/linaro/qemu-from-laptop/qemu/docs/interop/qmp-spec.rst:71:Could not lex literal_block as "json". Highlighting skipped.
(which I think means my system doesn't have the json lexer, but who knows...)
So the simplest fix is to turn all the no-language code-blocks into plain old literal blocks (the ones which are "QMP" format are fine, but specifying QMP doesn't work for these blocks, because the QMP lexer insists on seeing the -> and <- that indicate a command/response direction). This should work as a fixup to the patch.
Markus, could I ask you to squash it in for the next round of this pullreq ?
docs/interop/qmp-spec.rst +0 -0
@@ -68,7 +68,7 @@ ready for capabilities negotiation (for more
information refer to section
The greeting message format is:
-.. code-block::
+::
{ "QMP": { "version": json-object, "capabilities": json-array } }
@@ -94,13 +94,13 @@ Issuing Commands
The format for command execution is:
-.. code-block::
+::
{ "execute": json-string, "arguments": json-object, "id": json-value }
or
-.. code-block::
+::
{ "exec-oob": json-string, "arguments": json-object, "id": json-value }
@@ -164,7 +164,7 @@ Success
The format of a success response is:
-.. code-block::
+::
{ "return": json-value, "id": json-value }
@@ -183,7 +183,7 @@ Error
The format of an error response is:
-.. code-block::
+::
{ "error": { "class": json-string, "desc": json-string }, "id": json-value }
@@ -208,7 +208,7 @@ response. They are called "asynchronous events".
The format of asynchronous events is:
-.. code-block::
+::
{ "event": json-string, "data": json-object,
"timestamp": { "seconds": json-number, "microseconds": json-number } }thanks
-- PMM