1 # *-*- Mode: Python -*-*
5 # General note concerning the use of guest agent interfaces:
7 # "unsupported" is a higher-level error than the errors that individual
8 # commands might document. The caller should always be prepared to receive
9 # QERR_UNSUPPORTED, even if the given command doesn't specify it, or doesn't
10 # document any failure mode at all.
16 # Echo back a unique integer value, and prepend to response a
17 # leading sentinel byte (0xFF) the client can check scan for.
19 # This is used by clients talking to the guest agent over the
20 # wire to ensure the stream is in sync and doesn't contain stale
21 # data from previous client. It must be issued upon initial
22 # connection, and after any client-side timeouts (including
23 # timeouts on receiving a response to this command).
25 # After issuing this request, all guest agent responses should be
26 # ignored until the response containing the unique integer value
27 # the client passed in is returned. Receival of the 0xFF sentinel
28 # byte must be handled as an indication that the client's
29 # lexer/tokenizer/parser state should be flushed/reset in
30 # preparation for reliably receiving the subsequent response. As
31 # an optimization, clients may opt to ignore all data until a
32 # sentinel value is receiving to avoid unnecessary processing of
35 # Similarly, clients should also precede this *request*
36 # with a 0xFF byte to make sure the guest agent flushes any
37 # partially read JSON data from a previous client connection.
39 # @id: randomly generated 64-bit integer
41 # Returns: The unique integer id passed in by the client
45 { 'command': 'guest-sync-delimited',
46 'data': { 'id': 'int' },
52 # Echo back a unique integer value
54 # This is used by clients talking to the guest agent over the
55 # wire to ensure the stream is in sync and doesn't contain stale
56 # data from previous client. All guest agent responses should be
57 # ignored until the provided unique integer value is returned,
58 # and it is up to the client to handle stale whole or
59 # partially-delivered JSON text in such a way that this response
62 # In cases where a partial stale response was previously
63 # received by the client, this cannot always be done reliably.
64 # One particular scenario being if qemu-ga responses are fed
65 # character-by-character into a JSON parser. In these situations,
66 # using guest-sync-delimited may be optimal.
68 # For clients that fetch responses line by line and convert them
69 # to JSON objects, guest-sync should be sufficient, but note that
70 # in cases where the channel is dirty some attempts at parsing the
71 # response may result in a parser error.
73 # Such clients should also precede this command
74 # with a 0xFF byte to make sure the guest agent flushes any
75 # partially read JSON data from a previous session.
77 # @id: randomly generated 64-bit integer
79 # Returns: The unique integer id passed in by the client
83 { 'command': 'guest-sync',
84 'data': { 'id': 'int' },
90 # Ping the guest agent, a non-error return implies success
94 { 'command': 'guest-ping' }
99 # Get the information about guest time relative to the Epoch
100 # of 1970-01-01 in UTC.
102 # Returns: Time in nanoseconds.
106 { 'command': 'guest-get-time',
114 # When a guest is paused or migrated to a file then loaded
115 # from that file, the guest OS has no idea that there
116 # was a big gap in the time. Depending on how long the
117 # gap was, NTP might not be able to resynchronize the
120 # This command tries to set guest time to the given value,
121 # then sets the Hardware Clock to the current System Time.
122 # This will make it easier for a guest to resynchronize
123 # without waiting for NTP. If no @time is specified, then
124 # the time to set is read from RTC.
126 # @time: #optional time of nanoseconds, relative to the Epoch
127 # of 1970-01-01 in UTC.
129 # Returns: Nothing on success.
133 { 'command': 'guest-set-time',
134 'data': { '*time': 'int' } }
137 # @GuestAgentCommandInfo:
139 # Information about guest agent commands.
141 # @name: name of the command
143 # @enabled: whether command is currently enabled by guest admin
145 # @success-response: whether command returns a response on success
150 { 'type': 'GuestAgentCommandInfo',
151 'data': { 'name': 'str', 'enabled': 'bool', 'success-response': 'bool' } }
156 # Information about guest agent.
158 # @version: guest agent version
160 # @supported_commands: Information about guest agent commands
164 { 'type': 'GuestAgentInfo',
165 'data': { 'version': 'str',
166 'supported_commands': ['GuestAgentCommandInfo'] } }
170 # Get some information about the guest agent.
172 # Returns: @GuestAgentInfo
176 { 'command': 'guest-info',
177 'returns': 'GuestAgentInfo' }
182 # Initiate guest-activated shutdown. Note: this is an asynchronous
183 # shutdown request, with no guarantee of successful shutdown.
185 # @mode: #optional "halt", "powerdown" (default), or "reboot"
187 # This command does NOT return a response on success. Success condition
188 # is indicated by the VM exiting with a zero exit status or, when
189 # running with --no-shutdown, by issuing the query-status QMP command
190 # to confirm the VM status is "shutdown".
194 { 'command': 'guest-shutdown', 'data': { '*mode': 'str' },
195 'success-response': 'no' }
200 # Open a file in the guest and retrieve a file handle for it
202 # @filepath: Full path to the file in the guest to open.
204 # @mode: #optional open mode, as per fopen(), "r" is the default.
206 # Returns: Guest file handle on success.
210 { 'command': 'guest-file-open',
211 'data': { 'path': 'str', '*mode': 'str' },
217 # Close an open file in the guest
219 # @handle: filehandle returned by guest-file-open
221 # Returns: Nothing on success.
225 { 'command': 'guest-file-close',
226 'data': { 'handle': 'int' } }
231 # Result of guest agent file-read operation
233 # @count: number of bytes read (note: count is *before*
234 # base64-encoding is applied)
236 # @buf-b64: base64-encoded bytes read
238 # @eof: whether EOF was encountered during read operation.
242 { 'type': 'GuestFileRead',
243 'data': { 'count': 'int', 'buf-b64': 'str', 'eof': 'bool' } }
248 # Read from an open file in the guest. Data will be base64-encoded
250 # @handle: filehandle returned by guest-file-open
252 # @count: #optional maximum number of bytes to read (default is 4KB)
254 # Returns: @GuestFileRead on success.
258 { 'command': 'guest-file-read',
259 'data': { 'handle': 'int', '*count': 'int' },
260 'returns': 'GuestFileRead' }
265 # Result of guest agent file-write operation
267 # @count: number of bytes written (note: count is actual bytes
268 # written, after base64-decoding of provided buffer)
270 # @eof: whether EOF was encountered during write operation.
274 { 'type': 'GuestFileWrite',
275 'data': { 'count': 'int', 'eof': 'bool' } }
280 # Write to an open file in the guest.
282 # @handle: filehandle returned by guest-file-open
284 # @buf-b64: base64-encoded string representing data to be written
286 # @count: #optional bytes to write (actual bytes, after base64-decode),
287 # default is all content in buf-b64 buffer after base64 decoding
289 # Returns: @GuestFileWrite on success.
293 { 'command': 'guest-file-write',
294 'data': { 'handle': 'int', 'buf-b64': 'str', '*count': 'int' },
295 'returns': 'GuestFileWrite' }
301 # Result of guest agent file-seek operation
303 # @position: current file position
305 # @eof: whether EOF was encountered during file seek
309 { 'type': 'GuestFileSeek',
310 'data': { 'position': 'int', 'eof': 'bool' } }
315 # Seek to a position in the file, as with fseek(), and return the
316 # current file position afterward. Also encapsulates ftell()'s
317 # functionality, just Set offset=0, whence=SEEK_CUR.
319 # @handle: filehandle returned by guest-file-open
321 # @offset: bytes to skip over in the file stream
323 # @whence: SEEK_SET, SEEK_CUR, or SEEK_END, as with fseek()
325 # Returns: @GuestFileSeek on success.
329 { 'command': 'guest-file-seek',
330 'data': { 'handle': 'int', 'offset': 'int', 'whence': 'int' },
331 'returns': 'GuestFileSeek' }
336 # Write file changes bufferred in userspace to disk/kernel buffers
338 # @handle: filehandle returned by guest-file-open
340 # Returns: Nothing on success.
344 { 'command': 'guest-file-flush',
345 'data': { 'handle': 'int' } }
348 # @GuestFsFreezeStatus
350 # An enumeration of filesystem freeze states
352 # @thawed: filesystems thawed/unfrozen
354 # @frozen: all non-network guest filesystems frozen
358 { 'enum': 'GuestFsfreezeStatus',
359 'data': [ 'thawed', 'frozen' ] }
362 # @guest-fsfreeze-status:
364 # Get guest fsfreeze state. error state indicates
366 # Returns: GuestFsfreezeStatus ("thawed", "frozen", etc., as defined below)
368 # Note: This may fail to properly report the current state as a result of
369 # some other guest processes having issued an fs freeze/thaw.
373 { 'command': 'guest-fsfreeze-status',
374 'returns': 'GuestFsfreezeStatus' }
377 # @guest-fsfreeze-freeze:
379 # Sync and freeze all freezable, local guest filesystems
381 # Returns: Number of file systems currently frozen. On error, all filesystems
386 { 'command': 'guest-fsfreeze-freeze',
390 # @guest-fsfreeze-thaw:
392 # Unfreeze all frozen guest filesystems
394 # Returns: Number of file systems thawed by this call
396 # Note: if return value does not match the previous call to
397 # guest-fsfreeze-freeze, this likely means some freezable
398 # filesystems were unfrozen before this call, and that the
399 # filesystem state may have changed before issuing this
404 { 'command': 'guest-fsfreeze-thaw',
410 # Discard (or "trim") blocks which are not in use by the filesystem.
413 # Minimum contiguous free range to discard, in bytes. Free ranges
414 # smaller than this may be ignored (this is a hint and the guest
415 # may not respect it). By increasing this value, the fstrim
416 # operation will complete more quickly for filesystems with badly
417 # fragmented free space, although not all blocks will be discarded.
418 # The default value is zero, meaning "discard every free block".
424 { 'command': 'guest-fstrim',
425 'data': { '*minimum': 'int' } }
428 # @guest-suspend-disk
430 # Suspend guest to disk.
432 # This command tries to execute the scripts provided by the pm-utils package.
433 # If it's not available, the suspend operation will be performed by manually
434 # writing to a sysfs file.
436 # For the best results it's strongly recommended to have the pm-utils
437 # package installed in the guest.
439 # This command does NOT return a response on success. There is a high chance
440 # the command succeeded if the VM exits with a zero exit status or, when
441 # running with --no-shutdown, by issuing the query-status QMP command to
442 # to confirm the VM status is "shutdown". However, the VM could also exit
443 # (or set its status to "shutdown") due to other reasons.
445 # The following errors may be returned:
446 # If suspend to disk is not supported, Unsupported
448 # Notes: It's strongly recommended to issue the guest-sync command before
449 # sending commands when the guest resumes
453 { 'command': 'guest-suspend-disk', 'success-response': 'no' }
458 # Suspend guest to ram.
460 # This command tries to execute the scripts provided by the pm-utils package.
461 # If it's not available, the suspend operation will be performed by manually
462 # writing to a sysfs file.
464 # For the best results it's strongly recommended to have the pm-utils
465 # package installed in the guest.
467 # IMPORTANT: guest-suspend-ram requires QEMU to support the 'system_wakeup'
468 # command. Thus, it's *required* to query QEMU for the presence of the
469 # 'system_wakeup' command before issuing guest-suspend-ram.
471 # This command does NOT return a response on success. There are two options
472 # to check for success:
473 # 1. Wait for the SUSPEND QMP event from QEMU
474 # 2. Issue the query-status QMP command to confirm the VM status is
477 # The following errors may be returned:
478 # If suspend to ram is not supported, Unsupported
480 # Notes: It's strongly recommended to issue the guest-sync command before
481 # sending commands when the guest resumes
485 { 'command': 'guest-suspend-ram', 'success-response': 'no' }
488 # @guest-suspend-hybrid
490 # Save guest state to disk and suspend to ram.
492 # This command requires the pm-utils package to be installed in the guest.
494 # IMPORTANT: guest-suspend-hybrid requires QEMU to support the 'system_wakeup'
495 # command. Thus, it's *required* to query QEMU for the presence of the
496 # 'system_wakeup' command before issuing guest-suspend-hybrid.
498 # This command does NOT return a response on success. There are two options
499 # to check for success:
500 # 1. Wait for the SUSPEND QMP event from QEMU
501 # 2. Issue the query-status QMP command to confirm the VM status is
504 # The following errors may be returned:
505 # If hybrid suspend is not supported, Unsupported
507 # Notes: It's strongly recommended to issue the guest-sync command before
508 # sending commands when the guest resumes
512 { 'command': 'guest-suspend-hybrid', 'success-response': 'no' }
515 # @GuestIpAddressType:
517 # An enumeration of supported IP address types
519 # @ipv4: IP version 4
521 # @ipv6: IP version 6
525 { 'enum': 'GuestIpAddressType',
526 'data': [ 'ipv4', 'ipv6' ] }
531 # @ip-address: IP address
533 # @ip-address-type: Type of @ip-address (e.g. ipv4, ipv6)
535 # @prefix: Network prefix length of @ip-address
539 { 'type': 'GuestIpAddress',
540 'data': {'ip-address': 'str',
541 'ip-address-type': 'GuestIpAddressType',
545 # @GuestNetworkInterface:
547 # @name: The name of interface for which info are being delivered
549 # @hardware-address: Hardware address of @name
551 # @ip-addresses: List of addresses assigned to @name
555 { 'type': 'GuestNetworkInterface',
556 'data': {'name': 'str',
557 '*hardware-address': 'str',
558 '*ip-addresses': ['GuestIpAddress'] } }
561 # @guest-network-get-interfaces:
563 # Get list of guest IP addresses, MAC addresses
566 # Returns: List of GuestNetworkInfo on success.
570 { 'command': 'guest-network-get-interfaces',
571 'returns': ['GuestNetworkInterface'] }
574 # @GuestLogicalProcessor:
576 # @logical-id: Arbitrary guest-specific unique identifier of the VCPU.
578 # @online: Whether the VCPU is enabled.
580 # @can-offline: #optional Whether offlining the VCPU is possible. This member
581 # is always filled in by the guest agent when the structure is
582 # returned, and always ignored on input (hence it can be omitted
587 { 'type': 'GuestLogicalProcessor',
588 'data': {'logical-id': 'int',
590 '*can-offline': 'bool'} }
595 # Retrieve the list of the guest's logical processors.
597 # This is a read-only operation.
599 # Returns: The list of all VCPUs the guest knows about. Each VCPU is put on the
600 # list exactly once, but their order is unspecified.
604 { 'command': 'guest-get-vcpus',
605 'returns': ['GuestLogicalProcessor'] }
610 # Attempt to reconfigure (currently: enable/disable) logical processors inside
613 # The input list is processed node by node in order. In each node @logical-id
614 # is used to look up the guest VCPU, for which @online specifies the requested
615 # state. The set of distinct @logical-id's is only required to be a subset of
616 # the guest-supported identifiers. There's no restriction on list length or on
617 # repeating the same @logical-id (with possibly different @online field).
618 # Preferably the input list should describe a modified subset of
619 # @guest-get-vcpus' return value.
621 # Returns: The length of the initial sublist that has been successfully
622 # processed. The guest agent maximizes this value. Possible cases:
624 # 0: if the @vcpus list was empty on input. Guest state
625 # has not been changed. Otherwise,
627 # Error: processing the first node of @vcpus failed for the
628 # reason returned. Guest state has not been changed.
631 # < length(@vcpus): more than zero initial nodes have been processed,
632 # but not the entire @vcpus list. Guest state has
633 # changed accordingly. To retrieve the error
634 # (assuming it persists), repeat the call with the
635 # successfully processed initial sublist removed.
638 # length(@vcpus): call successful.
642 { 'command': 'guest-set-vcpus',
643 'data': {'vcpus': ['GuestLogicalProcessor'] },