qemu-ga: guest-suspend: make the API synchronous
[qemu.git] / qapi-schema-guest.json
blob7c6cb21a797632837e763cc70abb72128af3192e
1 # *-*- Mode: Python -*-*
3 ##
5 # Echo back a unique integer value, and prepend to response a
6 # leading sentinel byte (0xFF) the client can check scan for.
8 # This is used by clients talking to the guest agent over the
9 # wire to ensure the stream is in sync and doesn't contain stale
10 # data from previous client. It must be issued upon initial
11 # connection, and after any client-side timeouts (including
12 # timeouts on receiving a response to this command).
14 # After issuing this request, all guest agent responses should be
15 # ignored until the response containing the unique integer value
16 # the client passed in is returned. Receival of the 0xFF sentinel
17 # byte must be handled as an indication that the client's
18 # lexer/tokenizer/parser state should be flushed/reset in
19 # preparation for reliably receiving the subsequent response. As
20 # an optimization, clients may opt to ignore all data until a
21 # sentinel value is receiving to avoid unnecessary processing of
22 # stale data.
24 # Similarly, clients should also precede this *request*
25 # with a 0xFF byte to make sure the guest agent flushes any
26 # partially read JSON data from a previous client connection.
28 # @id: randomly generated 64-bit integer
30 # Returns: The unique integer id passed in by the client
32 # Since: 1.1
33 # ##
34 { 'command': 'guest-sync-delimited'
35   'data':    { 'id': 'int' },
36   'returns': 'int' }
39 # @guest-sync:
41 # Echo back a unique integer value
43 # This is used by clients talking to the guest agent over the
44 # wire to ensure the stream is in sync and doesn't contain stale
45 # data from previous client. All guest agent responses should be
46 # ignored until the provided unique integer value is returned,
47 # and it is up to the client to handle stale whole or
48 # partially-delivered JSON text in such a way that this response
49 # can be obtained.
51 # In cases where a partial stale response was previously
52 # received by the client, this cannot always be done reliably.
53 # One particular scenario being if qemu-ga responses are fed
54 # character-by-character into a JSON parser. In these situations,
55 # using guest-sync-delimited may be optimal.
57 # For clients that fetch responses line by line and convert them
58 # to JSON objects, guest-sync should be sufficient, but note that
59 # in cases where the channel is dirty some attempts at parsing the
60 # response may result in a parser error.
62 # Such clients should also precede this command
63 # with a 0xFF byte to make sure the guest agent flushes any
64 # partially read JSON data from a previous session.
66 # @id: randomly generated 64-bit integer
68 # Returns: The unique integer id passed in by the client
70 # Since: 0.15.0
72 { 'command': 'guest-sync'
73   'data':    { 'id': 'int' },
74   'returns': 'int' }
77 # @guest-ping:
79 # Ping the guest agent, a non-error return implies success
81 # Since: 0.15.0
83 { 'command': 'guest-ping' }
86 # @GuestAgentCommandInfo:
88 # Information about guest agent commands.
90 # @name: name of the command
92 # @enabled: whether command is currently enabled by guest admin
94 # Since 1.1.0
96 { 'type': 'GuestAgentCommandInfo',
97   'data': { 'name': 'str', 'enabled': 'bool' } }
100 # @GuestAgentInfo
102 # Information about guest agent.
104 # @version: guest agent version
106 # @supported_commands: Information about guest agent commands
108 # Since 0.15.0
110 { 'type': 'GuestAgentInfo',
111   'data': { 'version': 'str',
112             'supported_commands': ['GuestAgentCommandInfo'] } }
114 # @guest-info:
116 # Get some information about the guest agent.
118 # Returns: @GuestAgentInfo
120 # Since: 0.15.0
122 { 'command': 'guest-info',
123   'returns': 'GuestAgentInfo' }
126 # @guest-shutdown:
128 # Initiate guest-activated shutdown. Note: this is an asynchronous
129 # shutdown request, with no guaruntee of successful shutdown. Errors
130 # will be logged to guest's syslog.
132 # @mode: #optional "halt", "powerdown" (default), or "reboot"
134 # This command does NOT return a response on success. Success condition
135 # is indicated by the VM exiting with a zero exit status or, when
136 # running with --no-shutdown, by issuing the query-status QMP command
137 # to confirm the VM status is "shutdown".
139 # Since: 0.15.0
141 { 'command': 'guest-shutdown', 'data': { '*mode': 'str' },
142   'success-response': 'no' }
145 # @guest-file-open:
147 # Open a file in the guest and retrieve a file handle for it
149 # @filepath: Full path to the file in the guest to open.
151 # @mode: #optional open mode, as per fopen(), "r" is the default.
153 # Returns: Guest file handle on success.
155 # Since: 0.15.0
157 { 'command': 'guest-file-open',
158   'data':    { 'path': 'str', '*mode': 'str' },
159   'returns': 'int' }
162 # @guest-file-close:
164 # Close an open file in the guest
166 # @handle: filehandle returned by guest-file-open
168 # Returns: Nothing on success.
170 # Since: 0.15.0
172 { 'command': 'guest-file-close',
173   'data': { 'handle': 'int' } }
176 # @GuestFileRead
178 # Result of guest agent file-read operation
180 # @count: number of bytes read (note: count is *before*
181 #         base64-encoding is applied)
183 # @buf-b64: base64-encoded bytes read
185 # @eof: whether EOF was encountered during read operation.
187 # Since: 0.15.0
189 { 'type': 'GuestFileRead',
190   'data': { 'count': 'int', 'buf-b64': 'str', 'eof': 'bool' } }
193 # @guest-file-read:
195 # Read from an open file in the guest. Data will be base64-encoded
197 # @handle: filehandle returned by guest-file-open
199 # @count: #optional maximum number of bytes to read (default is 4KB)
201 # Returns: @GuestFileRead on success.
203 # Since: 0.15.0
205 { 'command': 'guest-file-read',
206   'data':    { 'handle': 'int', '*count': 'int' },
207   'returns': 'GuestFileRead' }
210 # @GuestFileWrite
212 # Result of guest agent file-write operation
214 # @count: number of bytes written (note: count is actual bytes
215 #         written, after base64-decoding of provided buffer)
217 # @eof: whether EOF was encountered during write operation.
219 # Since: 0.15.0
221 { 'type': 'GuestFileWrite',
222   'data': { 'count': 'int', 'eof': 'bool' } }
225 # @guest-file-write:
227 # Write to an open file in the guest.
229 # @handle: filehandle returned by guest-file-open
231 # @buf-b64: base64-encoded string representing data to be written
233 # @count: #optional bytes to write (actual bytes, after base64-decode),
234 #         default is all content in buf-b64 buffer after base64 decoding
236 # Returns: @GuestFileWrite on success.
238 # Since: 0.15.0
240 { 'command': 'guest-file-write',
241   'data':    { 'handle': 'int', 'buf-b64': 'str', '*count': 'int' },
242   'returns': 'GuestFileWrite' }
246 # @GuestFileSeek
248 # Result of guest agent file-seek operation
250 # @position: current file position
252 # @eof: whether EOF was encountered during file seek
254 # Since: 0.15.0
256 { 'type': 'GuestFileSeek',
257   'data': { 'position': 'int', 'eof': 'bool' } }
260 # @guest-file-seek:
262 # Seek to a position in the file, as with fseek(), and return the
263 # current file position afterward. Also encapsulates ftell()'s
264 # functionality, just Set offset=0, whence=SEEK_CUR.
266 # @handle: filehandle returned by guest-file-open
268 # @offset: bytes to skip over in the file stream
270 # @whence: SEEK_SET, SEEK_CUR, or SEEK_END, as with fseek()
272 # Returns: @GuestFileSeek on success.
274 # Since: 0.15.0
276 { 'command': 'guest-file-seek',
277   'data':    { 'handle': 'int', 'offset': 'int', 'whence': 'int' },
278   'returns': 'GuestFileSeek' }
281 # @guest-file-flush:
283 # Write file changes bufferred in userspace to disk/kernel buffers
285 # @handle: filehandle returned by guest-file-open
287 # Returns: Nothing on success.
289 # Since: 0.15.0
291 { 'command': 'guest-file-flush',
292   'data': { 'handle': 'int' } }
295 # @GuestFsFreezeStatus
297 # An enumation of filesystem freeze states
299 # @thawed: filesystems thawed/unfrozen
301 # @frozen: all non-network guest filesystems frozen
303 # Since: 0.15.0
305 { 'enum': 'GuestFsfreezeStatus',
306   'data': [ 'thawed', 'frozen' ] }
309 # @guest-fsfreeze-status:
311 # Get guest fsfreeze state. error state indicates
313 # Returns: GuestFsfreezeStatus ("thawed", "frozen", etc., as defined below)
315 # Note: This may fail to properly report the current state as a result of
316 # some other guest processes having issued an fs freeze/thaw.
318 # Since: 0.15.0
320 { 'command': 'guest-fsfreeze-status',
321   'returns': 'GuestFsfreezeStatus' }
324 # @guest-fsfreeze-freeze:
326 # Sync and freeze all freezable, local guest filesystems
328 # Returns: Number of file systems currently frozen. On error, all filesystems
329 # will be thawed.
331 # Since: 0.15.0
333 { 'command': 'guest-fsfreeze-freeze',
334   'returns': 'int' }
337 # @guest-fsfreeze-thaw:
339 # Unfreeze all frozen guest filesystems
341 # Returns: Number of file systems thawed by this call
343 # Note: if return value does not match the previous call to
344 #       guest-fsfreeze-freeze, this likely means some freezable
345 #       filesystems were unfrozen before this call, and that the
346 #       filesystem state may have changed before issuing this
347 #       command.
349 # Since: 0.15.0
351 { 'command': 'guest-fsfreeze-thaw',
352   'returns': 'int' }
355 # @guest-suspend-disk
357 # Suspend guest to disk.
359 # This command tries to execute the scripts provided by the pm-utils package.
360 # If it's not available, the suspend operation will be performed by manually
361 # writing to a sysfs file.
363 # For the best results it's strongly recommended to have the pm-utils
364 # package installed in the guest.
366 # This command does NOT return a response on success. There is a high chance
367 # the command succeeded if the VM exits with a zero exit status or, when
368 # running with --no-shutdown, by issuing the query-status QMP command to
369 # to confirm the VM status is "shutdown". However, the VM could also exit
370 # (or set its status to "shutdown") due to other reasons.
372 # The following errors may be returned:
373 #          If suspend to disk is not supported, Unsupported
375 # Notes: It's strongly recommended to issue the guest-sync command before
376 #        sending commands when the guest resumes
378 # Since: 1.1
380 { 'command': 'guest-suspend-disk', 'success-response': 'no' }
383 # @guest-suspend-ram
385 # Suspend guest to ram.
387 # This command tries to execute the scripts provided by the pm-utils package.
388 # If it's not available, the suspend operation will be performed by manually
389 # writing to a sysfs file.
391 # For the best results it's strongly recommended to have the pm-utils
392 # package installed in the guest.
394 # IMPORTANT: guest-suspend-ram requires QEMU to support the 'system_wakeup'
395 # command.  Thus, it's *required* to query QEMU for the presence of the
396 # 'system_wakeup' command before issuing guest-suspend-ram.
398 # This command does NOT return a response on success. There are two options
399 # to check for success:
400 #   1. Wait for the SUSPEND QMP event from QEMU
401 #   2. Issue the query-status QMP command to confirm the VM status is
402 #      "suspended"
404 # The following errors may be returned:
405 #          If suspend to ram is not supported, Unsupported
407 # Notes: It's strongly recommended to issue the guest-sync command before
408 #        sending commands when the guest resumes
410 # Since: 1.1
412 { 'command': 'guest-suspend-ram', 'success-response': 'no' }
415 # @guest-suspend-hybrid
417 # Save guest state to disk and suspend to ram.
419 # This command requires the pm-utils package to be installed in the guest.
421 # IMPORTANT: guest-suspend-hybrid requires QEMU to support the 'system_wakeup'
422 # command.  Thus, it's *required* to query QEMU for the presence of the
423 # 'system_wakeup' command before issuing guest-suspend-hybrid.
425 # This command does NOT return a response on success. There are two options
426 # to check for success:
427 #   1. Wait for the SUSPEND QMP event from QEMU
428 #   2. Issue the query-status QMP command to confirm the VM status is
429 #      "suspended"
431 # The following errors may be returned:
432 #          If hybrid suspend is not supported, Unsupported
434 # Notes: It's strongly recommended to issue the guest-sync command before
435 #        sending commands when the guest resumes
437 # Since: 1.1
439 { 'command': 'guest-suspend-hybrid', 'success-response': 'no' }
442 # @GuestIpAddressType:
444 # An enumeration of supported IP address types
446 # @ipv4: IP version 4
448 # @ipv6: IP version 6
450 # Since: 1.1
452 { 'enum': 'GuestIpAddressType',
453   'data': [ 'ipv4', 'ipv6' ] }
456 # @GuestIpAddress:
458 # @ip-address: IP address
460 # @ip-address-type: Type of @ip-address (e.g. ipv4, ipv6)
462 # @prefix: Network prefix length of @ip-address
464 # Since: 1.1
466 { 'type': 'GuestIpAddress',
467   'data': {'ip-address': 'str',
468            'ip-address-type': 'GuestIpAddressType',
469            'prefix': 'int'} }
472 # @GuestNetworkInterface:
474 # @name: The name of interface for which info are being delivered
476 # @hardware-address: Hardware address of @name
478 # @ip-addresses: List of addresses assigned to @name
480 # Since: 1.1
482 { 'type': 'GuestNetworkInterface',
483   'data': {'name': 'str',
484            '*hardware-address': 'str',
485            '*ip-addresses': ['GuestIpAddress'] } }
488 # @guest-network-get-interfaces:
490 # Get list of guest IP addresses, MAC addresses
491 # and netmasks.
493 # Returns: List of GuestNetworkInfo on success.
495 # Since: 1.1
497 { 'command': 'guest-network-get-interfaces',
498   'returns': ['GuestNetworkInterface'] }