[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 01/58] docs/interop/qmp-spec: How to force known good
From: |
Markus Armbruster |
Subject: |
[Qemu-devel] [PULL 01/58] docs/interop/qmp-spec: How to force known good parser state |
Date: |
Fri, 24 Aug 2018 21:31:09 +0200 |
Section "QGA Synchronization" specifies that sending "a raw 0xFF
sentinel byte" makes the server "reset its state and discard all
pending data prior to the sentinel." What actually happens there is a
lexical error, which will produce one or more error responses.
Moreover, it's not specific to QGA.
Create new section "Forcing the JSON parser into known-good state" to
document the technique properly. Rewrite section "QGA
Synchronization" to document just the other direction, i.e. command
guest-sync-delimited.
Section "Protocol Specification" mentions "synchronization bytes
(documented below)". Delete that.
While there, fix it not to claim '"Server" is QEMU itself', but
'"Server" is either QEMU or the QEMU Guest Agent'.
Signed-off-by: Markus Armbruster <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Message-Id: <address@hidden>
---
docs/interop/qmp-spec.txt | 42 ++++++++++++++++++++++++++-------------
1 file changed, 28 insertions(+), 14 deletions(-)
diff --git a/docs/interop/qmp-spec.txt b/docs/interop/qmp-spec.txt
index 1566b8ae5e..8f7da0245d 100644
--- a/docs/interop/qmp-spec.txt
+++ b/docs/interop/qmp-spec.txt
@@ -20,9 +20,9 @@ operating system.
2. Protocol Specification
=========================
-This section details the protocol format. For the purpose of this document
-"Client" is any application which is using QMP to communicate with QEMU and
-"Server" is QEMU itself.
+This section details the protocol format. For the purpose of this
+document, "Server" is either QEMU or the QEMU Guest Agent, and
+"Client" is any application communicating with it via QMP.
JSON data structures, when mentioned in this document, are always in the
following format:
@@ -34,9 +34,8 @@ by the JSON standard:
http://www.ietf.org/rfc/rfc7159.txt
-The protocol is always encoded in UTF-8 except for synchronization
-bytes (documented below); although thanks to json-string escape
-sequences, the server will reply using only the strict ASCII subset.
+The server expects its input to be encoded in UTF-8, and sends its
+output encoded in ASCII.
For convenience, json-object members mentioned in this document will
be in a certain order. However, in real protocol usage they can be in
@@ -215,16 +214,31 @@ Some events are rate-limited to at most one per second.
If additional
dropped, and the last one is delayed. "Similar" normally means same
event type. See qmp-events.txt for details.
-2.6 QGA Synchronization
+2.6 Forcing the JSON parser into known-good state
+-------------------------------------------------
+
+Incomplete or invalid input can leave the server's JSON parser in a
+state where it can't parse additional commands. To get it back into
+known-good state, the client should provoke a lexical error.
+
+The cleanest way to do that is sending an ASCII control character
+other than '\t' (horizontal tab), '\r' (carriage return), or '\n' (new
+line).
+
+Sadly, older versions of QEMU can fail to flag this as an error. If a
+client needs to deal with them, it should send a 0xFF byte.
+
+2.7 QGA Synchronization
-----------------------
-When using QGA, an additional synchronization feature is built into
-the protocol. If the Client sends a raw 0xFF sentinel byte (not valid
-JSON), then the Server will reset its state and discard all pending
-data prior to the sentinel. Conversely, if the Client makes use of
-the 'guest-sync-delimited' command, the Server will send a raw 0xFF
-sentinel byte prior to its response, to aid the Client in discarding
-any data prior to the sentinel.
+When a client connects to QGA over a transport lacking proper
+connection semantics such as virtio-serial, QGA may have read partial
+input from a previous client. The client needs to force QGA's parser
+into known-good state using the previous section's technique.
+Moreover, the client may receive output a previous client didn't read.
+To help with skipping that output, QGA provides the
+'guest-sync-delimited' command. Refer to its documentation for
+details.
3. QMP Examples
--
2.17.1
- [Qemu-devel] [PULL 03/58] check-qjson: Cover blank and lexically erroneous input, (continued)
- [Qemu-devel] [PULL 03/58] check-qjson: Cover blank and lexically erroneous input, Markus Armbruster, 2018/08/24
- [Qemu-devel] [PULL 17/58] json: Fix lexer to include the bad character in JSON_ERROR token, Markus Armbruster, 2018/08/24
- [Qemu-devel] [PULL 06/58] qmp-test: Cover syntax and lexical errors, Markus Armbruster, 2018/08/24
- [Qemu-devel] [PULL 13/58] check-qjson: Simplify utf8_string(), Markus Armbruster, 2018/08/24
- [Qemu-devel] [PULL 02/58] check-qjson: Cover multiple JSON objects in same string, Markus Armbruster, 2018/08/24
- [Qemu-devel] [PULL 20/58] json: Tighten and simplify qstring_from_escaped_str()'s loop, Markus Armbruster, 2018/08/24
- [Qemu-devel] [PULL 11/58] check-qjson: Consolidate partly redundant string tests, Markus Armbruster, 2018/08/24
- [Qemu-devel] [PULL 33/58] json: Have lexer call streamer directly, Markus Armbruster, 2018/08/24
- [Qemu-devel] [PULL 12/58] check-qjson: Cover UTF-8 in single quoted strings, Markus Armbruster, 2018/08/24
- [Qemu-devel] [PULL 25/58] json: Accept overlong \xC0\x80 as U+0000 ("modified UTF-8"), Markus Armbruster, 2018/08/24
- [Qemu-devel] [PULL 01/58] docs/interop/qmp-spec: How to force known good parser state,
Markus Armbruster <=
- [Qemu-devel] [PULL 15/58] check-qjson qmp-test: Cover control characters more thoroughly, Markus Armbruster, 2018/08/24
- [Qemu-devel] [PULL 16/58] check-qjson: Cover interpolation more thoroughly, Markus Armbruster, 2018/08/24
- [Qemu-devel] [PULL 10/58] check-qjson: Cover escaped characters more thoroughly, part 2, Markus Armbruster, 2018/08/24
- [Qemu-devel] [PULL 30/58] check-qjson: Fix and enable utf8_string()'s disabled part, Markus Armbruster, 2018/08/24
- [Qemu-devel] [PULL 28/58] json: Reject invalid \uXXXX, fix \u0000, Markus Armbruster, 2018/08/24
- [Qemu-devel] [PULL 39/58] json: Pass lexical errors and limit violations to callback, Markus Armbruster, 2018/08/24
- [Qemu-devel] [PULL 19/58] json: Revamp lexer documentation, Markus Armbruster, 2018/08/24
- [Qemu-devel] [PULL 23/58] json: Report first rather than last parse error, Markus Armbruster, 2018/08/24
- [Qemu-devel] [PULL 24/58] json: Leave rejecting invalid UTF-8 to parser, Markus Armbruster, 2018/08/24
- [Qemu-devel] [PULL 05/58] qmp-cmd-test: Split off qmp-test, Markus Armbruster, 2018/08/24