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