xref: /qemu/qga/qapi-schema.json (revision 9d116f42a38cb95a33da837e0b0b50d91e28906b)
1# *-*- Mode: Python -*-*
2# vim: filetype=python
3
4##
5# = QEMU guest agent protocol commands and structs
6#
7# For a concise listing of all commands, events, and types in the QEMU
8# guest agent, please consult the `qapi-qga-index`.
9##
10
11{ 'pragma': { 'doc-required': true } }
12
13# Lists with items allowed to permit QAPI rule violations; think twice
14# before you add to them!
15{ 'pragma': {
16    # Types whose member names may use '_'
17    'member-name-exceptions': [
18        'GuestAgentInfo'
19    ],
20    # Commands allowed to return a non-dictionary:
21    'command-returns-exceptions': [
22        'guest-file-open',
23        'guest-fsfreeze-freeze',
24        'guest-fsfreeze-freeze-list',
25        'guest-fsfreeze-status',
26        'guest-fsfreeze-thaw',
27        'guest-get-time',
28        'guest-set-vcpus',
29        'guest-sync',
30        'guest-sync-delimited' ],
31    # Types and commands with undocumented members:
32    'documentation-exceptions': [
33        'GuestNVMeSmart' ] } }
34
35##
36# @guest-sync-delimited:
37#
38# Echo back a unique integer value, and prepend to response a leading
39# sentinel byte (0xFF) the client can check scan for.
40#
41# This is used by clients talking to the guest agent over the wire to
42# ensure the stream is in sync and doesn't contain stale data from
43# previous client.  It must be issued upon initial connection, and
44# after any client-side timeouts (including timeouts on receiving a
45# response to this command).
46#
47# After issuing this request, all guest agent responses should be
48# ignored until the response containing the unique integer value the
49# client passed in is returned.  Receival of the 0xFF sentinel byte
50# must be handled as an indication that the client's
51# lexer/tokenizer/parser state should be flushed/reset in preparation
52# for reliably receiving the subsequent response.  As an optimization,
53# clients may opt to ignore all data until a sentinel value is
54# receiving to avoid unnecessary processing of stale data.
55#
56# Similarly, clients should also precede this *request* with a 0xFF
57# byte to make sure the guest agent flushes any partially read JSON
58# data from a previous client connection.
59#
60# @id: randomly generated 64-bit integer
61#
62# Returns: The unique integer id passed in by the client
63#
64# Since: 1.1
65##
66{ 'command': 'guest-sync-delimited',
67  'data':    { 'id': 'int' },
68  'returns': 'int' }
69
70##
71# @guest-sync:
72#
73# Echo back a unique integer value
74#
75# This is used by clients talking to the guest agent over the wire to
76# ensure the stream is in sync and doesn't contain stale data from
77# previous client.  All guest agent responses should be ignored until
78# the provided unique integer value is returned, and it is up to the
79# client to handle stale whole or partially-delivered JSON text in
80# such a way that this response can be obtained.
81#
82# In cases where a partial stale response was previously received by
83# the client, this cannot always be done reliably.  One particular
84# scenario being if qemu-ga responses are fed character-by-character
85# into a JSON parser.  In these situations, using guest-sync-delimited
86# may be optimal.
87#
88# For clients that fetch responses line by line and convert them to
89# JSON objects, guest-sync should be sufficient, but note that in
90# cases where the channel is dirty some attempts at parsing the
91# response may result in a parser error.
92#
93# Such clients should also precede this command with a 0xFF byte to
94# make sure the guest agent flushes any partially read JSON data from
95# a previous session.
96#
97# @id: randomly generated 64-bit integer
98#
99# Returns: The unique integer id passed in by the client
100#
101# Since: 0.15.0
102##
103{ 'command': 'guest-sync',
104  'data':    { 'id': 'int' },
105  'returns': 'int' }
106
107##
108# @guest-ping:
109#
110# Ping the guest agent, a non-error return implies success
111#
112# Since: 0.15.0
113##
114{ 'command': 'guest-ping' }
115
116##
117# @guest-get-time:
118#
119# Get the information about guest's System Time relative to the Epoch
120# of 1970-01-01 in UTC.
121#
122# Returns: Time in nanoseconds.
123#
124# Since: 1.5
125##
126{ 'command': 'guest-get-time',
127  'returns': 'int' }
128
129##
130# @guest-set-time:
131#
132# Set guest time.
133#
134# When a guest is paused or migrated to a file then loaded from that
135# file, the guest OS has no idea that there was a big gap in the time.
136# Depending on how long the gap was, NTP might not be able to
137# resynchronize the guest.
138#
139# This command tries to set guest's System Time to the given value,
140# then sets the Hardware Clock (RTC) to the current System Time.  This
141# will make it easier for a guest to resynchronize without waiting for
142# NTP. If no @time is specified, then the time to set is read from
143# RTC. However, this may not be supported on all platforms (i.e.
144# Windows). If that's the case users are advised to always pass a
145# value.
146#
147# @time: time of nanoseconds, relative to the Epoch of 1970-01-01 in
148#     UTC.
149#
150# Since: 1.5
151##
152{ 'command': 'guest-set-time',
153  'data': { '*time': 'int' } }
154
155##
156# @GuestAgentCommandInfo:
157#
158# Information about guest agent commands.
159#
160# @name: name of the command
161#
162# @enabled: whether command is currently enabled by guest admin
163#
164# @success-response: whether command returns a response on success
165#     (since 1.7)
166#
167# Since: 1.1.0
168##
169{ 'struct': 'GuestAgentCommandInfo',
170  'data': { 'name': 'str', 'enabled': 'bool', 'success-response': 'bool' } }
171
172##
173# @GuestAgentInfo:
174#
175# Information about guest agent.
176#
177# @version: guest agent version
178#
179# @supported_commands: Information about guest agent commands
180#
181# Since: 0.15.0
182##
183{ 'struct': 'GuestAgentInfo',
184  'data': { 'version': 'str',
185            'supported_commands': ['GuestAgentCommandInfo'] } }
186##
187# @guest-info:
188#
189# Get some information about the guest agent.
190#
191# Returns: @GuestAgentInfo
192#
193# Since: 0.15.0
194##
195{ 'command': 'guest-info',
196  'returns': 'GuestAgentInfo' }
197
198##
199# @guest-shutdown:
200#
201# Initiate guest-activated shutdown.  Note: this is an asynchronous
202# shutdown request, with no guarantee of successful shutdown.
203#
204# @mode: "halt", "powerdown" (default), or "reboot"
205#
206# This command does NOT return a response on success.  Success
207# condition is indicated by the VM exiting with a zero exit status or,
208# when running with --no-shutdown, by issuing the query-status QMP
209# command to confirm the VM status is "shutdown".
210#
211# Since: 0.15.0
212##
213{ 'command': 'guest-shutdown', 'data': { '*mode': 'str' },
214  'success-response': false }
215
216##
217# @guest-file-open:
218#
219# Open a file in the guest and retrieve a file handle for it
220#
221# @path: Full path to the file in the guest to open.
222#
223# @mode: open mode, as per fopen(), "r" is the default.
224#
225# Returns: Guest file handle
226#
227# Since: 0.15.0
228##
229{ 'command': 'guest-file-open',
230  'data':    { 'path': 'str', '*mode': 'str' },
231  'returns': 'int' }
232
233##
234# @guest-file-close:
235#
236# Close an open file in the guest
237#
238# @handle: filehandle returned by guest-file-open
239#
240# Since: 0.15.0
241##
242{ 'command': 'guest-file-close',
243  'data': { 'handle': 'int' } }
244
245##
246# @GuestFileRead:
247#
248# Result of guest agent file-read operation
249#
250# @count: number of bytes read (note: count is *before*
251#     base64-encoding is applied)
252#
253# @buf-b64: base64-encoded bytes read
254#
255# @eof: whether EOF was encountered during read operation.
256#
257# Since: 0.15.0
258##
259{ 'struct': 'GuestFileRead',
260  'data': { 'count': 'int', 'buf-b64': 'str', 'eof': 'bool' } }
261
262##
263# @guest-file-read:
264#
265# Read from an open file in the guest.  Data will be base64-encoded.
266# As this command is just for limited, ad-hoc debugging, such as log
267# file access, the number of bytes to read is limited to 48 MB.
268#
269# @handle: filehandle returned by guest-file-open
270#
271# @count: maximum number of bytes to read (default is 4KB, maximum is
272#     48MB)
273#
274# Returns: @GuestFileRead
275#
276# Since: 0.15.0
277##
278{ 'command': 'guest-file-read',
279  'data':    { 'handle': 'int', '*count': 'int' },
280  'returns': 'GuestFileRead' }
281
282##
283# @GuestFileWrite:
284#
285# Result of guest agent file-write operation
286#
287# @count: number of bytes written (note: count is actual bytes
288#     written, after base64-decoding of provided buffer)
289#
290# @eof: whether EOF was encountered during write operation.
291#
292# Since: 0.15.0
293##
294{ 'struct': 'GuestFileWrite',
295  'data': { 'count': 'int', 'eof': 'bool' } }
296
297##
298# @guest-file-write:
299#
300# Write to an open file in the guest.
301#
302# @handle: filehandle returned by guest-file-open
303#
304# @buf-b64: base64-encoded string representing data to be written
305#
306# @count: bytes to write (actual bytes, after base64-decode), default
307#     is all content in buf-b64 buffer after base64 decoding
308#
309# Returns: @GuestFileWrite
310#
311# Since: 0.15.0
312##
313{ 'command': 'guest-file-write',
314  'data':    { 'handle': 'int', 'buf-b64': 'str', '*count': 'int' },
315  'returns': 'GuestFileWrite' }
316
317
318##
319# @GuestFileSeek:
320#
321# Result of guest agent file-seek operation
322#
323# @position: current file position
324#
325# @eof: whether EOF was encountered during file seek
326#
327# Since: 0.15.0
328##
329{ 'struct': 'GuestFileSeek',
330  'data': { 'position': 'int', 'eof': 'bool' } }
331
332##
333# @QGASeek:
334#
335# Symbolic names for use in @guest-file-seek
336#
337# @set: Set to the specified offset (same effect as 'whence':0)
338#
339# @cur: Add offset to the current location (same effect as 'whence':1)
340#
341# @end: Add offset to the end of the file (same effect as 'whence':2)
342#
343# Since: 2.6
344##
345{ 'enum': 'QGASeek', 'data': [ 'set', 'cur', 'end' ] }
346
347##
348# @GuestFileWhence:
349#
350# Controls the meaning of offset to @guest-file-seek.
351#
352# @value: Integral value (0 for set, 1 for cur, 2 for end), available
353#     for historical reasons, and might differ from the host's or
354#     guest's SEEK_* values (since: 0.15)
355#
356# @name: Symbolic name, and preferred interface
357#
358# Since: 2.6
359##
360{ 'alternate': 'GuestFileWhence',
361  'data': { 'value': 'int', 'name': 'QGASeek' } }
362
363##
364# @guest-file-seek:
365#
366# Seek to a position in the file, as with fseek(), and return the
367# current file position afterward.  Also encapsulates ftell()'s
368# functionality, with offset=0 and whence=1.
369#
370# @handle: filehandle returned by guest-file-open
371#
372# @offset: bytes to skip over in the file stream
373#
374# @whence: Symbolic or numeric code for interpreting offset
375#
376# Returns: @GuestFileSeek
377#
378# Since: 0.15.0
379##
380{ 'command': 'guest-file-seek',
381  'data':    { 'handle': 'int', 'offset': 'int',
382               'whence': 'GuestFileWhence' },
383  'returns': 'GuestFileSeek' }
384
385##
386# @guest-file-flush:
387#
388# Write file changes buffered in userspace to disk/kernel buffers
389#
390# @handle: filehandle returned by guest-file-open
391#
392# Since: 0.15.0
393##
394{ 'command': 'guest-file-flush',
395  'data': { 'handle': 'int' } }
396
397##
398# @GuestFsfreezeStatus:
399#
400# An enumeration of filesystem freeze states
401#
402# @thawed: filesystems thawed/unfrozen
403#
404# @frozen: all non-network guest filesystems frozen
405#
406# Since: 0.15.0
407##
408{ 'enum': 'GuestFsfreezeStatus',
409  'data': [ 'thawed', 'frozen' ],
410  'if': { 'any': ['CONFIG_WIN32', 'CONFIG_FSFREEZE'] } }
411
412##
413# @guest-fsfreeze-status:
414#
415# Get guest fsfreeze state.
416#
417# Returns: GuestFsfreezeStatus ("thawed", "frozen", etc., as defined
418#     below)
419#
420# .. note:: This may fail to properly report the current state as a
421#    result of some other guest processes having issued an fs
422#    freeze/thaw.
423#
424# Since: 0.15.0
425##
426{ 'command': 'guest-fsfreeze-status',
427  'returns': 'GuestFsfreezeStatus',
428  'if': { 'any': ['CONFIG_WIN32', 'CONFIG_FSFREEZE'] } }
429
430##
431# @guest-fsfreeze-freeze:
432#
433# Sync and freeze all freezable, local guest filesystems.  If this
434# command succeeded, you may call @guest-fsfreeze-thaw later to
435# unfreeze.
436#
437# On error, all filesystems will be thawed.  If no filesystems are
438# frozen as a result of this call, then @guest-fsfreeze-status will
439# remain "thawed" and calling @guest-fsfreeze-thaw is not necessary.
440#
441# Returns: Number of file systems currently frozen.
442#
443# .. note:: On Windows, the command is implemented with the help of a
444#    Volume Shadow-copy Service DLL helper.  The frozen state is limited
445#    for up to 10 seconds by VSS.
446#
447# Since: 0.15.0
448##
449{ 'command': 'guest-fsfreeze-freeze',
450  'returns': 'int',
451  'if': { 'any': ['CONFIG_WIN32', 'CONFIG_FSFREEZE'] } }
452
453##
454# @guest-fsfreeze-freeze-list:
455#
456# Sync and freeze specified guest filesystems.  See also
457# @guest-fsfreeze-freeze.
458#
459# On error, all filesystems will be thawed.
460#
461# @mountpoints: an array of mountpoints of filesystems to be frozen.
462#     If omitted, every mounted filesystem is frozen.  Invalid mount
463#     points are ignored.
464#
465# Returns: Number of file systems currently frozen.
466#
467# Since: 2.2
468##
469{ 'command': 'guest-fsfreeze-freeze-list',
470  'data':    { '*mountpoints': ['str'] },
471  'returns': 'int',
472  'if': { 'any': ['CONFIG_WIN32', 'CONFIG_FSFREEZE'] } }
473
474##
475# @guest-fsfreeze-thaw:
476#
477# Unfreeze all frozen guest filesystems
478#
479# Returns: Number of file systems thawed by this call
480#
481# .. note:: If the return value does not match the previous call to
482#    guest-fsfreeze-freeze, this likely means some freezable filesystems
483#    were unfrozen before this call, and that the filesystem state may
484#    have changed before issuing this command.
485#
486# Since: 0.15.0
487##
488{ 'command': 'guest-fsfreeze-thaw',
489  'returns': 'int',
490  'if': { 'any': ['CONFIG_WIN32', 'CONFIG_FSFREEZE'] } }
491
492##
493# @GuestFilesystemTrimResult:
494#
495# @path: path that was trimmed
496#
497# @error: an error message when trim failed
498#
499# @trimmed: bytes trimmed for this path
500#
501# @minimum: reported effective minimum for this path
502#
503# Since: 2.4
504##
505{ 'struct': 'GuestFilesystemTrimResult',
506  'data': {'path': 'str',
507           '*trimmed': 'int', '*minimum': 'int', '*error': 'str'},
508  'if': { 'any': ['CONFIG_WIN32', 'CONFIG_FSTRIM'] } }
509
510##
511# @GuestFilesystemTrimResponse:
512#
513# @paths: list of @GuestFilesystemTrimResult per path that was trimmed
514#
515# Since: 2.4
516##
517{ 'struct': 'GuestFilesystemTrimResponse',
518  'data': {'paths': ['GuestFilesystemTrimResult']},
519  'if': { 'any': ['CONFIG_WIN32', 'CONFIG_FSTRIM'] } }
520
521##
522# @guest-fstrim:
523#
524# Discard (or "trim") blocks which are not in use by the filesystem.
525#
526# @minimum: Minimum contiguous free range to discard, in bytes.  Free
527#     ranges smaller than this may be ignored (this is a hint and the
528#     guest may not respect it).  By increasing this value, the fstrim
529#     operation will complete more quickly for filesystems with badly
530#     fragmented free space, although not all blocks will be
531#     discarded.  The default value is zero, meaning "discard every
532#     free block".
533#
534# Returns: A @GuestFilesystemTrimResponse which contains the status of
535#     all trimmed paths.  (since 2.4)
536#
537# Since: 1.2
538##
539{ 'command': 'guest-fstrim',
540  'data': { '*minimum': 'int' },
541  'returns': 'GuestFilesystemTrimResponse',
542  'if': { 'any': ['CONFIG_WIN32', 'CONFIG_FSTRIM'] } }
543
544##
545# @guest-suspend-disk:
546#
547# Suspend guest to disk.
548#
549# This command attempts to suspend the guest using three strategies,
550# in this order:
551#
552# - systemd hibernate
553# - pm-utils (via pm-hibernate)
554# - manual write into sysfs
555#
556# This command does NOT return a response on success.  There is a high
557# chance the command succeeded if the VM exits with a zero exit status
558# or, when running with --no-shutdown, by issuing the query-status QMP
559# command to to confirm the VM status is "shutdown". However, the VM
560# could also exit (or set its status to "shutdown") due to other
561# reasons.
562#
563# Errors:
564#     - If suspend to disk is not supported, Unsupported
565#
566# .. note:: It's strongly recommended to issue the guest-sync command
567#    before sending commands when the guest resumes.
568#
569# Since: 1.1
570##
571{ 'command': 'guest-suspend-disk', 'success-response': false,
572  'if': { 'any': ['CONFIG_LINUX', 'CONFIG_WIN32'] } }
573
574##
575# @guest-suspend-ram:
576#
577# Suspend guest to ram.
578#
579# This command attempts to suspend the guest using three strategies,
580# in this order:
581#
582# - systemd hibernate
583# - pm-utils (via pm-hibernate)
584# - manual write into sysfs
585#
586# IMPORTANT: guest-suspend-ram requires working wakeup support in
587# QEMU. You should check QMP command query-current-machine returns
588# wakeup-suspend-support: true before issuing this command.  Failure
589# in doing so can result in a suspended guest that QEMU will not be
590# able to awaken, forcing the user to power cycle the guest to bring
591# it back.
592#
593# This command does NOT return a response on success.  There are two
594# options to check for success:
595#
596# 1. Wait for the SUSPEND QMP event from QEMU
597# 2. Issue the query-status QMP command to confirm the VM status is
598#    "suspended"
599#
600# Errors:
601#     - If suspend to ram is not supported, Unsupported
602#
603# .. note:: It's strongly recommended to issue the guest-sync command
604#    before sending commands when the guest resumes.
605#
606# Since: 1.1
607##
608{ 'command': 'guest-suspend-ram', 'success-response': false,
609  'if': { 'any': ['CONFIG_LINUX', 'CONFIG_WIN32'] } }
610
611##
612# @guest-suspend-hybrid:
613#
614# Save guest state to disk and suspend to ram.
615#
616# This command attempts to suspend the guest by executing, in this
617# order:
618#
619# - systemd hybrid-sleep
620# - pm-utils (via pm-suspend-hybrid)
621#
622# IMPORTANT: guest-suspend-hybrid requires working wakeup support in
623# QEMU. You should check QMP command query-current-machine returns
624# wakeup-suspend-support: true before issuing this command.  Failure
625# in doing so can result in a suspended guest that QEMU will not be
626# able to awaken, forcing the user to power cycle the guest to bring
627# it back.
628#
629# This command does NOT return a response on success.  There are two
630# options to check for success:
631#
632# 1. Wait for the SUSPEND QMP event from QEMU
633# 2. Issue the query-status QMP command to confirm the VM status is
634#    "suspended"
635#
636# Errors:
637#     - If hybrid suspend is not supported, Unsupported
638#
639# .. note:: It's strongly recommended to issue the guest-sync command
640#    before sending commands when the guest resumes.
641#
642# Since: 1.1
643##
644{ 'command': 'guest-suspend-hybrid', 'success-response': false,
645  'if': 'CONFIG_LINUX' }
646
647##
648# @GuestIpAddressType:
649#
650# An enumeration of supported IP address types
651#
652# @ipv4: IP version 4
653#
654# @ipv6: IP version 6
655#
656# Since: 1.1
657##
658{ 'enum': 'GuestIpAddressType',
659  'data': [ 'ipv4', 'ipv6' ],
660  'if': { 'any': ['CONFIG_WIN32', 'HAVE_GETIFADDRS'] } }
661
662##
663# @GuestIpAddress:
664#
665# @ip-address: IP address
666#
667# @ip-address-type: Type of @ip-address (e.g. ipv4, ipv6)
668#
669# @prefix: Network prefix length of @ip-address
670#
671# Since: 1.1
672##
673{ 'struct': 'GuestIpAddress',
674  'data': {'ip-address': 'str',
675           'ip-address-type': 'GuestIpAddressType',
676           'prefix': 'int'},
677  'if': { 'any': ['CONFIG_WIN32', 'HAVE_GETIFADDRS'] } }
678
679##
680# @GuestNetworkInterfaceStat:
681#
682# @rx-bytes: total bytes received
683#
684# @rx-packets: total packets received
685#
686# @rx-errs: bad packets received
687#
688# @rx-dropped: receiver dropped packets
689#
690# @tx-bytes: total bytes transmitted
691#
692# @tx-packets: total packets transmitted
693#
694# @tx-errs: packet transmit problems
695#
696# @tx-dropped: dropped packets transmitted
697#
698# Since: 2.11
699##
700{ 'struct': 'GuestNetworkInterfaceStat',
701  'data': {'rx-bytes': 'uint64',
702            'rx-packets': 'uint64',
703            'rx-errs': 'uint64',
704            'rx-dropped': 'uint64',
705            'tx-bytes': 'uint64',
706            'tx-packets': 'uint64',
707            'tx-errs': 'uint64',
708            'tx-dropped': 'uint64'
709           },
710  'if': { 'any': ['CONFIG_WIN32', 'HAVE_GETIFADDRS'] } }
711
712##
713# @GuestNetworkInterface:
714#
715# @name: The name of interface for which info are being delivered
716#
717# @hardware-address: Hardware address of @name
718#
719# @ip-addresses: List of addresses assigned to @name
720#
721# @statistics: various statistic counters related to @name (since
722#     2.11)
723#
724# Since: 1.1
725##
726{ 'struct': 'GuestNetworkInterface',
727  'data': {'name': 'str',
728           '*hardware-address': 'str',
729           '*ip-addresses': ['GuestIpAddress'],
730           '*statistics': 'GuestNetworkInterfaceStat' },
731  'if': { 'any': ['CONFIG_WIN32', 'HAVE_GETIFADDRS'] } }
732
733##
734# @guest-network-get-interfaces:
735#
736# Get list of guest IP addresses, MAC addresses and netmasks.
737#
738# Returns: List of GuestNetworkInterface
739#
740# Since: 1.1
741##
742{ 'command': 'guest-network-get-interfaces',
743  'returns': ['GuestNetworkInterface'],
744  'if': { 'any': ['CONFIG_WIN32', 'HAVE_GETIFADDRS'] } }
745
746##
747# @GuestLogicalProcessor:
748#
749# @logical-id: Arbitrary guest-specific unique identifier of the VCPU.
750#
751# @online: Whether the VCPU is enabled.
752#
753# @can-offline: Whether offlining the VCPU is possible.  This member
754#     is always filled in by the guest agent when the structure is
755#     returned, and always ignored on input (hence it can be omitted
756#     then).
757#
758# Since: 1.5
759##
760{ 'struct': 'GuestLogicalProcessor',
761  'data': {'logical-id': 'int',
762           'online': 'bool',
763           '*can-offline': 'bool'},
764  'if': { 'any': ['CONFIG_LINUX', 'CONFIG_WIN32'] } }
765
766##
767# @guest-get-vcpus:
768#
769# Retrieve the list of the guest's logical processors.
770#
771# This is a read-only operation.
772#
773# Returns: The list of all VCPUs the guest knows about.  Each VCPU is
774#     put on the list exactly once, but their order is unspecified.
775#
776# Since: 1.5
777##
778{ 'command': 'guest-get-vcpus',
779  'returns': ['GuestLogicalProcessor'],
780  'if': { 'any': ['CONFIG_LINUX', 'CONFIG_WIN32'] } }
781
782##
783# @guest-set-vcpus:
784#
785# Attempt to reconfigure (currently: enable/disable) logical
786# processors inside the guest.
787#
788# @vcpus: The logical processors to be reconfigured.  This list is
789#     processed node by node in order.  In each node @logical-id is
790#     used to look up the guest VCPU, for which @online specifies the
791#     requested state.  The set of distinct @logical-id's is only
792#     required to be a subset of the guest-supported identifiers.
793#     There's no restriction on list length or on repeating the same
794#     @logical-id (with possibly different @online field).  Preferably
795#     the input list should describe a modified subset of
796#     @guest-get-vcpus' return value.
797#
798# Returns: The length of the initial sublist that has been
799#     successfully processed.  The guest agent maximizes this value.
800#     Possible cases:
801#
802#     - 0:
803#       if the @vcpus list was empty on input.  Guest state has not
804#       been changed.  Otherwise,
805#     - < length(@vcpus):
806#       more than zero initial nodes have been processed, but not the
807#       entire @vcpus list.  Guest state has changed accordingly.  To
808#       retrieve the error (assuming it persists), repeat the call
809#       with the successfully processed initial sublist removed.
810#       Otherwise,
811#     - length(@vcpus):
812#       call successful.
813#
814# Errors:
815#     - If the reconfiguration of the first node in @vcpus failed.
816#       Guest state has not been changed.
817#
818# Since: 1.5
819##
820{ 'command': 'guest-set-vcpus',
821  'data':    {'vcpus': ['GuestLogicalProcessor'] },
822  'returns': 'int',
823  'if': 'CONFIG_LINUX' }
824
825##
826# @GuestDiskBusType:
827#
828# An enumeration of bus type of disks
829#
830# @ide: IDE disks
831#
832# @fdc: floppy disks
833#
834# @scsi: SCSI disks
835#
836# @virtio: virtio disks
837#
838# @xen: Xen disks
839#
840# @usb: USB disks
841#
842# @uml: UML disks
843#
844# @sata: SATA disks
845#
846# @sd: SD cards
847#
848# @unknown: Unknown bus type
849#
850# @ieee1394: Win IEEE 1394 bus type
851#
852# @ssa: Win SSA bus type
853#
854# @fibre: Win fiber channel bus type
855#
856# @raid: Win RAID bus type
857#
858# @iscsi: Win iScsi bus type
859#
860# @sas: Win serial-attaches SCSI bus type
861#
862# @mmc: Win multimedia card (MMC) bus type
863#
864# @virtual: Win virtual bus type
865#
866# @file-backed-virtual: Win file-backed bus type
867#
868# @nvme: NVMe disks (since 7.1)
869#
870# Since: 2.2; 'Unknown' and all entries below since 2.4
871##
872{ 'enum': 'GuestDiskBusType',
873  'data': [ 'ide', 'fdc', 'scsi', 'virtio', 'xen', 'usb', 'uml', 'sata',
874            'sd', 'unknown', 'ieee1394', 'ssa', 'fibre', 'raid', 'iscsi',
875            'sas', 'mmc', 'virtual', 'file-backed-virtual', 'nvme' ],
876  'if': { 'any': [ 'CONFIG_WIN32', 'CONFIG_LINUX' ] } }
877
878
879##
880# @GuestPCIAddress:
881#
882# @domain: domain id
883#
884# @bus: bus id
885#
886# @slot: slot id
887#
888# @function: function id
889#
890# Since: 2.2
891##
892{ 'struct': 'GuestPCIAddress',
893  'data': {'domain': 'int', 'bus': 'int',
894           'slot': 'int', 'function': 'int'},
895  'if': { 'any': [ 'CONFIG_WIN32', 'CONFIG_LINUX' ] } }
896
897##
898# @GuestCCWAddress:
899#
900# @cssid: channel subsystem image id
901#
902# @ssid: subchannel set id
903#
904# @subchno: subchannel number
905#
906# @devno: device number
907#
908# Since: 6.0
909##
910{ 'struct': 'GuestCCWAddress',
911  'data': {'cssid': 'int',
912           'ssid': 'int',
913           'subchno': 'int',
914           'devno': 'int'},
915  'if': { 'any': [ 'CONFIG_WIN32', 'CONFIG_LINUX' ] } }
916
917##
918# @GuestDiskAddress:
919#
920# @pci-controller: controller's PCI address (fields are set to -1 if
921#     invalid)
922#
923# @bus-type: bus type
924#
925# @bus: bus id
926#
927# @target: target id
928#
929# @unit: unit id
930#
931# @serial: serial number (since: 3.1)
932#
933# @dev: device node (POSIX) or device UNC (Windows) (since: 3.1)
934#
935# @ccw-address: CCW address on s390x (since: 6.0)
936#
937# Since: 2.2
938##
939{ 'struct': 'GuestDiskAddress',
940  'data': {'pci-controller': 'GuestPCIAddress',
941           'bus-type': 'GuestDiskBusType',
942           'bus': 'int', 'target': 'int', 'unit': 'int',
943           '*serial': 'str', '*dev': 'str',
944           '*ccw-address': 'GuestCCWAddress'},
945  'if': { 'any': [ 'CONFIG_WIN32', 'CONFIG_LINUX' ] } }
946
947##
948# @GuestNVMeSmart:
949#
950# NVMe smart information, based on NVMe specification, section
951# <SMART / Health Information (Log Identifier 02h)>
952#
953# TODO: document members briefly
954#
955# Since: 7.1
956##
957{ 'struct': 'GuestNVMeSmart',
958  'data': {'critical-warning': 'int',
959           'temperature': 'int',
960           'available-spare': 'int',
961           'available-spare-threshold': 'int',
962           'percentage-used': 'int',
963           'data-units-read-lo': 'uint64',
964           'data-units-read-hi': 'uint64',
965           'data-units-written-lo': 'uint64',
966           'data-units-written-hi': 'uint64',
967           'host-read-commands-lo': 'uint64',
968           'host-read-commands-hi': 'uint64',
969           'host-write-commands-lo': 'uint64',
970           'host-write-commands-hi': 'uint64',
971           'controller-busy-time-lo': 'uint64',
972           'controller-busy-time-hi': 'uint64',
973           'power-cycles-lo': 'uint64',
974           'power-cycles-hi': 'uint64',
975           'power-on-hours-lo': 'uint64',
976           'power-on-hours-hi': 'uint64',
977           'unsafe-shutdowns-lo': 'uint64',
978           'unsafe-shutdowns-hi': 'uint64',
979           'media-errors-lo': 'uint64',
980           'media-errors-hi': 'uint64',
981           'number-of-error-log-entries-lo': 'uint64',
982           'number-of-error-log-entries-hi': 'uint64' },
983  'if': { 'any': [ 'CONFIG_WIN32', 'CONFIG_LIBUDEV' ] } }
984
985##
986# @GuestDiskSmart:
987#
988# Disk type related smart information.
989#
990# @type: disk bus type
991#
992# Since: 7.1
993##
994{ 'union': 'GuestDiskSmart',
995  'base': { 'type': 'GuestDiskBusType' },
996  'discriminator': 'type',
997  'data': { 'nvme': 'GuestNVMeSmart' },
998  'if': { 'any': [ 'CONFIG_WIN32', 'CONFIG_LIBUDEV' ] } }
999
1000##
1001# @GuestDiskInfo:
1002#
1003# @name: device node (Linux) or device UNC (Windows)
1004#
1005# @partition: whether this is a partition or disk
1006#
1007# @dependencies: list of device dependencies; e.g. for LVs of the LVM
1008#     this will hold the list of PVs, for LUKS encrypted volume this
1009#     will contain the disk where the volume is placed.  (Linux)
1010#
1011# @address: disk address information (only for non-virtual devices)
1012#
1013# @alias: optional alias assigned to the disk, on Linux this is a name
1014#     assigned by device mapper
1015#
1016# @smart: disk smart information (Since 7.1)
1017#
1018# Since: 5.2
1019##
1020{ 'struct': 'GuestDiskInfo',
1021  'data': {'name': 'str', 'partition': 'bool', '*dependencies': ['str'],
1022           '*address': 'GuestDiskAddress', '*alias': 'str',
1023           '*smart': 'GuestDiskSmart'},
1024  'if': { 'any': [ 'CONFIG_WIN32', 'CONFIG_LIBUDEV' ] } }
1025
1026##
1027# @guest-get-disks:
1028#
1029# Returns: The list of disks in the guest.  For Windows these are only
1030#     the physical disks.  On Linux these are all root block devices
1031#     of non-zero size including e.g. removable devices, loop devices,
1032#     NBD, etc.
1033#
1034# Since: 5.2
1035##
1036{ 'command': 'guest-get-disks',
1037  'returns': ['GuestDiskInfo'],
1038  'if': { 'any': [ 'CONFIG_WIN32', 'CONFIG_LIBUDEV' ] } }
1039
1040##
1041# @GuestFilesystemInfo:
1042#
1043# @name: disk name
1044#
1045# @mountpoint: mount point path
1046#
1047# @type: file system type string
1048#
1049# @used-bytes: file system used bytes (since 3.0)
1050#
1051# @total-bytes: filesystem capacity in bytes for unprivileged users (since 3.0)
1052#
1053# @total-bytes-privileged: filesystem capacity in bytes for privileged users
1054#     (since 9.1)
1055#
1056# @disk: an array of disk hardware information that the volume lies
1057#     on, which may be empty if the disk type is not supported
1058#
1059# Since: 2.2
1060##
1061{ 'struct': 'GuestFilesystemInfo',
1062  'data': {'name': 'str', 'mountpoint': 'str', 'type': 'str',
1063           '*used-bytes': 'uint64', '*total-bytes': 'uint64',
1064           '*total-bytes-privileged': 'uint64', 'disk': ['GuestDiskAddress']},
1065  'if': { 'any': [ 'CONFIG_WIN32', 'CONFIG_LINUX' ] } }
1066
1067##
1068# @guest-get-fsinfo:
1069#
1070# Returns: The list of filesystems information mounted in the guest.
1071#     The returned mountpoints may be specified to
1072#     @guest-fsfreeze-freeze-list.  Network filesystems (such as CIFS
1073#     and NFS) are not listed.
1074#
1075# Since: 2.2
1076##
1077{ 'command': 'guest-get-fsinfo',
1078  'returns': ['GuestFilesystemInfo'],
1079  'if': { 'any': [ 'CONFIG_WIN32', 'CONFIG_LINUX' ] } }
1080
1081##
1082# @guest-set-user-password:
1083#
1084# @username: the user account whose password to change
1085#
1086# @password: the new password entry string, base64 encoded
1087#
1088# @crypted: true if password is already crypt()d, false if raw
1089#
1090# If the @crypted flag is true, it is the caller's responsibility to
1091# ensure the correct crypt() encryption scheme is used.  This command
1092# does not attempt to interpret or report on the encryption scheme.
1093# Refer to the documentation of the guest operating system in question
1094# to determine what is supported.
1095#
1096# Not all guest operating systems will support use of the @crypted
1097# flag, as they may require the clear-text password
1098#
1099# The @password parameter must always be base64 encoded before
1100# transmission, even if already crypt()d, to ensure it is 8-bit safe
1101# when passed as JSON.
1102#
1103# Since: 2.3
1104##
1105{ 'command': 'guest-set-user-password',
1106  'data': { 'username': 'str', 'password': 'str', 'crypted': 'bool' },
1107  'if': { 'any': [ 'CONFIG_WIN32', 'CONFIG_LINUX', 'CONFIG_FREEBSD'] } }
1108
1109##
1110# @GuestMemoryBlock:
1111#
1112# @phys-index: Arbitrary guest-specific unique identifier of the
1113#     MEMORY BLOCK.
1114#
1115# @online: Whether the MEMORY BLOCK is enabled in guest.
1116#
1117# @can-offline: Whether offlining the MEMORY BLOCK is possible.  This
1118#     member is always filled in by the guest agent when the structure
1119#     is returned, and always ignored on input (hence it can be
1120#     omitted then).
1121#
1122# Since: 2.3
1123##
1124{ 'struct': 'GuestMemoryBlock',
1125  'data': {'phys-index': 'uint64',
1126           'online': 'bool',
1127           '*can-offline': 'bool'},
1128  'if': 'CONFIG_LINUX' }
1129
1130##
1131# @guest-get-memory-blocks:
1132#
1133# Retrieve the list of the guest's memory blocks.
1134#
1135# This is a read-only operation.
1136#
1137# Returns: The list of all memory blocks the guest knows about.  Each
1138#     memory block is put on the list exactly once, but their order is
1139#     unspecified.
1140#
1141# Since: 2.3
1142##
1143{ 'command': 'guest-get-memory-blocks',
1144  'returns': ['GuestMemoryBlock'],
1145  'if': 'CONFIG_LINUX' }
1146
1147##
1148# @GuestMemoryBlockResponseType:
1149#
1150# An enumeration of memory block operation result.
1151#
1152# @success: the operation of online/offline memory block is
1153#     successful.
1154#
1155# @not-found: can't find the corresponding memoryXXX directory in
1156#     sysfs.
1157#
1158# @operation-not-supported: for some old kernels, it does not support
1159#     online or offline memory block.
1160#
1161# @operation-failed: the operation of online/offline memory block
1162#     fails, because of some errors happen.
1163#
1164# Since: 2.3
1165##
1166{ 'enum': 'GuestMemoryBlockResponseType',
1167  'data': ['success', 'not-found', 'operation-not-supported',
1168           'operation-failed'],
1169  'if': 'CONFIG_LINUX' }
1170
1171##
1172# @GuestMemoryBlockResponse:
1173#
1174# @phys-index: same with the 'phys-index' member of @GuestMemoryBlock.
1175#
1176# @response: the result of memory block operation.
1177#
1178# @error-code: the error number.  When memory block operation fails,
1179#     we assign the value of 'errno' to this member, it indicates what
1180#     goes wrong.  When the operation succeeds, it will be omitted.
1181#
1182# Since: 2.3
1183##
1184{ 'struct': 'GuestMemoryBlockResponse',
1185  'data': { 'phys-index': 'uint64',
1186            'response': 'GuestMemoryBlockResponseType',
1187            '*error-code': 'int' },
1188  'if': 'CONFIG_LINUX'}
1189
1190##
1191# @guest-set-memory-blocks:
1192#
1193# Attempt to reconfigure (currently: enable/disable) state of memory
1194# blocks inside the guest.
1195#
1196# @mem-blks: The memory blocks to be reconfigured.  This list is
1197#     processed node by node in order.  In each node @phys-index is
1198#     used to look up the guest MEMORY BLOCK, for which @online
1199#     specifies the requested state.  The set of distinct
1200#     @phys-index's is only required to be a subset of the
1201#     guest-supported identifiers.  There's no restriction on list
1202#     length or on repeating the same @phys-index (with possibly
1203#     different @online field).  Preferably the input list should
1204#     describe a modified subset of @guest-get-memory-blocks' return
1205#     value.
1206#
1207# Returns: The operation results, it is a list of
1208#     @GuestMemoryBlockResponse, which is corresponding to the input
1209#     list.
1210#
1211#     Note: it will return an empty list if the @mem-blks list was
1212#     empty on input, or there is an error, and in this case, guest
1213#     state will not be changed.
1214#
1215# Since: 2.3
1216##
1217{ 'command': 'guest-set-memory-blocks',
1218  'data':    {'mem-blks': ['GuestMemoryBlock'] },
1219  'returns': ['GuestMemoryBlockResponse'],
1220  'if': 'CONFIG_LINUX' }
1221
1222##
1223# @GuestMemoryBlockInfo:
1224#
1225# @size: the size (in bytes) of the guest memory blocks, which are the
1226#     minimal units of memory block online/offline operations (also
1227#     called Logical Memory Hotplug).
1228#
1229# Since: 2.3
1230##
1231{ 'struct': 'GuestMemoryBlockInfo',
1232  'data': {'size': 'uint64'},
1233  'if': 'CONFIG_LINUX' }
1234
1235##
1236# @guest-get-memory-block-info:
1237#
1238# Get information relating to guest memory blocks.
1239#
1240# Returns: @GuestMemoryBlockInfo
1241#
1242# Since: 2.3
1243##
1244{ 'command': 'guest-get-memory-block-info',
1245  'returns': 'GuestMemoryBlockInfo',
1246  'if': 'CONFIG_LINUX' }
1247
1248##
1249# @GuestExecStatus:
1250#
1251# @exited: true if process has already terminated.
1252#
1253# @exitcode: process exit code if it was normally terminated.
1254#
1255# @signal: signal number (linux) or unhandled exception code (windows)
1256#     if the process was abnormally terminated.
1257#
1258# @out-data: base64-encoded stdout of the process.  This field will
1259#     only be populated after the process exits.
1260#
1261# @err-data: base64-encoded stderr of the process.  Note: @out-data
1262#     and @err-data are present only if 'capture-output' was specified
1263#     for 'guest-exec'.  This field will only be populated after the
1264#     process exits.
1265#
1266# @out-truncated: true if stdout was not fully captured due to size
1267#     limitation.
1268#
1269# @err-truncated: true if stderr was not fully captured due to size
1270#     limitation.
1271#
1272# Since: 2.5
1273##
1274{ 'struct': 'GuestExecStatus',
1275  'data': { 'exited': 'bool', '*exitcode': 'int', '*signal': 'int',
1276            '*out-data': 'str', '*err-data': 'str',
1277            '*out-truncated': 'bool', '*err-truncated': 'bool' }}
1278##
1279# @guest-exec-status:
1280#
1281# Check status of process associated with PID retrieved via
1282# guest-exec.  Reap the process and associated metadata if it has
1283# exited.
1284#
1285# @pid: pid returned from guest-exec
1286#
1287# Returns: GuestExecStatus
1288#
1289# Since: 2.5
1290##
1291{ 'command': 'guest-exec-status',
1292  'data':    { 'pid': 'int' },
1293  'returns': 'GuestExecStatus' }
1294
1295##
1296# @GuestExec:
1297#
1298# @pid: pid of child process in guest OS
1299#
1300# Since: 2.5
1301##
1302{ 'struct': 'GuestExec',
1303  'data': { 'pid': 'int'} }
1304
1305##
1306# @GuestExecCaptureOutputMode:
1307#
1308# An enumeration of guest-exec capture modes.
1309#
1310# @none: do not capture any output
1311#
1312# @stdout: only capture stdout
1313#
1314# @stderr: only capture stderr
1315#
1316# @separated: capture both stdout and stderr, but separated into
1317#     GuestExecStatus out-data and err-data, respectively
1318#
1319# @merged: capture both stdout and stderr, but merge together into
1320#     out-data.  Not effective on windows guests.
1321#
1322# Since: 8.0
1323##
1324 { 'enum': 'GuestExecCaptureOutputMode',
1325   'data': [ 'none', 'stdout', 'stderr', 'separated',
1326             { 'name': 'merged', 'if': { 'not': 'CONFIG_WIN32' } } ] }
1327
1328##
1329# @GuestExecCaptureOutput:
1330#
1331# Controls what guest-exec output gets captures.
1332#
1333# @flag: captures both stdout and stderr if true.  Equivalent to
1334#     GuestExecCaptureOutputMode::all.  (since 2.5)
1335#
1336# @mode: capture mode; preferred interface
1337#
1338# Since: 8.0
1339##
1340 { 'alternate': 'GuestExecCaptureOutput',
1341   'data': { 'flag': 'bool',
1342             'mode': 'GuestExecCaptureOutputMode'} }
1343
1344##
1345# @guest-exec:
1346#
1347# Execute a command in the guest
1348#
1349# @path: path or executable name to execute
1350#
1351# @arg: argument list to pass to executable
1352#
1353# @env: environment variables to pass to executable
1354#
1355# @input-data: data to be passed to process stdin (base64 encoded)
1356#
1357# @capture-output: bool flag to enable capture of stdout/stderr of
1358#     running process.  Defaults to false.
1359#
1360# Returns: PID
1361#
1362# Since: 2.5
1363##
1364{ 'command': 'guest-exec',
1365  'data':    { 'path': 'str', '*arg': ['str'], '*env': ['str'],
1366               '*input-data': 'str', '*capture-output': 'GuestExecCaptureOutput' },
1367  'returns': 'GuestExec' }
1368
1369
1370##
1371# @GuestHostName:
1372#
1373# @host-name: Fully qualified domain name of the guest OS
1374#
1375# Since: 2.10
1376##
1377{ 'struct': 'GuestHostName',
1378  'data':   { 'host-name': 'str' } }
1379
1380##
1381# @guest-get-host-name:
1382#
1383# Return a name for the machine.
1384#
1385# The returned name is not necessarily a fully-qualified domain name,
1386# or even present in DNS or some other name service at all.  It need
1387# not even be unique on your local network or site, but usually it is.
1388#
1389# Returns: the host name of the machine
1390#
1391# Since: 2.10
1392##
1393{ 'command': 'guest-get-host-name',
1394  'returns': 'GuestHostName' }
1395
1396
1397##
1398# @GuestUser:
1399#
1400# @user: Username
1401#
1402# @domain: Logon domain (windows only)
1403#
1404# @login-time: Time of login of this user on the computer.  If
1405#     multiple instances of the user are logged in, the earliest login
1406#     time is reported.  The value is in fractional seconds since
1407#     epoch time.
1408#
1409# Since: 2.10
1410##
1411{ 'struct': 'GuestUser',
1412  'data': { 'user': 'str', 'login-time': 'number', '*domain': 'str' },
1413  'if': { 'any': ['CONFIG_WIN32', 'HAVE_UTMPX' ] } }
1414
1415##
1416# @guest-get-users:
1417#
1418# Retrieves a list of currently active users on the VM.
1419#
1420# Returns: A unique list of users.
1421#
1422# Since: 2.10
1423##
1424{ 'command': 'guest-get-users',
1425  'returns': ['GuestUser'],
1426  'if': { 'any': ['CONFIG_WIN32', 'HAVE_UTMPX' ] } }
1427
1428##
1429# @GuestTimezone:
1430#
1431# @zone: Timezone name.  These values may differ depending on guest/OS
1432#     and should only be used for informational purposes.
1433#
1434# @offset: Offset to UTC in seconds, negative numbers for time zones
1435#     west of GMT, positive numbers for east
1436#
1437# Since: 2.10
1438##
1439{ 'struct': 'GuestTimezone',
1440  'data':   { '*zone': 'str', 'offset': 'int' } }
1441
1442##
1443# @guest-get-timezone:
1444#
1445# Retrieves the timezone information from the guest.
1446#
1447# Returns: A GuestTimezone dictionary.
1448#
1449# Since: 2.10
1450##
1451{ 'command': 'guest-get-timezone',
1452  'returns': 'GuestTimezone' }
1453
1454##
1455# @GuestOSInfo:
1456#
1457# @kernel-release:
1458#     * POSIX: release field returned by uname(2)
1459#     * Windows: build number of the OS
1460#
1461# @kernel-version:
1462#     * POSIX: version field returned by uname(2)
1463#     * Windows: version number of the OS
1464#
1465# @machine:
1466#     * POSIX: machine field returned by uname(2)
1467#     * Windows: one of x86, x86_64, arm, ia64
1468#
1469# @id:
1470#     * POSIX: as defined by os-release(5)
1471#     * Windows: contains string "mswindows"
1472#
1473# @name:
1474#     * POSIX: as defined by os-release(5)
1475#     * Windows: contains string "Microsoft Windows"
1476#
1477# @pretty-name:
1478#     * POSIX: as defined by os-release(5)
1479#     * Windows: product name, e.g. "Microsoft Windows 10 Enterprise"
1480#
1481# @version:
1482#     * POSIX: as defined by os-release(5)
1483#     * Windows: long version string, e.g. "Microsoft Windows Server
1484#       2008"
1485#
1486# @version-id:
1487#     * POSIX: as defined by os-release(5)
1488#     * Windows: short version identifier, e.g. "7" or "20012r2"
1489#
1490# @variant:
1491#     * POSIX: as defined by os-release(5)
1492#     * Windows: contains string "server" or "client"
1493#
1494# @variant-id:
1495#     * POSIX: as defined by os-release(5)
1496#     * Windows: contains string "server" or "client"
1497#
1498# .. note:: On POSIX systems the fields @id, @name, @pretty-name,
1499#    @version, @version-id, @variant and @variant-id follow the
1500#    definition specified in os-release(5). Refer to the manual page for
1501#    exact description of the fields.  Their values are taken from the
1502#    os-release file.  If the file is not present in the system, or the
1503#    values are not present in the file, the fields are not included.
1504#
1505#    On Windows the values are filled from information gathered from
1506#    the system.
1507#
1508# Since: 2.10
1509##
1510{ 'struct': 'GuestOSInfo',
1511  'data': {
1512      '*kernel-release': 'str', '*kernel-version': 'str',
1513      '*machine': 'str', '*id': 'str', '*name': 'str',
1514      '*pretty-name': 'str', '*version': 'str', '*version-id': 'str',
1515      '*variant': 'str', '*variant-id': 'str' } }
1516
1517##
1518# @guest-get-osinfo:
1519#
1520# Retrieve guest operating system information
1521#
1522# Returns: @GuestOSInfo
1523#
1524# Since: 2.10
1525##
1526{ 'command': 'guest-get-osinfo',
1527  'returns': 'GuestOSInfo' }
1528
1529##
1530# @GuestDeviceType:
1531#
1532# @pci: PCI device
1533##
1534{ 'enum': 'GuestDeviceType',
1535  'data': [ 'pci' ],
1536  'if': 'CONFIG_WIN32' }
1537
1538##
1539# @GuestDeviceIdPCI:
1540#
1541# @vendor-id: vendor ID
1542#
1543# @device-id: device ID
1544#
1545# Since: 5.2
1546##
1547{ 'struct': 'GuestDeviceIdPCI',
1548  'data': { 'vendor-id': 'uint16', 'device-id': 'uint16' },
1549  'if': 'CONFIG_WIN32' }
1550
1551##
1552# @GuestDeviceId:
1553#
1554# Id of the device
1555#
1556# @type: device type
1557#
1558# Since: 5.2
1559##
1560{ 'union': 'GuestDeviceId',
1561  'base': { 'type': 'GuestDeviceType' },
1562  'discriminator': 'type',
1563  'data': { 'pci': 'GuestDeviceIdPCI' },
1564  'if': 'CONFIG_WIN32' }
1565
1566##
1567# @GuestDeviceInfo:
1568#
1569# @driver-name: name of the associated driver
1570#
1571# @driver-date: driver release date, in nanoseconds since the epoch
1572#
1573# @driver-version: driver version
1574#
1575# @id: device ID
1576#
1577# Since: 5.2
1578##
1579{ 'struct': 'GuestDeviceInfo',
1580  'data': {
1581      'driver-name': 'str',
1582      '*driver-date': 'int',
1583      '*driver-version': 'str',
1584      '*id': 'GuestDeviceId'
1585  },
1586  'if': 'CONFIG_WIN32' }
1587
1588##
1589# @guest-get-devices:
1590#
1591# Retrieve information about device drivers in Windows guest
1592#
1593# Returns: @GuestDeviceInfo
1594#
1595# Since: 5.2
1596##
1597{ 'command': 'guest-get-devices',
1598  'returns': ['GuestDeviceInfo'],
1599  'if': 'CONFIG_WIN32' }
1600
1601##
1602# @GuestAuthorizedKeys:
1603#
1604# @keys: public keys (in OpenSSH/sshd(8) authorized_keys format)
1605#
1606# Since: 5.2
1607##
1608{ 'struct': 'GuestAuthorizedKeys',
1609  'data': {
1610      'keys': ['str']
1611  }
1612}
1613
1614##
1615# @guest-ssh-get-authorized-keys:
1616#
1617# Return the public keys from user .ssh/authorized_keys on Unix
1618# systems (not implemented for other systems).
1619#
1620# @username: the user account to add the authorized keys
1621#
1622# Returns: @GuestAuthorizedKeys
1623#
1624# Since: 5.2
1625##
1626{ 'command': 'guest-ssh-get-authorized-keys',
1627  'data': { 'username': 'str' },
1628  'returns': 'GuestAuthorizedKeys'
1629}
1630
1631##
1632# @guest-ssh-add-authorized-keys:
1633#
1634# Append public keys to user .ssh/authorized_keys on Unix systems (not
1635# implemented for other systems).
1636#
1637# @username: the user account to add the authorized keys
1638#
1639# @keys: the public keys to add (in OpenSSH/sshd(8) authorized_keys
1640#     format)
1641#
1642# @reset: ignore the existing content, set it with the given keys only
1643#
1644# Since: 5.2
1645##
1646{ 'command': 'guest-ssh-add-authorized-keys',
1647  'data': { 'username': 'str', 'keys': ['str'], '*reset': 'bool' }
1648}
1649
1650##
1651# @guest-ssh-remove-authorized-keys:
1652#
1653# Remove public keys from the user .ssh/authorized_keys on Unix
1654# systems (not implemented for other systems). It's not an error if
1655# the key is already missing.
1656#
1657# @username: the user account to remove the authorized keys
1658#
1659# @keys: the public keys to remove (in OpenSSH/sshd(8) authorized_keys
1660#     format)
1661#
1662# Since: 5.2
1663##
1664{ 'command': 'guest-ssh-remove-authorized-keys',
1665  'data': { 'username': 'str', 'keys': ['str'] }
1666}
1667
1668##
1669# @GuestDiskStats:
1670#
1671# @read-sectors: sectors read
1672#
1673# @read-ios: reads completed successfully
1674#
1675# @read-merges: read requests merged
1676#
1677# @write-sectors: sectors written
1678#
1679# @write-ios: writes completed
1680#
1681# @write-merges: write requests merged
1682#
1683# @discard-sectors: sectors discarded
1684#
1685# @discard-ios: discards completed successfully
1686#
1687# @discard-merges: discard requests merged
1688#
1689# @flush-ios: flush requests completed successfully
1690#
1691# @read-ticks: time spent reading(ms)
1692#
1693# @write-ticks: time spent writing(ms)
1694#
1695# @discard-ticks: time spent discarding(ms)
1696#
1697# @flush-ticks: time spent flushing(ms)
1698#
1699# @ios-pgr: number of I/Os currently in flight
1700#
1701# @total-ticks: time spent doing I/Os (ms)
1702#
1703# @weight-ticks: weighted time spent doing I/Os since the last update
1704#     of this field(ms)
1705#
1706# Since: 7.1
1707##
1708{ 'struct': 'GuestDiskStats',
1709  'data': {'*read-sectors': 'uint64',
1710           '*read-ios': 'uint64',
1711           '*read-merges': 'uint64',
1712           '*write-sectors': 'uint64',
1713           '*write-ios': 'uint64',
1714           '*write-merges': 'uint64',
1715           '*discard-sectors': 'uint64',
1716           '*discard-ios': 'uint64',
1717           '*discard-merges': 'uint64',
1718           '*flush-ios': 'uint64',
1719           '*read-ticks': 'uint64',
1720           '*write-ticks': 'uint64',
1721           '*discard-ticks': 'uint64',
1722           '*flush-ticks': 'uint64',
1723           '*ios-pgr': 'uint64',
1724           '*total-ticks': 'uint64',
1725           '*weight-ticks': 'uint64'
1726           },
1727  'if': 'CONFIG_LINUX' }
1728
1729##
1730# @GuestDiskStatsInfo:
1731#
1732# @name: disk name
1733#
1734# @major: major device number of disk
1735#
1736# @minor: minor device number of disk
1737#
1738# @stats: I/O statistics
1739##
1740{ 'struct': 'GuestDiskStatsInfo',
1741  'data': {'name': 'str',
1742           'major': 'uint64',
1743           'minor': 'uint64',
1744           'stats': 'GuestDiskStats' },
1745  'if': 'CONFIG_LINUX' }
1746
1747##
1748# @guest-get-diskstats:
1749#
1750# Retrieve information about disk stats.
1751#
1752# Returns: List of disk stats of guest.
1753#
1754# Since: 7.1
1755##
1756{ 'command': 'guest-get-diskstats',
1757  'returns': ['GuestDiskStatsInfo'],
1758  'if': 'CONFIG_LINUX'
1759}
1760
1761##
1762# @GuestCpuStatsType:
1763#
1764# Guest operating systems supporting CPU statistics
1765#
1766# @linux: Linux
1767#
1768# Since: 7.1
1769##
1770{ 'enum': 'GuestCpuStatsType',
1771  'data': [ 'linux' ],
1772  'if': 'CONFIG_LINUX' }
1773
1774
1775##
1776# @GuestLinuxCpuStats:
1777#
1778# CPU statistics of Linux
1779#
1780# @cpu: CPU index in guest OS
1781#
1782# @user: Time spent in user mode
1783#
1784# @nice: Time spent in user mode with low priority (nice)
1785#
1786# @system: Time spent in system mode
1787#
1788# @idle: Time spent in the idle task
1789#
1790# @iowait: Time waiting for I/O to complete (since Linux 2.5.41)
1791#
1792# @irq: Time servicing interrupts (since Linux 2.6.0-test4)
1793#
1794# @softirq: Time servicing softirqs (since Linux 2.6.0-test4)
1795#
1796# @steal: Stolen time by host (since Linux 2.6.11)
1797#
1798# @guest: ime spent running a virtual CPU for guest operating systems
1799#     under the  control of the Linux kernel (since Linux 2.6.24)
1800#
1801# @guestnice: Time spent running a niced guest (since Linux 2.6.33)
1802#
1803# Since: 7.1
1804##
1805{ 'struct': 'GuestLinuxCpuStats',
1806  'data': {'cpu': 'int',
1807           'user': 'uint64',
1808           'nice': 'uint64',
1809           'system': 'uint64',
1810           'idle': 'uint64',
1811           '*iowait': 'uint64',
1812           '*irq': 'uint64',
1813           '*softirq': 'uint64',
1814           '*steal': 'uint64',
1815           '*guest': 'uint64',
1816           '*guestnice': 'uint64'
1817           },
1818  'if': 'CONFIG_LINUX' }
1819
1820##
1821# @GuestCpuStats:
1822#
1823# Get statistics of each CPU in millisecond.
1824#
1825# @type: guest operating system
1826#
1827# Since: 7.1
1828##
1829{ 'union': 'GuestCpuStats',
1830  'base': { 'type': 'GuestCpuStatsType' },
1831  'discriminator': 'type',
1832  'data': { 'linux': 'GuestLinuxCpuStats' },
1833  'if': 'CONFIG_LINUX' }
1834
1835##
1836# @guest-get-cpustats:
1837#
1838# Retrieve information about CPU stats.
1839#
1840# Returns: List of CPU stats of guest.
1841#
1842# Since: 7.1
1843##
1844{ 'command': 'guest-get-cpustats',
1845  'returns': ['GuestCpuStats'],
1846  'if': 'CONFIG_LINUX'
1847}
1848
1849
1850##
1851# @GuestLoadAverage:
1852#
1853# Statistics about process load information
1854#
1855# @load1m: 1-minute load avage
1856#
1857# @load5m: 5-minute load avage
1858#
1859# @load15m: 15-minute load avage
1860#
1861# Since: 10.0
1862##
1863{ 'struct': 'GuestLoadAverage',
1864  'data': {
1865      'load1m': 'number',
1866      'load5m': 'number',
1867      'load15m': 'number'
1868  },
1869  'if': 'CONFIG_GETLOADAVG'
1870}
1871
1872##
1873# @guest-get-load:
1874#
1875# Retrieve CPU process load information
1876#
1877# Returns: load information
1878#
1879# Since: 10.0
1880##
1881{ 'command': 'guest-get-load',
1882  'returns': 'GuestLoadAverage',
1883  'if': 'CONFIG_GETLOADAVG'
1884}
1885
1886##
1887# @GuestNetworkRoute:
1888#
1889# Route information, currently, only linux supported.
1890#
1891# @iface: The destination network or host's egress network interface in the routing table
1892#
1893# @destination: The IP address of the target network or host, The final destination of the packet
1894#
1895# @metric: Route metric
1896#
1897# @gateway: The IP address of the next hop router
1898#
1899# @mask: Subnet Mask (IPv4 only)
1900#
1901# @irtt: Initial round-trip delay (not for windows, IPv4 only)
1902#
1903# @flags: Route flags (not for windows)
1904#
1905# @refcnt: The route's reference count (not for windows)
1906#
1907# @use: Route usage count (not for windows)
1908#
1909# @window: TCP window size, used for flow control (not for windows, IPv4 only)
1910#
1911# @mtu: Data link layer maximum packet size (not for windows)
1912#
1913# @desprefixlen: Destination prefix length (for IPv6)
1914#
1915# @source: Source IP address (for IPv6)
1916#
1917# @srcprefixlen: Source prefix length (for IPv6)
1918#
1919# @nexthop: Next hop IP address (for IPv6)
1920#
1921# @version: IP version (4 or 6)
1922#
1923# Since: 9.1
1924
1925##
1926{ 'struct': 'GuestNetworkRoute',
1927  'data': {'iface': 'str',
1928           'destination': 'str',
1929           'metric': 'int',
1930           '*gateway': 'str',
1931           '*mask': 'str',
1932           '*irtt': 'int',
1933           '*flags': 'uint64',
1934           '*refcnt': 'int',
1935           '*use': 'int',
1936           '*window': 'int',
1937           '*mtu': 'int',
1938           '*desprefixlen': 'str',
1939           '*source': 'str',
1940           '*srcprefixlen': 'str',
1941           '*nexthop': 'str',
1942           'version': 'int'
1943           },
1944  'if': 'CONFIG_LINUX' }
1945
1946##
1947# @guest-network-get-route:
1948#
1949# Retrieve information about route of network.
1950# Returns: List of route info of guest.
1951#
1952# Since: 9.1
1953##
1954{ 'command': 'guest-network-get-route',
1955  'returns': ['GuestNetworkRoute'],
1956  'if': 'CONFIG_LINUX'
1957}
1958