xref: /openbmc/qemu/qapi/block-core.json (revision 63785678)
1# -*- Mode: Python -*-
2#
3# QAPI block core definitions (vm unrelated)
4
5# QAPI common definitions
6{ 'include': 'common.json' }
7
8##
9# @SnapshotInfo
10#
11# @id: unique snapshot id
12#
13# @name: user chosen name
14#
15# @vm-state-size: size of the VM state
16#
17# @date-sec: UTC date of the snapshot in seconds
18#
19# @date-nsec: fractional part in nano seconds to be used with date-sec
20#
21# @vm-clock-sec: VM clock relative to boot in seconds
22#
23# @vm-clock-nsec: fractional part in nano seconds to be used with vm-clock-sec
24#
25# Since: 1.3
26#
27##
28
29{ 'struct': 'SnapshotInfo',
30  'data': { 'id': 'str', 'name': 'str', 'vm-state-size': 'int',
31            'date-sec': 'int', 'date-nsec': 'int',
32            'vm-clock-sec': 'int', 'vm-clock-nsec': 'int' } }
33
34##
35# @ImageInfoSpecificQCow2:
36#
37# @compat: compatibility level
38#
39# @lazy-refcounts: #optional on or off; only valid for compat >= 1.1
40#
41# @corrupt: #optional true if the image has been marked corrupt; only valid for
42#           compat >= 1.1 (since 2.2)
43#
44# @refcount-bits: width of a refcount entry in bits (since 2.3)
45#
46# Since: 1.7
47##
48{ 'struct': 'ImageInfoSpecificQCow2',
49  'data': {
50      'compat': 'str',
51      '*lazy-refcounts': 'bool',
52      '*corrupt': 'bool',
53      'refcount-bits': 'int'
54  } }
55
56##
57# @ImageInfoSpecificVmdk:
58#
59# @create-type: The create type of VMDK image
60#
61# @cid: Content id of image
62#
63# @parent-cid: Parent VMDK image's cid
64#
65# @extents: List of extent files
66#
67# Since: 1.7
68##
69{ 'struct': 'ImageInfoSpecificVmdk',
70  'data': {
71      'create-type': 'str',
72      'cid': 'int',
73      'parent-cid': 'int',
74      'extents': ['ImageInfo']
75  } }
76
77##
78# @ImageInfoSpecific:
79#
80# A discriminated record of image format specific information structures.
81#
82# Since: 1.7
83##
84
85{ 'union': 'ImageInfoSpecific',
86  'data': {
87      'qcow2': 'ImageInfoSpecificQCow2',
88      'vmdk': 'ImageInfoSpecificVmdk'
89  } }
90
91##
92# @ImageInfo:
93#
94# Information about a QEMU image file
95#
96# @filename: name of the image file
97#
98# @format: format of the image file
99#
100# @virtual-size: maximum capacity in bytes of the image
101#
102# @actual-size: #optional actual size on disk in bytes of the image
103#
104# @dirty-flag: #optional true if image is not cleanly closed
105#
106# @cluster-size: #optional size of a cluster in bytes
107#
108# @encrypted: #optional true if the image is encrypted
109#
110# @compressed: #optional true if the image is compressed (Since 1.7)
111#
112# @backing-filename: #optional name of the backing file
113#
114# @full-backing-filename: #optional full path of the backing file
115#
116# @backing-filename-format: #optional the format of the backing file
117#
118# @snapshots: #optional list of VM snapshots
119#
120# @backing-image: #optional info of the backing image (since 1.6)
121#
122# @format-specific: #optional structure supplying additional format-specific
123# information (since 1.7)
124#
125# Since: 1.3
126#
127##
128
129{ 'struct': 'ImageInfo',
130  'data': {'filename': 'str', 'format': 'str', '*dirty-flag': 'bool',
131           '*actual-size': 'int', 'virtual-size': 'int',
132           '*cluster-size': 'int', '*encrypted': 'bool', '*compressed': 'bool',
133           '*backing-filename': 'str', '*full-backing-filename': 'str',
134           '*backing-filename-format': 'str', '*snapshots': ['SnapshotInfo'],
135           '*backing-image': 'ImageInfo',
136           '*format-specific': 'ImageInfoSpecific' } }
137
138##
139# @ImageCheck:
140#
141# Information about a QEMU image file check
142#
143# @filename: name of the image file checked
144#
145# @format: format of the image file checked
146#
147# @check-errors: number of unexpected errors occurred during check
148#
149# @image-end-offset: #optional offset (in bytes) where the image ends, this
150#                    field is present if the driver for the image format
151#                    supports it
152#
153# @corruptions: #optional number of corruptions found during the check if any
154#
155# @leaks: #optional number of leaks found during the check if any
156#
157# @corruptions-fixed: #optional number of corruptions fixed during the check
158#                     if any
159#
160# @leaks-fixed: #optional number of leaks fixed during the check if any
161#
162# @total-clusters: #optional total number of clusters, this field is present
163#                  if the driver for the image format supports it
164#
165# @allocated-clusters: #optional total number of allocated clusters, this
166#                      field is present if the driver for the image format
167#                      supports it
168#
169# @fragmented-clusters: #optional total number of fragmented clusters, this
170#                       field is present if the driver for the image format
171#                       supports it
172#
173# @compressed-clusters: #optional total number of compressed clusters, this
174#                       field is present if the driver for the image format
175#                       supports it
176#
177# Since: 1.4
178#
179##
180
181{ 'struct': 'ImageCheck',
182  'data': {'filename': 'str', 'format': 'str', 'check-errors': 'int',
183           '*image-end-offset': 'int', '*corruptions': 'int', '*leaks': 'int',
184           '*corruptions-fixed': 'int', '*leaks-fixed': 'int',
185           '*total-clusters': 'int', '*allocated-clusters': 'int',
186           '*fragmented-clusters': 'int', '*compressed-clusters': 'int' } }
187
188##
189# @MapEntry:
190#
191# Mapping information from a virtual block range to a host file range
192#
193# @start: the start byte of the mapped virtual range
194#
195# @length: the number of bytes of the mapped virtual range
196#
197# @data: whether the mapped range has data
198#
199# @zero: whether the virtual blocks are zeroed
200#
201# @depth: the depth of the mapping
202#
203# @offset: #optional the offset in file that the virtual sectors are mapped to
204#
205# @filename: #optional filename that is referred to by @offset
206#
207# Since: 2.6
208#
209##
210{ 'struct': 'MapEntry',
211  'data': {'start': 'int', 'length': 'int', 'data': 'bool',
212           'zero': 'bool', 'depth': 'int', '*offset': 'int',
213           '*filename': 'str' } }
214
215##
216# @BlockdevCacheInfo
217#
218# Cache mode information for a block device
219#
220# @writeback:   true if writeback mode is enabled
221# @direct:      true if the host page cache is bypassed (O_DIRECT)
222# @no-flush:    true if flush requests are ignored for the device
223#
224# Since: 2.3
225##
226{ 'struct': 'BlockdevCacheInfo',
227  'data': { 'writeback': 'bool',
228            'direct': 'bool',
229            'no-flush': 'bool' } }
230
231##
232# @BlockDeviceInfo:
233#
234# Information about the backing device for a block device.
235#
236# @file: the filename of the backing device
237#
238# @node-name: #optional the name of the block driver node (Since 2.0)
239#
240# @ro: true if the backing device was open read-only
241#
242# @drv: the name of the block format used to open the backing device. As of
243#       0.14.0 this can be: 'blkdebug', 'bochs', 'cloop', 'cow', 'dmg',
244#       'file', 'file', 'ftp', 'ftps', 'host_cdrom', 'host_device',
245#       'http', 'https', 'luks', 'nbd', 'parallels', 'qcow',
246#       'qcow2', 'raw', 'tftp', 'vdi', 'vmdk', 'vpc', 'vvfat'
247#       2.2: 'archipelago' added, 'cow' dropped
248#       2.3: 'host_floppy' deprecated
249#       2.5: 'host_floppy' dropped
250#       2.6: 'luks' added
251#
252# @backing_file: #optional the name of the backing file (for copy-on-write)
253#
254# @backing_file_depth: number of files in the backing file chain (since: 1.2)
255#
256# @encrypted: true if the backing device is encrypted
257#
258# @encryption_key_missing: true if the backing device is encrypted but an
259#                          valid encryption key is missing
260#
261# @detect_zeroes: detect and optimize zero writes (Since 2.1)
262#
263# @bps: total throughput limit in bytes per second is specified
264#
265# @bps_rd: read throughput limit in bytes per second is specified
266#
267# @bps_wr: write throughput limit in bytes per second is specified
268#
269# @iops: total I/O operations per second is specified
270#
271# @iops_rd: read I/O operations per second is specified
272#
273# @iops_wr: write I/O operations per second is specified
274#
275# @image: the info of image used (since: 1.6)
276#
277# @bps_max: #optional total throughput limit during bursts,
278#                     in bytes (Since 1.7)
279#
280# @bps_rd_max: #optional read throughput limit during bursts,
281#                        in bytes (Since 1.7)
282#
283# @bps_wr_max: #optional write throughput limit during bursts,
284#                        in bytes (Since 1.7)
285#
286# @iops_max: #optional total I/O operations per second during bursts,
287#                      in bytes (Since 1.7)
288#
289# @iops_rd_max: #optional read I/O operations per second during bursts,
290#                         in bytes (Since 1.7)
291#
292# @iops_wr_max: #optional write I/O operations per second during bursts,
293#                         in bytes (Since 1.7)
294#
295# @bps_max_length: #optional maximum length of the @bps_max burst
296#                            period, in seconds. (Since 2.6)
297#
298# @bps_rd_max_length: #optional maximum length of the @bps_rd_max
299#                               burst period, in seconds. (Since 2.6)
300#
301# @bps_wr_max_length: #optional maximum length of the @bps_wr_max
302#                               burst period, in seconds. (Since 2.6)
303#
304# @iops_max_length: #optional maximum length of the @iops burst
305#                             period, in seconds. (Since 2.6)
306#
307# @iops_rd_max_length: #optional maximum length of the @iops_rd_max
308#                                burst period, in seconds. (Since 2.6)
309#
310# @iops_wr_max_length: #optional maximum length of the @iops_wr_max
311#                                burst period, in seconds. (Since 2.6)
312#
313# @iops_size: #optional an I/O size in bytes (Since 1.7)
314#
315# @group: #optional throttle group name (Since 2.4)
316#
317# @cache: the cache mode used for the block device (since: 2.3)
318#
319# @write_threshold: configured write threshold for the device.
320#                   0 if disabled. (Since 2.3)
321#
322# Since: 0.14.0
323#
324##
325{ 'struct': 'BlockDeviceInfo',
326  'data': { 'file': 'str', '*node-name': 'str', 'ro': 'bool', 'drv': 'str',
327            '*backing_file': 'str', 'backing_file_depth': 'int',
328            'encrypted': 'bool', 'encryption_key_missing': 'bool',
329            'detect_zeroes': 'BlockdevDetectZeroesOptions',
330            'bps': 'int', 'bps_rd': 'int', 'bps_wr': 'int',
331            'iops': 'int', 'iops_rd': 'int', 'iops_wr': 'int',
332            'image': 'ImageInfo',
333            '*bps_max': 'int', '*bps_rd_max': 'int',
334            '*bps_wr_max': 'int', '*iops_max': 'int',
335            '*iops_rd_max': 'int', '*iops_wr_max': 'int',
336            '*bps_max_length': 'int', '*bps_rd_max_length': 'int',
337            '*bps_wr_max_length': 'int', '*iops_max_length': 'int',
338            '*iops_rd_max_length': 'int', '*iops_wr_max_length': 'int',
339            '*iops_size': 'int', '*group': 'str', 'cache': 'BlockdevCacheInfo',
340            'write_threshold': 'int' } }
341
342##
343# @BlockDeviceIoStatus:
344#
345# An enumeration of block device I/O status.
346#
347# @ok: The last I/O operation has succeeded
348#
349# @failed: The last I/O operation has failed
350#
351# @nospace: The last I/O operation has failed due to a no-space condition
352#
353# Since: 1.0
354##
355{ 'enum': 'BlockDeviceIoStatus', 'data': [ 'ok', 'failed', 'nospace' ] }
356
357##
358# @BlockDeviceMapEntry:
359#
360# Entry in the metadata map of the device (returned by "qemu-img map")
361#
362# @start: Offset in the image of the first byte described by this entry
363#         (in bytes)
364#
365# @length: Length of the range described by this entry (in bytes)
366#
367# @depth: Number of layers (0 = top image, 1 = top image's backing file, etc.)
368#         before reaching one for which the range is allocated.  The value is
369#         in the range 0 to the depth of the image chain - 1.
370#
371# @zero: the sectors in this range read as zeros
372#
373# @data: reading the image will actually read data from a file (in particular,
374#        if @offset is present this means that the sectors are not simply
375#        preallocated, but contain actual data in raw format)
376#
377# @offset: if present, the image file stores the data for this range in
378#          raw format at the given offset.
379#
380# Since 1.7
381##
382{ 'struct': 'BlockDeviceMapEntry',
383  'data': { 'start': 'int', 'length': 'int', 'depth': 'int', 'zero': 'bool',
384            'data': 'bool', '*offset': 'int' } }
385
386##
387# @DirtyBitmapStatus:
388#
389# An enumeration of possible states that a dirty bitmap can report to the user.
390#
391# @frozen: The bitmap is currently in-use by a backup operation or block job,
392#          and is immutable.
393#
394# @disabled: The bitmap is currently in-use by an internal operation and is
395#            read-only. It can still be deleted.
396#
397# @active: The bitmap is actively monitoring for new writes, and can be cleared,
398#          deleted, or used for backup operations.
399#
400# Since: 2.4
401##
402{ 'enum': 'DirtyBitmapStatus',
403  'data': ['active', 'disabled', 'frozen'] }
404
405##
406# @BlockDirtyInfo:
407#
408# Block dirty bitmap information.
409#
410# @name: #optional the name of the dirty bitmap (Since 2.4)
411#
412# @count: number of dirty bytes according to the dirty bitmap
413#
414# @granularity: granularity of the dirty bitmap in bytes (since 1.4)
415#
416# @status: current status of the dirty bitmap (since 2.4)
417#
418# Since: 1.3
419##
420{ 'struct': 'BlockDirtyInfo',
421  'data': {'*name': 'str', 'count': 'int', 'granularity': 'uint32',
422           'status': 'DirtyBitmapStatus'} }
423
424##
425# @BlockInfo:
426#
427# Block device information.  This structure describes a virtual device and
428# the backing device associated with it.
429#
430# @device: The device name associated with the virtual device.
431#
432# @type: This field is returned only for compatibility reasons, it should
433#        not be used (always returns 'unknown')
434#
435# @removable: True if the device supports removable media.
436#
437# @locked: True if the guest has locked this device from having its media
438#          removed
439#
440# @tray_open: #optional True if the device's tray is open
441#             (only present if it has a tray)
442#
443# @dirty-bitmaps: #optional dirty bitmaps information (only present if the
444#                 driver has one or more dirty bitmaps) (Since 2.0)
445#
446# @io-status: #optional @BlockDeviceIoStatus. Only present if the device
447#             supports it and the VM is configured to stop on errors
448#             (supported device models: virtio-blk, ide, scsi-disk)
449#
450# @inserted: #optional @BlockDeviceInfo describing the device if media is
451#            present
452#
453# Since:  0.14.0
454##
455{ 'struct': 'BlockInfo',
456  'data': {'device': 'str', 'type': 'str', 'removable': 'bool',
457           'locked': 'bool', '*inserted': 'BlockDeviceInfo',
458           '*tray_open': 'bool', '*io-status': 'BlockDeviceIoStatus',
459           '*dirty-bitmaps': ['BlockDirtyInfo'] } }
460
461##
462# @query-block:
463#
464# Get a list of BlockInfo for all virtual block devices.
465#
466# Returns: a list of @BlockInfo describing each virtual block device
467#
468# Since: 0.14.0
469##
470{ 'command': 'query-block', 'returns': ['BlockInfo'] }
471
472
473##
474# @BlockDeviceTimedStats:
475#
476# Statistics of a block device during a given interval of time.
477#
478# @interval_length: Interval used for calculating the statistics,
479#                   in seconds.
480#
481# @min_rd_latency_ns: Minimum latency of read operations in the
482#                     defined interval, in nanoseconds.
483#
484# @min_wr_latency_ns: Minimum latency of write operations in the
485#                     defined interval, in nanoseconds.
486#
487# @min_flush_latency_ns: Minimum latency of flush operations in the
488#                        defined interval, in nanoseconds.
489#
490# @max_rd_latency_ns: Maximum latency of read operations in the
491#                     defined interval, in nanoseconds.
492#
493# @max_wr_latency_ns: Maximum latency of write operations in the
494#                     defined interval, in nanoseconds.
495#
496# @max_flush_latency_ns: Maximum latency of flush operations in the
497#                        defined interval, in nanoseconds.
498#
499# @avg_rd_latency_ns: Average latency of read operations in the
500#                     defined interval, in nanoseconds.
501#
502# @avg_wr_latency_ns: Average latency of write operations in the
503#                     defined interval, in nanoseconds.
504#
505# @avg_flush_latency_ns: Average latency of flush operations in the
506#                        defined interval, in nanoseconds.
507#
508# @avg_rd_queue_depth: Average number of pending read operations
509#                      in the defined interval.
510#
511# @avg_wr_queue_depth: Average number of pending write operations
512#                      in the defined interval.
513#
514# Since: 2.5
515##
516
517{ 'struct': 'BlockDeviceTimedStats',
518  'data': { 'interval_length': 'int', 'min_rd_latency_ns': 'int',
519            'max_rd_latency_ns': 'int', 'avg_rd_latency_ns': 'int',
520            'min_wr_latency_ns': 'int', 'max_wr_latency_ns': 'int',
521            'avg_wr_latency_ns': 'int', 'min_flush_latency_ns': 'int',
522            'max_flush_latency_ns': 'int', 'avg_flush_latency_ns': 'int',
523            'avg_rd_queue_depth': 'number', 'avg_wr_queue_depth': 'number' } }
524
525##
526# @BlockDeviceStats:
527#
528# Statistics of a virtual block device or a block backing device.
529#
530# @rd_bytes:      The number of bytes read by the device.
531#
532# @wr_bytes:      The number of bytes written by the device.
533#
534# @rd_operations: The number of read operations performed by the device.
535#
536# @wr_operations: The number of write operations performed by the device.
537#
538# @flush_operations: The number of cache flush operations performed by the
539#                    device (since 0.15.0)
540#
541# @flush_total_time_ns: Total time spend on cache flushes in nano-seconds
542#                       (since 0.15.0).
543#
544# @wr_total_time_ns: Total time spend on writes in nano-seconds (since 0.15.0).
545#
546# @rd_total_time_ns: Total_time_spend on reads in nano-seconds (since 0.15.0).
547#
548# @wr_highest_offset: The offset after the greatest byte written to the
549#                     device.  The intended use of this information is for
550#                     growable sparse files (like qcow2) that are used on top
551#                     of a physical device.
552#
553# @rd_merged: Number of read requests that have been merged into another
554#             request (Since 2.3).
555#
556# @wr_merged: Number of write requests that have been merged into another
557#             request (Since 2.3).
558#
559# @idle_time_ns: #optional Time since the last I/O operation, in
560#                nanoseconds. If the field is absent it means that
561#                there haven't been any operations yet (Since 2.5).
562#
563# @failed_rd_operations: The number of failed read operations
564#                        performed by the device (Since 2.5)
565#
566# @failed_wr_operations: The number of failed write operations
567#                        performed by the device (Since 2.5)
568#
569# @failed_flush_operations: The number of failed flush operations
570#                           performed by the device (Since 2.5)
571#
572# @invalid_rd_operations: The number of invalid read operations
573#                          performed by the device (Since 2.5)
574#
575# @invalid_wr_operations: The number of invalid write operations
576#                         performed by the device (Since 2.5)
577#
578# @invalid_flush_operations: The number of invalid flush operations
579#                            performed by the device (Since 2.5)
580#
581# @account_invalid: Whether invalid operations are included in the
582#                   last access statistics (Since 2.5)
583#
584# @account_failed: Whether failed operations are included in the
585#                  latency and last access statistics (Since 2.5)
586#
587# @timed_stats: Statistics specific to the set of previously defined
588#               intervals of time (Since 2.5)
589#
590# Since: 0.14.0
591##
592{ 'struct': 'BlockDeviceStats',
593  'data': {'rd_bytes': 'int', 'wr_bytes': 'int', 'rd_operations': 'int',
594           'wr_operations': 'int', 'flush_operations': 'int',
595           'flush_total_time_ns': 'int', 'wr_total_time_ns': 'int',
596           'rd_total_time_ns': 'int', 'wr_highest_offset': 'int',
597           'rd_merged': 'int', 'wr_merged': 'int', '*idle_time_ns': 'int',
598           'failed_rd_operations': 'int', 'failed_wr_operations': 'int',
599           'failed_flush_operations': 'int', 'invalid_rd_operations': 'int',
600           'invalid_wr_operations': 'int', 'invalid_flush_operations': 'int',
601           'account_invalid': 'bool', 'account_failed': 'bool',
602           'timed_stats': ['BlockDeviceTimedStats'] } }
603
604##
605# @BlockStats:
606#
607# Statistics of a virtual block device or a block backing device.
608#
609# @device: #optional If the stats are for a virtual block device, the name
610#          corresponding to the virtual block device.
611#
612# @node-name: #optional The node name of the device. (Since 2.3)
613#
614# @stats:  A @BlockDeviceStats for the device.
615#
616# @parent: #optional This describes the file block device if it has one.
617#
618# @backing: #optional This describes the backing block device if it has one.
619#           (Since 2.0)
620#
621# Since: 0.14.0
622##
623{ 'struct': 'BlockStats',
624  'data': {'*device': 'str', '*node-name': 'str',
625           'stats': 'BlockDeviceStats',
626           '*parent': 'BlockStats',
627           '*backing': 'BlockStats'} }
628
629##
630# @query-blockstats:
631#
632# Query the @BlockStats for all virtual block devices.
633#
634# @query-nodes: #optional If true, the command will query all the block nodes
635#               that have a node name, in a list which will include "parent"
636#               information, but not "backing".
637#               If false or omitted, the behavior is as before - query all the
638#               device backends, recursively including their "parent" and
639#               "backing". (Since 2.3)
640#
641# Returns: A list of @BlockStats for each virtual block devices.
642#
643# Since: 0.14.0
644##
645{ 'command': 'query-blockstats',
646  'data': { '*query-nodes': 'bool' },
647  'returns': ['BlockStats'] }
648
649##
650# @BlockdevOnError:
651#
652# An enumeration of possible behaviors for errors on I/O operations.
653# The exact meaning depends on whether the I/O was initiated by a guest
654# or by a block job
655#
656# @report: for guest operations, report the error to the guest;
657#          for jobs, cancel the job
658#
659# @ignore: ignore the error, only report a QMP event (BLOCK_IO_ERROR
660#          or BLOCK_JOB_ERROR)
661#
662# @enospc: same as @stop on ENOSPC, same as @report otherwise.
663#
664# @stop: for guest operations, stop the virtual machine;
665#        for jobs, pause the job
666#
667# Since: 1.3
668##
669{ 'enum': 'BlockdevOnError',
670  'data': ['report', 'ignore', 'enospc', 'stop'] }
671
672##
673# @MirrorSyncMode:
674#
675# An enumeration of possible behaviors for the initial synchronization
676# phase of storage mirroring.
677#
678# @top: copies data in the topmost image to the destination
679#
680# @full: copies data from all images to the destination
681#
682# @none: only copy data written from now on
683#
684# @incremental: only copy data described by the dirty bitmap. Since: 2.4
685#
686# Since: 1.3
687##
688{ 'enum': 'MirrorSyncMode',
689  'data': ['top', 'full', 'none', 'incremental'] }
690
691##
692# @BlockJobType:
693#
694# Type of a block job.
695#
696# @commit: block commit job type, see "block-commit"
697#
698# @stream: block stream job type, see "block-stream"
699#
700# @mirror: drive mirror job type, see "drive-mirror"
701#
702# @backup: drive backup job type, see "drive-backup"
703#
704# Since: 1.7
705##
706{ 'enum': 'BlockJobType',
707  'data': ['commit', 'stream', 'mirror', 'backup'] }
708
709##
710# @BlockJobInfo:
711#
712# Information about a long-running block device operation.
713#
714# @type: the job type ('stream' for image streaming)
715#
716# @device: the block device name
717#
718# @len: the maximum progress value
719#
720# @busy: false if the job is known to be in a quiescent state, with
721#        no pending I/O.  Since 1.3.
722#
723# @paused: whether the job is paused or, if @busy is true, will
724#          pause itself as soon as possible.  Since 1.3.
725#
726# @offset: the current progress value
727#
728# @speed: the rate limit, bytes per second
729#
730# @io-status: the status of the job (since 1.3)
731#
732# @ready: true if the job may be completed (since 2.2)
733#
734# Since: 1.1
735##
736{ 'struct': 'BlockJobInfo',
737  'data': {'type': 'str', 'device': 'str', 'len': 'int',
738           'offset': 'int', 'busy': 'bool', 'paused': 'bool', 'speed': 'int',
739           'io-status': 'BlockDeviceIoStatus', 'ready': 'bool'} }
740
741##
742# @query-block-jobs:
743#
744# Return information about long-running block device operations.
745#
746# Returns: a list of @BlockJobInfo for each active block job
747#
748# Since: 1.1
749##
750{ 'command': 'query-block-jobs', 'returns': ['BlockJobInfo'] }
751
752##
753# @block_passwd:
754#
755# This command sets the password of a block device that has not been open
756# with a password and requires one.
757#
758# The two cases where this can happen are a block device is created through
759# QEMU's initial command line or a block device is changed through the legacy
760# @change interface.
761#
762# In the event that the block device is created through the initial command
763# line, the VM will start in the stopped state regardless of whether '-S' is
764# used.  The intention is for a management tool to query the block devices to
765# determine which ones are encrypted, set the passwords with this command, and
766# then start the guest with the @cont command.
767#
768# Either @device or @node-name must be set but not both.
769#
770# @device: #optional the name of the block backend device to set the password on
771#
772# @node-name: #optional graph node name to set the password on (Since 2.0)
773#
774# @password: the password to use for the device
775#
776# Returns: nothing on success
777#          If @device is not a valid block device, DeviceNotFound
778#          If @device is not encrypted, DeviceNotEncrypted
779#
780# Notes:  Not all block formats support encryption and some that do are not
781#         able to validate that a password is correct.  Disk corruption may
782#         occur if an invalid password is specified.
783#
784# Since: 0.14.0
785##
786{ 'command': 'block_passwd', 'data': {'*device': 'str',
787                                      '*node-name': 'str', 'password': 'str'} }
788
789##
790# @block_resize
791#
792# Resize a block image while a guest is running.
793#
794# Either @device or @node-name must be set but not both.
795#
796# @device: #optional the name of the device to get the image resized
797#
798# @node-name: #optional graph node name to get the image resized (Since 2.0)
799#
800# @size:  new image size in bytes
801#
802# Returns: nothing on success
803#          If @device is not a valid block device, DeviceNotFound
804#
805# Since: 0.14.0
806##
807{ 'command': 'block_resize', 'data': { '*device': 'str',
808                                       '*node-name': 'str',
809                                       'size': 'int' }}
810
811##
812# @NewImageMode
813#
814# An enumeration that tells QEMU how to set the backing file path in
815# a new image file.
816#
817# @existing: QEMU should look for an existing image file.
818#
819# @absolute-paths: QEMU should create a new image with absolute paths
820# for the backing file. If there is no backing file available, the new
821# image will not be backed either.
822#
823# Since: 1.1
824##
825{ 'enum': 'NewImageMode',
826  'data': [ 'existing', 'absolute-paths' ] }
827
828##
829# @BlockdevSnapshotSync
830#
831# Either @device or @node-name must be set but not both.
832#
833# @device: #optional the name of the device to generate the snapshot from.
834#
835# @node-name: #optional graph node name to generate the snapshot from (Since 2.0)
836#
837# @snapshot-file: the target of the new image. A new file will be created.
838#
839# @snapshot-node-name: #optional the graph node name of the new image (Since 2.0)
840#
841# @format: #optional the format of the snapshot image, default is 'qcow2'.
842#
843# @mode: #optional whether and how QEMU should create a new image, default is
844#        'absolute-paths'.
845##
846{ 'struct': 'BlockdevSnapshotSync',
847  'data': { '*device': 'str', '*node-name': 'str',
848            'snapshot-file': 'str', '*snapshot-node-name': 'str',
849            '*format': 'str', '*mode': 'NewImageMode' } }
850
851##
852# @BlockdevSnapshot
853#
854# @node: device or node name that will have a snapshot created.
855#
856# @overlay: reference to the existing block device that will become
857#           the overlay of @node, as part of creating the snapshot.
858#           It must not have a current backing file (this can be
859#           achieved by passing "backing": "" to blockdev-add).
860#
861# Since 2.5
862##
863{ 'struct': 'BlockdevSnapshot',
864  'data': { 'node': 'str', 'overlay': 'str' } }
865
866##
867# @DriveBackup
868#
869# @device: the name of the device which should be copied.
870#
871# @target: the target of the new image. If the file exists, or if it
872#          is a device, the existing file/device will be used as the new
873#          destination.  If it does not exist, a new file will be created.
874#
875# @format: #optional the format of the new destination, default is to
876#          probe if @mode is 'existing', else the format of the source
877#
878# @sync: what parts of the disk image should be copied to the destination
879#        (all the disk, only the sectors allocated in the topmost image, from a
880#        dirty bitmap, or only new I/O).
881#
882# @mode: #optional whether and how QEMU should create a new image, default is
883#        'absolute-paths'.
884#
885# @speed: #optional the maximum speed, in bytes per second
886#
887# @bitmap: #optional the name of dirty bitmap if sync is "incremental".
888#          Must be present if sync is "incremental", must NOT be present
889#          otherwise. (Since 2.4)
890#
891# @on-source-error: #optional the action to take on an error on the source,
892#                   default 'report'.  'stop' and 'enospc' can only be used
893#                   if the block device supports io-status (see BlockInfo).
894#
895# @on-target-error: #optional the action to take on an error on the target,
896#                   default 'report' (no limitations, since this applies to
897#                   a different block device than @device).
898#
899# Note that @on-source-error and @on-target-error only affect background I/O.
900# If an error occurs during a guest write request, the device's rerror/werror
901# actions will be used.
902#
903# Since: 1.6
904##
905{ 'struct': 'DriveBackup',
906  'data': { 'device': 'str', 'target': 'str', '*format': 'str',
907            'sync': 'MirrorSyncMode', '*mode': 'NewImageMode',
908            '*speed': 'int', '*bitmap': 'str',
909            '*on-source-error': 'BlockdevOnError',
910            '*on-target-error': 'BlockdevOnError' } }
911
912##
913# @BlockdevBackup
914#
915# @device: the name of the device which should be copied.
916#
917# @target: the name of the backup target device.
918#
919# @sync: what parts of the disk image should be copied to the destination
920#        (all the disk, only the sectors allocated in the topmost image, or
921#        only new I/O).
922#
923# @speed: #optional the maximum speed, in bytes per second. The default is 0,
924#         for unlimited.
925#
926# @on-source-error: #optional the action to take on an error on the source,
927#                   default 'report'.  'stop' and 'enospc' can only be used
928#                   if the block device supports io-status (see BlockInfo).
929#
930# @on-target-error: #optional the action to take on an error on the target,
931#                   default 'report' (no limitations, since this applies to
932#                   a different block device than @device).
933#
934# Note that @on-source-error and @on-target-error only affect background I/O.
935# If an error occurs during a guest write request, the device's rerror/werror
936# actions will be used.
937#
938# Since: 2.3
939##
940{ 'struct': 'BlockdevBackup',
941  'data': { 'device': 'str', 'target': 'str',
942            'sync': 'MirrorSyncMode',
943            '*speed': 'int',
944            '*on-source-error': 'BlockdevOnError',
945            '*on-target-error': 'BlockdevOnError' } }
946
947##
948# @blockdev-snapshot-sync
949#
950# Generates a synchronous snapshot of a block device.
951#
952# For the arguments, see the documentation of BlockdevSnapshotSync.
953#
954# Returns: nothing on success
955#          If @device is not a valid block device, DeviceNotFound
956#
957# Since 0.14.0
958##
959{ 'command': 'blockdev-snapshot-sync',
960  'data': 'BlockdevSnapshotSync' }
961
962
963##
964# @blockdev-snapshot
965#
966# Generates a snapshot of a block device.
967#
968# For the arguments, see the documentation of BlockdevSnapshot.
969#
970# Since 2.5
971##
972{ 'command': 'blockdev-snapshot',
973  'data': 'BlockdevSnapshot' }
974
975##
976# @change-backing-file
977#
978# Change the backing file in the image file metadata.  This does not
979# cause QEMU to reopen the image file to reparse the backing filename
980# (it may, however, perform a reopen to change permissions from
981# r/o -> r/w -> r/o, if needed). The new backing file string is written
982# into the image file metadata, and the QEMU internal strings are
983# updated.
984#
985# @image-node-name: The name of the block driver state node of the
986#                   image to modify.
987#
988# @device:          The name of the device that owns image-node-name.
989#
990# @backing-file:    The string to write as the backing file.  This
991#                   string is not validated, so care should be taken
992#                   when specifying the string or the image chain may
993#                   not be able to be reopened again.
994#
995# Since: 2.1
996##
997{ 'command': 'change-backing-file',
998  'data': { 'device': 'str', 'image-node-name': 'str',
999            'backing-file': 'str' } }
1000
1001##
1002# @block-commit
1003#
1004# Live commit of data from overlay image nodes into backing nodes - i.e.,
1005# writes data between 'top' and 'base' into 'base'.
1006#
1007# @device:  the name of the device
1008#
1009# @base:   #optional The file name of the backing image to write data into.
1010#                    If not specified, this is the deepest backing image
1011#
1012# @top:    #optional The file name of the backing image within the image chain,
1013#                    which contains the topmost data to be committed down. If
1014#                    not specified, this is the active layer.
1015#
1016# @backing-file:  #optional The backing file string to write into the overlay
1017#                           image of 'top'.  If 'top' is the active layer,
1018#                           specifying a backing file string is an error. This
1019#                           filename is not validated.
1020#
1021#                           If a pathname string is such that it cannot be
1022#                           resolved by QEMU, that means that subsequent QMP or
1023#                           HMP commands must use node-names for the image in
1024#                           question, as filename lookup methods will fail.
1025#
1026#                           If not specified, QEMU will automatically determine
1027#                           the backing file string to use, or error out if
1028#                           there is no obvious choice. Care should be taken
1029#                           when specifying the string, to specify a valid
1030#                           filename or protocol.
1031#                           (Since 2.1)
1032#
1033#                    If top == base, that is an error.
1034#                    If top == active, the job will not be completed by itself,
1035#                    user needs to complete the job with the block-job-complete
1036#                    command after getting the ready event. (Since 2.0)
1037#
1038#                    If the base image is smaller than top, then the base image
1039#                    will be resized to be the same size as top.  If top is
1040#                    smaller than the base image, the base will not be
1041#                    truncated.  If you want the base image size to match the
1042#                    size of the smaller top, you can safely truncate it
1043#                    yourself once the commit operation successfully completes.
1044#
1045# @speed:  #optional the maximum speed, in bytes per second
1046#
1047# Returns: Nothing on success
1048#          If commit or stream is already active on this device, DeviceInUse
1049#          If @device does not exist, DeviceNotFound
1050#          If image commit is not supported by this device, NotSupported
1051#          If @base or @top is invalid, a generic error is returned
1052#          If @speed is invalid, InvalidParameter
1053#
1054# Since: 1.3
1055#
1056##
1057{ 'command': 'block-commit',
1058  'data': { 'device': 'str', '*base': 'str', '*top': 'str',
1059            '*backing-file': 'str', '*speed': 'int' } }
1060
1061##
1062# @drive-backup
1063#
1064# Start a point-in-time copy of a block device to a new destination.  The
1065# status of ongoing drive-backup operations can be checked with
1066# query-block-jobs where the BlockJobInfo.type field has the value 'backup'.
1067# The operation can be stopped before it has completed using the
1068# block-job-cancel command.
1069#
1070# For the arguments, see the documentation of DriveBackup.
1071#
1072# Returns: nothing on success
1073#          If @device is not a valid block device, DeviceNotFound
1074#
1075# Since 1.6
1076##
1077{ 'command': 'drive-backup', 'data': 'DriveBackup' }
1078
1079##
1080# @blockdev-backup
1081#
1082# Start a point-in-time copy of a block device to a new destination.  The
1083# status of ongoing blockdev-backup operations can be checked with
1084# query-block-jobs where the BlockJobInfo.type field has the value 'backup'.
1085# The operation can be stopped before it has completed using the
1086# block-job-cancel command.
1087#
1088# For the arguments, see the documentation of BlockdevBackup.
1089#
1090# Since 2.3
1091##
1092{ 'command': 'blockdev-backup', 'data': 'BlockdevBackup' }
1093
1094
1095##
1096# @query-named-block-nodes
1097#
1098# Get the named block driver list
1099#
1100# Returns: the list of BlockDeviceInfo
1101#
1102# Since 2.0
1103##
1104{ 'command': 'query-named-block-nodes', 'returns': [ 'BlockDeviceInfo' ] }
1105
1106##
1107# @drive-mirror
1108#
1109# Start mirroring a block device's writes to a new destination.
1110#
1111# @device:  the name of the device whose writes should be mirrored.
1112#
1113# @target: the target of the new image. If the file exists, or if it
1114#          is a device, the existing file/device will be used as the new
1115#          destination.  If it does not exist, a new file will be created.
1116#
1117# @format: #optional the format of the new destination, default is to
1118#          probe if @mode is 'existing', else the format of the source
1119#
1120# @node-name: #optional the new block driver state node name in the graph
1121#             (Since 2.1)
1122#
1123# @replaces: #optional with sync=full graph node name to be replaced by the new
1124#            image when a whole image copy is done. This can be used to repair
1125#            broken Quorum files. (Since 2.1)
1126#
1127# @mode: #optional whether and how QEMU should create a new image, default is
1128#        'absolute-paths'.
1129#
1130# @speed:  #optional the maximum speed, in bytes per second
1131#
1132# @sync: what parts of the disk image should be copied to the destination
1133#        (all the disk, only the sectors allocated in the topmost image, or
1134#        only new I/O).
1135#
1136# @granularity: #optional granularity of the dirty bitmap, default is 64K
1137#               if the image format doesn't have clusters, 4K if the clusters
1138#               are smaller than that, else the cluster size.  Must be a
1139#               power of 2 between 512 and 64M (since 1.4).
1140#
1141# @buf-size: #optional maximum amount of data in flight from source to
1142#            target (since 1.4).
1143#
1144# @on-source-error: #optional the action to take on an error on the source,
1145#                   default 'report'.  'stop' and 'enospc' can only be used
1146#                   if the block device supports io-status (see BlockInfo).
1147#
1148# @on-target-error: #optional the action to take on an error on the target,
1149#                   default 'report' (no limitations, since this applies to
1150#                   a different block device than @device).
1151# @unmap: #optional Whether to try to unmap target sectors where source has
1152#         only zero. If true, and target unallocated sectors will read as zero,
1153#         target image sectors will be unmapped; otherwise, zeroes will be
1154#         written. Both will result in identical contents.
1155#         Default is true. (Since 2.4)
1156#
1157# Returns: nothing on success
1158#          If @device is not a valid block device, DeviceNotFound
1159#
1160# Since 1.3
1161##
1162{ 'command': 'drive-mirror',
1163  'data': { 'device': 'str', 'target': 'str', '*format': 'str',
1164            '*node-name': 'str', '*replaces': 'str',
1165            'sync': 'MirrorSyncMode', '*mode': 'NewImageMode',
1166            '*speed': 'int', '*granularity': 'uint32',
1167            '*buf-size': 'int', '*on-source-error': 'BlockdevOnError',
1168            '*on-target-error': 'BlockdevOnError',
1169            '*unmap': 'bool' } }
1170
1171##
1172# @BlockDirtyBitmap
1173#
1174# @node: name of device/node which the bitmap is tracking
1175#
1176# @name: name of the dirty bitmap
1177#
1178# Since 2.4
1179##
1180{ 'struct': 'BlockDirtyBitmap',
1181  'data': { 'node': 'str', 'name': 'str' } }
1182
1183##
1184# @BlockDirtyBitmapAdd
1185#
1186# @node: name of device/node which the bitmap is tracking
1187#
1188# @name: name of the dirty bitmap
1189#
1190# @granularity: #optional the bitmap granularity, default is 64k for
1191#               block-dirty-bitmap-add
1192#
1193# Since 2.4
1194##
1195{ 'struct': 'BlockDirtyBitmapAdd',
1196  'data': { 'node': 'str', 'name': 'str', '*granularity': 'uint32' } }
1197
1198##
1199# @block-dirty-bitmap-add
1200#
1201# Create a dirty bitmap with a name on the node
1202#
1203# Returns: nothing on success
1204#          If @node is not a valid block device or node, DeviceNotFound
1205#          If @name is already taken, GenericError with an explanation
1206#
1207# Since 2.4
1208##
1209{ 'command': 'block-dirty-bitmap-add',
1210  'data': 'BlockDirtyBitmapAdd' }
1211
1212##
1213# @block-dirty-bitmap-remove
1214#
1215# Remove a dirty bitmap on the node
1216#
1217# Returns: nothing on success
1218#          If @node is not a valid block device or node, DeviceNotFound
1219#          If @name is not found, GenericError with an explanation
1220#          if @name is frozen by an operation, GenericError
1221#
1222# Since 2.4
1223##
1224{ 'command': 'block-dirty-bitmap-remove',
1225  'data': 'BlockDirtyBitmap' }
1226
1227##
1228# @block-dirty-bitmap-clear
1229#
1230# Clear (reset) a dirty bitmap on the device
1231#
1232# Returns: nothing on success
1233#          If @node is not a valid block device, DeviceNotFound
1234#          If @name is not found, GenericError with an explanation
1235#
1236# Since 2.4
1237##
1238{ 'command': 'block-dirty-bitmap-clear',
1239  'data': 'BlockDirtyBitmap' }
1240
1241##
1242# @blockdev-mirror
1243#
1244# Start mirroring a block device's writes to a new destination.
1245#
1246# @device: the name of the device whose writes should be mirrored.
1247#
1248# @target: the id or node-name of the block device to mirror to. This mustn't be
1249#          attached to guest.
1250#
1251# @replaces: #optional with sync=full graph node name to be replaced by the new
1252#            image when a whole image copy is done. This can be used to repair
1253#            broken Quorum files.
1254#
1255# @speed:  #optional the maximum speed, in bytes per second
1256#
1257# @sync: what parts of the disk image should be copied to the destination
1258#        (all the disk, only the sectors allocated in the topmost image, or
1259#        only new I/O).
1260#
1261# @granularity: #optional granularity of the dirty bitmap, default is 64K
1262#               if the image format doesn't have clusters, 4K if the clusters
1263#               are smaller than that, else the cluster size.  Must be a
1264#               power of 2 between 512 and 64M
1265#
1266# @buf-size: #optional maximum amount of data in flight from source to
1267#            target
1268#
1269# @on-source-error: #optional the action to take on an error on the source,
1270#                   default 'report'.  'stop' and 'enospc' can only be used
1271#                   if the block device supports io-status (see BlockInfo).
1272#
1273# @on-target-error: #optional the action to take on an error on the target,
1274#                   default 'report' (no limitations, since this applies to
1275#                   a different block device than @device).
1276#
1277# Returns: nothing on success.
1278#
1279# Since 2.6
1280##
1281{ 'command': 'blockdev-mirror',
1282  'data': { 'device': 'str', 'target': 'str',
1283            '*replaces': 'str',
1284            'sync': 'MirrorSyncMode',
1285            '*speed': 'int', '*granularity': 'uint32',
1286            '*buf-size': 'int', '*on-source-error': 'BlockdevOnError',
1287            '*on-target-error': 'BlockdevOnError' } }
1288
1289##
1290# @block_set_io_throttle:
1291#
1292# Change I/O throttle limits for a block drive.
1293#
1294# Since QEMU 2.4, each device with I/O limits is member of a throttle
1295# group.
1296#
1297# If two or more devices are members of the same group, the limits
1298# will apply to the combined I/O of the whole group in a round-robin
1299# fashion. Therefore, setting new I/O limits to a device will affect
1300# the whole group.
1301#
1302# The name of the group can be specified using the 'group' parameter.
1303# If the parameter is unset, it is assumed to be the current group of
1304# that device. If it's not in any group yet, the name of the device
1305# will be used as the name for its group.
1306#
1307# The 'group' parameter can also be used to move a device to a
1308# different group. In this case the limits specified in the parameters
1309# will be applied to the new group only.
1310#
1311# I/O limits can be disabled by setting all of them to 0. In this case
1312# the device will be removed from its group and the rest of its
1313# members will not be affected. The 'group' parameter is ignored.
1314#
1315# @device: The name of the device
1316#
1317# @bps: total throughput limit in bytes per second
1318#
1319# @bps_rd: read throughput limit in bytes per second
1320#
1321# @bps_wr: write throughput limit in bytes per second
1322#
1323# @iops: total I/O operations per second
1324#
1325# @iops_rd: read I/O operations per second
1326#
1327# @iops_wr: write I/O operations per second
1328#
1329# @bps_max: #optional total throughput limit during bursts,
1330#                     in bytes (Since 1.7)
1331#
1332# @bps_rd_max: #optional read throughput limit during bursts,
1333#                        in bytes (Since 1.7)
1334#
1335# @bps_wr_max: #optional write throughput limit during bursts,
1336#                        in bytes (Since 1.7)
1337#
1338# @iops_max: #optional total I/O operations per second during bursts,
1339#                      in bytes (Since 1.7)
1340#
1341# @iops_rd_max: #optional read I/O operations per second during bursts,
1342#                         in bytes (Since 1.7)
1343#
1344# @iops_wr_max: #optional write I/O operations per second during bursts,
1345#                         in bytes (Since 1.7)
1346#
1347# @bps_max_length: #optional maximum length of the @bps_max burst
1348#                            period, in seconds. It must only
1349#                            be set if @bps_max is set as well.
1350#                            Defaults to 1. (Since 2.6)
1351#
1352# @bps_rd_max_length: #optional maximum length of the @bps_rd_max
1353#                               burst period, in seconds. It must only
1354#                               be set if @bps_rd_max is set as well.
1355#                               Defaults to 1. (Since 2.6)
1356#
1357# @bps_wr_max_length: #optional maximum length of the @bps_wr_max
1358#                               burst period, in seconds. It must only
1359#                               be set if @bps_wr_max is set as well.
1360#                               Defaults to 1. (Since 2.6)
1361#
1362# @iops_max_length: #optional maximum length of the @iops burst
1363#                             period, in seconds. It must only
1364#                             be set if @iops_max is set as well.
1365#                             Defaults to 1. (Since 2.6)
1366#
1367# @iops_rd_max_length: #optional maximum length of the @iops_rd_max
1368#                                burst period, in seconds. It must only
1369#                                be set if @iops_rd_max is set as well.
1370#                                Defaults to 1. (Since 2.6)
1371#
1372# @iops_wr_max_length: #optional maximum length of the @iops_wr_max
1373#                                burst period, in seconds. It must only
1374#                                be set if @iops_wr_max is set as well.
1375#                                Defaults to 1. (Since 2.6)
1376#
1377# @iops_size: #optional an I/O size in bytes (Since 1.7)
1378#
1379# @group: #optional throttle group name (Since 2.4)
1380#
1381# Returns: Nothing on success
1382#          If @device is not a valid block device, DeviceNotFound
1383#
1384# Since: 1.1
1385##
1386{ 'command': 'block_set_io_throttle',
1387  'data': { 'device': 'str', 'bps': 'int', 'bps_rd': 'int', 'bps_wr': 'int',
1388            'iops': 'int', 'iops_rd': 'int', 'iops_wr': 'int',
1389            '*bps_max': 'int', '*bps_rd_max': 'int',
1390            '*bps_wr_max': 'int', '*iops_max': 'int',
1391            '*iops_rd_max': 'int', '*iops_wr_max': 'int',
1392            '*bps_max_length': 'int', '*bps_rd_max_length': 'int',
1393            '*bps_wr_max_length': 'int', '*iops_max_length': 'int',
1394            '*iops_rd_max_length': 'int', '*iops_wr_max_length': 'int',
1395            '*iops_size': 'int', '*group': 'str' } }
1396
1397##
1398# @block-stream:
1399#
1400# Copy data from a backing file into a block device.
1401#
1402# The block streaming operation is performed in the background until the entire
1403# backing file has been copied.  This command returns immediately once streaming
1404# has started.  The status of ongoing block streaming operations can be checked
1405# with query-block-jobs.  The operation can be stopped before it has completed
1406# using the block-job-cancel command.
1407#
1408# If a base file is specified then sectors are not copied from that base file and
1409# its backing chain.  When streaming completes the image file will have the base
1410# file as its backing file.  This can be used to stream a subset of the backing
1411# file chain instead of flattening the entire image.
1412#
1413# On successful completion the image file is updated to drop the backing file
1414# and the BLOCK_JOB_COMPLETED event is emitted.
1415#
1416# @device: the device name
1417#
1418# @base:   #optional the common backing file name
1419#
1420# @backing-file: #optional The backing file string to write into the active
1421#                          layer. This filename is not validated.
1422#
1423#                          If a pathname string is such that it cannot be
1424#                          resolved by QEMU, that means that subsequent QMP or
1425#                          HMP commands must use node-names for the image in
1426#                          question, as filename lookup methods will fail.
1427#
1428#                          If not specified, QEMU will automatically determine
1429#                          the backing file string to use, or error out if there
1430#                          is no obvious choice.  Care should be taken when
1431#                          specifying the string, to specify a valid filename or
1432#                          protocol.
1433#                          (Since 2.1)
1434#
1435# @speed:  #optional the maximum speed, in bytes per second
1436#
1437# @on-error: #optional the action to take on an error (default report).
1438#            'stop' and 'enospc' can only be used if the block device
1439#            supports io-status (see BlockInfo).  Since 1.3.
1440#
1441# Returns: Nothing on success
1442#          If @device does not exist, DeviceNotFound
1443#
1444# Since: 1.1
1445##
1446{ 'command': 'block-stream',
1447  'data': { 'device': 'str', '*base': 'str', '*backing-file': 'str',
1448            '*speed': 'int', '*on-error': 'BlockdevOnError' } }
1449
1450##
1451# @block-job-set-speed:
1452#
1453# Set maximum speed for a background block operation.
1454#
1455# This command can only be issued when there is an active block job.
1456#
1457# Throttling can be disabled by setting the speed to 0.
1458#
1459# @device: the device name
1460#
1461# @speed:  the maximum speed, in bytes per second, or 0 for unlimited.
1462#          Defaults to 0.
1463#
1464# Returns: Nothing on success
1465#          If no background operation is active on this device, DeviceNotActive
1466#
1467# Since: 1.1
1468##
1469{ 'command': 'block-job-set-speed',
1470  'data': { 'device': 'str', 'speed': 'int' } }
1471
1472##
1473# @block-job-cancel:
1474#
1475# Stop an active background block operation.
1476#
1477# This command returns immediately after marking the active background block
1478# operation for cancellation.  It is an error to call this command if no
1479# operation is in progress.
1480#
1481# The operation will cancel as soon as possible and then emit the
1482# BLOCK_JOB_CANCELLED event.  Before that happens the job is still visible when
1483# enumerated using query-block-jobs.
1484#
1485# For streaming, the image file retains its backing file unless the streaming
1486# operation happens to complete just as it is being cancelled.  A new streaming
1487# operation can be started at a later time to finish copying all data from the
1488# backing file.
1489#
1490# @device: the device name
1491#
1492# @force: #optional whether to allow cancellation of a paused job (default
1493#         false).  Since 1.3.
1494#
1495# Returns: Nothing on success
1496#          If no background operation is active on this device, DeviceNotActive
1497#
1498# Since: 1.1
1499##
1500{ 'command': 'block-job-cancel', 'data': { 'device': 'str', '*force': 'bool' } }
1501
1502##
1503# @block-job-pause:
1504#
1505# Pause an active background block operation.
1506#
1507# This command returns immediately after marking the active background block
1508# operation for pausing.  It is an error to call this command if no
1509# operation is in progress.  Pausing an already paused job has no cumulative
1510# effect; a single block-job-resume command will resume the job.
1511#
1512# The operation will pause as soon as possible.  No event is emitted when
1513# the operation is actually paused.  Cancelling a paused job automatically
1514# resumes it.
1515#
1516# @device: the device name
1517#
1518# Returns: Nothing on success
1519#          If no background operation is active on this device, DeviceNotActive
1520#
1521# Since: 1.3
1522##
1523{ 'command': 'block-job-pause', 'data': { 'device': 'str' } }
1524
1525##
1526# @block-job-resume:
1527#
1528# Resume an active background block operation.
1529#
1530# This command returns immediately after resuming a paused background block
1531# operation.  It is an error to call this command if no operation is in
1532# progress.  Resuming an already running job is not an error.
1533#
1534# This command also clears the error status of the job.
1535#
1536# @device: the device name
1537#
1538# Returns: Nothing on success
1539#          If no background operation is active on this device, DeviceNotActive
1540#
1541# Since: 1.3
1542##
1543{ 'command': 'block-job-resume', 'data': { 'device': 'str' } }
1544
1545##
1546# @block-job-complete:
1547#
1548# Manually trigger completion of an active background block operation.  This
1549# is supported for drive mirroring, where it also switches the device to
1550# write to the target path only.  The ability to complete is signaled with
1551# a BLOCK_JOB_READY event.
1552#
1553# This command completes an active background block operation synchronously.
1554# The ordering of this command's return with the BLOCK_JOB_COMPLETED event
1555# is not defined.  Note that if an I/O error occurs during the processing of
1556# this command: 1) the command itself will fail; 2) the error will be processed
1557# according to the rerror/werror arguments that were specified when starting
1558# the operation.
1559#
1560# A cancelled or paused job cannot be completed.
1561#
1562# @device: the device name
1563#
1564# Returns: Nothing on success
1565#          If no background operation is active on this device, DeviceNotActive
1566#
1567# Since: 1.3
1568##
1569{ 'command': 'block-job-complete', 'data': { 'device': 'str' } }
1570
1571##
1572# @BlockdevDiscardOptions
1573#
1574# Determines how to handle discard requests.
1575#
1576# @ignore:      Ignore the request
1577# @unmap:       Forward as an unmap request
1578#
1579# Since: 1.7
1580##
1581{ 'enum': 'BlockdevDiscardOptions',
1582  'data': [ 'ignore', 'unmap' ] }
1583
1584##
1585# @BlockdevDetectZeroesOptions
1586#
1587# Describes the operation mode for the automatic conversion of plain
1588# zero writes by the OS to driver specific optimized zero write commands.
1589#
1590# @off:      Disabled (default)
1591# @on:       Enabled
1592# @unmap:    Enabled and even try to unmap blocks if possible. This requires
1593#            also that @BlockdevDiscardOptions is set to unmap for this device.
1594#
1595# Since: 2.1
1596##
1597{ 'enum': 'BlockdevDetectZeroesOptions',
1598  'data': [ 'off', 'on', 'unmap' ] }
1599
1600##
1601# @BlockdevAioOptions
1602#
1603# Selects the AIO backend to handle I/O requests
1604#
1605# @threads:     Use qemu's thread pool
1606# @native:      Use native AIO backend (only Linux and Windows)
1607#
1608# Since: 1.7
1609##
1610{ 'enum': 'BlockdevAioOptions',
1611  'data': [ 'threads', 'native' ] }
1612
1613##
1614# @BlockdevCacheOptions
1615#
1616# Includes cache-related options for block devices
1617#
1618# @direct:      #optional enables use of O_DIRECT (bypass the host page cache;
1619#               default: false)
1620# @no-flush:    #optional ignore any flush requests for the device (default:
1621#               false)
1622#
1623# Since: 1.7
1624##
1625{ 'struct': 'BlockdevCacheOptions',
1626  'data': { '*direct': 'bool',
1627            '*no-flush': 'bool' } }
1628
1629##
1630# @BlockdevDriver
1631#
1632# Drivers that are supported in block device operations.
1633#
1634# @host_device, @host_cdrom: Since 2.1
1635#
1636# Since: 2.0
1637##
1638{ 'enum': 'BlockdevDriver',
1639  'data': [ 'archipelago', 'blkdebug', 'blkverify', 'bochs', 'cloop',
1640            'dmg', 'file', 'ftp', 'ftps', 'host_cdrom', 'host_device',
1641            'http', 'https', 'luks', 'null-aio', 'null-co', 'parallels',
1642            'qcow', 'qcow2', 'qed', 'quorum', 'raw', 'tftp', 'vdi', 'vhdx',
1643            'vmdk', 'vpc', 'vvfat' ] }
1644
1645##
1646# @BlockdevOptionsFile
1647#
1648# Driver specific block device options for the file backend and similar
1649# protocols.
1650#
1651# @filename:    path to the image file
1652#
1653# Since: 1.7
1654##
1655{ 'struct': 'BlockdevOptionsFile',
1656  'data': { 'filename': 'str' } }
1657
1658##
1659# @BlockdevOptionsNull
1660#
1661# Driver specific block device options for the null backend.
1662#
1663# @size:    #optional size of the device in bytes.
1664# @latency-ns: #optional emulated latency (in nanoseconds) in processing
1665#              requests. Default to zero which completes requests immediately.
1666#              (Since 2.4)
1667#
1668# Since: 2.2
1669##
1670{ 'struct': 'BlockdevOptionsNull',
1671  'data': { '*size': 'int', '*latency-ns': 'uint64' } }
1672
1673##
1674# @BlockdevOptionsVVFAT
1675#
1676# Driver specific block device options for the vvfat protocol.
1677#
1678# @dir:         directory to be exported as FAT image
1679# @fat-type:    #optional FAT type: 12, 16 or 32
1680# @floppy:      #optional whether to export a floppy image (true) or
1681#               partitioned hard disk (false; default)
1682# @label:       #optional set the volume label, limited to 11 bytes. FAT16 and
1683#               FAT32 traditionally have some restrictions on labels, which are
1684#               ignored by most operating systems. Defaults to "QEMU VVFAT".
1685#               (since 2.4)
1686# @rw:          #optional whether to allow write operations (default: false)
1687#
1688# Since: 1.7
1689##
1690{ 'struct': 'BlockdevOptionsVVFAT',
1691  'data': { 'dir': 'str', '*fat-type': 'int', '*floppy': 'bool',
1692            '*label': 'str', '*rw': 'bool' } }
1693
1694##
1695# @BlockdevOptionsGenericFormat
1696#
1697# Driver specific block device options for image format that have no option
1698# besides their data source.
1699#
1700# @file:        reference to or definition of the data source block device
1701#
1702# Since: 1.7
1703##
1704{ 'struct': 'BlockdevOptionsGenericFormat',
1705  'data': { 'file': 'BlockdevRef' } }
1706
1707##
1708# @BlockdevOptionsLUKS
1709#
1710# Driver specific block device options for LUKS.
1711#
1712# @key-secret: #optional the ID of a QCryptoSecret object providing
1713#              the decryption key (since 2.6). Mandatory except when
1714#              doing a metadata-only probe of the image.
1715#
1716# Since: 2.6
1717##
1718{ 'struct': 'BlockdevOptionsLUKS',
1719  'base': 'BlockdevOptionsGenericFormat',
1720  'data': { '*key-secret': 'str' } }
1721
1722
1723##
1724# @BlockdevOptionsGenericCOWFormat
1725#
1726# Driver specific block device options for image format that have no option
1727# besides their data source and an optional backing file.
1728#
1729# @backing:     #optional reference to or definition of the backing file block
1730#               device (if missing, taken from the image file content). It is
1731#               allowed to pass an empty string here in order to disable the
1732#               default backing file.
1733#
1734# Since: 1.7
1735##
1736{ 'struct': 'BlockdevOptionsGenericCOWFormat',
1737  'base': 'BlockdevOptionsGenericFormat',
1738  'data': { '*backing': 'BlockdevRef' } }
1739
1740##
1741# @Qcow2OverlapCheckMode
1742#
1743# General overlap check modes.
1744#
1745# @none:        Do not perform any checks
1746#
1747# @constant:    Perform only checks which can be done in constant time and
1748#               without reading anything from disk
1749#
1750# @cached:      Perform only checks which can be done without reading anything
1751#               from disk
1752#
1753# @all:         Perform all available overlap checks
1754#
1755# Since: 2.2
1756##
1757{ 'enum': 'Qcow2OverlapCheckMode',
1758  'data': [ 'none', 'constant', 'cached', 'all' ] }
1759
1760##
1761# @Qcow2OverlapCheckFlags
1762#
1763# Structure of flags for each metadata structure. Setting a field to 'true'
1764# makes qemu guard that structure against unintended overwriting. The default
1765# value is chosen according to the template given.
1766#
1767# @template: Specifies a template mode which can be adjusted using the other
1768#            flags, defaults to 'cached'
1769#
1770# Since: 2.2
1771##
1772{ 'struct': 'Qcow2OverlapCheckFlags',
1773  'data': { '*template':       'Qcow2OverlapCheckMode',
1774            '*main-header':    'bool',
1775            '*active-l1':      'bool',
1776            '*active-l2':      'bool',
1777            '*refcount-table': 'bool',
1778            '*refcount-block': 'bool',
1779            '*snapshot-table': 'bool',
1780            '*inactive-l1':    'bool',
1781            '*inactive-l2':    'bool' } }
1782
1783##
1784# @Qcow2OverlapChecks
1785#
1786# Specifies which metadata structures should be guarded against unintended
1787# overwriting.
1788#
1789# @flags:   set of flags for separate specification of each metadata structure
1790#           type
1791#
1792# @mode:    named mode which chooses a specific set of flags
1793#
1794# Since: 2.2
1795##
1796{ 'alternate': 'Qcow2OverlapChecks',
1797  'data': { 'flags': 'Qcow2OverlapCheckFlags',
1798            'mode':  'Qcow2OverlapCheckMode' } }
1799
1800##
1801# @BlockdevOptionsQcow2
1802#
1803# Driver specific block device options for qcow2.
1804#
1805# @lazy-refcounts:        #optional whether to enable the lazy refcounts
1806#                         feature (default is taken from the image file)
1807#
1808# @pass-discard-request:  #optional whether discard requests to the qcow2
1809#                         device should be forwarded to the data source
1810#
1811# @pass-discard-snapshot: #optional whether discard requests for the data source
1812#                         should be issued when a snapshot operation (e.g.
1813#                         deleting a snapshot) frees clusters in the qcow2 file
1814#
1815# @pass-discard-other:    #optional whether discard requests for the data source
1816#                         should be issued on other occasions where a cluster
1817#                         gets freed
1818#
1819# @overlap-check:         #optional which overlap checks to perform for writes
1820#                         to the image, defaults to 'cached' (since 2.2)
1821#
1822# @cache-size:            #optional the maximum total size of the L2 table and
1823#                         refcount block caches in bytes (since 2.2)
1824#
1825# @l2-cache-size:         #optional the maximum size of the L2 table cache in
1826#                         bytes (since 2.2)
1827#
1828# @refcount-cache-size:   #optional the maximum size of the refcount block cache
1829#                         in bytes (since 2.2)
1830#
1831# @cache-clean-interval:  #optional clean unused entries in the L2 and refcount
1832#                         caches. The interval is in seconds. The default value
1833#                         is 0 and it disables this feature (since 2.5)
1834#
1835# Since: 1.7
1836##
1837{ 'struct': 'BlockdevOptionsQcow2',
1838  'base': 'BlockdevOptionsGenericCOWFormat',
1839  'data': { '*lazy-refcounts': 'bool',
1840            '*pass-discard-request': 'bool',
1841            '*pass-discard-snapshot': 'bool',
1842            '*pass-discard-other': 'bool',
1843            '*overlap-check': 'Qcow2OverlapChecks',
1844            '*cache-size': 'int',
1845            '*l2-cache-size': 'int',
1846            '*refcount-cache-size': 'int',
1847            '*cache-clean-interval': 'int' } }
1848
1849
1850##
1851# @BlockdevOptionsArchipelago
1852#
1853# Driver specific block device options for Archipelago.
1854#
1855# @volume:              Name of the Archipelago volume image
1856#
1857# @mport:               #optional The port number on which mapperd is
1858#                       listening. This is optional
1859#                       and if not specified, QEMU will make Archipelago
1860#                       use the default port (1001).
1861#
1862# @vport:               #optional The port number on which vlmcd is
1863#                       listening. This is optional
1864#                       and if not specified, QEMU will make Archipelago
1865#                       use the default port (501).
1866#
1867# @segment:             #optional The name of the shared memory segment
1868#                       Archipelago stack is using. This is optional
1869#                       and if not specified, QEMU will make Archipelago
1870#                       use the default value, 'archipelago'.
1871# Since: 2.2
1872##
1873{ 'struct': 'BlockdevOptionsArchipelago',
1874  'data': { 'volume': 'str',
1875            '*mport': 'int',
1876            '*vport': 'int',
1877            '*segment': 'str' } }
1878
1879
1880##
1881# @BlkdebugEvent
1882#
1883# Trigger events supported by blkdebug.
1884#
1885# Since: 2.0
1886##
1887{ 'enum': 'BlkdebugEvent', 'prefix': 'BLKDBG',
1888  'data': [ 'l1_update', 'l1_grow_alloc_table', 'l1_grow_write_table',
1889            'l1_grow_activate_table', 'l2_load', 'l2_update',
1890            'l2_update_compressed', 'l2_alloc_cow_read', 'l2_alloc_write',
1891            'read_aio', 'read_backing_aio', 'read_compressed', 'write_aio',
1892            'write_compressed', 'vmstate_load', 'vmstate_save', 'cow_read',
1893            'cow_write', 'reftable_load', 'reftable_grow', 'reftable_update',
1894            'refblock_load', 'refblock_update', 'refblock_update_part',
1895            'refblock_alloc', 'refblock_alloc_hookup', 'refblock_alloc_write',
1896            'refblock_alloc_write_blocks', 'refblock_alloc_write_table',
1897            'refblock_alloc_switch_table', 'cluster_alloc',
1898            'cluster_alloc_bytes', 'cluster_free', 'flush_to_os',
1899            'flush_to_disk', 'pwritev_rmw_head', 'pwritev_rmw_after_head',
1900            'pwritev_rmw_tail', 'pwritev_rmw_after_tail', 'pwritev',
1901            'pwritev_zero', 'pwritev_done', 'empty_image_prepare' ] }
1902
1903##
1904# @BlkdebugInjectErrorOptions
1905#
1906# Describes a single error injection for blkdebug.
1907#
1908# @event:       trigger event
1909#
1910# @state:       #optional the state identifier blkdebug needs to be in to
1911#               actually trigger the event; defaults to "any"
1912#
1913# @errno:       #optional error identifier (errno) to be returned; defaults to
1914#               EIO
1915#
1916# @sector:      #optional specifies the sector index which has to be affected
1917#               in order to actually trigger the event; defaults to "any
1918#               sector"
1919#
1920# @once:        #optional disables further events after this one has been
1921#               triggered; defaults to false
1922#
1923# @immediately: #optional fail immediately; defaults to false
1924#
1925# Since: 2.0
1926##
1927{ 'struct': 'BlkdebugInjectErrorOptions',
1928  'data': { 'event': 'BlkdebugEvent',
1929            '*state': 'int',
1930            '*errno': 'int',
1931            '*sector': 'int',
1932            '*once': 'bool',
1933            '*immediately': 'bool' } }
1934
1935##
1936# @BlkdebugSetStateOptions
1937#
1938# Describes a single state-change event for blkdebug.
1939#
1940# @event:       trigger event
1941#
1942# @state:       #optional the current state identifier blkdebug needs to be in;
1943#               defaults to "any"
1944#
1945# @new_state:   the state identifier blkdebug is supposed to assume if
1946#               this event is triggered
1947#
1948# Since: 2.0
1949##
1950{ 'struct': 'BlkdebugSetStateOptions',
1951  'data': { 'event': 'BlkdebugEvent',
1952            '*state': 'int',
1953            'new_state': 'int' } }
1954
1955##
1956# @BlockdevOptionsBlkdebug
1957#
1958# Driver specific block device options for blkdebug.
1959#
1960# @image:           underlying raw block device (or image file)
1961#
1962# @config:          #optional filename of the configuration file
1963#
1964# @align:           #optional required alignment for requests in bytes
1965#
1966# @inject-error:    #optional array of error injection descriptions
1967#
1968# @set-state:       #optional array of state-change descriptions
1969#
1970# Since: 2.0
1971##
1972{ 'struct': 'BlockdevOptionsBlkdebug',
1973  'data': { 'image': 'BlockdevRef',
1974            '*config': 'str',
1975            '*align': 'int',
1976            '*inject-error': ['BlkdebugInjectErrorOptions'],
1977            '*set-state': ['BlkdebugSetStateOptions'] } }
1978
1979##
1980# @BlockdevOptionsBlkverify
1981#
1982# Driver specific block device options for blkverify.
1983#
1984# @test:    block device to be tested
1985#
1986# @raw:     raw image used for verification
1987#
1988# Since: 2.0
1989##
1990{ 'struct': 'BlockdevOptionsBlkverify',
1991  'data': { 'test': 'BlockdevRef',
1992            'raw': 'BlockdevRef' } }
1993
1994##
1995# @QuorumReadPattern
1996#
1997# An enumeration of quorum read patterns.
1998#
1999# @quorum: read all the children and do a quorum vote on reads
2000#
2001# @fifo: read only from the first child that has not failed
2002#
2003# Since: 2.2
2004##
2005{ 'enum': 'QuorumReadPattern', 'data': [ 'quorum', 'fifo' ] }
2006
2007##
2008# @BlockdevOptionsQuorum
2009#
2010# Driver specific block device options for Quorum
2011#
2012# @blkverify:      #optional true if the driver must print content mismatch
2013#                  set to false by default
2014#
2015# @children:       the children block devices to use
2016#
2017# @vote-threshold: the vote limit under which a read will fail
2018#
2019# @rewrite-corrupted: #optional rewrite corrupted data when quorum is reached
2020#                     (Since 2.1)
2021#
2022# @read-pattern: #optional choose read pattern and set to quorum by default
2023#                (Since 2.2)
2024#
2025# Since: 2.0
2026##
2027{ 'struct': 'BlockdevOptionsQuorum',
2028  'data': { '*blkverify': 'bool',
2029            'children': [ 'BlockdevRef' ],
2030            'vote-threshold': 'int',
2031            '*rewrite-corrupted': 'bool',
2032            '*read-pattern': 'QuorumReadPattern' } }
2033
2034##
2035# @BlockdevOptions
2036#
2037# Options for creating a block device.  Many options are available for all
2038# block devices, independent of the block driver:
2039#
2040# @driver:        block driver name
2041# @id:            #optional id by which the new block device can be referred to.
2042#                 This option is only allowed on the top level of blockdev-add.
2043#                 A BlockBackend will be created by blockdev-add if and only if
2044#                 this option is given.
2045# @node-name:     #optional the name of a block driver state node (Since 2.0).
2046#                 This option is required on the top level of blockdev-add if
2047#                 the @id option is not given there.
2048# @discard:       #optional discard-related options (default: ignore)
2049# @cache:         #optional cache-related options
2050# @aio:           #optional AIO backend (default: threads)
2051# @rerror:        #optional how to handle read errors on the device
2052#                 (default: report)
2053# @werror:        #optional how to handle write errors on the device
2054#                 (default: enospc)
2055# @read-only:     #optional whether the block device should be read-only
2056#                 (default: false)
2057# @stats-account-invalid: #optional whether to include invalid
2058#                         operations when computing last access statistics
2059#                         (default: true) (Since 2.5)
2060# @stats-account-failed: #optional whether to include failed
2061#                         operations when computing latency and last
2062#                         access statistics (default: true) (Since 2.5)
2063# @stats-intervals: #optional list of intervals for collecting I/O
2064#                   statistics, in seconds (default: none) (Since 2.5)
2065# @detect-zeroes: #optional detect and optimize zero writes (Since 2.1)
2066#                 (default: off)
2067#
2068# Remaining options are determined by the block driver.
2069#
2070# Since: 1.7
2071##
2072{ 'union': 'BlockdevOptions',
2073  'base': { 'driver': 'BlockdevDriver',
2074            '*id': 'str',
2075            '*node-name': 'str',
2076            '*discard': 'BlockdevDiscardOptions',
2077            '*cache': 'BlockdevCacheOptions',
2078            '*aio': 'BlockdevAioOptions',
2079            '*rerror': 'BlockdevOnError',
2080            '*werror': 'BlockdevOnError',
2081            '*read-only': 'bool',
2082            '*stats-account-invalid': 'bool',
2083            '*stats-account-failed': 'bool',
2084            '*stats-intervals': ['int'],
2085            '*detect-zeroes': 'BlockdevDetectZeroesOptions' },
2086  'discriminator': 'driver',
2087  'data': {
2088      'archipelago':'BlockdevOptionsArchipelago',
2089      'blkdebug':   'BlockdevOptionsBlkdebug',
2090      'blkverify':  'BlockdevOptionsBlkverify',
2091      'bochs':      'BlockdevOptionsGenericFormat',
2092      'cloop':      'BlockdevOptionsGenericFormat',
2093      'dmg':        'BlockdevOptionsGenericFormat',
2094      'file':       'BlockdevOptionsFile',
2095      'ftp':        'BlockdevOptionsFile',
2096      'ftps':       'BlockdevOptionsFile',
2097# TODO gluster: Wait for structured options
2098      'host_cdrom': 'BlockdevOptionsFile',
2099      'host_device':'BlockdevOptionsFile',
2100      'http':       'BlockdevOptionsFile',
2101      'https':      'BlockdevOptionsFile',
2102# TODO iscsi: Wait for structured options
2103      'luks':       'BlockdevOptionsLUKS',
2104# TODO nbd: Should take InetSocketAddress for 'host'?
2105# TODO nfs: Wait for structured options
2106      'null-aio':   'BlockdevOptionsNull',
2107      'null-co':    'BlockdevOptionsNull',
2108      'parallels':  'BlockdevOptionsGenericFormat',
2109      'qcow2':      'BlockdevOptionsQcow2',
2110      'qcow':       'BlockdevOptionsGenericCOWFormat',
2111      'qed':        'BlockdevOptionsGenericCOWFormat',
2112      'quorum':     'BlockdevOptionsQuorum',
2113      'raw':        'BlockdevOptionsGenericFormat',
2114# TODO rbd: Wait for structured options
2115# TODO sheepdog: Wait for structured options
2116# TODO ssh: Should take InetSocketAddress for 'host'?
2117      'tftp':       'BlockdevOptionsFile',
2118      'vdi':        'BlockdevOptionsGenericFormat',
2119      'vhdx':       'BlockdevOptionsGenericFormat',
2120      'vmdk':       'BlockdevOptionsGenericCOWFormat',
2121      'vpc':        'BlockdevOptionsGenericFormat',
2122      'vvfat':      'BlockdevOptionsVVFAT'
2123  } }
2124
2125##
2126# @BlockdevRef
2127#
2128# Reference to a block device.
2129#
2130# @definition:      defines a new block device inline
2131# @reference:       references the ID of an existing block device. An
2132#                   empty string means that no block device should be
2133#                   referenced.
2134#
2135# Since: 1.7
2136##
2137{ 'alternate': 'BlockdevRef',
2138  'data': { 'definition': 'BlockdevOptions',
2139            'reference': 'str' } }
2140
2141##
2142# @blockdev-add:
2143#
2144# Creates a new block device. If the @id option is given at the top level, a
2145# BlockBackend will be created; otherwise, @node-name is mandatory at the top
2146# level and no BlockBackend will be created.
2147#
2148# This command is still a work in progress.  It doesn't support all
2149# block drivers among other things.  Stay away from it unless you want
2150# to help with its development.
2151#
2152# @options: block device options for the new device
2153#
2154# Since: 1.7
2155##
2156{ 'command': 'blockdev-add', 'data': { 'options': 'BlockdevOptions' } }
2157
2158##
2159# @x-blockdev-del:
2160#
2161# Deletes a block device that has been added using blockdev-add.
2162# The selected device can be either a block backend or a graph node.
2163#
2164# In the former case the backend will be destroyed, along with its
2165# inserted medium if there's any. The command will fail if the backend
2166# or its medium are in use.
2167#
2168# In the latter case the node will be destroyed. The command will fail
2169# if the node is attached to a block backend or is otherwise being
2170# used.
2171#
2172# One of @id or @node-name must be specified, but not both.
2173#
2174# This command is still a work in progress and is considered
2175# experimental. Stay away from it unless you want to help with its
2176# development.
2177#
2178# @id: #optional Name of the block backend device to delete.
2179#
2180# @node-name: #optional Name of the graph node to delete.
2181#
2182# Since: 2.5
2183##
2184{ 'command': 'x-blockdev-del', 'data': { '*id': 'str', '*node-name': 'str' } }
2185
2186##
2187# @blockdev-open-tray:
2188#
2189# Opens a block device's tray. If there is a block driver state tree inserted as
2190# a medium, it will become inaccessible to the guest (but it will remain
2191# associated to the block device, so closing the tray will make it accessible
2192# again).
2193#
2194# If the tray was already open before, this will be a no-op.
2195#
2196# Once the tray opens, a DEVICE_TRAY_MOVED event is emitted. There are cases in
2197# which no such event will be generated, these include:
2198# - if the guest has locked the tray, @force is false and the guest does not
2199#   respond to the eject request
2200# - if the BlockBackend denoted by @device does not have a guest device attached
2201#   to it
2202# - if the guest device does not have an actual tray
2203#
2204# @device: block device name
2205#
2206# @force:  #optional if false (the default), an eject request will be sent to
2207#          the guest if it has locked the tray (and the tray will not be opened
2208#          immediately); if true, the tray will be opened regardless of whether
2209#          it is locked
2210#
2211# Since: 2.5
2212##
2213{ 'command': 'blockdev-open-tray',
2214  'data': { 'device': 'str',
2215            '*force': 'bool' } }
2216
2217##
2218# @blockdev-close-tray:
2219#
2220# Closes a block device's tray. If there is a block driver state tree associated
2221# with the block device (which is currently ejected), that tree will be loaded
2222# as the medium.
2223#
2224# If the tray was already closed before, this will be a no-op.
2225#
2226# @device: block device name
2227#
2228# Since: 2.5
2229##
2230{ 'command': 'blockdev-close-tray',
2231  'data': { 'device': 'str' } }
2232
2233##
2234# @x-blockdev-remove-medium:
2235#
2236# Removes a medium (a block driver state tree) from a block device. That block
2237# device's tray must currently be open (unless there is no attached guest
2238# device).
2239#
2240# If the tray is open and there is no medium inserted, this will be a no-op.
2241#
2242# This command is still a work in progress and is considered experimental.
2243# Stay away from it unless you want to help with its development.
2244#
2245# @device: block device name
2246#
2247# Since: 2.5
2248##
2249{ 'command': 'x-blockdev-remove-medium',
2250  'data': { 'device': 'str' } }
2251
2252##
2253# @x-blockdev-insert-medium:
2254#
2255# Inserts a medium (a block driver state tree) into a block device. That block
2256# device's tray must currently be open (unless there is no attached guest
2257# device) and there must be no medium inserted already.
2258#
2259# This command is still a work in progress and is considered experimental.
2260# Stay away from it unless you want to help with its development.
2261#
2262# @device:    block device name
2263#
2264# @node-name: name of a node in the block driver state graph
2265#
2266# Since: 2.5
2267##
2268{ 'command': 'x-blockdev-insert-medium',
2269  'data': { 'device': 'str',
2270            'node-name': 'str'} }
2271
2272
2273##
2274# @BlockdevChangeReadOnlyMode:
2275#
2276# Specifies the new read-only mode of a block device subject to the
2277# @blockdev-change-medium command.
2278#
2279# @retain:      Retains the current read-only mode
2280#
2281# @read-only:   Makes the device read-only
2282#
2283# @read-write:  Makes the device writable
2284#
2285# Since: 2.3
2286##
2287{ 'enum': 'BlockdevChangeReadOnlyMode',
2288  'data': ['retain', 'read-only', 'read-write'] }
2289
2290
2291##
2292# @blockdev-change-medium:
2293#
2294# Changes the medium inserted into a block device by ejecting the current medium
2295# and loading a new image file which is inserted as the new medium (this command
2296# combines blockdev-open-tray, x-blockdev-remove-medium,
2297# x-blockdev-insert-medium and blockdev-close-tray).
2298#
2299# @device:          block device name
2300#
2301# @filename:        filename of the new image to be loaded
2302#
2303# @format:          #optional, format to open the new image with (defaults to
2304#                   the probed format)
2305#
2306# @read-only-mode:  #optional, change the read-only mode of the device; defaults
2307#                   to 'retain'
2308#
2309# Since: 2.5
2310##
2311{ 'command': 'blockdev-change-medium',
2312  'data': { 'device': 'str',
2313            'filename': 'str',
2314            '*format': 'str',
2315            '*read-only-mode': 'BlockdevChangeReadOnlyMode' } }
2316
2317
2318##
2319# @BlockErrorAction
2320#
2321# An enumeration of action that has been taken when a DISK I/O occurs
2322#
2323# @ignore: error has been ignored
2324#
2325# @report: error has been reported to the device
2326#
2327# @stop: error caused VM to be stopped
2328#
2329# Since: 2.1
2330##
2331{ 'enum': 'BlockErrorAction',
2332  'data': [ 'ignore', 'report', 'stop' ] }
2333
2334
2335##
2336# @BLOCK_IMAGE_CORRUPTED
2337#
2338# Emitted when a corruption has been detected in a disk image
2339#
2340# @device: device name. This is always present for compatibility
2341#          reasons, but it can be empty ("") if the image does not
2342#          have a device name associated.
2343#
2344# @node-name: #optional node name (Since: 2.4)
2345#
2346# @msg: informative message for human consumption, such as the kind of
2347#       corruption being detected. It should not be parsed by machine as it is
2348#       not guaranteed to be stable
2349#
2350# @offset: #optional, if the corruption resulted from an image access, this is
2351#          the host's access offset into the image
2352#
2353# @size: #optional, if the corruption resulted from an image access, this is
2354#        the access size
2355#
2356# fatal: if set, the image is marked corrupt and therefore unusable after this
2357#        event and must be repaired (Since 2.2; before, every
2358#        BLOCK_IMAGE_CORRUPTED event was fatal)
2359#
2360# Since: 1.7
2361##
2362{ 'event': 'BLOCK_IMAGE_CORRUPTED',
2363  'data': { 'device'     : 'str',
2364            '*node-name' : 'str',
2365            'msg'        : 'str',
2366            '*offset'    : 'int',
2367            '*size'      : 'int',
2368            'fatal'      : 'bool' } }
2369
2370##
2371# @BLOCK_IO_ERROR
2372#
2373# Emitted when a disk I/O error occurs
2374#
2375# @device: device name
2376#
2377# @operation: I/O operation
2378#
2379# @action: action that has been taken
2380#
2381# @nospace: #optional true if I/O error was caused due to a no-space
2382#           condition. This key is only present if query-block's
2383#           io-status is present, please see query-block documentation
2384#           for more information (since: 2.2)
2385#
2386# @reason: human readable string describing the error cause.
2387#          (This field is a debugging aid for humans, it should not
2388#           be parsed by applications) (since: 2.2)
2389#
2390# Note: If action is "stop", a STOP event will eventually follow the
2391# BLOCK_IO_ERROR event
2392#
2393# Since: 0.13.0
2394##
2395{ 'event': 'BLOCK_IO_ERROR',
2396  'data': { 'device': 'str', 'operation': 'IoOperationType',
2397            'action': 'BlockErrorAction', '*nospace': 'bool',
2398            'reason': 'str' } }
2399
2400##
2401# @BLOCK_JOB_COMPLETED
2402#
2403# Emitted when a block job has completed
2404#
2405# @type: job type
2406#
2407# @device: device name
2408#
2409# @len: maximum progress value
2410#
2411# @offset: current progress value. On success this is equal to len.
2412#          On failure this is less than len
2413#
2414# @speed: rate limit, bytes per second
2415#
2416# @error: #optional, error message. Only present on failure. This field
2417#         contains a human-readable error message. There are no semantics
2418#         other than that streaming has failed and clients should not try to
2419#         interpret the error string
2420#
2421# Since: 1.1
2422##
2423{ 'event': 'BLOCK_JOB_COMPLETED',
2424  'data': { 'type'  : 'BlockJobType',
2425            'device': 'str',
2426            'len'   : 'int',
2427            'offset': 'int',
2428            'speed' : 'int',
2429            '*error': 'str' } }
2430
2431##
2432# @BLOCK_JOB_CANCELLED
2433#
2434# Emitted when a block job has been cancelled
2435#
2436# @type: job type
2437#
2438# @device: device name
2439#
2440# @len: maximum progress value
2441#
2442# @offset: current progress value. On success this is equal to len.
2443#          On failure this is less than len
2444#
2445# @speed: rate limit, bytes per second
2446#
2447# Since: 1.1
2448##
2449{ 'event': 'BLOCK_JOB_CANCELLED',
2450  'data': { 'type'  : 'BlockJobType',
2451            'device': 'str',
2452            'len'   : 'int',
2453            'offset': 'int',
2454            'speed' : 'int' } }
2455
2456##
2457# @BLOCK_JOB_ERROR
2458#
2459# Emitted when a block job encounters an error
2460#
2461# @device: device name
2462#
2463# @operation: I/O operation
2464#
2465# @action: action that has been taken
2466#
2467# Since: 1.3
2468##
2469{ 'event': 'BLOCK_JOB_ERROR',
2470  'data': { 'device'   : 'str',
2471            'operation': 'IoOperationType',
2472            'action'   : 'BlockErrorAction' } }
2473
2474##
2475# @BLOCK_JOB_READY
2476#
2477# Emitted when a block job is ready to complete
2478#
2479# @type: job type
2480#
2481# @device: device name
2482#
2483# @len: maximum progress value
2484#
2485# @offset: current progress value. On success this is equal to len.
2486#          On failure this is less than len
2487#
2488# @speed: rate limit, bytes per second
2489#
2490# Note: The "ready to complete" status is always reset by a @BLOCK_JOB_ERROR
2491# event
2492#
2493# Since: 1.3
2494##
2495{ 'event': 'BLOCK_JOB_READY',
2496  'data': { 'type'  : 'BlockJobType',
2497            'device': 'str',
2498            'len'   : 'int',
2499            'offset': 'int',
2500            'speed' : 'int' } }
2501
2502# @PreallocMode
2503#
2504# Preallocation mode of QEMU image file
2505#
2506# @off: no preallocation
2507# @metadata: preallocate only for metadata
2508# @falloc: like @full preallocation but allocate disk space by
2509#          posix_fallocate() rather than writing zeros.
2510# @full: preallocate all data by writing zeros to device to ensure disk
2511#        space is really available. @full preallocation also sets up
2512#        metadata correctly.
2513#
2514# Since 2.2
2515##
2516{ 'enum': 'PreallocMode',
2517  'data': [ 'off', 'metadata', 'falloc', 'full' ] }
2518
2519##
2520# @BLOCK_WRITE_THRESHOLD
2521#
2522# Emitted when writes on block device reaches or exceeds the
2523# configured write threshold. For thin-provisioned devices, this
2524# means the device should be extended to avoid pausing for
2525# disk exhaustion.
2526# The event is one shot. Once triggered, it needs to be
2527# re-registered with another block-set-threshold command.
2528#
2529# @node-name: graph node name on which the threshold was exceeded.
2530#
2531# @amount-exceeded: amount of data which exceeded the threshold, in bytes.
2532#
2533# @write-threshold: last configured threshold, in bytes.
2534#
2535# Since: 2.3
2536##
2537{ 'event': 'BLOCK_WRITE_THRESHOLD',
2538  'data': { 'node-name': 'str',
2539            'amount-exceeded': 'uint64',
2540            'write-threshold': 'uint64' } }
2541
2542##
2543# @block-set-write-threshold
2544#
2545# Change the write threshold for a block drive. An event will be delivered
2546# if a write to this block drive crosses the configured threshold.
2547# This is useful to transparently resize thin-provisioned drives without
2548# the guest OS noticing.
2549#
2550# @node-name: graph node name on which the threshold must be set.
2551#
2552# @write-threshold: configured threshold for the block device, bytes.
2553#                   Use 0 to disable the threshold.
2554#
2555# Since: 2.3
2556##
2557{ 'command': 'block-set-write-threshold',
2558  'data': { 'node-name': 'str', 'write-threshold': 'uint64' } }
2559