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