kvm: x86: Fix initial kvm_has_msr_star
[qemu/aliguori-queue.git] / QMP / qmp-spec.txt
blob8429789a9c3c1e03234e80ba8aaeadbcb739b97f
1            QEMU Monitor Protocol Draft Specification - Version 0.1
3 1. Introduction
4 ===============
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 2. Protocol Specification
14 =========================
16 This section details the protocol format. For the purpose of this document
17 "Client" is any application which is communicating with QEMU in control mode,
18 and "Server" is QEMU itself.
20 JSON data structures, when mentioned in this document, are always in the
21 following format:
23     json-DATA-STRUCTURE-NAME
25 Where DATA-STRUCTURE-NAME is any valid JSON data structure, as defined by
26 the JSON standard:
28 http://www.ietf.org/rfc/rfc4627.txt
30 For convenience, json-objects mentioned in this document will have its members
31 in a certain order. However, in real protocol usage json-objects members can
32 be in ANY order, thus no particular order should be assumed.
34 2.1 General Definitions
35 -----------------------
37 2.1.1 All interactions transmitted by the Server are json-objects, always
38       terminating with CRLF
40 2.1.2 All json-objects members are mandatory when not specified otherwise
42 2.2 Server Greeting
43 -------------------
45 Right when connected the Server will issue a greeting message, which signals
46 that the connection has been successfully established and that the Server is
47 waiting for commands.
49 The format is:
51 { "QMP": { "capabilities": json-array } }
53  Where,
55 - The "capabilities" member specify the availability of features beyond the
56   baseline specification
58 2.3 Issuing Commands
59 --------------------
61 The format for command execution is:
63 { "execute": json-string, "arguments": json-object, "id": json-value }
65  Where,
67 - The "execute" member identifies the command to be executed by the Server
68 - The "arguments" member is used to pass any arguments required for the
69   execution of the command, it is optional when no arguments are required
70 - The "id" member is a transaction identification associated with the
71   command execution, it is optional and will be part of the response if
72   provided
74 2.4 Commands Responses
75 ----------------------
77 There are two possible responses which the Server will issue as the result
78 of a command execution: success or error.
80 2.4.1 success
81 -------------
83 The success response is issued when the command execution has finished
84 without errors.
86 The format is:
88 { "return": json-value, "id": json-value }
90  Where,
92 - The "return" member contains the command returned data, which is defined
93   in a per-command basis or "OK" if the command does not return data
94 - The "id" member contains the transaction identification associated
95   with the command execution (if issued by the Client)
97 2.4.2 error
98 -----------
100 The error response is issued when the command execution could not be
101 completed because of an error condition.
103 The format is:
105 { "error": { "class": json-string, "data": json-value }, "id": json-value }
107  Where,
109 - The "class" member contains the error class name (eg. "ServiceUnavailable")
110 - The "data" member contains specific error data and is defined in a
111   per-command basis, it will be an empty json-object if the error has no data
112 - The "id" member contains the transaction identification associated with
113   the command execution (if issued by the Client)
115 NOTE: Some errors can occur before the Server is able to read the "id" member,
116 in these cases the "id" member will not be part of the error response, even
117 if provided by the client.
119 2.5 Asynchronous events
120 -----------------------
122 As a result of state changes, the Server may send messages unilaterally
123 to the Client at any time. They are called 'asynchronous events'.
125 The format is:
127 { "event": json-string, "data": json-value,
128   "timestamp": { "seconds": json-number, "microseconds": json-number } }
130  Where,
132 - The "event" member contains the event's name
133 - The "data" member contains event specific data, which is defined in a
134   per-event basis, it is optional
135 - The "timestamp" member contains the exact time of when the event ocurred
136   in the Server. It is a fixed json-object with time in seconds and
137   microseconds
139 For a listing of supported asynchronous events, please, refer to the
140 qmp-events.txt file.
142 3. QMP Examples
143 ===============
145 This section provides some examples of real QMP usage, in all of them
146 'C' stands for 'Client' and 'S' stands for 'Server'.
148 3.1 Server greeting
149 -------------------
151 S: {"QMP": {"capabilities": []}}
153 3.2 Simple 'stop' execution
154 ---------------------------
156 C: { "execute": "stop" }
157 S: {"return": "OK"}
159 3.3 KVM information
160 -------------------
162 C: {"execute": "query-kvm", "id": "example"}
163 S: {"return": "enabled", "id": "example"}
165 3.4 Parsing error
166 ------------------
168 C: { "execute": }
169 S: {"error": {"class": "JSONParsing", "data": {}}}
171 3.5 Powerdown event
172 -------------------
174 S: {"timestamp": {"seconds": 1258551470, "microseconds": 802384}, "event":
175 "POWERDOWN"}
177 4. Notes to Client implementors
178 -------------------------------
180 4.1 It is recommended to always start the Server in pause mode, thus the
181     Client is able to perform any setup procedure without the risk of
182     race conditions and related problems
184 4.2 It is recommended to always check the capabilities json-array, issued
185     with the greeting message, at connection time
187 4.3 Json-objects or json-arrays mentioned in this document are not fixed
188     and no particular size or number of members/elements should be assumed.
189     New members/elements can be added at any time.
191 4.4 No particular order of json-objects members should be assumed, they
192     can change at any time