xref: /qemu/qga/qapi-schema.json (revision 7a4e543d)
1# *-*- Mode: Python -*-*
2
3##
4#
5# General note concerning the use of guest agent interfaces:
6#
7# "unsupported" is a higher-level error than the errors that individual
8# commands might document. The caller should always be prepared to receive
9# QERR_UNSUPPORTED, even if the given command doesn't specify it, or doesn't
10# document any failure mode at all.
11#
12##
13
14##
15# @guest-sync-delimited:
16#
17# Echo back a unique integer value, and prepend to response a
18# leading sentinel byte (0xFF) the client can check scan for.
19#
20# This is used by clients talking to the guest agent over the
21# wire to ensure the stream is in sync and doesn't contain stale
22# data from previous client. It must be issued upon initial
23# connection, and after any client-side timeouts (including
24# timeouts on receiving a response to this command).
25#
26# After issuing this request, all guest agent responses should be
27# ignored until the response containing the unique integer value
28# the client passed in is returned. Receival of the 0xFF sentinel
29# byte must be handled as an indication that the client's
30# lexer/tokenizer/parser state should be flushed/reset in
31# preparation for reliably receiving the subsequent response. As
32# an optimization, clients may opt to ignore all data until a
33# sentinel value is receiving to avoid unnecessary processing of
34# stale data.
35#
36# Similarly, clients should also precede this *request*
37# with a 0xFF byte to make sure the guest agent flushes any
38# partially read JSON data from a previous client connection.
39#
40# @id: randomly generated 64-bit integer
41#
42# Returns: The unique integer id passed in by the client
43#
44# Since: 1.1
45##
46{ 'command': 'guest-sync-delimited',
47  'data':    { 'id': 'int' },
48  'returns': 'int' }
49
50##
51# @guest-sync:
52#
53# Echo back a unique integer value
54#
55# This is used by clients talking to the guest agent over the
56# wire to ensure the stream is in sync and doesn't contain stale
57# data from previous client. All guest agent responses should be
58# ignored until the provided unique integer value is returned,
59# and it is up to the client to handle stale whole or
60# partially-delivered JSON text in such a way that this response
61# can be obtained.
62#
63# In cases where a partial stale response was previously
64# received by the client, this cannot always be done reliably.
65# One particular scenario being if qemu-ga responses are fed
66# character-by-character into a JSON parser. In these situations,
67# using guest-sync-delimited may be optimal.
68#
69# For clients that fetch responses line by line and convert them
70# to JSON objects, guest-sync should be sufficient, but note that
71# in cases where the channel is dirty some attempts at parsing the
72# response may result in a parser error.
73#
74# Such clients should also precede this command
75# with a 0xFF byte to make sure the guest agent flushes any
76# partially read JSON data from a previous session.
77#
78# @id: randomly generated 64-bit integer
79#
80# Returns: The unique integer id passed in by the client
81#
82# Since: 0.15.0
83##
84{ 'command': 'guest-sync',
85  'data':    { 'id': 'int' },
86  'returns': 'int' }
87
88##
89# @guest-ping:
90#
91# Ping the guest agent, a non-error return implies success
92#
93# Since: 0.15.0
94##
95{ 'command': 'guest-ping' }
96
97##
98# @guest-get-time:
99#
100# Get the information about guest's System Time relative to
101# the Epoch of 1970-01-01 in UTC.
102#
103# Returns: Time in nanoseconds.
104#
105# Since 1.5
106##
107{ 'command': 'guest-get-time',
108  'returns': 'int' }
109
110##
111# @guest-set-time:
112#
113# Set guest time.
114#
115# When a guest is paused or migrated to a file then loaded
116# from that file, the guest OS has no idea that there
117# was a big gap in the time. Depending on how long the
118# gap was, NTP might not be able to resynchronize the
119# guest.
120#
121# This command tries to set guest's System Time to the
122# given value, then sets the Hardware Clock (RTC) to the
123# current System Time. This will make it easier for a guest
124# to resynchronize without waiting for NTP. If no @time is
125# specified, then the time to set is read from RTC. However,
126# this may not be supported on all platforms (i.e. Windows).
127# If that's the case users are advised to always pass a
128# value.
129#
130# @time: #optional time of nanoseconds, relative to the Epoch
131#        of 1970-01-01 in UTC.
132#
133# Returns: Nothing on success.
134#
135# Since: 1.5
136##
137{ 'command': 'guest-set-time',
138  'data': { '*time': 'int' } }
139
140##
141# @GuestAgentCommandInfo:
142#
143# Information about guest agent commands.
144#
145# @name: name of the command
146#
147# @enabled: whether command is currently enabled by guest admin
148#
149# @success-response: whether command returns a response on success
150#                    (since 1.7)
151#
152# Since 1.1.0
153##
154{ 'struct': 'GuestAgentCommandInfo',
155  'data': { 'name': 'str', 'enabled': 'bool', 'success-response': 'bool' } }
156
157##
158# @GuestAgentInfo
159#
160# Information about guest agent.
161#
162# @version: guest agent version
163#
164# @supported_commands: Information about guest agent commands
165#
166# Since 0.15.0
167##
168{ 'struct': 'GuestAgentInfo',
169  'data': { 'version': 'str',
170            'supported_commands': ['GuestAgentCommandInfo'] } }
171##
172# @guest-info:
173#
174# Get some information about the guest agent.
175#
176# Returns: @GuestAgentInfo
177#
178# Since: 0.15.0
179##
180{ 'command': 'guest-info',
181  'returns': 'GuestAgentInfo' }
182
183##
184# @guest-shutdown:
185#
186# Initiate guest-activated shutdown. Note: this is an asynchronous
187# shutdown request, with no guarantee of successful shutdown.
188#
189# @mode: #optional "halt", "powerdown" (default), or "reboot"
190#
191# This command does NOT return a response on success. Success condition
192# is indicated by the VM exiting with a zero exit status or, when
193# running with --no-shutdown, by issuing the query-status QMP command
194# to confirm the VM status is "shutdown".
195#
196# Since: 0.15.0
197##
198{ 'command': 'guest-shutdown', 'data': { '*mode': 'str' },
199  'success-response': false }
200
201##
202# @guest-file-open:
203#
204# Open a file in the guest and retrieve a file handle for it
205#
206# @filepath: Full path to the file in the guest to open.
207#
208# @mode: #optional open mode, as per fopen(), "r" is the default.
209#
210# Returns: Guest file handle on success.
211#
212# Since: 0.15.0
213##
214{ 'command': 'guest-file-open',
215  'data':    { 'path': 'str', '*mode': 'str' },
216  'returns': 'int' }
217
218##
219# @guest-file-close:
220#
221# Close an open file in the guest
222#
223# @handle: filehandle returned by guest-file-open
224#
225# Returns: Nothing on success.
226#
227# Since: 0.15.0
228##
229{ 'command': 'guest-file-close',
230  'data': { 'handle': 'int' } }
231
232##
233# @GuestFileRead
234#
235# Result of guest agent file-read operation
236#
237# @count: number of bytes read (note: count is *before*
238#         base64-encoding is applied)
239#
240# @buf-b64: base64-encoded bytes read
241#
242# @eof: whether EOF was encountered during read operation.
243#
244# Since: 0.15.0
245##
246{ 'struct': 'GuestFileRead',
247  'data': { 'count': 'int', 'buf-b64': 'str', 'eof': 'bool' } }
248
249##
250# @guest-file-read:
251#
252# Read from an open file in the guest. Data will be base64-encoded
253#
254# @handle: filehandle returned by guest-file-open
255#
256# @count: #optional maximum number of bytes to read (default is 4KB)
257#
258# Returns: @GuestFileRead on success.
259#
260# Since: 0.15.0
261##
262{ 'command': 'guest-file-read',
263  'data':    { 'handle': 'int', '*count': 'int' },
264  'returns': 'GuestFileRead' }
265
266##
267# @GuestFileWrite
268#
269# Result of guest agent file-write operation
270#
271# @count: number of bytes written (note: count is actual bytes
272#         written, after base64-decoding of provided buffer)
273#
274# @eof: whether EOF was encountered during write operation.
275#
276# Since: 0.15.0
277##
278{ 'struct': 'GuestFileWrite',
279  'data': { 'count': 'int', 'eof': 'bool' } }
280
281##
282# @guest-file-write:
283#
284# Write to an open file in the guest.
285#
286# @handle: filehandle returned by guest-file-open
287#
288# @buf-b64: base64-encoded string representing data to be written
289#
290# @count: #optional bytes to write (actual bytes, after base64-decode),
291#         default is all content in buf-b64 buffer after base64 decoding
292#
293# Returns: @GuestFileWrite on success.
294#
295# Since: 0.15.0
296##
297{ 'command': 'guest-file-write',
298  'data':    { 'handle': 'int', 'buf-b64': 'str', '*count': 'int' },
299  'returns': 'GuestFileWrite' }
300
301
302##
303# @GuestFileSeek
304#
305# Result of guest agent file-seek operation
306#
307# @position: current file position
308#
309# @eof: whether EOF was encountered during file seek
310#
311# Since: 0.15.0
312##
313{ 'struct': 'GuestFileSeek',
314  'data': { 'position': 'int', 'eof': 'bool' } }
315
316##
317# @guest-file-seek:
318#
319# Seek to a position in the file, as with fseek(), and return the
320# current file position afterward. Also encapsulates ftell()'s
321# functionality, with offset=0 and whence=1.
322#
323# @handle: filehandle returned by guest-file-open
324#
325# @offset: bytes to skip over in the file stream
326#
327# @whence: 0 for SEEK_SET, 1 for SEEK_CUR, or 2 for SEEK_END
328#
329# Returns: @GuestFileSeek on success.
330#
331# Since: 0.15.0
332##
333{ 'command': 'guest-file-seek',
334  'data':    { 'handle': 'int', 'offset': 'int', 'whence': 'int' },
335  'returns': 'GuestFileSeek' }
336
337##
338# @guest-file-flush:
339#
340# Write file changes bufferred in userspace to disk/kernel buffers
341#
342# @handle: filehandle returned by guest-file-open
343#
344# Returns: Nothing on success.
345#
346# Since: 0.15.0
347##
348{ 'command': 'guest-file-flush',
349  'data': { 'handle': 'int' } }
350
351##
352# @GuestFsFreezeStatus
353#
354# An enumeration of filesystem freeze states
355#
356# @thawed: filesystems thawed/unfrozen
357#
358# @frozen: all non-network guest filesystems frozen
359#
360# Since: 0.15.0
361##
362{ 'enum': 'GuestFsfreezeStatus',
363  'data': [ 'thawed', 'frozen' ] }
364
365##
366# @guest-fsfreeze-status:
367#
368# Get guest fsfreeze state. error state indicates
369#
370# Returns: GuestFsfreezeStatus ("thawed", "frozen", etc., as defined below)
371#
372# Note: This may fail to properly report the current state as a result of
373# some other guest processes having issued an fs freeze/thaw.
374#
375# Since: 0.15.0
376##
377{ 'command': 'guest-fsfreeze-status',
378  'returns': 'GuestFsfreezeStatus' }
379
380##
381# @guest-fsfreeze-freeze:
382#
383# Sync and freeze all freezable, local guest filesystems
384#
385# Returns: Number of file systems currently frozen. On error, all filesystems
386# will be thawed.
387#
388# Since: 0.15.0
389##
390{ 'command': 'guest-fsfreeze-freeze',
391  'returns': 'int' }
392
393##
394# @guest-fsfreeze-freeze-list:
395#
396# Sync and freeze specified guest filesystems
397#
398# @mountpoints: #optional an array of mountpoints of filesystems to be frozen.
399#               If omitted, every mounted filesystem is frozen.
400#
401# Returns: Number of file systems currently frozen. On error, all filesystems
402# will be thawed.
403#
404# Since: 2.2
405##
406{ 'command': 'guest-fsfreeze-freeze-list',
407  'data':    { '*mountpoints': ['str'] },
408  'returns': 'int' }
409
410##
411# @guest-fsfreeze-thaw:
412#
413# Unfreeze all frozen guest filesystems
414#
415# Returns: Number of file systems thawed by this call
416#
417# Note: if return value does not match the previous call to
418#       guest-fsfreeze-freeze, this likely means some freezable
419#       filesystems were unfrozen before this call, and that the
420#       filesystem state may have changed before issuing this
421#       command.
422#
423# Since: 0.15.0
424##
425{ 'command': 'guest-fsfreeze-thaw',
426  'returns': 'int' }
427
428##
429# @GuestFilesystemTrimResult
430#
431# @path: path that was trimmed
432# @error: an error message when trim failed
433# @trimmed: bytes trimmed for this path
434# @minimum: reported effective minimum for this path
435#
436# Since: 2.4
437##
438{ 'struct': 'GuestFilesystemTrimResult',
439  'data': {'path': 'str',
440           '*trimmed': 'int', '*minimum': 'int', '*error': 'str'} }
441
442##
443# @GuestFilesystemTrimResponse
444#
445# @paths: list of @GuestFilesystemTrimResult per path that was trimmed
446#
447# Since: 2.4
448##
449{ 'struct': 'GuestFilesystemTrimResponse',
450  'data': {'paths': ['GuestFilesystemTrimResult']} }
451
452##
453# @guest-fstrim:
454#
455# Discard (or "trim") blocks which are not in use by the filesystem.
456#
457# @minimum:
458#       Minimum contiguous free range to discard, in bytes. Free ranges
459#       smaller than this may be ignored (this is a hint and the guest
460#       may not respect it).  By increasing this value, the fstrim
461#       operation will complete more quickly for filesystems with badly
462#       fragmented free space, although not all blocks will be discarded.
463#       The default value is zero, meaning "discard every free block".
464#
465# Returns: A @GuestFilesystemTrimResponse which contains the
466#          status of all trimmed paths. (since 2.4)
467#
468# Since: 1.2
469##
470{ 'command': 'guest-fstrim',
471  'data': { '*minimum': 'int' },
472  'returns': 'GuestFilesystemTrimResponse' }
473
474##
475# @guest-suspend-disk
476#
477# Suspend guest to disk.
478#
479# This command tries to execute the scripts provided by the pm-utils package.
480# If it's not available, the suspend operation will be performed by manually
481# writing to a sysfs file.
482#
483# For the best results it's strongly recommended to have the pm-utils
484# package installed in the guest.
485#
486# This command does NOT return a response on success. There is a high chance
487# the command succeeded if the VM exits with a zero exit status or, when
488# running with --no-shutdown, by issuing the query-status QMP command to
489# to confirm the VM status is "shutdown". However, the VM could also exit
490# (or set its status to "shutdown") due to other reasons.
491#
492# The following errors may be returned:
493#          If suspend to disk is not supported, Unsupported
494#
495# Notes: It's strongly recommended to issue the guest-sync command before
496#        sending commands when the guest resumes
497#
498# Since: 1.1
499##
500{ 'command': 'guest-suspend-disk', 'success-response': false }
501
502##
503# @guest-suspend-ram
504#
505# Suspend guest to ram.
506#
507# This command tries to execute the scripts provided by the pm-utils package.
508# If it's not available, the suspend operation will be performed by manually
509# writing to a sysfs file.
510#
511# For the best results it's strongly recommended to have the pm-utils
512# package installed in the guest.
513#
514# IMPORTANT: guest-suspend-ram requires QEMU to support the 'system_wakeup'
515# command.  Thus, it's *required* to query QEMU for the presence of the
516# 'system_wakeup' command before issuing guest-suspend-ram.
517#
518# This command does NOT return a response on success. There are two options
519# to check for success:
520#   1. Wait for the SUSPEND QMP event from QEMU
521#   2. Issue the query-status QMP command to confirm the VM status is
522#      "suspended"
523#
524# The following errors may be returned:
525#          If suspend to ram is not supported, Unsupported
526#
527# Notes: It's strongly recommended to issue the guest-sync command before
528#        sending commands when the guest resumes
529#
530# Since: 1.1
531##
532{ 'command': 'guest-suspend-ram', 'success-response': false }
533
534##
535# @guest-suspend-hybrid
536#
537# Save guest state to disk and suspend to ram.
538#
539# This command requires the pm-utils package to be installed in the guest.
540#
541# IMPORTANT: guest-suspend-hybrid requires QEMU to support the 'system_wakeup'
542# command.  Thus, it's *required* to query QEMU for the presence of the
543# 'system_wakeup' command before issuing guest-suspend-hybrid.
544#
545# This command does NOT return a response on success. There are two options
546# to check for success:
547#   1. Wait for the SUSPEND QMP event from QEMU
548#   2. Issue the query-status QMP command to confirm the VM status is
549#      "suspended"
550#
551# The following errors may be returned:
552#          If hybrid suspend is not supported, Unsupported
553#
554# Notes: It's strongly recommended to issue the guest-sync command before
555#        sending commands when the guest resumes
556#
557# Since: 1.1
558##
559{ 'command': 'guest-suspend-hybrid', 'success-response': false }
560
561##
562# @GuestIpAddressType:
563#
564# An enumeration of supported IP address types
565#
566# @ipv4: IP version 4
567#
568# @ipv6: IP version 6
569#
570# Since: 1.1
571##
572{ 'enum': 'GuestIpAddressType',
573  'data': [ 'ipv4', 'ipv6' ] }
574
575##
576# @GuestIpAddress:
577#
578# @ip-address: IP address
579#
580# @ip-address-type: Type of @ip-address (e.g. ipv4, ipv6)
581#
582# @prefix: Network prefix length of @ip-address
583#
584# Since: 1.1
585##
586{ 'struct': 'GuestIpAddress',
587  'data': {'ip-address': 'str',
588           'ip-address-type': 'GuestIpAddressType',
589           'prefix': 'int'} }
590
591##
592# @GuestNetworkInterface:
593#
594# @name: The name of interface for which info are being delivered
595#
596# @hardware-address: Hardware address of @name
597#
598# @ip-addresses: List of addresses assigned to @name
599#
600# Since: 1.1
601##
602{ 'struct': 'GuestNetworkInterface',
603  'data': {'name': 'str',
604           '*hardware-address': 'str',
605           '*ip-addresses': ['GuestIpAddress'] } }
606
607##
608# @guest-network-get-interfaces:
609#
610# Get list of guest IP addresses, MAC addresses
611# and netmasks.
612#
613# Returns: List of GuestNetworkInfo on success.
614#
615# Since: 1.1
616##
617{ 'command': 'guest-network-get-interfaces',
618  'returns': ['GuestNetworkInterface'] }
619
620##
621# @GuestLogicalProcessor:
622#
623# @logical-id: Arbitrary guest-specific unique identifier of the VCPU.
624#
625# @online: Whether the VCPU is enabled.
626#
627# @can-offline: #optional Whether offlining the VCPU is possible. This member
628#               is always filled in by the guest agent when the structure is
629#               returned, and always ignored on input (hence it can be omitted
630#               then).
631#
632# Since: 1.5
633##
634{ 'struct': 'GuestLogicalProcessor',
635  'data': {'logical-id': 'int',
636           'online': 'bool',
637           '*can-offline': 'bool'} }
638
639##
640# @guest-get-vcpus:
641#
642# Retrieve the list of the guest's logical processors.
643#
644# This is a read-only operation.
645#
646# Returns: The list of all VCPUs the guest knows about. Each VCPU is put on the
647# list exactly once, but their order is unspecified.
648#
649# Since: 1.5
650##
651{ 'command': 'guest-get-vcpus',
652  'returns': ['GuestLogicalProcessor'] }
653
654##
655# @guest-set-vcpus:
656#
657# Attempt to reconfigure (currently: enable/disable) logical processors inside
658# the guest.
659#
660# The input list is processed node by node in order. In each node @logical-id
661# is used to look up the guest VCPU, for which @online specifies the requested
662# state. The set of distinct @logical-id's is only required to be a subset of
663# the guest-supported identifiers. There's no restriction on list length or on
664# repeating the same @logical-id (with possibly different @online field).
665# Preferably the input list should describe a modified subset of
666# @guest-get-vcpus' return value.
667#
668# Returns: The length of the initial sublist that has been successfully
669#          processed. The guest agent maximizes this value. Possible cases:
670#
671#          0:                if the @vcpus list was empty on input. Guest state
672#                            has not been changed. Otherwise,
673#
674#          Error:            processing the first node of @vcpus failed for the
675#                            reason returned. Guest state has not been changed.
676#                            Otherwise,
677#
678#          < length(@vcpus): more than zero initial nodes have been processed,
679#                            but not the entire @vcpus list. Guest state has
680#                            changed accordingly. To retrieve the error
681#                            (assuming it persists), repeat the call with the
682#                            successfully processed initial sublist removed.
683#                            Otherwise,
684#
685#          length(@vcpus):   call successful.
686#
687# Since: 1.5
688##
689{ 'command': 'guest-set-vcpus',
690  'data':    {'vcpus': ['GuestLogicalProcessor'] },
691  'returns': 'int' }
692
693##
694# @GuestDiskBusType
695#
696# An enumeration of bus type of disks
697#
698# @ide: IDE disks
699# @fdc: floppy disks
700# @scsi: SCSI disks
701# @virtio: virtio disks
702# @xen: Xen disks
703# @usb: USB disks
704# @uml: UML disks
705# @sata: SATA disks
706# @sd: SD cards
707# @unknown: Unknown bus type
708# @ieee1394: Win IEEE 1394 bus type
709# @ssa: Win SSA bus type
710# @fibre: Win fiber channel bus type
711# @raid: Win RAID bus type
712# @iscsi: Win iScsi bus type
713# @sas: Win serial-attaches SCSI bus type
714# @mmc: Win multimedia card (MMC) bus type
715# @virtual: Win virtual bus type
716# @file-backed virtual: Win file-backed bus type
717#
718# Since: 2.2; 'Unknown' and all entries below since 2.4
719##
720{ 'enum': 'GuestDiskBusType',
721  'data': [ 'ide', 'fdc', 'scsi', 'virtio', 'xen', 'usb', 'uml', 'sata',
722            'sd', 'unknown', 'ieee1394', 'ssa', 'fibre', 'raid', 'iscsi',
723            'sas', 'mmc', 'virtual', 'file-backed-virtual' ] }
724
725
726##
727# @GuestPCIAddress:
728#
729# @domain: domain id
730# @bus: bus id
731# @slot: slot id
732# @function: function id
733#
734# Since: 2.2
735##
736{ 'struct': 'GuestPCIAddress',
737  'data': {'domain': 'int', 'bus': 'int',
738           'slot': 'int', 'function': 'int'} }
739
740##
741# @GuestDiskAddress:
742#
743# @pci-controller: controller's PCI address
744# @type: bus type
745# @bus: bus id
746# @target: target id
747# @unit: unit id
748#
749# Since: 2.2
750##
751{ 'struct': 'GuestDiskAddress',
752  'data': {'pci-controller': 'GuestPCIAddress',
753           'bus-type': 'GuestDiskBusType',
754           'bus': 'int', 'target': 'int', 'unit': 'int'} }
755
756##
757# @GuestFilesystemInfo
758#
759# @name: disk name
760# @mountpoint: mount point path
761# @type: file system type string
762# @disk: an array of disk hardware information that the volume lies on,
763#        which may be empty if the disk type is not supported
764#
765# Since: 2.2
766##
767{ 'struct': 'GuestFilesystemInfo',
768  'data': {'name': 'str', 'mountpoint': 'str', 'type': 'str',
769           'disk': ['GuestDiskAddress']} }
770
771##
772# @guest-get-fsinfo:
773#
774# Returns: The list of filesystems information mounted in the guest.
775#          The returned mountpoints may be specified to
776#          @guest-fsfreeze-freeze-list.
777#          Network filesystems (such as CIFS and NFS) are not listed.
778#
779# Since: 2.2
780##
781{ 'command': 'guest-get-fsinfo',
782  'returns': ['GuestFilesystemInfo'] }
783
784##
785# @guest-set-user-password
786#
787# @username: the user account whose password to change
788# @password: the new password entry string, base64 encoded
789# @crypted: true if password is already crypt()d, false if raw
790#
791# If the @crypted flag is true, it is the caller's responsibility
792# to ensure the correct crypt() encryption scheme is used. This
793# command does not attempt to interpret or report on the encryption
794# scheme. Refer to the documentation of the guest operating system
795# in question to determine what is supported.
796#
797# Not all guest operating systems will support use of the
798# @crypted flag, as they may require the clear-text password
799#
800# The @password parameter must always be base64 encoded before
801# transmission, even if already crypt()d, to ensure it is 8-bit
802# safe when passed as JSON.
803#
804# Returns: Nothing on success.
805#
806# Since 2.3
807##
808{ 'command': 'guest-set-user-password',
809  'data': { 'username': 'str', 'password': 'str', 'crypted': 'bool' } }
810
811# @GuestMemoryBlock:
812#
813# @phys-index: Arbitrary guest-specific unique identifier of the MEMORY BLOCK.
814#
815# @online: Whether the MEMORY BLOCK is enabled in guest.
816#
817# @can-offline: #optional Whether offlining the MEMORY BLOCK is possible.
818#               This member is always filled in by the guest agent when the
819#               structure is returned, and always ignored on input (hence it
820#               can be omitted then).
821#
822# Since: 2.3
823##
824{ 'struct': 'GuestMemoryBlock',
825  'data': {'phys-index': 'uint64',
826           'online': 'bool',
827           '*can-offline': 'bool'} }
828
829##
830# @guest-get-memory-blocks:
831#
832# Retrieve the list of the guest's memory blocks.
833#
834# This is a read-only operation.
835#
836# Returns: The list of all memory blocks the guest knows about.
837# Each memory block is put on the list exactly once, but their order
838# is unspecified.
839#
840# Since: 2.3
841##
842{ 'command': 'guest-get-memory-blocks',
843  'returns': ['GuestMemoryBlock'] }
844
845##
846# @GuestMemoryBlockResponseType
847#
848# An enumeration of memory block operation result.
849#
850# @success: the operation of online/offline memory block is successful.
851# @not-found: can't find the corresponding memoryXXX directory in sysfs.
852# @operation-not-supported: for some old kernels, it does not support
853#                           online or offline memory block.
854# @operation-failed: the operation of online/offline memory block fails,
855#                    because of some errors happen.
856#
857# Since: 2.3
858##
859{ 'enum': 'GuestMemoryBlockResponseType',
860  'data': ['success', 'not-found', 'operation-not-supported',
861           'operation-failed'] }
862
863##
864# @GuestMemoryBlockResponse:
865#
866# @phys-index: same with the 'phys-index' member of @GuestMemoryBlock.
867#
868# @response: the result of memory block operation.
869#
870# @error-code: #optional the error number.
871#               When memory block operation fails, we assign the value of
872#               'errno' to this member, it indicates what goes wrong.
873#               When the operation succeeds, it will be omitted.
874#
875# Since: 2.3
876##
877{ 'struct': 'GuestMemoryBlockResponse',
878  'data': { 'phys-index': 'uint64',
879            'response': 'GuestMemoryBlockResponseType',
880            '*error-code': 'int' }}
881
882##
883# @guest-set-memory-blocks:
884#
885# Attempt to reconfigure (currently: enable/disable) state of memory blocks
886# inside the guest.
887#
888# The input list is processed node by node in order. In each node @phys-index
889# is used to look up the guest MEMORY BLOCK, for which @online specifies the
890# requested state. The set of distinct @phys-index's is only required to be a
891# subset of the guest-supported identifiers. There's no restriction on list
892# length or on repeating the same @phys-index (with possibly different @online
893# field).
894# Preferably the input list should describe a modified subset of
895# @guest-get-memory-blocks' return value.
896#
897# Returns: The operation results, it is a list of @GuestMemoryBlockResponse,
898#          which is corresponding to the input list.
899#
900#          Note: it will return NULL if the @mem-blks list was empty on input,
901#          or there is an error, and in this case, guest state will not be
902#          changed.
903#
904# Since: 2.3
905##
906{ 'command': 'guest-set-memory-blocks',
907  'data':    {'mem-blks': ['GuestMemoryBlock'] },
908  'returns': ['GuestMemoryBlockResponse'] }
909
910# @GuestMemoryBlockInfo:
911#
912# @size: the size (in bytes) of the guest memory blocks,
913#        which are the minimal units of memory block online/offline
914#        operations (also called Logical Memory Hotplug).
915#
916# Since: 2.3
917##
918{ 'struct': 'GuestMemoryBlockInfo',
919  'data': {'size': 'uint64'} }
920
921##
922# @guest-get-memory-block-info:
923#
924# Get information relating to guest memory blocks.
925#
926# Returns: memory block size in bytes.
927# Returns: @GuestMemoryBlockInfo
928#
929# Since 2.3
930##
931{ 'command': 'guest-get-memory-block-info',
932  'returns': 'GuestMemoryBlockInfo' }
933
934# @GuestExecStatus:
935#
936# @exited: true if process has already terminated.
937# @exitcode: #optional process exit code if it was normally terminated.
938# @signal: #optional signal number (linux) or unhandled exception code
939#       (windows) if the process was abnormally terminated.
940# @out-data: #optional base64-encoded stdout of the process
941# @err-data: #optional base64-encoded stderr of the process
942#       Note: @out-data and @err-data are present only
943#       if 'capture-output' was specified for 'guest-exec'
944# @out-truncated: #optional true if stdout was not fully captured
945#       due to size limitation.
946# @err-truncated: #optional true if stderr was not fully captured
947#       due to size limitation.
948#
949# Since: 2.5
950##
951{ 'struct': 'GuestExecStatus',
952  'data': { 'exited': 'bool', '*exitcode': 'int', '*signal': 'int',
953            '*out-data': 'str', '*err-data': 'str',
954            '*out-truncated': 'bool', '*err-truncated': 'bool' }}
955##
956# @guest-exec-status
957#
958# Check status of process associated with PID retrieved via guest-exec.
959# Reap the process and associated metadata if it has exited.
960#
961# @pid: pid returned from guest-exec
962#
963# Returns: GuestExecStatus on success.
964#
965# Since 2.5
966##
967{ 'command': 'guest-exec-status',
968  'data':    { 'pid': 'int' },
969  'returns': 'GuestExecStatus' }
970
971##
972# @GuestExec:
973# @pid: pid of child process in guest OS
974#
975#Since: 2.5
976##
977{ 'struct': 'GuestExec',
978  'data': { 'pid': 'int'} }
979
980##
981# @guest-exec:
982#
983# Execute a command in the guest
984#
985# @path: path or executable name to execute
986# @arg: #optional argument list to pass to executable
987# @env: #optional environment variables to pass to executable
988# @input-data: #optional data to be passed to process stdin (base64 encoded)
989# @capture-output: #optional bool flag to enable capture of
990#                  stdout/stderr of running process. defaults to false.
991#
992# Returns: PID on success.
993#
994# Since: 2.5
995##
996{ 'command': 'guest-exec',
997  'data':    { 'path': 'str', '*arg': ['str'], '*env': ['str'],
998               '*input-data': 'str', '*capture-output': 'bool' },
999  'returns': 'GuestExec' }
1000