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