1 QEMU Monitor Protocol Draft Specification - Version 0.1
6 This document specifies the QEMU Monitor Protocol (QMP), a JSON-based protocol
7 which is available for applications to control QEMU at the machine-level.
9 To enable QMP support, QEMU has to be run in "control mode". This is done by
10 starting QEMU with the appropriate command-line options. Please, refer to the
11 QEMU manual page for more information.
13 This specification is a work in progress and part of it may NOT be available
14 in QEMU, the 'Current Implementation' section has details regarding what has
15 already been implemented and known problems.
17 2. Protocol Specification
18 =========================
20 This section details the protocol format. For the purpose of this document
21 "Client" is any application which is communicating with QEMU in control mode,
22 and "Server" is QEMU itself.
24 JSON data structures, when mentioned in this document, are always in the
27 json-DATA-STRUCTURE-NAME
29 Where DATA-STRUCTURE-NAME is any valid JSON data structure, as defined by
32 http://www.ietf.org/rfc/rfc4627.txt
34 For convenience, json-objects mentioned in this document will have its members
35 in a certain order. However, in real protocol usage json-objects members can
36 be in ANY order, thus no particular order should be assumed.
38 2.1 General Definitions
39 -----------------------
41 All interactions transmitted by the Server are json-objects that end with CRLF.
43 All json-objects members are mandatory when not specified otherwise.
48 Right when connected the Server will issue a greeting message, which signals
49 that the connection has been successfully established and that the Server is
54 { "QMP": { "capabilities": json-array } }
58 - The "capabilities" member specify the availability of features beyond the
59 baseline specification
64 The format for command execution is:
66 { "execute": json-string, "id": json-value, "arguments": json-object }
70 - The "execute" member identifies the command to be executed by the Server
71 - The "id" member is a transaction identification associated with the
72 command execution, it is optional
73 - The "arguments" member is used to pass any arguments required for the
74 execution of the command, it is optional when no arguments are required
76 For a listing of supported commands and theirs arguments, please, refer to
77 the qmp-command-set.txt file.
79 2.4 Commands Execution
80 ----------------------
82 TODO: explain parallel execution and the "id" member.
84 2.5 Commands Responses
85 ----------------------
87 There are two possible responses which the Server will issue as the result
88 of a command completion: success or error.
93 The success response is issued when the command execution has finished
98 { "return": json-value, "id": json-value, "timestamp": json-string }
102 - The "return" member contains the command returned data, which is defined
103 in a per-command basis or json-null if the command does not return data
104 - The "id" member contains the transaction identification associated
105 with the command execution (if issued by the Client)
106 - The "timestamp" member contains the exact time of when the response was
107 generated by the Server (FIXME: format)
112 The error response is issued when the command execution could not be
113 completed because of an error condition.
117 { "error": { "code": json-number, "desc": json-string, "data": json-value } "id": json-value, "timestamp": json-string }
121 - The "code" member contains the error code. Its first digit indicates the
122 error type, as show below:
128 - The "desc" member contains the error description
129 - The "data" member contains specific error data, it is optional
130 - The "id" member contains the transaction identification associated with
131 the command execution (if issued by the Client)
132 - The "timestamp" member contains the exact time of when the response was
133 generated by the Server (FIXME: format)
135 Section '2.7 Server and Protocol errors' contains additional information about
138 2.6 Asynchronous events
139 -----------------------
141 As a result of state changes, the Server may send messages unilaterally
142 to the Client at any time. This is called 'asynchronous events'.
146 { "event": json-string, "timestamp": json-string, "data": json-value }
150 - The "event" member contains the event's name
151 - The "timestamp" member contains the exact time of when the event happend
152 in the Server (FIXME: format)
153 - The "data" member contains event specific data, which is defined in a
154 per-event basis, it is optional
156 For a listing of supported asynchronous events, please, refer to the
157 qmp-command-set.txt file.
159 2.7 Server and Protocol errors
160 ------------------------------
162 TODO: describe all possible server and protocol errors.
167 This section provides some examples of real QMP usage, in all of them
168 'C' stands for 'Client' and 'S' stands for 'Server'.
170 3.1 Simple 'stop' execution
171 ---------------------------
173 S: { "QEMU": "0.11.50", "QMP": "0.1", "capabilities": [] }
174 C: { "execute": "stop" }
175 S: { "return": null, "timestamp": "" }
180 S: { "QEMU": "0.11.50", "QMP": "0.1", "capabilities": [] }
181 C: { "execute": "info", "id": 1, "arguments": { "item": "kvm" } }
182 S: { "return": "enabled", "id": 1, "timestamp": "" }
184 3.3 Error on 'info balloon' execution
185 -------------------------------------
187 S: { "QEMU": "0.11.50", "QMP": "0.1", "capabilities": [] }
188 C: { "execute": "info", "id": "abc", "arguments": { "item": "balloon" } }
189 S: { "error": { "code": 354, "Ballooning not activated in VM" }, "id": "abc", "timestamp": "" }
194 S: { "QEMU": "0.11.50", "QMP": "0.1", "capabilities": [] }
196 S: { "event": "POWERDOWN", "timestamp": "" }
199 4. Current Implementation
200 =========================
202 The current QMP implementation lacks some of the protocol capabilities
203 specified in this document.
205 The most important one is the execution of commands as discussed in the
206 section '2.3 Issuing Commands'. Currently the Server does not support it.
208 Protocol input is done by issuing regular ASCII strings, as it is done when
209 using the humam Monitor protocol.
211 For example, to query the current balloon information the Client should
216 Additionally, the following limitations are present:
218 - The transaction "id" is not supported
219 - json-strings issued by the Server are not in Unicode format
220 - All "timestamp" members are always an empty json-string ""
221 - Error handling is basically not implemented