xref: /openbmc/qemu/qapi/block-core.json (revision 69430111)
1# -*- Mode: Python -*-
2# vim: filetype=python
3
4##
5# == Block core (VM unrelated)
6##
7
8{ 'include': 'common.json' }
9{ 'include': 'crypto.json' }
10{ 'include': 'job.json' }
11{ 'include': 'sockets.json' }
12
13##
14# @SnapshotInfo:
15#
16# @id: unique snapshot id
17#
18# @name: user chosen name
19#
20# @vm-state-size: size of the VM state
21#
22# @date-sec: UTC date of the snapshot in seconds
23#
24# @date-nsec: fractional part in nano seconds to be used with date-sec
25#
26# @vm-clock-sec: VM clock relative to boot in seconds
27#
28# @vm-clock-nsec: fractional part in nano seconds to be used with vm-clock-sec
29#
30# @icount: Current instruction count. Appears when execution record/replay
31#          is enabled. Used for "time-traveling" to match the moment
32#          in the recorded execution with the snapshots. This counter may
33#          be obtained through @query-replay command (since 5.2)
34#
35# Since: 1.3
36#
37##
38{ 'struct': 'SnapshotInfo',
39  'data': { 'id': 'str', 'name': 'str', 'vm-state-size': 'int',
40            'date-sec': 'int', 'date-nsec': 'int',
41            'vm-clock-sec': 'int', 'vm-clock-nsec': 'int',
42            '*icount': 'int' } }
43
44##
45# @ImageInfoSpecificQCow2EncryptionBase:
46#
47# @format: The encryption format
48#
49# Since: 2.10
50##
51{ 'struct': 'ImageInfoSpecificQCow2EncryptionBase',
52  'data': { 'format': 'BlockdevQcow2EncryptionFormat'}}
53
54##
55# @ImageInfoSpecificQCow2Encryption:
56#
57# Since: 2.10
58##
59{ 'union': 'ImageInfoSpecificQCow2Encryption',
60  'base': 'ImageInfoSpecificQCow2EncryptionBase',
61  'discriminator': 'format',
62  'data': { 'luks': 'QCryptoBlockInfoLUKS' } }
63
64##
65# @ImageInfoSpecificQCow2:
66#
67# @compat: compatibility level
68#
69# @data-file: the filename of the external data file that is stored in the
70#             image and used as a default for opening the image (since: 4.0)
71#
72# @data-file-raw: True if the external data file must stay valid as a
73#                 standalone (read-only) raw image without looking at qcow2
74#                 metadata (since: 4.0)
75#
76# @extended-l2: true if the image has extended L2 entries; only valid for
77#               compat >= 1.1 (since 5.2)
78#
79# @lazy-refcounts: on or off; only valid for compat >= 1.1
80#
81# @corrupt: true if the image has been marked corrupt; only valid for
82#           compat >= 1.1 (since 2.2)
83#
84# @refcount-bits: width of a refcount entry in bits (since 2.3)
85#
86# @encrypt: details about encryption parameters; only set if image
87#           is encrypted (since 2.10)
88#
89# @bitmaps: A list of qcow2 bitmap details (since 4.0)
90#
91# @compression-type: the image cluster compression method (since 5.1)
92#
93# Since: 1.7
94##
95{ 'struct': 'ImageInfoSpecificQCow2',
96  'data': {
97      'compat': 'str',
98      '*data-file': 'str',
99      '*data-file-raw': 'bool',
100      '*extended-l2': 'bool',
101      '*lazy-refcounts': 'bool',
102      '*corrupt': 'bool',
103      'refcount-bits': 'int',
104      '*encrypt': 'ImageInfoSpecificQCow2Encryption',
105      '*bitmaps': ['Qcow2BitmapInfo'],
106      'compression-type': 'Qcow2CompressionType'
107  } }
108
109##
110# @ImageInfoSpecificVmdk:
111#
112# @create-type: The create type of VMDK image
113#
114# @cid: Content id of image
115#
116# @parent-cid: Parent VMDK image's cid
117#
118# @extents: List of extent files
119#
120# Since: 1.7
121##
122{ 'struct': 'ImageInfoSpecificVmdk',
123  'data': {
124      'create-type': 'str',
125      'cid': 'int',
126      'parent-cid': 'int',
127      'extents': ['ImageInfo']
128  } }
129
130##
131# @ImageInfoSpecific:
132#
133# A discriminated record of image format specific information structures.
134#
135# Since: 1.7
136##
137{ 'union': 'ImageInfoSpecific',
138  'data': {
139      'qcow2': 'ImageInfoSpecificQCow2',
140      'vmdk': 'ImageInfoSpecificVmdk',
141      # If we need to add block driver specific parameters for
142      # LUKS in future, then we'll subclass QCryptoBlockInfoLUKS
143      # to define a ImageInfoSpecificLUKS
144      'luks': 'QCryptoBlockInfoLUKS'
145  } }
146
147##
148# @ImageInfo:
149#
150# Information about a QEMU image file
151#
152# @filename: name of the image file
153#
154# @format: format of the image file
155#
156# @virtual-size: maximum capacity in bytes of the image
157#
158# @actual-size: actual size on disk in bytes of the image
159#
160# @dirty-flag: true if image is not cleanly closed
161#
162# @cluster-size: size of a cluster in bytes
163#
164# @encrypted: true if the image is encrypted
165#
166# @compressed: true if the image is compressed (Since 1.7)
167#
168# @backing-filename: name of the backing file
169#
170# @full-backing-filename: full path of the backing file
171#
172# @backing-filename-format: the format of the backing file
173#
174# @snapshots: list of VM snapshots
175#
176# @backing-image: info of the backing image (since 1.6)
177#
178# @format-specific: structure supplying additional format-specific
179#                   information (since 1.7)
180#
181# Since: 1.3
182#
183##
184{ 'struct': 'ImageInfo',
185  'data': {'filename': 'str', 'format': 'str', '*dirty-flag': 'bool',
186           '*actual-size': 'int', 'virtual-size': 'int',
187           '*cluster-size': 'int', '*encrypted': 'bool', '*compressed': 'bool',
188           '*backing-filename': 'str', '*full-backing-filename': 'str',
189           '*backing-filename-format': 'str', '*snapshots': ['SnapshotInfo'],
190           '*backing-image': 'ImageInfo',
191           '*format-specific': 'ImageInfoSpecific' } }
192
193##
194# @ImageCheck:
195#
196# Information about a QEMU image file check
197#
198# @filename: name of the image file checked
199#
200# @format: format of the image file checked
201#
202# @check-errors: number of unexpected errors occurred during check
203#
204# @image-end-offset: offset (in bytes) where the image ends, this
205#                    field is present if the driver for the image format
206#                    supports it
207#
208# @corruptions: number of corruptions found during the check if any
209#
210# @leaks: number of leaks found during the check if any
211#
212# @corruptions-fixed: number of corruptions fixed during the check
213#                     if any
214#
215# @leaks-fixed: number of leaks fixed during the check if any
216#
217# @total-clusters: total number of clusters, this field is present
218#                  if the driver for the image format supports it
219#
220# @allocated-clusters: total number of allocated clusters, this
221#                      field is present if the driver for the image format
222#                      supports it
223#
224# @fragmented-clusters: total number of fragmented clusters, this
225#                       field is present if the driver for the image format
226#                       supports it
227#
228# @compressed-clusters: total number of compressed clusters, this
229#                       field is present if the driver for the image format
230#                       supports it
231#
232# Since: 1.4
233#
234##
235{ 'struct': 'ImageCheck',
236  'data': {'filename': 'str', 'format': 'str', 'check-errors': 'int',
237           '*image-end-offset': 'int', '*corruptions': 'int', '*leaks': 'int',
238           '*corruptions-fixed': 'int', '*leaks-fixed': 'int',
239           '*total-clusters': 'int', '*allocated-clusters': 'int',
240           '*fragmented-clusters': 'int', '*compressed-clusters': 'int' } }
241
242##
243# @MapEntry:
244#
245# Mapping information from a virtual block range to a host file range
246#
247# @start: the start byte of the mapped virtual range
248#
249# @length: the number of bytes of the mapped virtual range
250#
251# @data: whether the mapped range has data
252#
253# @zero: whether the virtual blocks are zeroed
254#
255# @depth: the depth of the mapping
256#
257# @offset: the offset in file that the virtual sectors are mapped to
258#
259# @filename: filename that is referred to by @offset
260#
261# Since: 2.6
262#
263##
264{ 'struct': 'MapEntry',
265  'data': {'start': 'int', 'length': 'int', 'data': 'bool',
266           'zero': 'bool', 'depth': 'int', '*offset': 'int',
267           '*filename': 'str' } }
268
269##
270# @BlockdevCacheInfo:
271#
272# Cache mode information for a block device
273#
274# @writeback:   true if writeback mode is enabled
275# @direct:      true if the host page cache is bypassed (O_DIRECT)
276# @no-flush:    true if flush requests are ignored for the device
277#
278# Since: 2.3
279##
280{ 'struct': 'BlockdevCacheInfo',
281  'data': { 'writeback': 'bool',
282            'direct': 'bool',
283            'no-flush': 'bool' } }
284
285##
286# @BlockDeviceInfo:
287#
288# Information about the backing device for a block device.
289#
290# @file: the filename of the backing device
291#
292# @node-name: the name of the block driver node (Since 2.0)
293#
294# @ro: true if the backing device was open read-only
295#
296# @drv: the name of the block format used to open the backing device. As of
297#       0.14.0 this can be: 'blkdebug', 'bochs', 'cloop', 'cow', 'dmg',
298#       'file', 'file', 'ftp', 'ftps', 'host_cdrom', 'host_device',
299#       'http', 'https', 'luks', 'nbd', 'parallels', 'qcow',
300#       'qcow2', 'raw', 'vdi', 'vmdk', 'vpc', 'vvfat'
301#       2.2: 'archipelago' added, 'cow' dropped
302#       2.3: 'host_floppy' deprecated
303#       2.5: 'host_floppy' dropped
304#       2.6: 'luks' added
305#       2.8: 'replication' added, 'tftp' dropped
306#       2.9: 'archipelago' dropped
307#
308# @backing_file: the name of the backing file (for copy-on-write)
309#
310# @backing_file_depth: number of files in the backing file chain (since: 1.2)
311#
312# @encrypted: true if the backing device is encrypted
313#
314# @encryption_key_missing: always false
315#
316# @detect_zeroes: detect and optimize zero writes (Since 2.1)
317#
318# @bps: total throughput limit in bytes per second is specified
319#
320# @bps_rd: read throughput limit in bytes per second is specified
321#
322# @bps_wr: write throughput limit in bytes per second is specified
323#
324# @iops: total I/O operations per second is specified
325#
326# @iops_rd: read I/O operations per second is specified
327#
328# @iops_wr: write I/O operations per second is specified
329#
330# @image: the info of image used (since: 1.6)
331#
332# @bps_max: total throughput limit during bursts,
333#                     in bytes (Since 1.7)
334#
335# @bps_rd_max: read throughput limit during bursts,
336#                        in bytes (Since 1.7)
337#
338# @bps_wr_max: write throughput limit during bursts,
339#                        in bytes (Since 1.7)
340#
341# @iops_max: total I/O operations per second during bursts,
342#                      in bytes (Since 1.7)
343#
344# @iops_rd_max: read I/O operations per second during bursts,
345#                         in bytes (Since 1.7)
346#
347# @iops_wr_max: write I/O operations per second during bursts,
348#                         in bytes (Since 1.7)
349#
350# @bps_max_length: maximum length of the @bps_max burst
351#                            period, in seconds. (Since 2.6)
352#
353# @bps_rd_max_length: maximum length of the @bps_rd_max
354#                               burst period, in seconds. (Since 2.6)
355#
356# @bps_wr_max_length: maximum length of the @bps_wr_max
357#                               burst period, in seconds. (Since 2.6)
358#
359# @iops_max_length: maximum length of the @iops burst
360#                             period, in seconds. (Since 2.6)
361#
362# @iops_rd_max_length: maximum length of the @iops_rd_max
363#                                burst period, in seconds. (Since 2.6)
364#
365# @iops_wr_max_length: maximum length of the @iops_wr_max
366#                                burst period, in seconds. (Since 2.6)
367#
368# @iops_size: an I/O size in bytes (Since 1.7)
369#
370# @group: throttle group name (Since 2.4)
371#
372# @cache: the cache mode used for the block device (since: 2.3)
373#
374# @write_threshold: configured write threshold for the device.
375#                   0 if disabled. (Since 2.3)
376#
377# @dirty-bitmaps: dirty bitmaps information (only present if node
378#                 has one or more dirty bitmaps) (Since 4.2)
379#
380# Features:
381# @deprecated: Member @encryption_key_missing is deprecated.  It is
382#              always false.
383#
384# Since: 0.14.0
385#
386##
387{ 'struct': 'BlockDeviceInfo',
388  'data': { 'file': 'str', '*node-name': 'str', 'ro': 'bool', 'drv': 'str',
389            '*backing_file': 'str', 'backing_file_depth': 'int',
390            'encrypted': 'bool',
391            'encryption_key_missing': { 'type': 'bool',
392                                        'features': [ 'deprecated' ] },
393            'detect_zeroes': 'BlockdevDetectZeroesOptions',
394            'bps': 'int', 'bps_rd': 'int', 'bps_wr': 'int',
395            'iops': 'int', 'iops_rd': 'int', 'iops_wr': 'int',
396            'image': 'ImageInfo',
397            '*bps_max': 'int', '*bps_rd_max': 'int',
398            '*bps_wr_max': 'int', '*iops_max': 'int',
399            '*iops_rd_max': 'int', '*iops_wr_max': 'int',
400            '*bps_max_length': 'int', '*bps_rd_max_length': 'int',
401            '*bps_wr_max_length': 'int', '*iops_max_length': 'int',
402            '*iops_rd_max_length': 'int', '*iops_wr_max_length': 'int',
403            '*iops_size': 'int', '*group': 'str', 'cache': 'BlockdevCacheInfo',
404            'write_threshold': 'int', '*dirty-bitmaps': ['BlockDirtyInfo'] } }
405
406##
407# @BlockDeviceIoStatus:
408#
409# An enumeration of block device I/O status.
410#
411# @ok: The last I/O operation has succeeded
412#
413# @failed: The last I/O operation has failed
414#
415# @nospace: The last I/O operation has failed due to a no-space condition
416#
417# Since: 1.0
418##
419{ 'enum': 'BlockDeviceIoStatus', 'data': [ 'ok', 'failed', 'nospace' ] }
420
421##
422# @BlockDeviceMapEntry:
423#
424# Entry in the metadata map of the device (returned by "qemu-img map")
425#
426# @start: Offset in the image of the first byte described by this entry
427#         (in bytes)
428#
429# @length: Length of the range described by this entry (in bytes)
430#
431# @depth: Number of layers (0 = top image, 1 = top image's backing file, etc.)
432#         before reaching one for which the range is allocated.  The value is
433#         in the range 0 to the depth of the image chain - 1.
434#
435# @zero: the sectors in this range read as zeros
436#
437# @data: reading the image will actually read data from a file (in particular,
438#        if @offset is present this means that the sectors are not simply
439#        preallocated, but contain actual data in raw format)
440#
441# @offset: if present, the image file stores the data for this range in
442#          raw format at the given offset.
443#
444# Since: 1.7
445##
446{ 'struct': 'BlockDeviceMapEntry',
447  'data': { 'start': 'int', 'length': 'int', 'depth': 'int', 'zero': 'bool',
448            'data': 'bool', '*offset': 'int' } }
449
450##
451# @DirtyBitmapStatus:
452#
453# An enumeration of possible states that a dirty bitmap can report to the user.
454#
455# @frozen: The bitmap is currently in-use by some operation and is immutable.
456#          If the bitmap was @active prior to the operation, new writes by the
457#          guest are being recorded in a temporary buffer, and will not be lost.
458#          Generally, bitmaps are cleared on successful use in an operation and
459#          the temporary buffer is committed into the bitmap. On failure, the
460#          temporary buffer is merged back into the bitmap without first
461#          clearing it.
462#          Please refer to the documentation for each bitmap-using operation,
463#          See also @blockdev-backup, @drive-backup.
464#
465# @disabled: The bitmap is not currently recording new writes by the guest.
466#            This is requested explicitly via @block-dirty-bitmap-disable.
467#            It can still be cleared, deleted, or used for backup operations.
468#
469# @active: The bitmap is actively monitoring for new writes, and can be cleared,
470#          deleted, or used for backup operations.
471#
472# @locked: The bitmap is currently in-use by some operation and is immutable.
473#          If the bitmap was @active prior to the operation, it is still
474#          recording new writes. If the bitmap was @disabled, it is not
475#          recording new writes. (Since 2.12)
476#
477# @inconsistent: This is a persistent dirty bitmap that was marked in-use on
478#                disk, and is unusable by QEMU. It can only be deleted.
479#                Please rely on the inconsistent field in @BlockDirtyInfo
480#                instead, as the status field is deprecated. (Since 4.0)
481#
482# Since: 2.4
483##
484{ 'enum': 'DirtyBitmapStatus',
485  'data': ['active', 'disabled', 'frozen', 'locked', 'inconsistent'] }
486
487##
488# @BlockDirtyInfo:
489#
490# Block dirty bitmap information.
491#
492# @name: the name of the dirty bitmap (Since 2.4)
493#
494# @count: number of dirty bytes according to the dirty bitmap
495#
496# @granularity: granularity of the dirty bitmap in bytes (since 1.4)
497#
498# @status: current status of the dirty bitmap (since 2.4)
499#
500# @recording: true if the bitmap is recording new writes from the guest.
501#             Replaces `active` and `disabled` statuses. (since 4.0)
502#
503# @busy: true if the bitmap is in-use by some operation (NBD or jobs)
504#        and cannot be modified via QMP or used by another operation.
505#        Replaces `locked` and `frozen` statuses. (since 4.0)
506#
507# @persistent: true if the bitmap was stored on disk, is scheduled to be stored
508#              on disk, or both. (since 4.0)
509#
510# @inconsistent: true if this is a persistent bitmap that was improperly
511#                stored. Implies @persistent to be true; @recording and
512#                @busy to be false. This bitmap cannot be used. To remove
513#                it, use @block-dirty-bitmap-remove. (Since 4.0)
514#
515# Features:
516# @deprecated: Member @status is deprecated.  Use @recording and
517#              @locked instead.
518#
519# Since: 1.3
520##
521{ 'struct': 'BlockDirtyInfo',
522  'data': {'*name': 'str', 'count': 'int', 'granularity': 'uint32',
523           'recording': 'bool', 'busy': 'bool',
524           'status': { 'type': 'DirtyBitmapStatus',
525                       'features': [ 'deprecated' ] },
526           'persistent': 'bool', '*inconsistent': 'bool' } }
527
528##
529# @Qcow2BitmapInfoFlags:
530#
531# An enumeration of flags that a bitmap can report to the user.
532#
533# @in-use: This flag is set by any process actively modifying the qcow2 file,
534#          and cleared when the updated bitmap is flushed to the qcow2 image.
535#          The presence of this flag in an offline image means that the bitmap
536#          was not saved correctly after its last usage, and may contain
537#          inconsistent data.
538#
539# @auto: The bitmap must reflect all changes of the virtual disk by any
540#        application that would write to this qcow2 file.
541#
542# Since: 4.0
543##
544{ 'enum': 'Qcow2BitmapInfoFlags',
545  'data': ['in-use', 'auto'] }
546
547##
548# @Qcow2BitmapInfo:
549#
550# Qcow2 bitmap information.
551#
552# @name: the name of the bitmap
553#
554# @granularity: granularity of the bitmap in bytes
555#
556# @flags: flags of the bitmap
557#
558# Since: 4.0
559##
560{ 'struct': 'Qcow2BitmapInfo',
561  'data': {'name': 'str', 'granularity': 'uint32',
562           'flags': ['Qcow2BitmapInfoFlags'] } }
563
564##
565# @BlockLatencyHistogramInfo:
566#
567# Block latency histogram.
568#
569# @boundaries: list of interval boundary values in nanoseconds, all greater
570#              than zero and in ascending order.
571#              For example, the list [10, 50, 100] produces the following
572#              histogram intervals: [0, 10), [10, 50), [50, 100), [100, +inf).
573#
574# @bins: list of io request counts corresponding to histogram intervals.
575#        len(@bins) = len(@boundaries) + 1
576#        For the example above, @bins may be something like [3, 1, 5, 2],
577#        and corresponding histogram looks like:
578#
579# ::
580#
581#        5|           *
582#        4|           *
583#        3| *         *
584#        2| *         *    *
585#        1| *    *    *    *
586#         +------------------
587#             10   50   100
588#
589# Since: 4.0
590##
591{ 'struct': 'BlockLatencyHistogramInfo',
592  'data': {'boundaries': ['uint64'], 'bins': ['uint64'] } }
593
594##
595# @BlockInfo:
596#
597# Block device information.  This structure describes a virtual device and
598# the backing device associated with it.
599#
600# @device: The device name associated with the virtual device.
601#
602# @qdev: The qdev ID, or if no ID is assigned, the QOM path of the block
603#        device. (since 2.10)
604#
605# @type: This field is returned only for compatibility reasons, it should
606#        not be used (always returns 'unknown')
607#
608# @removable: True if the device supports removable media.
609#
610# @locked: True if the guest has locked this device from having its media
611#          removed
612#
613# @tray_open: True if the device's tray is open
614#             (only present if it has a tray)
615#
616# @dirty-bitmaps: dirty bitmaps information (only present if the
617#                 driver has one or more dirty bitmaps) (Since 2.0)
618#
619# @io-status: @BlockDeviceIoStatus. Only present if the device
620#             supports it and the VM is configured to stop on errors
621#             (supported device models: virtio-blk, IDE, SCSI except
622#             scsi-generic)
623#
624# @inserted: @BlockDeviceInfo describing the device if media is
625#            present
626#
627# Features:
628# @deprecated: Member @dirty-bitmaps is deprecated.  Use @inserted
629#              member @dirty-bitmaps instead.
630#
631# Since:  0.14.0
632##
633{ 'struct': 'BlockInfo',
634  'data': {'device': 'str', '*qdev': 'str', 'type': 'str', 'removable': 'bool',
635           'locked': 'bool', '*inserted': 'BlockDeviceInfo',
636           '*tray_open': 'bool', '*io-status': 'BlockDeviceIoStatus',
637           '*dirty-bitmaps': { 'type': ['BlockDirtyInfo'],
638                               'features': [ 'deprecated' ] } } }
639
640##
641# @BlockMeasureInfo:
642#
643# Image file size calculation information.  This structure describes the size
644# requirements for creating a new image file.
645#
646# The size requirements depend on the new image file format.  File size always
647# equals virtual disk size for the 'raw' format, even for sparse POSIX files.
648# Compact formats such as 'qcow2' represent unallocated and zero regions
649# efficiently so file size may be smaller than virtual disk size.
650#
651# The values are upper bounds that are guaranteed to fit the new image file.
652# Subsequent modification, such as internal snapshot or further bitmap
653# creation, may require additional space and is not covered here.
654#
655# @required: Size required for a new image file, in bytes, when copying just
656#            allocated guest-visible contents.
657#
658# @fully-allocated: Image file size, in bytes, once data has been written
659#                   to all sectors, when copying just guest-visible contents.
660#
661# @bitmaps: Additional size required if all the top-level bitmap metadata
662#           in the source image were to be copied to the destination,
663#           present only when source and destination both support
664#           persistent bitmaps. (since 5.1)
665#
666# Since: 2.10
667##
668{ 'struct': 'BlockMeasureInfo',
669  'data': {'required': 'int', 'fully-allocated': 'int', '*bitmaps': 'int'} }
670
671##
672# @query-block:
673#
674# Get a list of BlockInfo for all virtual block devices.
675#
676# Returns: a list of @BlockInfo describing each virtual block device. Filter
677#          nodes that were created implicitly are skipped over.
678#
679# Since: 0.14.0
680#
681# Example:
682#
683# -> { "execute": "query-block" }
684# <- {
685#       "return":[
686#          {
687#             "io-status": "ok",
688#             "device":"ide0-hd0",
689#             "locked":false,
690#             "removable":false,
691#             "inserted":{
692#                "ro":false,
693#                "drv":"qcow2",
694#                "encrypted":false,
695#                "file":"disks/test.qcow2",
696#                "backing_file_depth":1,
697#                "bps":1000000,
698#                "bps_rd":0,
699#                "bps_wr":0,
700#                "iops":1000000,
701#                "iops_rd":0,
702#                "iops_wr":0,
703#                "bps_max": 8000000,
704#                "bps_rd_max": 0,
705#                "bps_wr_max": 0,
706#                "iops_max": 0,
707#                "iops_rd_max": 0,
708#                "iops_wr_max": 0,
709#                "iops_size": 0,
710#                "detect_zeroes": "on",
711#                "write_threshold": 0,
712#                "image":{
713#                   "filename":"disks/test.qcow2",
714#                   "format":"qcow2",
715#                   "virtual-size":2048000,
716#                   "backing_file":"base.qcow2",
717#                   "full-backing-filename":"disks/base.qcow2",
718#                   "backing-filename-format":"qcow2",
719#                   "snapshots":[
720#                      {
721#                         "id": "1",
722#                         "name": "snapshot1",
723#                         "vm-state-size": 0,
724#                         "date-sec": 10000200,
725#                         "date-nsec": 12,
726#                         "vm-clock-sec": 206,
727#                         "vm-clock-nsec": 30
728#                      }
729#                   ],
730#                   "backing-image":{
731#                       "filename":"disks/base.qcow2",
732#                       "format":"qcow2",
733#                       "virtual-size":2048000
734#                   }
735#                }
736#             },
737#             "qdev": "ide_disk",
738#             "type":"unknown"
739#          },
740#          {
741#             "io-status": "ok",
742#             "device":"ide1-cd0",
743#             "locked":false,
744#             "removable":true,
745#             "qdev": "/machine/unattached/device[23]",
746#             "tray_open": false,
747#             "type":"unknown"
748#          },
749#          {
750#             "device":"floppy0",
751#             "locked":false,
752#             "removable":true,
753#             "qdev": "/machine/unattached/device[20]",
754#             "type":"unknown"
755#          },
756#          {
757#             "device":"sd0",
758#             "locked":false,
759#             "removable":true,
760#             "type":"unknown"
761#          }
762#       ]
763#    }
764#
765##
766{ 'command': 'query-block', 'returns': ['BlockInfo'] }
767
768
769##
770# @BlockDeviceTimedStats:
771#
772# Statistics of a block device during a given interval of time.
773#
774# @interval_length: Interval used for calculating the statistics,
775#                   in seconds.
776#
777# @min_rd_latency_ns: Minimum latency of read operations in the
778#                     defined interval, in nanoseconds.
779#
780# @min_wr_latency_ns: Minimum latency of write operations in the
781#                     defined interval, in nanoseconds.
782#
783# @min_flush_latency_ns: Minimum latency of flush operations in the
784#                        defined interval, in nanoseconds.
785#
786# @max_rd_latency_ns: Maximum latency of read operations in the
787#                     defined interval, in nanoseconds.
788#
789# @max_wr_latency_ns: Maximum latency of write operations in the
790#                     defined interval, in nanoseconds.
791#
792# @max_flush_latency_ns: Maximum latency of flush operations in the
793#                        defined interval, in nanoseconds.
794#
795# @avg_rd_latency_ns: Average latency of read operations in the
796#                     defined interval, in nanoseconds.
797#
798# @avg_wr_latency_ns: Average latency of write operations in the
799#                     defined interval, in nanoseconds.
800#
801# @avg_flush_latency_ns: Average latency of flush operations in the
802#                        defined interval, in nanoseconds.
803#
804# @avg_rd_queue_depth: Average number of pending read operations
805#                      in the defined interval.
806#
807# @avg_wr_queue_depth: Average number of pending write operations
808#                      in the defined interval.
809#
810# Since: 2.5
811##
812{ 'struct': 'BlockDeviceTimedStats',
813  'data': { 'interval_length': 'int', 'min_rd_latency_ns': 'int',
814            'max_rd_latency_ns': 'int', 'avg_rd_latency_ns': 'int',
815            'min_wr_latency_ns': 'int', 'max_wr_latency_ns': 'int',
816            'avg_wr_latency_ns': 'int', 'min_flush_latency_ns': 'int',
817            'max_flush_latency_ns': 'int', 'avg_flush_latency_ns': 'int',
818            'avg_rd_queue_depth': 'number', 'avg_wr_queue_depth': 'number' } }
819
820##
821# @BlockDeviceStats:
822#
823# Statistics of a virtual block device or a block backing device.
824#
825# @rd_bytes:      The number of bytes read by the device.
826#
827# @wr_bytes:      The number of bytes written by the device.
828#
829# @unmap_bytes: The number of bytes unmapped by the device (Since 4.2)
830#
831# @rd_operations: The number of read operations performed by the device.
832#
833# @wr_operations: The number of write operations performed by the device.
834#
835# @flush_operations: The number of cache flush operations performed by the
836#                    device (since 0.15.0)
837#
838# @unmap_operations: The number of unmap operations performed by the device
839#                    (Since 4.2)
840#
841# @rd_total_time_ns: Total time spent on reads in nanoseconds (since 0.15.0).
842#
843# @wr_total_time_ns: Total time spent on writes in nanoseconds (since 0.15.0).
844#
845# @flush_total_time_ns: Total time spent on cache flushes in nanoseconds
846#                       (since 0.15.0).
847#
848# @unmap_total_time_ns: Total time spent on unmap operations in nanoseconds
849#                       (Since 4.2)
850#
851# @wr_highest_offset: The offset after the greatest byte written to the
852#                     device.  The intended use of this information is for
853#                     growable sparse files (like qcow2) that are used on top
854#                     of a physical device.
855#
856# @rd_merged: Number of read requests that have been merged into another
857#             request (Since 2.3).
858#
859# @wr_merged: Number of write requests that have been merged into another
860#             request (Since 2.3).
861#
862# @unmap_merged: Number of unmap requests that have been merged into another
863#                request (Since 4.2)
864#
865# @idle_time_ns: Time since the last I/O operation, in
866#                nanoseconds. If the field is absent it means that
867#                there haven't been any operations yet (Since 2.5).
868#
869# @failed_rd_operations: The number of failed read operations
870#                        performed by the device (Since 2.5)
871#
872# @failed_wr_operations: The number of failed write operations
873#                        performed by the device (Since 2.5)
874#
875# @failed_flush_operations: The number of failed flush operations
876#                           performed by the device (Since 2.5)
877#
878# @failed_unmap_operations: The number of failed unmap operations performed
879#                           by the device (Since 4.2)
880#
881# @invalid_rd_operations: The number of invalid read operations
882#                          performed by the device (Since 2.5)
883#
884# @invalid_wr_operations: The number of invalid write operations
885#                         performed by the device (Since 2.5)
886#
887# @invalid_flush_operations: The number of invalid flush operations
888#                            performed by the device (Since 2.5)
889#
890# @invalid_unmap_operations: The number of invalid unmap operations performed
891#                            by the device (Since 4.2)
892#
893# @account_invalid: Whether invalid operations are included in the
894#                   last access statistics (Since 2.5)
895#
896# @account_failed: Whether failed operations are included in the
897#                  latency and last access statistics (Since 2.5)
898#
899# @timed_stats: Statistics specific to the set of previously defined
900#               intervals of time (Since 2.5)
901#
902# @rd_latency_histogram: @BlockLatencyHistogramInfo. (Since 4.0)
903#
904# @wr_latency_histogram: @BlockLatencyHistogramInfo. (Since 4.0)
905#
906# @flush_latency_histogram: @BlockLatencyHistogramInfo. (Since 4.0)
907#
908# Since: 0.14.0
909##
910{ 'struct': 'BlockDeviceStats',
911  'data': {'rd_bytes': 'int', 'wr_bytes': 'int', 'unmap_bytes' : 'int',
912           'rd_operations': 'int', 'wr_operations': 'int',
913           'flush_operations': 'int', 'unmap_operations': 'int',
914           'rd_total_time_ns': 'int', 'wr_total_time_ns': 'int',
915           'flush_total_time_ns': 'int', 'unmap_total_time_ns': 'int',
916           'wr_highest_offset': 'int',
917           'rd_merged': 'int', 'wr_merged': 'int', 'unmap_merged': 'int',
918           '*idle_time_ns': 'int',
919           'failed_rd_operations': 'int', 'failed_wr_operations': 'int',
920           'failed_flush_operations': 'int', 'failed_unmap_operations': 'int',
921           'invalid_rd_operations': 'int', 'invalid_wr_operations': 'int',
922           'invalid_flush_operations': 'int', 'invalid_unmap_operations': 'int',
923           'account_invalid': 'bool', 'account_failed': 'bool',
924           'timed_stats': ['BlockDeviceTimedStats'],
925           '*rd_latency_histogram': 'BlockLatencyHistogramInfo',
926           '*wr_latency_histogram': 'BlockLatencyHistogramInfo',
927           '*flush_latency_histogram': 'BlockLatencyHistogramInfo' } }
928
929##
930# @BlockStatsSpecificFile:
931#
932# File driver statistics
933#
934# @discard-nb-ok: The number of successful discard operations performed by
935#                 the driver.
936#
937# @discard-nb-failed: The number of failed discard operations performed by
938#                     the driver.
939#
940# @discard-bytes-ok: The number of bytes discarded by the driver.
941#
942# Since: 4.2
943##
944{ 'struct': 'BlockStatsSpecificFile',
945  'data': {
946      'discard-nb-ok': 'uint64',
947      'discard-nb-failed': 'uint64',
948      'discard-bytes-ok': 'uint64' } }
949
950##
951# @BlockStatsSpecific:
952#
953# Block driver specific statistics
954#
955# Since: 4.2
956##
957{ 'union': 'BlockStatsSpecific',
958  'base': { 'driver': 'BlockdevDriver' },
959  'discriminator': 'driver',
960  'data': {
961      'file': 'BlockStatsSpecificFile',
962      'host_device': 'BlockStatsSpecificFile' } }
963
964##
965# @BlockStats:
966#
967# Statistics of a virtual block device or a block backing device.
968#
969# @device: If the stats are for a virtual block device, the name
970#          corresponding to the virtual block device.
971#
972# @node-name: The node name of the device. (Since 2.3)
973#
974# @qdev: The qdev ID, or if no ID is assigned, the QOM path of the block
975#        device. (since 3.0)
976#
977# @stats:  A @BlockDeviceStats for the device.
978#
979# @driver-specific: Optional driver-specific stats. (Since 4.2)
980#
981# @parent: This describes the file block device if it has one.
982#          Contains recursively the statistics of the underlying
983#          protocol (e.g. the host file for a qcow2 image). If there is
984#          no underlying protocol, this field is omitted
985#
986# @backing: This describes the backing block device if it has one.
987#           (Since 2.0)
988#
989# Since: 0.14.0
990##
991{ 'struct': 'BlockStats',
992  'data': {'*device': 'str', '*qdev': 'str', '*node-name': 'str',
993           'stats': 'BlockDeviceStats',
994           '*driver-specific': 'BlockStatsSpecific',
995           '*parent': 'BlockStats',
996           '*backing': 'BlockStats'} }
997
998##
999# @query-blockstats:
1000#
1001# Query the @BlockStats for all virtual block devices.
1002#
1003# @query-nodes: If true, the command will query all the block nodes
1004#               that have a node name, in a list which will include "parent"
1005#               information, but not "backing".
1006#               If false or omitted, the behavior is as before - query all the
1007#               device backends, recursively including their "parent" and
1008#               "backing". Filter nodes that were created implicitly are
1009#               skipped over in this mode. (Since 2.3)
1010#
1011# Returns: A list of @BlockStats for each virtual block devices.
1012#
1013# Since: 0.14.0
1014#
1015# Example:
1016#
1017# -> { "execute": "query-blockstats" }
1018# <- {
1019#       "return":[
1020#          {
1021#             "device":"ide0-hd0",
1022#             "parent":{
1023#                "stats":{
1024#                   "wr_highest_offset":3686448128,
1025#                   "wr_bytes":9786368,
1026#                   "wr_operations":751,
1027#                   "rd_bytes":122567168,
1028#                   "rd_operations":36772
1029#                   "wr_total_times_ns":313253456
1030#                   "rd_total_times_ns":3465673657
1031#                   "flush_total_times_ns":49653
1032#                   "flush_operations":61,
1033#                   "rd_merged":0,
1034#                   "wr_merged":0,
1035#                   "idle_time_ns":2953431879,
1036#                   "account_invalid":true,
1037#                   "account_failed":false
1038#                }
1039#             },
1040#             "stats":{
1041#                "wr_highest_offset":2821110784,
1042#                "wr_bytes":9786368,
1043#                "wr_operations":692,
1044#                "rd_bytes":122739200,
1045#                "rd_operations":36604
1046#                "flush_operations":51,
1047#                "wr_total_times_ns":313253456
1048#                "rd_total_times_ns":3465673657
1049#                "flush_total_times_ns":49653,
1050#                "rd_merged":0,
1051#                "wr_merged":0,
1052#                "idle_time_ns":2953431879,
1053#                "account_invalid":true,
1054#                "account_failed":false
1055#             },
1056#             "qdev": "/machine/unattached/device[23]"
1057#          },
1058#          {
1059#             "device":"ide1-cd0",
1060#             "stats":{
1061#                "wr_highest_offset":0,
1062#                "wr_bytes":0,
1063#                "wr_operations":0,
1064#                "rd_bytes":0,
1065#                "rd_operations":0
1066#                "flush_operations":0,
1067#                "wr_total_times_ns":0
1068#                "rd_total_times_ns":0
1069#                "flush_total_times_ns":0,
1070#                "rd_merged":0,
1071#                "wr_merged":0,
1072#                "account_invalid":false,
1073#                "account_failed":false
1074#             },
1075#             "qdev": "/machine/unattached/device[24]"
1076#          },
1077#          {
1078#             "device":"floppy0",
1079#             "stats":{
1080#                "wr_highest_offset":0,
1081#                "wr_bytes":0,
1082#                "wr_operations":0,
1083#                "rd_bytes":0,
1084#                "rd_operations":0
1085#                "flush_operations":0,
1086#                "wr_total_times_ns":0
1087#                "rd_total_times_ns":0
1088#                "flush_total_times_ns":0,
1089#                "rd_merged":0,
1090#                "wr_merged":0,
1091#                "account_invalid":false,
1092#                "account_failed":false
1093#             },
1094#             "qdev": "/machine/unattached/device[16]"
1095#          },
1096#          {
1097#             "device":"sd0",
1098#             "stats":{
1099#                "wr_highest_offset":0,
1100#                "wr_bytes":0,
1101#                "wr_operations":0,
1102#                "rd_bytes":0,
1103#                "rd_operations":0
1104#                "flush_operations":0,
1105#                "wr_total_times_ns":0
1106#                "rd_total_times_ns":0
1107#                "flush_total_times_ns":0,
1108#                "rd_merged":0,
1109#                "wr_merged":0,
1110#                "account_invalid":false,
1111#                "account_failed":false
1112#             }
1113#          }
1114#       ]
1115#    }
1116#
1117##
1118{ 'command': 'query-blockstats',
1119  'data': { '*query-nodes': 'bool' },
1120  'returns': ['BlockStats'] }
1121
1122##
1123# @BlockdevOnError:
1124#
1125# An enumeration of possible behaviors for errors on I/O operations.
1126# The exact meaning depends on whether the I/O was initiated by a guest
1127# or by a block job
1128#
1129# @report: for guest operations, report the error to the guest;
1130#          for jobs, cancel the job
1131#
1132# @ignore: ignore the error, only report a QMP event (BLOCK_IO_ERROR
1133#          or BLOCK_JOB_ERROR). The backup, mirror and commit block jobs retry
1134#          the failing request later and may still complete successfully. The
1135#          stream block job continues to stream and will complete with an
1136#          error.
1137#
1138# @enospc: same as @stop on ENOSPC, same as @report otherwise.
1139#
1140# @stop: for guest operations, stop the virtual machine;
1141#        for jobs, pause the job
1142#
1143# @auto: inherit the error handling policy of the backend (since: 2.7)
1144#
1145# Since: 1.3
1146##
1147{ 'enum': 'BlockdevOnError',
1148  'data': ['report', 'ignore', 'enospc', 'stop', 'auto'] }
1149
1150##
1151# @MirrorSyncMode:
1152#
1153# An enumeration of possible behaviors for the initial synchronization
1154# phase of storage mirroring.
1155#
1156# @top: copies data in the topmost image to the destination
1157#
1158# @full: copies data from all images to the destination
1159#
1160# @none: only copy data written from now on
1161#
1162# @incremental: only copy data described by the dirty bitmap. (since: 2.4)
1163#
1164# @bitmap: only copy data described by the dirty bitmap. (since: 4.2)
1165#          Behavior on completion is determined by the BitmapSyncMode.
1166#
1167# Since: 1.3
1168##
1169{ 'enum': 'MirrorSyncMode',
1170  'data': ['top', 'full', 'none', 'incremental', 'bitmap'] }
1171
1172##
1173# @BitmapSyncMode:
1174#
1175# An enumeration of possible behaviors for the synchronization of a bitmap
1176# when used for data copy operations.
1177#
1178# @on-success: The bitmap is only synced when the operation is successful.
1179#              This is the behavior always used for 'INCREMENTAL' backups.
1180#
1181# @never: The bitmap is never synchronized with the operation, and is
1182#         treated solely as a read-only manifest of blocks to copy.
1183#
1184# @always: The bitmap is always synchronized with the operation,
1185#          regardless of whether or not the operation was successful.
1186#
1187# Since: 4.2
1188##
1189{ 'enum': 'BitmapSyncMode',
1190  'data': ['on-success', 'never', 'always'] }
1191
1192##
1193# @MirrorCopyMode:
1194#
1195# An enumeration whose values tell the mirror block job when to
1196# trigger writes to the target.
1197#
1198# @background: copy data in background only.
1199#
1200# @write-blocking: when data is written to the source, write it
1201#                  (synchronously) to the target as well.  In
1202#                  addition, data is copied in background just like in
1203#                  @background mode.
1204#
1205# Since: 3.0
1206##
1207{ 'enum': 'MirrorCopyMode',
1208  'data': ['background', 'write-blocking'] }
1209
1210##
1211# @BlockJobInfo:
1212#
1213# Information about a long-running block device operation.
1214#
1215# @type: the job type ('stream' for image streaming)
1216#
1217# @device: The job identifier. Originally the device name but other
1218#          values are allowed since QEMU 2.7
1219#
1220# @len: Estimated @offset value at the completion of the job. This value can
1221#       arbitrarily change while the job is running, in both directions.
1222#
1223# @offset: Progress made until now. The unit is arbitrary and the value can
1224#          only meaningfully be used for the ratio of @offset to @len. The
1225#          value is monotonically increasing.
1226#
1227# @busy: false if the job is known to be in a quiescent state, with
1228#        no pending I/O.  Since 1.3.
1229#
1230# @paused: whether the job is paused or, if @busy is true, will
1231#          pause itself as soon as possible.  Since 1.3.
1232#
1233# @speed: the rate limit, bytes per second
1234#
1235# @io-status: the status of the job (since 1.3)
1236#
1237# @ready: true if the job may be completed (since 2.2)
1238#
1239# @status: Current job state/status (since 2.12)
1240#
1241# @auto-finalize: Job will finalize itself when PENDING, moving to
1242#                 the CONCLUDED state. (since 2.12)
1243#
1244# @auto-dismiss: Job will dismiss itself when CONCLUDED, moving to the NULL
1245#                state and disappearing from the query list. (since 2.12)
1246#
1247# @error: Error information if the job did not complete successfully.
1248#         Not set if the job completed successfully. (since 2.12.1)
1249#
1250# Since: 1.1
1251##
1252{ 'struct': 'BlockJobInfo',
1253  'data': {'type': 'str', 'device': 'str', 'len': 'int',
1254           'offset': 'int', 'busy': 'bool', 'paused': 'bool', 'speed': 'int',
1255           'io-status': 'BlockDeviceIoStatus', 'ready': 'bool',
1256           'status': 'JobStatus',
1257           'auto-finalize': 'bool', 'auto-dismiss': 'bool',
1258           '*error': 'str' } }
1259
1260##
1261# @query-block-jobs:
1262#
1263# Return information about long-running block device operations.
1264#
1265# Returns: a list of @BlockJobInfo for each active block job
1266#
1267# Since: 1.1
1268##
1269{ 'command': 'query-block-jobs', 'returns': ['BlockJobInfo'] }
1270
1271##
1272# @block_passwd:
1273#
1274# This command sets the password of a block device that has not been open
1275# with a password and requires one.
1276#
1277# This command is now obsolete and will always return an error since 2.10
1278#
1279##
1280{ 'command': 'block_passwd',
1281  'data': { '*device': 'str',
1282            '*node-name': 'str',
1283            'password': 'str' } }
1284
1285##
1286# @block_resize:
1287#
1288# Resize a block image while a guest is running.
1289#
1290# Either @device or @node-name must be set but not both.
1291#
1292# @device: the name of the device to get the image resized
1293#
1294# @node-name: graph node name to get the image resized (Since 2.0)
1295#
1296# @size:  new image size in bytes
1297#
1298# Returns: - nothing on success
1299#          - If @device is not a valid block device, DeviceNotFound
1300#
1301# Since: 0.14.0
1302#
1303# Example:
1304#
1305# -> { "execute": "block_resize",
1306#      "arguments": { "device": "scratch", "size": 1073741824 } }
1307# <- { "return": {} }
1308#
1309##
1310{ 'command': 'block_resize',
1311  'data': { '*device': 'str',
1312            '*node-name': 'str',
1313            'size': 'int' },
1314  'coroutine': true }
1315
1316##
1317# @NewImageMode:
1318#
1319# An enumeration that tells QEMU how to set the backing file path in
1320# a new image file.
1321#
1322# @existing: QEMU should look for an existing image file.
1323#
1324# @absolute-paths: QEMU should create a new image with absolute paths
1325#                  for the backing file. If there is no backing file available, the new
1326#                  image will not be backed either.
1327#
1328# Since: 1.1
1329##
1330{ 'enum': 'NewImageMode',
1331  'data': [ 'existing', 'absolute-paths' ] }
1332
1333##
1334# @BlockdevSnapshotSync:
1335#
1336# Either @device or @node-name must be set but not both.
1337#
1338# @device: the name of the device to take a snapshot of.
1339#
1340# @node-name: graph node name to generate the snapshot from (Since 2.0)
1341#
1342# @snapshot-file: the target of the new overlay image. If the file
1343#                 exists, or if it is a device, the overlay will be created in the
1344#                 existing file/device. Otherwise, a new file will be created.
1345#
1346# @snapshot-node-name: the graph node name of the new image (Since 2.0)
1347#
1348# @format: the format of the overlay image, default is 'qcow2'.
1349#
1350# @mode: whether and how QEMU should create a new image, default is
1351#        'absolute-paths'.
1352##
1353{ 'struct': 'BlockdevSnapshotSync',
1354  'data': { '*device': 'str', '*node-name': 'str',
1355            'snapshot-file': 'str', '*snapshot-node-name': 'str',
1356            '*format': 'str', '*mode': 'NewImageMode' } }
1357
1358##
1359# @BlockdevSnapshot:
1360#
1361# @node: device or node name that will have a snapshot taken.
1362#
1363# @overlay: reference to the existing block device that will become
1364#           the overlay of @node, as part of taking the snapshot.
1365#           It must not have a current backing file (this can be
1366#           achieved by passing "backing": null to blockdev-add).
1367#
1368# Since: 2.5
1369##
1370{ 'struct': 'BlockdevSnapshot',
1371  'data': { 'node': 'str', 'overlay': 'str' } }
1372
1373##
1374# @BackupCommon:
1375#
1376# @job-id: identifier for the newly-created block job. If
1377#          omitted, the device name will be used. (Since 2.7)
1378#
1379# @device: the device name or node-name of a root node which should be copied.
1380#
1381# @sync: what parts of the disk image should be copied to the destination
1382#        (all the disk, only the sectors allocated in the topmost image, from a
1383#        dirty bitmap, or only new I/O).
1384#
1385# @speed: the maximum speed, in bytes per second. The default is 0,
1386#         for unlimited.
1387#
1388# @bitmap: The name of a dirty bitmap to use.
1389#          Must be present if sync is "bitmap" or "incremental".
1390#          Can be present if sync is "full" or "top".
1391#          Must not be present otherwise.
1392#          (Since 2.4 (drive-backup), 3.1 (blockdev-backup))
1393#
1394# @bitmap-mode: Specifies the type of data the bitmap should contain after
1395#               the operation concludes.
1396#               Must be present if a bitmap was provided,
1397#               Must NOT be present otherwise. (Since 4.2)
1398#
1399# @compress: true to compress data, if the target format supports it.
1400#            (default: false) (since 2.8)
1401#
1402# @on-source-error: the action to take on an error on the source,
1403#                   default 'report'.  'stop' and 'enospc' can only be used
1404#                   if the block device supports io-status (see BlockInfo).
1405#
1406# @on-target-error: the action to take on an error on the target,
1407#                   default 'report' (no limitations, since this applies to
1408#                   a different block device than @device).
1409#
1410# @auto-finalize: When false, this job will wait in a PENDING state after it has
1411#                 finished its work, waiting for @block-job-finalize before
1412#                 making any block graph changes.
1413#                 When true, this job will automatically
1414#                 perform its abort or commit actions.
1415#                 Defaults to true. (Since 2.12)
1416#
1417# @auto-dismiss: When false, this job will wait in a CONCLUDED state after it
1418#                has completely ceased all work, and awaits @block-job-dismiss.
1419#                When true, this job will automatically disappear from the query
1420#                list without user intervention.
1421#                Defaults to true. (Since 2.12)
1422#
1423# @filter-node-name: the node name that should be assigned to the
1424#                    filter driver that the backup job inserts into the graph
1425#                    above node specified by @drive. If this option is not given,
1426#                    a node name is autogenerated. (Since: 4.2)
1427#
1428# Note: @on-source-error and @on-target-error only affect background
1429#       I/O.  If an error occurs during a guest write request, the device's
1430#       rerror/werror actions will be used.
1431#
1432# Since: 4.2
1433##
1434{ 'struct': 'BackupCommon',
1435  'data': { '*job-id': 'str', 'device': 'str',
1436            'sync': 'MirrorSyncMode', '*speed': 'int',
1437            '*bitmap': 'str', '*bitmap-mode': 'BitmapSyncMode',
1438            '*compress': 'bool',
1439            '*on-source-error': 'BlockdevOnError',
1440            '*on-target-error': 'BlockdevOnError',
1441            '*auto-finalize': 'bool', '*auto-dismiss': 'bool',
1442            '*filter-node-name': 'str' } }
1443
1444##
1445# @DriveBackup:
1446#
1447# @target: the target of the new image. If the file exists, or if it
1448#          is a device, the existing file/device will be used as the new
1449#          destination.  If it does not exist, a new file will be created.
1450#
1451# @format: the format of the new destination, default is to
1452#          probe if @mode is 'existing', else the format of the source
1453#
1454# @mode: whether and how QEMU should create a new image, default is
1455#        'absolute-paths'.
1456#
1457# Since: 1.6
1458##
1459{ 'struct': 'DriveBackup',
1460  'base': 'BackupCommon',
1461  'data': { 'target': 'str',
1462            '*format': 'str',
1463            '*mode': 'NewImageMode' } }
1464
1465##
1466# @BlockdevBackup:
1467#
1468# @target: the device name or node-name of the backup target node.
1469#
1470# Since: 2.3
1471##
1472{ 'struct': 'BlockdevBackup',
1473  'base': 'BackupCommon',
1474  'data': { 'target': 'str' } }
1475
1476##
1477# @blockdev-snapshot-sync:
1478#
1479# Takes a synchronous snapshot of a block device.
1480#
1481# For the arguments, see the documentation of BlockdevSnapshotSync.
1482#
1483# Returns: - nothing on success
1484#          - If @device is not a valid block device, DeviceNotFound
1485#
1486# Since: 0.14.0
1487#
1488# Example:
1489#
1490# -> { "execute": "blockdev-snapshot-sync",
1491#      "arguments": { "device": "ide-hd0",
1492#                     "snapshot-file":
1493#                     "/some/place/my-image",
1494#                     "format": "qcow2" } }
1495# <- { "return": {} }
1496#
1497##
1498{ 'command': 'blockdev-snapshot-sync',
1499  'data': 'BlockdevSnapshotSync' }
1500
1501
1502##
1503# @blockdev-snapshot:
1504#
1505# Takes a snapshot of a block device.
1506#
1507# Take a snapshot, by installing 'node' as the backing image of
1508# 'overlay'. Additionally, if 'node' is associated with a block
1509# device, the block device changes to using 'overlay' as its new active
1510# image.
1511#
1512# For the arguments, see the documentation of BlockdevSnapshot.
1513#
1514# Features:
1515# @allow-write-only-overlay: If present, the check whether this operation is safe
1516#                            was relaxed so that it can be used to change
1517#                            backing file of a destination of a blockdev-mirror.
1518#                            (since 5.0)
1519#
1520# Since: 2.5
1521#
1522# Example:
1523#
1524# -> { "execute": "blockdev-add",
1525#      "arguments": { "driver": "qcow2",
1526#                     "node-name": "node1534",
1527#                     "file": { "driver": "file",
1528#                               "filename": "hd1.qcow2" },
1529#                     "backing": null } }
1530#
1531# <- { "return": {} }
1532#
1533# -> { "execute": "blockdev-snapshot",
1534#      "arguments": { "node": "ide-hd0",
1535#                     "overlay": "node1534" } }
1536# <- { "return": {} }
1537#
1538##
1539{ 'command': 'blockdev-snapshot',
1540  'data': 'BlockdevSnapshot',
1541  'features': [ 'allow-write-only-overlay' ] }
1542
1543##
1544# @change-backing-file:
1545#
1546# Change the backing file in the image file metadata.  This does not
1547# cause QEMU to reopen the image file to reparse the backing filename
1548# (it may, however, perform a reopen to change permissions from
1549# r/o -> r/w -> r/o, if needed). The new backing file string is written
1550# into the image file metadata, and the QEMU internal strings are
1551# updated.
1552#
1553# @image-node-name: The name of the block driver state node of the
1554#                   image to modify. The "device" argument is used
1555#                   to verify "image-node-name" is in the chain
1556#                   described by "device".
1557#
1558# @device: The device name or node-name of the root node that owns
1559#          image-node-name.
1560#
1561# @backing-file: The string to write as the backing file.  This
1562#                string is not validated, so care should be taken
1563#                when specifying the string or the image chain may
1564#                not be able to be reopened again.
1565#
1566# Returns: - Nothing on success
1567#          - If "device" does not exist or cannot be determined, DeviceNotFound
1568#
1569# Since: 2.1
1570##
1571{ 'command': 'change-backing-file',
1572  'data': { 'device': 'str', 'image-node-name': 'str',
1573            'backing-file': 'str' } }
1574
1575##
1576# @block-commit:
1577#
1578# Live commit of data from overlay image nodes into backing nodes - i.e.,
1579# writes data between 'top' and 'base' into 'base'.
1580#
1581# If top == base, that is an error.
1582# If top has no overlays on top of it, or if it is in use by a writer,
1583# the job will not be completed by itself.  The user needs to complete
1584# the job with the block-job-complete command after getting the ready
1585# event. (Since 2.0)
1586#
1587# If the base image is smaller than top, then the base image will be
1588# resized to be the same size as top.  If top is smaller than the base
1589# image, the base will not be truncated.  If you want the base image
1590# size to match the size of the smaller top, you can safely truncate
1591# it yourself once the commit operation successfully completes.
1592#
1593# @job-id: identifier for the newly-created block job. If
1594#          omitted, the device name will be used. (Since 2.7)
1595#
1596# @device: the device name or node-name of a root node
1597#
1598# @base-node: The node name of the backing image to write data into.
1599#             If not specified, this is the deepest backing image.
1600#             (since: 3.1)
1601#
1602# @base: Same as @base-node, except that it is a file name rather than a node
1603#        name. This must be the exact filename string that was used to open the
1604#        node; other strings, even if addressing the same file, are not
1605#        accepted
1606#
1607# @top-node: The node name of the backing image within the image chain
1608#            which contains the topmost data to be committed down. If
1609#            not specified, this is the active layer. (since: 3.1)
1610#
1611# @top: Same as @top-node, except that it is a file name rather than a node
1612#       name. This must be the exact filename string that was used to open the
1613#       node; other strings, even if addressing the same file, are not
1614#       accepted
1615#
1616# @backing-file: The backing file string to write into the overlay
1617#                image of 'top'.  If 'top' does not have an overlay
1618#                image, or if 'top' is in use by a writer, specifying
1619#                a backing file string is an error.
1620#
1621#                This filename is not validated.  If a pathname string
1622#                is such that it cannot be resolved by QEMU, that
1623#                means that subsequent QMP or HMP commands must use
1624#                node-names for the image in question, as filename
1625#                lookup methods will fail.
1626#
1627#                If not specified, QEMU will automatically determine
1628#                the backing file string to use, or error out if
1629#                there is no obvious choice. Care should be taken
1630#                when specifying the string, to specify a valid
1631#                filename or protocol.
1632#                (Since 2.1)
1633#
1634# @speed: the maximum speed, in bytes per second
1635#
1636# @on-error: the action to take on an error. 'ignore' means that the request
1637#            should be retried. (default: report; Since: 5.0)
1638#
1639# @filter-node-name: the node name that should be assigned to the
1640#                    filter driver that the commit job inserts into the graph
1641#                    above @top. If this option is not given, a node name is
1642#                    autogenerated. (Since: 2.9)
1643#
1644# @auto-finalize: When false, this job will wait in a PENDING state after it has
1645#                 finished its work, waiting for @block-job-finalize before
1646#                 making any block graph changes.
1647#                 When true, this job will automatically
1648#                 perform its abort or commit actions.
1649#                 Defaults to true. (Since 3.1)
1650#
1651# @auto-dismiss: When false, this job will wait in a CONCLUDED state after it
1652#                has completely ceased all work, and awaits @block-job-dismiss.
1653#                When true, this job will automatically disappear from the query
1654#                list without user intervention.
1655#                Defaults to true. (Since 3.1)
1656#
1657# Features:
1658# @deprecated: Members @base and @top are deprecated.  Use @base-node
1659#              and @top-node instead.
1660#
1661# Returns: - Nothing on success
1662#          - If @device does not exist, DeviceNotFound
1663#          - Any other error returns a GenericError.
1664#
1665# Since: 1.3
1666#
1667# Example:
1668#
1669# -> { "execute": "block-commit",
1670#      "arguments": { "device": "virtio0",
1671#                     "top": "/tmp/snap1.qcow2" } }
1672# <- { "return": {} }
1673#
1674##
1675{ 'command': 'block-commit',
1676  'data': { '*job-id': 'str', 'device': 'str', '*base-node': 'str',
1677            '*base': { 'type': 'str', 'features': [ 'deprecated' ] },
1678            '*top-node': 'str',
1679            '*top': { 'type': 'str', 'features': [ 'deprecated' ] },
1680            '*backing-file': 'str', '*speed': 'int',
1681            '*on-error': 'BlockdevOnError',
1682            '*filter-node-name': 'str',
1683            '*auto-finalize': 'bool', '*auto-dismiss': 'bool' } }
1684
1685##
1686# @drive-backup:
1687#
1688# Start a point-in-time copy of a block device to a new destination.  The
1689# status of ongoing drive-backup operations can be checked with
1690# query-block-jobs where the BlockJobInfo.type field has the value 'backup'.
1691# The operation can be stopped before it has completed using the
1692# block-job-cancel command.
1693#
1694# Returns: - nothing on success
1695#          - If @device is not a valid block device, GenericError
1696#
1697# Since: 1.6
1698#
1699# Example:
1700#
1701# -> { "execute": "drive-backup",
1702#      "arguments": { "device": "drive0",
1703#                     "sync": "full",
1704#                     "target": "backup.img" } }
1705# <- { "return": {} }
1706#
1707##
1708{ 'command': 'drive-backup', 'boxed': true,
1709  'data': 'DriveBackup' }
1710
1711##
1712# @blockdev-backup:
1713#
1714# Start a point-in-time copy of a block device to a new destination.  The
1715# status of ongoing blockdev-backup operations can be checked with
1716# query-block-jobs where the BlockJobInfo.type field has the value 'backup'.
1717# The operation can be stopped before it has completed using the
1718# block-job-cancel command.
1719#
1720# Returns: - nothing on success
1721#          - If @device is not a valid block device, DeviceNotFound
1722#
1723# Since: 2.3
1724#
1725# Example:
1726# -> { "execute": "blockdev-backup",
1727#      "arguments": { "device": "src-id",
1728#                     "sync": "full",
1729#                     "target": "tgt-id" } }
1730# <- { "return": {} }
1731#
1732##
1733{ 'command': 'blockdev-backup', 'boxed': true,
1734  'data': 'BlockdevBackup' }
1735
1736
1737##
1738# @query-named-block-nodes:
1739#
1740# Get the named block driver list
1741#
1742# @flat: Omit the nested data about backing image ("backing-image" key) if true.
1743#        Default is false (Since 5.0)
1744#
1745# Returns: the list of BlockDeviceInfo
1746#
1747# Since: 2.0
1748#
1749# Example:
1750#
1751# -> { "execute": "query-named-block-nodes" }
1752# <- { "return": [ { "ro":false,
1753#                    "drv":"qcow2",
1754#                    "encrypted":false,
1755#                    "file":"disks/test.qcow2",
1756#                    "node-name": "my-node",
1757#                    "backing_file_depth":1,
1758#                    "bps":1000000,
1759#                    "bps_rd":0,
1760#                    "bps_wr":0,
1761#                    "iops":1000000,
1762#                    "iops_rd":0,
1763#                    "iops_wr":0,
1764#                    "bps_max": 8000000,
1765#                    "bps_rd_max": 0,
1766#                    "bps_wr_max": 0,
1767#                    "iops_max": 0,
1768#                    "iops_rd_max": 0,
1769#                    "iops_wr_max": 0,
1770#                    "iops_size": 0,
1771#                    "write_threshold": 0,
1772#                    "image":{
1773#                       "filename":"disks/test.qcow2",
1774#                       "format":"qcow2",
1775#                       "virtual-size":2048000,
1776#                       "backing_file":"base.qcow2",
1777#                       "full-backing-filename":"disks/base.qcow2",
1778#                       "backing-filename-format":"qcow2",
1779#                       "snapshots":[
1780#                          {
1781#                             "id": "1",
1782#                             "name": "snapshot1",
1783#                             "vm-state-size": 0,
1784#                             "date-sec": 10000200,
1785#                             "date-nsec": 12,
1786#                             "vm-clock-sec": 206,
1787#                             "vm-clock-nsec": 30
1788#                          }
1789#                       ],
1790#                       "backing-image":{
1791#                           "filename":"disks/base.qcow2",
1792#                           "format":"qcow2",
1793#                           "virtual-size":2048000
1794#                       }
1795#                    } } ] }
1796#
1797##
1798{ 'command': 'query-named-block-nodes',
1799  'returns': [ 'BlockDeviceInfo' ],
1800  'data': { '*flat': 'bool' } }
1801
1802##
1803# @XDbgBlockGraphNodeType:
1804#
1805# @block-backend: corresponds to BlockBackend
1806#
1807# @block-job: corresponds to BlockJob
1808#
1809# @block-driver: corresponds to BlockDriverState
1810#
1811# Since: 4.0
1812##
1813{ 'enum': 'XDbgBlockGraphNodeType',
1814  'data': [ 'block-backend', 'block-job', 'block-driver' ] }
1815
1816##
1817# @XDbgBlockGraphNode:
1818#
1819# @id: Block graph node identifier. This @id is generated only for
1820#      x-debug-query-block-graph and does not relate to any other identifiers in
1821#      Qemu.
1822#
1823# @type: Type of graph node. Can be one of block-backend, block-job or
1824#        block-driver-state.
1825#
1826# @name: Human readable name of the node. Corresponds to node-name for
1827#        block-driver-state nodes; is not guaranteed to be unique in the whole
1828#        graph (with block-jobs and block-backends).
1829#
1830# Since: 4.0
1831##
1832{ 'struct': 'XDbgBlockGraphNode',
1833  'data': { 'id': 'uint64', 'type': 'XDbgBlockGraphNodeType', 'name': 'str' } }
1834
1835##
1836# @BlockPermission:
1837#
1838# Enum of base block permissions.
1839#
1840# @consistent-read: A user that has the "permission" of consistent reads is
1841#                   guaranteed that their view of the contents of the block
1842#                   device is complete and self-consistent, representing the
1843#                   contents of a disk at a specific point.
1844#                   For most block devices (including their backing files) this
1845#                   is true, but the property cannot be maintained in a few
1846#                   situations like for intermediate nodes of a commit block
1847#                   job.
1848#
1849# @write: This permission is required to change the visible disk contents.
1850#
1851# @write-unchanged: This permission (which is weaker than BLK_PERM_WRITE) is
1852#                   both enough and required for writes to the block node when
1853#                   the caller promises that the visible disk content doesn't
1854#                   change.
1855#                   As the BLK_PERM_WRITE permission is strictly stronger,
1856#                   either is sufficient to perform an unchanging write.
1857#
1858# @resize: This permission is required to change the size of a block node.
1859#
1860# @graph-mod: This permission is required to change the node that this
1861#             BdrvChild points to.
1862#
1863# Since: 4.0
1864##
1865{ 'enum': 'BlockPermission',
1866  'data': [ 'consistent-read', 'write', 'write-unchanged', 'resize',
1867            'graph-mod' ] }
1868##
1869# @XDbgBlockGraphEdge:
1870#
1871# Block Graph edge description for x-debug-query-block-graph.
1872#
1873# @parent: parent id
1874#
1875# @child: child id
1876#
1877# @name: name of the relation (examples are 'file' and 'backing')
1878#
1879# @perm: granted permissions for the parent operating on the child
1880#
1881# @shared-perm: permissions that can still be granted to other users of the
1882#               child while it is still attached to this parent
1883#
1884# Since: 4.0
1885##
1886{ 'struct': 'XDbgBlockGraphEdge',
1887  'data': { 'parent': 'uint64', 'child': 'uint64',
1888            'name': 'str', 'perm': [ 'BlockPermission' ],
1889            'shared-perm': [ 'BlockPermission' ] } }
1890
1891##
1892# @XDbgBlockGraph:
1893#
1894# Block Graph - list of nodes and list of edges.
1895#
1896# Since: 4.0
1897##
1898{ 'struct': 'XDbgBlockGraph',
1899  'data': { 'nodes': ['XDbgBlockGraphNode'], 'edges': ['XDbgBlockGraphEdge'] } }
1900
1901##
1902# @x-debug-query-block-graph:
1903#
1904# Get the block graph.
1905#
1906# Since: 4.0
1907##
1908{ 'command': 'x-debug-query-block-graph', 'returns': 'XDbgBlockGraph' }
1909
1910##
1911# @drive-mirror:
1912#
1913# Start mirroring a block device's writes to a new destination. target
1914# specifies the target of the new image. If the file exists, or if it
1915# is a device, it will be used as the new destination for writes. If
1916# it does not exist, a new file will be created. format specifies the
1917# format of the mirror image, default is to probe if mode='existing',
1918# else the format of the source.
1919#
1920# Returns: - nothing on success
1921#          - If @device is not a valid block device, GenericError
1922#
1923# Since: 1.3
1924#
1925# Example:
1926#
1927# -> { "execute": "drive-mirror",
1928#      "arguments": { "device": "ide-hd0",
1929#                     "target": "/some/place/my-image",
1930#                     "sync": "full",
1931#                     "format": "qcow2" } }
1932# <- { "return": {} }
1933#
1934##
1935{ 'command': 'drive-mirror', 'boxed': true,
1936  'data': 'DriveMirror' }
1937
1938##
1939# @DriveMirror:
1940#
1941# A set of parameters describing drive mirror setup.
1942#
1943# @job-id: identifier for the newly-created block job. If
1944#          omitted, the device name will be used. (Since 2.7)
1945#
1946# @device:  the device name or node-name of a root node whose writes should be
1947#           mirrored.
1948#
1949# @target: the target of the new image. If the file exists, or if it
1950#          is a device, the existing file/device will be used as the new
1951#          destination.  If it does not exist, a new file will be created.
1952#
1953# @format: the format of the new destination, default is to
1954#          probe if @mode is 'existing', else the format of the source
1955#
1956# @node-name: the new block driver state node name in the graph
1957#             (Since 2.1)
1958#
1959# @replaces: with sync=full graph node name to be replaced by the new
1960#            image when a whole image copy is done. This can be used to repair
1961#            broken Quorum files.  By default, @device is replaced, although
1962#            implicitly created filters on it are kept. (Since 2.1)
1963#
1964# @mode: whether and how QEMU should create a new image, default is
1965#        'absolute-paths'.
1966#
1967# @speed:  the maximum speed, in bytes per second
1968#
1969# @sync: what parts of the disk image should be copied to the destination
1970#        (all the disk, only the sectors allocated in the topmost image, or
1971#        only new I/O).
1972#
1973# @granularity: granularity of the dirty bitmap, default is 64K
1974#               if the image format doesn't have clusters, 4K if the clusters
1975#               are smaller than that, else the cluster size.  Must be a
1976#               power of 2 between 512 and 64M (since 1.4).
1977#
1978# @buf-size: maximum amount of data in flight from source to
1979#            target (since 1.4).
1980#
1981# @on-source-error: the action to take on an error on the source,
1982#                   default 'report'.  'stop' and 'enospc' can only be used
1983#                   if the block device supports io-status (see BlockInfo).
1984#
1985# @on-target-error: the action to take on an error on the target,
1986#                   default 'report' (no limitations, since this applies to
1987#                   a different block device than @device).
1988# @unmap: Whether to try to unmap target sectors where source has
1989#         only zero. If true, and target unallocated sectors will read as zero,
1990#         target image sectors will be unmapped; otherwise, zeroes will be
1991#         written. Both will result in identical contents.
1992#         Default is true. (Since 2.4)
1993#
1994# @copy-mode: when to copy data to the destination; defaults to 'background'
1995#             (Since: 3.0)
1996#
1997# @auto-finalize: When false, this job will wait in a PENDING state after it has
1998#                 finished its work, waiting for @block-job-finalize before
1999#                 making any block graph changes.
2000#                 When true, this job will automatically
2001#                 perform its abort or commit actions.
2002#                 Defaults to true. (Since 3.1)
2003#
2004# @auto-dismiss: When false, this job will wait in a CONCLUDED state after it
2005#                has completely ceased all work, and awaits @block-job-dismiss.
2006#                When true, this job will automatically disappear from the query
2007#                list without user intervention.
2008#                Defaults to true. (Since 3.1)
2009# Since: 1.3
2010##
2011{ 'struct': 'DriveMirror',
2012  'data': { '*job-id': 'str', 'device': 'str', 'target': 'str',
2013            '*format': 'str', '*node-name': 'str', '*replaces': 'str',
2014            'sync': 'MirrorSyncMode', '*mode': 'NewImageMode',
2015            '*speed': 'int', '*granularity': 'uint32',
2016            '*buf-size': 'int', '*on-source-error': 'BlockdevOnError',
2017            '*on-target-error': 'BlockdevOnError',
2018            '*unmap': 'bool', '*copy-mode': 'MirrorCopyMode',
2019            '*auto-finalize': 'bool', '*auto-dismiss': 'bool' } }
2020
2021##
2022# @BlockDirtyBitmap:
2023#
2024# @node: name of device/node which the bitmap is tracking
2025#
2026# @name: name of the dirty bitmap
2027#
2028# Since: 2.4
2029##
2030{ 'struct': 'BlockDirtyBitmap',
2031  'data': { 'node': 'str', 'name': 'str' } }
2032
2033##
2034# @BlockDirtyBitmapAdd:
2035#
2036# @node: name of device/node which the bitmap is tracking
2037#
2038# @name: name of the dirty bitmap (must be less than 1024 bytes)
2039#
2040# @granularity: the bitmap granularity, default is 64k for
2041#               block-dirty-bitmap-add
2042#
2043# @persistent: the bitmap is persistent, i.e. it will be saved to the
2044#              corresponding block device image file on its close. For now only
2045#              Qcow2 disks support persistent bitmaps. Default is false for
2046#              block-dirty-bitmap-add. (Since: 2.10)
2047#
2048# @disabled: the bitmap is created in the disabled state, which means that
2049#            it will not track drive changes. The bitmap may be enabled with
2050#            block-dirty-bitmap-enable. Default is false. (Since: 4.0)
2051#
2052# Since: 2.4
2053##
2054{ 'struct': 'BlockDirtyBitmapAdd',
2055  'data': { 'node': 'str', 'name': 'str', '*granularity': 'uint32',
2056            '*persistent': 'bool', '*disabled': 'bool' } }
2057
2058##
2059# @BlockDirtyBitmapMergeSource:
2060#
2061# @local: name of the bitmap, attached to the same node as target bitmap.
2062#
2063# @external: bitmap with specified node
2064#
2065# Since: 4.1
2066##
2067{ 'alternate': 'BlockDirtyBitmapMergeSource',
2068  'data': { 'local': 'str',
2069            'external': 'BlockDirtyBitmap' } }
2070
2071##
2072# @BlockDirtyBitmapMerge:
2073#
2074# @node: name of device/node which the @target bitmap is tracking
2075#
2076# @target: name of the destination dirty bitmap
2077#
2078# @bitmaps: name(s) of the source dirty bitmap(s) at @node and/or fully
2079#           specified BlockDirtyBitmap elements. The latter are supported
2080#           since 4.1.
2081#
2082# Since: 4.0
2083##
2084{ 'struct': 'BlockDirtyBitmapMerge',
2085  'data': { 'node': 'str', 'target': 'str',
2086            'bitmaps': ['BlockDirtyBitmapMergeSource'] } }
2087
2088##
2089# @block-dirty-bitmap-add:
2090#
2091# Create a dirty bitmap with a name on the node, and start tracking the writes.
2092#
2093# Returns: - nothing on success
2094#          - If @node is not a valid block device or node, DeviceNotFound
2095#          - If @name is already taken, GenericError with an explanation
2096#
2097# Since: 2.4
2098#
2099# Example:
2100#
2101# -> { "execute": "block-dirty-bitmap-add",
2102#      "arguments": { "node": "drive0", "name": "bitmap0" } }
2103# <- { "return": {} }
2104#
2105##
2106{ 'command': 'block-dirty-bitmap-add',
2107  'data': 'BlockDirtyBitmapAdd' }
2108
2109##
2110# @block-dirty-bitmap-remove:
2111#
2112# Stop write tracking and remove the dirty bitmap that was created
2113# with block-dirty-bitmap-add. If the bitmap is persistent, remove it from its
2114# storage too.
2115#
2116# Returns: - nothing on success
2117#          - If @node is not a valid block device or node, DeviceNotFound
2118#          - If @name is not found, GenericError with an explanation
2119#          - if @name is frozen by an operation, GenericError
2120#
2121# Since: 2.4
2122#
2123# Example:
2124#
2125# -> { "execute": "block-dirty-bitmap-remove",
2126#      "arguments": { "node": "drive0", "name": "bitmap0" } }
2127# <- { "return": {} }
2128#
2129##
2130{ 'command': 'block-dirty-bitmap-remove',
2131  'data': 'BlockDirtyBitmap' }
2132
2133##
2134# @block-dirty-bitmap-clear:
2135#
2136# Clear (reset) a dirty bitmap on the device, so that an incremental
2137# backup from this point in time forward will only backup clusters
2138# modified after this clear operation.
2139#
2140# Returns: - nothing on success
2141#          - If @node is not a valid block device, DeviceNotFound
2142#          - If @name is not found, GenericError with an explanation
2143#
2144# Since: 2.4
2145#
2146# Example:
2147#
2148# -> { "execute": "block-dirty-bitmap-clear",
2149#      "arguments": { "node": "drive0", "name": "bitmap0" } }
2150# <- { "return": {} }
2151#
2152##
2153{ 'command': 'block-dirty-bitmap-clear',
2154  'data': 'BlockDirtyBitmap' }
2155
2156##
2157# @block-dirty-bitmap-enable:
2158#
2159# Enables a dirty bitmap so that it will begin tracking disk changes.
2160#
2161# Returns: - nothing on success
2162#          - If @node is not a valid block device, DeviceNotFound
2163#          - If @name is not found, GenericError with an explanation
2164#
2165# Since: 4.0
2166#
2167# Example:
2168#
2169# -> { "execute": "block-dirty-bitmap-enable",
2170#      "arguments": { "node": "drive0", "name": "bitmap0" } }
2171# <- { "return": {} }
2172#
2173##
2174{ 'command': 'block-dirty-bitmap-enable',
2175  'data': 'BlockDirtyBitmap' }
2176
2177##
2178# @block-dirty-bitmap-disable:
2179#
2180# Disables a dirty bitmap so that it will stop tracking disk changes.
2181#
2182# Returns: - nothing on success
2183#          - If @node is not a valid block device, DeviceNotFound
2184#          - If @name is not found, GenericError with an explanation
2185#
2186# Since: 4.0
2187#
2188# Example:
2189#
2190# -> { "execute": "block-dirty-bitmap-disable",
2191#      "arguments": { "node": "drive0", "name": "bitmap0" } }
2192# <- { "return": {} }
2193#
2194##
2195{ 'command': 'block-dirty-bitmap-disable',
2196  'data': 'BlockDirtyBitmap' }
2197
2198##
2199# @block-dirty-bitmap-merge:
2200#
2201# Merge dirty bitmaps listed in @bitmaps to the @target dirty bitmap.
2202# Dirty bitmaps in @bitmaps will be unchanged, except if it also appears
2203# as the @target bitmap. Any bits already set in @target will still be
2204# set after the merge, i.e., this operation does not clear the target.
2205# On error, @target is unchanged.
2206#
2207# The resulting bitmap will count as dirty any clusters that were dirty in any
2208# of the source bitmaps. This can be used to achieve backup checkpoints, or in
2209# simpler usages, to copy bitmaps.
2210#
2211# Returns: - nothing on success
2212#          - If @node is not a valid block device, DeviceNotFound
2213#          - If any bitmap in @bitmaps or @target is not found, GenericError
2214#          - If any of the bitmaps have different sizes or granularities,
2215#            GenericError
2216#
2217# Since: 4.0
2218#
2219# Example:
2220#
2221# -> { "execute": "block-dirty-bitmap-merge",
2222#      "arguments": { "node": "drive0", "target": "bitmap0",
2223#                     "bitmaps": ["bitmap1"] } }
2224# <- { "return": {} }
2225#
2226##
2227{ 'command': 'block-dirty-bitmap-merge',
2228  'data': 'BlockDirtyBitmapMerge' }
2229
2230##
2231# @BlockDirtyBitmapSha256:
2232#
2233# SHA256 hash of dirty bitmap data
2234#
2235# @sha256: ASCII representation of SHA256 bitmap hash
2236#
2237# Since: 2.10
2238##
2239{ 'struct': 'BlockDirtyBitmapSha256',
2240  'data': {'sha256': 'str'} }
2241
2242##
2243# @x-debug-block-dirty-bitmap-sha256:
2244#
2245# Get bitmap SHA256.
2246#
2247# Returns: - BlockDirtyBitmapSha256 on success
2248#          - If @node is not a valid block device, DeviceNotFound
2249#          - If @name is not found or if hashing has failed, GenericError with an
2250#            explanation
2251#
2252# Since: 2.10
2253##
2254{ 'command': 'x-debug-block-dirty-bitmap-sha256',
2255  'data': 'BlockDirtyBitmap', 'returns': 'BlockDirtyBitmapSha256' }
2256
2257##
2258# @blockdev-mirror:
2259#
2260# Start mirroring a block device's writes to a new destination.
2261#
2262# @job-id: identifier for the newly-created block job. If
2263#          omitted, the device name will be used. (Since 2.7)
2264#
2265# @device: The device name or node-name of a root node whose writes should be
2266#          mirrored.
2267#
2268# @target: the id or node-name of the block device to mirror to. This mustn't be
2269#          attached to guest.
2270#
2271# @replaces: with sync=full graph node name to be replaced by the new
2272#            image when a whole image copy is done. This can be used to repair
2273#            broken Quorum files.  By default, @device is replaced, although
2274#            implicitly created filters on it are kept.
2275#
2276# @speed:  the maximum speed, in bytes per second
2277#
2278# @sync: what parts of the disk image should be copied to the destination
2279#        (all the disk, only the sectors allocated in the topmost image, or
2280#        only new I/O).
2281#
2282# @granularity: granularity of the dirty bitmap, default is 64K
2283#               if the image format doesn't have clusters, 4K if the clusters
2284#               are smaller than that, else the cluster size.  Must be a
2285#               power of 2 between 512 and 64M
2286#
2287# @buf-size: maximum amount of data in flight from source to
2288#            target
2289#
2290# @on-source-error: the action to take on an error on the source,
2291#                   default 'report'.  'stop' and 'enospc' can only be used
2292#                   if the block device supports io-status (see BlockInfo).
2293#
2294# @on-target-error: the action to take on an error on the target,
2295#                   default 'report' (no limitations, since this applies to
2296#                   a different block device than @device).
2297#
2298# @filter-node-name: the node name that should be assigned to the
2299#                    filter driver that the mirror job inserts into the graph
2300#                    above @device. If this option is not given, a node name is
2301#                    autogenerated. (Since: 2.9)
2302#
2303# @copy-mode: when to copy data to the destination; defaults to 'background'
2304#             (Since: 3.0)
2305#
2306# @auto-finalize: When false, this job will wait in a PENDING state after it has
2307#                 finished its work, waiting for @block-job-finalize before
2308#                 making any block graph changes.
2309#                 When true, this job will automatically
2310#                 perform its abort or commit actions.
2311#                 Defaults to true. (Since 3.1)
2312#
2313# @auto-dismiss: When false, this job will wait in a CONCLUDED state after it
2314#                has completely ceased all work, and awaits @block-job-dismiss.
2315#                When true, this job will automatically disappear from the query
2316#                list without user intervention.
2317#                Defaults to true. (Since 3.1)
2318# Returns: nothing on success.
2319#
2320# Since: 2.6
2321#
2322# Example:
2323#
2324# -> { "execute": "blockdev-mirror",
2325#      "arguments": { "device": "ide-hd0",
2326#                     "target": "target0",
2327#                     "sync": "full" } }
2328# <- { "return": {} }
2329#
2330##
2331{ 'command': 'blockdev-mirror',
2332  'data': { '*job-id': 'str', 'device': 'str', 'target': 'str',
2333            '*replaces': 'str',
2334            'sync': 'MirrorSyncMode',
2335            '*speed': 'int', '*granularity': 'uint32',
2336            '*buf-size': 'int', '*on-source-error': 'BlockdevOnError',
2337            '*on-target-error': 'BlockdevOnError',
2338            '*filter-node-name': 'str',
2339            '*copy-mode': 'MirrorCopyMode',
2340            '*auto-finalize': 'bool', '*auto-dismiss': 'bool' } }
2341
2342##
2343# @BlockIOThrottle:
2344#
2345# A set of parameters describing block throttling.
2346#
2347# @device: Block device name
2348#
2349# @id: The name or QOM path of the guest device (since: 2.8)
2350#
2351# @bps: total throughput limit in bytes per second
2352#
2353# @bps_rd: read throughput limit in bytes per second
2354#
2355# @bps_wr: write throughput limit in bytes per second
2356#
2357# @iops: total I/O operations per second
2358#
2359# @iops_rd: read I/O operations per second
2360#
2361# @iops_wr: write I/O operations per second
2362#
2363# @bps_max: total throughput limit during bursts,
2364#           in bytes (Since 1.7)
2365#
2366# @bps_rd_max: read throughput limit during bursts,
2367#              in bytes (Since 1.7)
2368#
2369# @bps_wr_max: write throughput limit during bursts,
2370#              in bytes (Since 1.7)
2371#
2372# @iops_max: total I/O operations per second during bursts,
2373#            in bytes (Since 1.7)
2374#
2375# @iops_rd_max: read I/O operations per second during bursts,
2376#               in bytes (Since 1.7)
2377#
2378# @iops_wr_max: write I/O operations per second during bursts,
2379#               in bytes (Since 1.7)
2380#
2381# @bps_max_length: maximum length of the @bps_max burst
2382#                  period, in seconds. It must only
2383#                  be set if @bps_max is set as well.
2384#                  Defaults to 1. (Since 2.6)
2385#
2386# @bps_rd_max_length: maximum length of the @bps_rd_max
2387#                     burst period, in seconds. It must only
2388#                     be set if @bps_rd_max is set as well.
2389#                     Defaults to 1. (Since 2.6)
2390#
2391# @bps_wr_max_length: maximum length of the @bps_wr_max
2392#                     burst period, in seconds. It must only
2393#                     be set if @bps_wr_max is set as well.
2394#                     Defaults to 1. (Since 2.6)
2395#
2396# @iops_max_length: maximum length of the @iops burst
2397#                   period, in seconds. It must only
2398#                   be set if @iops_max is set as well.
2399#                   Defaults to 1. (Since 2.6)
2400#
2401# @iops_rd_max_length: maximum length of the @iops_rd_max
2402#                      burst period, in seconds. It must only
2403#                      be set if @iops_rd_max is set as well.
2404#                      Defaults to 1. (Since 2.6)
2405#
2406# @iops_wr_max_length: maximum length of the @iops_wr_max
2407#                      burst period, in seconds. It must only
2408#                      be set if @iops_wr_max is set as well.
2409#                      Defaults to 1. (Since 2.6)
2410#
2411# @iops_size: an I/O size in bytes (Since 1.7)
2412#
2413# @group: throttle group name (Since 2.4)
2414#
2415# Features:
2416# @deprecated: Member @device is deprecated.  Use @id instead.
2417#
2418# Since: 1.1
2419##
2420{ 'struct': 'BlockIOThrottle',
2421  'data': { '*device': { 'type': 'str', 'features': [ 'deprecated' ] },
2422            '*id': 'str', 'bps': 'int', 'bps_rd': 'int',
2423            'bps_wr': 'int', 'iops': 'int', 'iops_rd': 'int', 'iops_wr': 'int',
2424            '*bps_max': 'int', '*bps_rd_max': 'int',
2425            '*bps_wr_max': 'int', '*iops_max': 'int',
2426            '*iops_rd_max': 'int', '*iops_wr_max': 'int',
2427            '*bps_max_length': 'int', '*bps_rd_max_length': 'int',
2428            '*bps_wr_max_length': 'int', '*iops_max_length': 'int',
2429            '*iops_rd_max_length': 'int', '*iops_wr_max_length': 'int',
2430            '*iops_size': 'int', '*group': 'str' } }
2431
2432##
2433# @ThrottleLimits:
2434#
2435# Limit parameters for throttling.
2436# Since some limit combinations are illegal, limits should always be set in one
2437# transaction. All fields are optional. When setting limits, if a field is
2438# missing the current value is not changed.
2439#
2440# @iops-total: limit total I/O operations per second
2441# @iops-total-max: I/O operations burst
2442# @iops-total-max-length: length of the iops-total-max burst period, in seconds
2443#                         It must only be set if @iops-total-max is set as well.
2444# @iops-read: limit read operations per second
2445# @iops-read-max: I/O operations read burst
2446# @iops-read-max-length: length of the iops-read-max burst period, in seconds
2447#                        It must only be set if @iops-read-max is set as well.
2448# @iops-write: limit write operations per second
2449# @iops-write-max: I/O operations write burst
2450# @iops-write-max-length: length of the iops-write-max burst period, in seconds
2451#                         It must only be set if @iops-write-max is set as well.
2452# @bps-total: limit total bytes per second
2453# @bps-total-max: total bytes burst
2454# @bps-total-max-length: length of the bps-total-max burst period, in seconds.
2455#                        It must only be set if @bps-total-max is set as well.
2456# @bps-read: limit read bytes per second
2457# @bps-read-max: total bytes read burst
2458# @bps-read-max-length: length of the bps-read-max burst period, in seconds
2459#                       It must only be set if @bps-read-max is set as well.
2460# @bps-write: limit write bytes per second
2461# @bps-write-max: total bytes write burst
2462# @bps-write-max-length: length of the bps-write-max burst period, in seconds
2463#                        It must only be set if @bps-write-max is set as well.
2464# @iops-size: when limiting by iops max size of an I/O in bytes
2465#
2466# Since: 2.11
2467##
2468{ 'struct': 'ThrottleLimits',
2469  'data': { '*iops-total' : 'int', '*iops-total-max' : 'int',
2470            '*iops-total-max-length' : 'int', '*iops-read' : 'int',
2471            '*iops-read-max' : 'int', '*iops-read-max-length' : 'int',
2472            '*iops-write' : 'int', '*iops-write-max' : 'int',
2473            '*iops-write-max-length' : 'int', '*bps-total' : 'int',
2474            '*bps-total-max' : 'int', '*bps-total-max-length' : 'int',
2475            '*bps-read' : 'int', '*bps-read-max' : 'int',
2476            '*bps-read-max-length' : 'int', '*bps-write' : 'int',
2477            '*bps-write-max' : 'int', '*bps-write-max-length' : 'int',
2478            '*iops-size' : 'int' } }
2479
2480##
2481# @block-stream:
2482#
2483# Copy data from a backing file into a block device.
2484#
2485# The block streaming operation is performed in the background until the entire
2486# backing file has been copied.  This command returns immediately once streaming
2487# has started.  The status of ongoing block streaming operations can be checked
2488# with query-block-jobs.  The operation can be stopped before it has completed
2489# using the block-job-cancel command.
2490#
2491# The node that receives the data is called the top image, can be located in
2492# any part of the chain (but always above the base image; see below) and can be
2493# specified using its device or node name. Earlier qemu versions only allowed
2494# 'device' to name the top level node; presence of the 'base-node' parameter
2495# during introspection can be used as a witness of the enhanced semantics
2496# of 'device'.
2497#
2498# If a base file is specified then sectors are not copied from that base file and
2499# its backing chain.  This can be used to stream a subset of the backing file
2500# chain instead of flattening the entire image.
2501# When streaming completes the image file will have the base file as its backing
2502# file, unless that node was changed while the job was running.  In that case,
2503# base's parent's backing (or filtered, whichever exists) child (i.e., base at
2504# the beginning of the job) will be the new backing file.
2505#
2506# On successful completion the image file is updated to drop the backing file
2507# and the BLOCK_JOB_COMPLETED event is emitted.
2508#
2509# In case @device is a filter node, block-stream modifies the first non-filter
2510# overlay node below it to point to the new backing node instead of modifying
2511# @device itself.
2512#
2513# @job-id: identifier for the newly-created block job. If
2514#          omitted, the device name will be used. (Since 2.7)
2515#
2516# @device: the device or node name of the top image
2517#
2518# @base: the common backing file name.
2519#        It cannot be set if @base-node is also set.
2520#
2521# @base-node: the node name of the backing file.
2522#             It cannot be set if @base is also set. (Since 2.8)
2523#
2524# @backing-file: The backing file string to write into the top
2525#                image. This filename is not validated.
2526#
2527#                If a pathname string is such that it cannot be
2528#                resolved by QEMU, that means that subsequent QMP or
2529#                HMP commands must use node-names for the image in
2530#                question, as filename lookup methods will fail.
2531#
2532#                If not specified, QEMU will automatically determine
2533#                the backing file string to use, or error out if there
2534#                is no obvious choice.  Care should be taken when
2535#                specifying the string, to specify a valid filename or
2536#                protocol.
2537#                (Since 2.1)
2538#
2539# @speed: the maximum speed, in bytes per second
2540#
2541# @on-error: the action to take on an error (default report).
2542#            'stop' and 'enospc' can only be used if the block device
2543#            supports io-status (see BlockInfo).  Since 1.3.
2544#
2545# @auto-finalize: When false, this job will wait in a PENDING state after it has
2546#                 finished its work, waiting for @block-job-finalize before
2547#                 making any block graph changes.
2548#                 When true, this job will automatically
2549#                 perform its abort or commit actions.
2550#                 Defaults to true. (Since 3.1)
2551#
2552# @auto-dismiss: When false, this job will wait in a CONCLUDED state after it
2553#                has completely ceased all work, and awaits @block-job-dismiss.
2554#                When true, this job will automatically disappear from the query
2555#                list without user intervention.
2556#                Defaults to true. (Since 3.1)
2557#
2558# Returns: - Nothing on success.
2559#          - If @device does not exist, DeviceNotFound.
2560#
2561# Since: 1.1
2562#
2563# Example:
2564#
2565# -> { "execute": "block-stream",
2566#      "arguments": { "device": "virtio0",
2567#                     "base": "/tmp/master.qcow2" } }
2568# <- { "return": {} }
2569#
2570##
2571{ 'command': 'block-stream',
2572  'data': { '*job-id': 'str', 'device': 'str', '*base': 'str',
2573            '*base-node': 'str', '*backing-file': 'str', '*speed': 'int',
2574            '*on-error': 'BlockdevOnError',
2575            '*auto-finalize': 'bool', '*auto-dismiss': 'bool' } }
2576
2577##
2578# @block-job-set-speed:
2579#
2580# Set maximum speed for a background block operation.
2581#
2582# This command can only be issued when there is an active block job.
2583#
2584# Throttling can be disabled by setting the speed to 0.
2585#
2586# @device: The job identifier. This used to be a device name (hence
2587#          the name of the parameter), but since QEMU 2.7 it can have
2588#          other values.
2589#
2590# @speed: the maximum speed, in bytes per second, or 0 for unlimited.
2591#         Defaults to 0.
2592#
2593# Returns: - Nothing on success
2594#          - If no background operation is active on this device, DeviceNotActive
2595#
2596# Since: 1.1
2597##
2598{ 'command': 'block-job-set-speed',
2599  'data': { 'device': 'str', 'speed': 'int' } }
2600
2601##
2602# @block-job-cancel:
2603#
2604# Stop an active background block operation.
2605#
2606# This command returns immediately after marking the active background block
2607# operation for cancellation.  It is an error to call this command if no
2608# operation is in progress.
2609#
2610# The operation will cancel as soon as possible and then emit the
2611# BLOCK_JOB_CANCELLED event.  Before that happens the job is still visible when
2612# enumerated using query-block-jobs.
2613#
2614# Note that if you issue 'block-job-cancel' after 'drive-mirror' has indicated
2615# (via the event BLOCK_JOB_READY) that the source and destination are
2616# synchronized, then the event triggered by this command changes to
2617# BLOCK_JOB_COMPLETED, to indicate that the mirroring has ended and the
2618# destination now has a point-in-time copy tied to the time of the cancellation.
2619#
2620# For streaming, the image file retains its backing file unless the streaming
2621# operation happens to complete just as it is being cancelled.  A new streaming
2622# operation can be started at a later time to finish copying all data from the
2623# backing file.
2624#
2625# @device: The job identifier. This used to be a device name (hence
2626#          the name of the parameter), but since QEMU 2.7 it can have
2627#          other values.
2628#
2629# @force: If true, and the job has already emitted the event BLOCK_JOB_READY,
2630#         abandon the job immediately (even if it is paused) instead of waiting
2631#         for the destination to complete its final synchronization (since 1.3)
2632#
2633# Returns: - Nothing on success
2634#          - If no background operation is active on this device, DeviceNotActive
2635#
2636# Since: 1.1
2637##
2638{ 'command': 'block-job-cancel', 'data': { 'device': 'str', '*force': 'bool' } }
2639
2640##
2641# @block-job-pause:
2642#
2643# Pause an active background block operation.
2644#
2645# This command returns immediately after marking the active background block
2646# operation for pausing.  It is an error to call this command if no
2647# operation is in progress or if the job is already paused.
2648#
2649# The operation will pause as soon as possible.  No event is emitted when
2650# the operation is actually paused.  Cancelling a paused job automatically
2651# resumes it.
2652#
2653# @device: The job identifier. This used to be a device name (hence
2654#          the name of the parameter), but since QEMU 2.7 it can have
2655#          other values.
2656#
2657# Returns: - Nothing on success
2658#          - If no background operation is active on this device, DeviceNotActive
2659#
2660# Since: 1.3
2661##
2662{ 'command': 'block-job-pause', 'data': { 'device': 'str' } }
2663
2664##
2665# @block-job-resume:
2666#
2667# Resume an active background block operation.
2668#
2669# This command returns immediately after resuming a paused background block
2670# operation.  It is an error to call this command if no operation is in
2671# progress or if the job is not paused.
2672#
2673# This command also clears the error status of the job.
2674#
2675# @device: The job identifier. This used to be a device name (hence
2676#          the name of the parameter), but since QEMU 2.7 it can have
2677#          other values.
2678#
2679# Returns: - Nothing on success
2680#          - If no background operation is active on this device, DeviceNotActive
2681#
2682# Since: 1.3
2683##
2684{ 'command': 'block-job-resume', 'data': { 'device': 'str' } }
2685
2686##
2687# @block-job-complete:
2688#
2689# Manually trigger completion of an active background block operation.  This
2690# is supported for drive mirroring, where it also switches the device to
2691# write to the target path only.  The ability to complete is signaled with
2692# a BLOCK_JOB_READY event.
2693#
2694# This command completes an active background block operation synchronously.
2695# The ordering of this command's return with the BLOCK_JOB_COMPLETED event
2696# is not defined.  Note that if an I/O error occurs during the processing of
2697# this command: 1) the command itself will fail; 2) the error will be processed
2698# according to the rerror/werror arguments that were specified when starting
2699# the operation.
2700#
2701# A cancelled or paused job cannot be completed.
2702#
2703# @device: The job identifier. This used to be a device name (hence
2704#          the name of the parameter), but since QEMU 2.7 it can have
2705#          other values.
2706#
2707# Returns: - Nothing on success
2708#          - If no background operation is active on this device, DeviceNotActive
2709#
2710# Since: 1.3
2711##
2712{ 'command': 'block-job-complete', 'data': { 'device': 'str' } }
2713
2714##
2715# @block-job-dismiss:
2716#
2717# For jobs that have already concluded, remove them from the block-job-query
2718# list. This command only needs to be run for jobs which were started with
2719# QEMU 2.12+ job lifetime management semantics.
2720#
2721# This command will refuse to operate on any job that has not yet reached
2722# its terminal state, JOB_STATUS_CONCLUDED. For jobs that make use of the
2723# BLOCK_JOB_READY event, block-job-cancel or block-job-complete will still need
2724# to be used as appropriate.
2725#
2726# @id: The job identifier.
2727#
2728# Returns: Nothing on success
2729#
2730# Since: 2.12
2731##
2732{ 'command': 'block-job-dismiss', 'data': { 'id': 'str' } }
2733
2734##
2735# @block-job-finalize:
2736#
2737# Once a job that has manual=true reaches the pending state, it can be
2738# instructed to finalize any graph changes and do any necessary cleanup
2739# via this command.
2740# For jobs in a transaction, instructing one job to finalize will force
2741# ALL jobs in the transaction to finalize, so it is only necessary to instruct
2742# a single member job to finalize.
2743#
2744# @id: The job identifier.
2745#
2746# Returns: Nothing on success
2747#
2748# Since: 2.12
2749##
2750{ 'command': 'block-job-finalize', 'data': { 'id': 'str' } }
2751
2752##
2753# @BlockdevDiscardOptions:
2754#
2755# Determines how to handle discard requests.
2756#
2757# @ignore: Ignore the request
2758# @unmap: Forward as an unmap request
2759#
2760# Since: 2.9
2761##
2762{ 'enum': 'BlockdevDiscardOptions',
2763  'data': [ 'ignore', 'unmap' ] }
2764
2765##
2766# @BlockdevDetectZeroesOptions:
2767#
2768# Describes the operation mode for the automatic conversion of plain
2769# zero writes by the OS to driver specific optimized zero write commands.
2770#
2771# @off: Disabled (default)
2772# @on: Enabled
2773# @unmap: Enabled and even try to unmap blocks if possible. This requires
2774#         also that @BlockdevDiscardOptions is set to unmap for this device.
2775#
2776# Since: 2.1
2777##
2778{ 'enum': 'BlockdevDetectZeroesOptions',
2779  'data': [ 'off', 'on', 'unmap' ] }
2780
2781##
2782# @BlockdevAioOptions:
2783#
2784# Selects the AIO backend to handle I/O requests
2785#
2786# @threads: Use qemu's thread pool
2787# @native: Use native AIO backend (only Linux and Windows)
2788# @io_uring: Use linux io_uring (since 5.0)
2789#
2790# Since: 2.9
2791##
2792{ 'enum': 'BlockdevAioOptions',
2793  'data': [ 'threads', 'native',
2794            { 'name': 'io_uring', 'if': 'defined(CONFIG_LINUX_IO_URING)' } ] }
2795
2796##
2797# @BlockdevCacheOptions:
2798#
2799# Includes cache-related options for block devices
2800#
2801# @direct: enables use of O_DIRECT (bypass the host page cache;
2802#          default: false)
2803# @no-flush: ignore any flush requests for the device (default:
2804#            false)
2805#
2806# Since: 2.9
2807##
2808{ 'struct': 'BlockdevCacheOptions',
2809  'data': { '*direct': 'bool',
2810            '*no-flush': 'bool' } }
2811
2812##
2813# @BlockdevDriver:
2814#
2815# Drivers that are supported in block device operations.
2816#
2817# @throttle: Since 2.11
2818# @nvme: Since 2.12
2819# @copy-on-read: Since 3.0
2820# @blklogwrites: Since 3.0
2821# @blkreplay: Since 4.2
2822# @compress: Since 5.0
2823#
2824# Since: 2.9
2825##
2826{ 'enum': 'BlockdevDriver',
2827  'data': [ 'blkdebug', 'blklogwrites', 'blkreplay', 'blkverify', 'bochs',
2828            'cloop', 'compress', 'copy-on-read', 'dmg', 'file', 'ftp', 'ftps',
2829            'gluster', 'host_cdrom', 'host_device', 'http', 'https', 'iscsi',
2830            'luks', 'nbd', 'nfs', 'null-aio', 'null-co', 'nvme', 'parallels',
2831            'qcow', 'qcow2', 'qed', 'quorum', 'raw', 'rbd',
2832            { 'name': 'replication', 'if': 'defined(CONFIG_REPLICATION)' },
2833            'sheepdog',
2834            'ssh', 'throttle', 'vdi', 'vhdx', 'vmdk', 'vpc', 'vvfat' ] }
2835
2836##
2837# @BlockdevOptionsFile:
2838#
2839# Driver specific block device options for the file backend.
2840#
2841# @filename: path to the image file
2842# @pr-manager: the id for the object that will handle persistent reservations
2843#              for this device (default: none, forward the commands via SG_IO;
2844#              since 2.11)
2845# @aio: AIO backend (default: threads) (since: 2.8)
2846# @locking: whether to enable file locking. If set to 'auto', only enable
2847#           when Open File Descriptor (OFD) locking API is available
2848#           (default: auto, since 2.10)
2849# @drop-cache: invalidate page cache during live migration.  This prevents
2850#              stale data on the migration destination with cache.direct=off.
2851#              Currently only supported on Linux hosts.
2852#              (default: on, since: 4.0)
2853# @x-check-cache-dropped: whether to check that page cache was dropped on live
2854#                         migration.  May cause noticeable delays if the image
2855#                         file is large, do not use in production.
2856#                         (default: off) (since: 3.0)
2857#
2858# Features:
2859# @dynamic-auto-read-only: If present, enabled auto-read-only means that the
2860#                          driver will open the image read-only at first,
2861#                          dynamically reopen the image file read-write when
2862#                          the first writer is attached to the node and reopen
2863#                          read-only when the last writer is detached. This
2864#                          allows giving QEMU write permissions only on demand
2865#                          when an operation actually needs write access.
2866#
2867# Since: 2.9
2868##
2869{ 'struct': 'BlockdevOptionsFile',
2870  'data': { 'filename': 'str',
2871            '*pr-manager': 'str',
2872            '*locking': 'OnOffAuto',
2873            '*aio': 'BlockdevAioOptions',
2874            '*drop-cache': {'type': 'bool',
2875                            'if': 'defined(CONFIG_LINUX)'},
2876            '*x-check-cache-dropped': 'bool' },
2877  'features': [ { 'name': 'dynamic-auto-read-only',
2878                  'if': 'defined(CONFIG_POSIX)' } ] }
2879
2880##
2881# @BlockdevOptionsNull:
2882#
2883# Driver specific block device options for the null backend.
2884#
2885# @size: size of the device in bytes.
2886# @latency-ns: emulated latency (in nanoseconds) in processing
2887#              requests. Default to zero which completes requests immediately.
2888#              (Since 2.4)
2889# @read-zeroes: if true, reads from the device produce zeroes; if false, the
2890#               buffer is left unchanged. (default: false; since: 4.1)
2891#
2892# Since: 2.9
2893##
2894{ 'struct': 'BlockdevOptionsNull',
2895  'data': { '*size': 'int', '*latency-ns': 'uint64', '*read-zeroes': 'bool' } }
2896
2897##
2898# @BlockdevOptionsNVMe:
2899#
2900# Driver specific block device options for the NVMe backend.
2901#
2902# @device: PCI controller address of the NVMe device in
2903#          format hhhh:bb:ss.f (host:bus:slot.function)
2904# @namespace: namespace number of the device, starting from 1.
2905#
2906# Note that the PCI @device must have been unbound from any host
2907# kernel driver before instructing QEMU to add the blockdev.
2908#
2909# Since: 2.12
2910##
2911{ 'struct': 'BlockdevOptionsNVMe',
2912  'data': { 'device': 'str', 'namespace': 'int' } }
2913
2914##
2915# @BlockdevOptionsVVFAT:
2916#
2917# Driver specific block device options for the vvfat protocol.
2918#
2919# @dir: directory to be exported as FAT image
2920# @fat-type: FAT type: 12, 16 or 32
2921# @floppy: whether to export a floppy image (true) or
2922#          partitioned hard disk (false; default)
2923# @label: set the volume label, limited to 11 bytes. FAT16 and
2924#         FAT32 traditionally have some restrictions on labels, which are
2925#         ignored by most operating systems. Defaults to "QEMU VVFAT".
2926#         (since 2.4)
2927# @rw: whether to allow write operations (default: false)
2928#
2929# Since: 2.9
2930##
2931{ 'struct': 'BlockdevOptionsVVFAT',
2932  'data': { 'dir': 'str', '*fat-type': 'int', '*floppy': 'bool',
2933            '*label': 'str', '*rw': 'bool' } }
2934
2935##
2936# @BlockdevOptionsGenericFormat:
2937#
2938# Driver specific block device options for image format that have no option
2939# besides their data source.
2940#
2941# @file: reference to or definition of the data source block device
2942#
2943# Since: 2.9
2944##
2945{ 'struct': 'BlockdevOptionsGenericFormat',
2946  'data': { 'file': 'BlockdevRef' } }
2947
2948##
2949# @BlockdevOptionsLUKS:
2950#
2951# Driver specific block device options for LUKS.
2952#
2953# @key-secret: the ID of a QCryptoSecret object providing
2954#              the decryption key (since 2.6). Mandatory except when
2955#              doing a metadata-only probe of the image.
2956#
2957# Since: 2.9
2958##
2959{ 'struct': 'BlockdevOptionsLUKS',
2960  'base': 'BlockdevOptionsGenericFormat',
2961  'data': { '*key-secret': 'str' } }
2962
2963
2964##
2965# @BlockdevOptionsGenericCOWFormat:
2966#
2967# Driver specific block device options for image format that have no option
2968# besides their data source and an optional backing file.
2969#
2970# @backing: reference to or definition of the backing file block
2971#           device, null disables the backing file entirely.
2972#           Defaults to the backing file stored the image file.
2973#
2974# Since: 2.9
2975##
2976{ 'struct': 'BlockdevOptionsGenericCOWFormat',
2977  'base': 'BlockdevOptionsGenericFormat',
2978  'data': { '*backing': 'BlockdevRefOrNull' } }
2979
2980##
2981# @Qcow2OverlapCheckMode:
2982#
2983# General overlap check modes.
2984#
2985# @none: Do not perform any checks
2986#
2987# @constant: Perform only checks which can be done in constant time and
2988#            without reading anything from disk
2989#
2990# @cached: Perform only checks which can be done without reading anything
2991#          from disk
2992#
2993# @all: Perform all available overlap checks
2994#
2995# Since: 2.9
2996##
2997{ 'enum': 'Qcow2OverlapCheckMode',
2998  'data': [ 'none', 'constant', 'cached', 'all' ] }
2999
3000##
3001# @Qcow2OverlapCheckFlags:
3002#
3003# Structure of flags for each metadata structure. Setting a field to 'true'
3004# makes qemu guard that structure against unintended overwriting. The default
3005# value is chosen according to the template given.
3006#
3007# @template: Specifies a template mode which can be adjusted using the other
3008#            flags, defaults to 'cached'
3009#
3010# @bitmap-directory: since 3.0
3011#
3012# Since: 2.9
3013##
3014{ 'struct': 'Qcow2OverlapCheckFlags',
3015  'data': { '*template':         'Qcow2OverlapCheckMode',
3016            '*main-header':      'bool',
3017            '*active-l1':        'bool',
3018            '*active-l2':        'bool',
3019            '*refcount-table':   'bool',
3020            '*refcount-block':   'bool',
3021            '*snapshot-table':   'bool',
3022            '*inactive-l1':      'bool',
3023            '*inactive-l2':      'bool',
3024            '*bitmap-directory': 'bool' } }
3025
3026##
3027# @Qcow2OverlapChecks:
3028#
3029# Specifies which metadata structures should be guarded against unintended
3030# overwriting.
3031#
3032# @flags: set of flags for separate specification of each metadata structure
3033#         type
3034#
3035# @mode: named mode which chooses a specific set of flags
3036#
3037# Since: 2.9
3038##
3039{ 'alternate': 'Qcow2OverlapChecks',
3040  'data': { 'flags': 'Qcow2OverlapCheckFlags',
3041            'mode':  'Qcow2OverlapCheckMode' } }
3042
3043##
3044# @BlockdevQcowEncryptionFormat:
3045#
3046# @aes: AES-CBC with plain64 initialization vectors
3047#
3048# Since: 2.10
3049##
3050{ 'enum': 'BlockdevQcowEncryptionFormat',
3051  'data': [ 'aes' ] }
3052
3053##
3054# @BlockdevQcowEncryption:
3055#
3056# Since: 2.10
3057##
3058{ 'union': 'BlockdevQcowEncryption',
3059  'base': { 'format': 'BlockdevQcowEncryptionFormat' },
3060  'discriminator': 'format',
3061  'data': { 'aes': 'QCryptoBlockOptionsQCow' } }
3062
3063##
3064# @BlockdevOptionsQcow:
3065#
3066# Driver specific block device options for qcow.
3067#
3068# @encrypt: Image decryption options. Mandatory for
3069#           encrypted images, except when doing a metadata-only
3070#           probe of the image.
3071#
3072# Since: 2.10
3073##
3074{ 'struct': 'BlockdevOptionsQcow',
3075  'base': 'BlockdevOptionsGenericCOWFormat',
3076  'data': { '*encrypt': 'BlockdevQcowEncryption' } }
3077
3078
3079
3080##
3081# @BlockdevQcow2EncryptionFormat:
3082# @aes: AES-CBC with plain64 initialization vectors
3083#
3084# Since: 2.10
3085##
3086{ 'enum': 'BlockdevQcow2EncryptionFormat',
3087  'data': [ 'aes', 'luks' ] }
3088
3089##
3090# @BlockdevQcow2Encryption:
3091#
3092# Since: 2.10
3093##
3094{ 'union': 'BlockdevQcow2Encryption',
3095  'base': { 'format': 'BlockdevQcow2EncryptionFormat' },
3096  'discriminator': 'format',
3097  'data': { 'aes': 'QCryptoBlockOptionsQCow',
3098            'luks': 'QCryptoBlockOptionsLUKS'} }
3099
3100##
3101# @BlockdevOptionsQcow2:
3102#
3103# Driver specific block device options for qcow2.
3104#
3105# @lazy-refcounts: whether to enable the lazy refcounts
3106#                  feature (default is taken from the image file)
3107#
3108# @pass-discard-request: whether discard requests to the qcow2
3109#                        device should be forwarded to the data source
3110#
3111# @pass-discard-snapshot: whether discard requests for the data source
3112#                         should be issued when a snapshot operation (e.g.
3113#                         deleting a snapshot) frees clusters in the qcow2 file
3114#
3115# @pass-discard-other: whether discard requests for the data source
3116#                      should be issued on other occasions where a cluster
3117#                      gets freed
3118#
3119# @overlap-check: which overlap checks to perform for writes
3120#                 to the image, defaults to 'cached' (since 2.2)
3121#
3122# @cache-size: the maximum total size of the L2 table and
3123#              refcount block caches in bytes (since 2.2)
3124#
3125# @l2-cache-size: the maximum size of the L2 table cache in
3126#                 bytes (since 2.2)
3127#
3128# @l2-cache-entry-size: the size of each entry in the L2 cache in
3129#                       bytes. It must be a power of two between 512
3130#                       and the cluster size. The default value is
3131#                       the cluster size (since 2.12)
3132#
3133# @refcount-cache-size: the maximum size of the refcount block cache
3134#                       in bytes (since 2.2)
3135#
3136# @cache-clean-interval: clean unused entries in the L2 and refcount
3137#                        caches. The interval is in seconds. The default value
3138#                        is 600 on supporting platforms, and 0 on other
3139#                        platforms. 0 disables this feature. (since 2.5)
3140#
3141# @encrypt: Image decryption options. Mandatory for
3142#           encrypted images, except when doing a metadata-only
3143#           probe of the image. (since 2.10)
3144#
3145# @data-file: reference to or definition of the external data file.
3146#             This may only be specified for images that require an
3147#             external data file. If it is not specified for such
3148#             an image, the data file name is loaded from the image
3149#             file. (since 4.0)
3150#
3151# Since: 2.9
3152##
3153{ 'struct': 'BlockdevOptionsQcow2',
3154  'base': 'BlockdevOptionsGenericCOWFormat',
3155  'data': { '*lazy-refcounts': 'bool',
3156            '*pass-discard-request': 'bool',
3157            '*pass-discard-snapshot': 'bool',
3158            '*pass-discard-other': 'bool',
3159            '*overlap-check': 'Qcow2OverlapChecks',
3160            '*cache-size': 'int',
3161            '*l2-cache-size': 'int',
3162            '*l2-cache-entry-size': 'int',
3163            '*refcount-cache-size': 'int',
3164            '*cache-clean-interval': 'int',
3165            '*encrypt': 'BlockdevQcow2Encryption',
3166            '*data-file': 'BlockdevRef' } }
3167
3168##
3169# @SshHostKeyCheckMode:
3170#
3171# @none: Don't check the host key at all
3172# @hash: Compare the host key with a given hash
3173# @known_hosts: Check the host key against the known_hosts file
3174#
3175# Since: 2.12
3176##
3177{ 'enum': 'SshHostKeyCheckMode',
3178  'data': [ 'none', 'hash', 'known_hosts' ] }
3179
3180##
3181# @SshHostKeyCheckHashType:
3182#
3183# @md5: The given hash is an md5 hash
3184# @sha1: The given hash is an sha1 hash
3185#
3186# Since: 2.12
3187##
3188{ 'enum': 'SshHostKeyCheckHashType',
3189  'data': [ 'md5', 'sha1' ] }
3190
3191##
3192# @SshHostKeyHash:
3193#
3194# @type: The hash algorithm used for the hash
3195# @hash: The expected hash value
3196#
3197# Since: 2.12
3198##
3199{ 'struct': 'SshHostKeyHash',
3200  'data': { 'type': 'SshHostKeyCheckHashType',
3201            'hash': 'str' }}
3202
3203##
3204# @SshHostKeyCheck:
3205#
3206# Since: 2.12
3207##
3208{ 'union': 'SshHostKeyCheck',
3209  'base': { 'mode': 'SshHostKeyCheckMode' },
3210  'discriminator': 'mode',
3211  'data': { 'hash': 'SshHostKeyHash' } }
3212
3213##
3214# @BlockdevOptionsSsh:
3215#
3216# @server:              host address
3217#
3218# @path:                path to the image on the host
3219#
3220# @user:                user as which to connect, defaults to current
3221#                       local user name
3222#
3223# @host-key-check:      Defines how and what to check the host key against
3224#                       (default: known_hosts)
3225#
3226# Since: 2.9
3227##
3228{ 'struct': 'BlockdevOptionsSsh',
3229  'data': { 'server': 'InetSocketAddress',
3230            'path': 'str',
3231            '*user': 'str',
3232            '*host-key-check': 'SshHostKeyCheck' } }
3233
3234
3235##
3236# @BlkdebugEvent:
3237#
3238# Trigger events supported by blkdebug.
3239#
3240# @l1_shrink_write_table: write zeros to the l1 table to shrink image.
3241#                         (since 2.11)
3242#
3243# @l1_shrink_free_l2_clusters: discard the l2 tables. (since 2.11)
3244#
3245# @cor_write: a write due to copy-on-read (since 2.11)
3246#
3247# @cluster_alloc_space: an allocation of file space for a cluster (since 4.1)
3248#
3249# @none: triggers once at creation of the blkdebug node (since 4.1)
3250#
3251# Since: 2.9
3252##
3253{ 'enum': 'BlkdebugEvent', 'prefix': 'BLKDBG',
3254  'data': [ 'l1_update', 'l1_grow_alloc_table', 'l1_grow_write_table',
3255            'l1_grow_activate_table', 'l2_load', 'l2_update',
3256            'l2_update_compressed', 'l2_alloc_cow_read', 'l2_alloc_write',
3257            'read_aio', 'read_backing_aio', 'read_compressed', 'write_aio',
3258            'write_compressed', 'vmstate_load', 'vmstate_save', 'cow_read',
3259            'cow_write', 'reftable_load', 'reftable_grow', 'reftable_update',
3260            'refblock_load', 'refblock_update', 'refblock_update_part',
3261            'refblock_alloc', 'refblock_alloc_hookup', 'refblock_alloc_write',
3262            'refblock_alloc_write_blocks', 'refblock_alloc_write_table',
3263            'refblock_alloc_switch_table', 'cluster_alloc',
3264            'cluster_alloc_bytes', 'cluster_free', 'flush_to_os',
3265            'flush_to_disk', 'pwritev_rmw_head', 'pwritev_rmw_after_head',
3266            'pwritev_rmw_tail', 'pwritev_rmw_after_tail', 'pwritev',
3267            'pwritev_zero', 'pwritev_done', 'empty_image_prepare',
3268            'l1_shrink_write_table', 'l1_shrink_free_l2_clusters',
3269            'cor_write', 'cluster_alloc_space', 'none'] }
3270
3271##
3272# @BlkdebugIOType:
3273#
3274# Kinds of I/O that blkdebug can inject errors in.
3275#
3276# @read: .bdrv_co_preadv()
3277#
3278# @write: .bdrv_co_pwritev()
3279#
3280# @write-zeroes: .bdrv_co_pwrite_zeroes()
3281#
3282# @discard: .bdrv_co_pdiscard()
3283#
3284# @flush: .bdrv_co_flush_to_disk()
3285#
3286# @block-status: .bdrv_co_block_status()
3287#
3288# Since: 4.1
3289##
3290{ 'enum': 'BlkdebugIOType', 'prefix': 'BLKDEBUG_IO_TYPE',
3291  'data': [ 'read', 'write', 'write-zeroes', 'discard', 'flush',
3292            'block-status' ] }
3293
3294##
3295# @BlkdebugInjectErrorOptions:
3296#
3297# Describes a single error injection for blkdebug.
3298#
3299# @event: trigger event
3300#
3301# @state: the state identifier blkdebug needs to be in to
3302#         actually trigger the event; defaults to "any"
3303#
3304# @iotype: the type of I/O operations on which this error should
3305#          be injected; defaults to "all read, write,
3306#          write-zeroes, discard, and flush operations"
3307#          (since: 4.1)
3308#
3309# @errno: error identifier (errno) to be returned; defaults to
3310#         EIO
3311#
3312# @sector: specifies the sector index which has to be affected
3313#          in order to actually trigger the event; defaults to "any
3314#          sector"
3315#
3316# @once: disables further events after this one has been
3317#        triggered; defaults to false
3318#
3319# @immediately: fail immediately; defaults to false
3320#
3321# Since: 2.9
3322##
3323{ 'struct': 'BlkdebugInjectErrorOptions',
3324  'data': { 'event': 'BlkdebugEvent',
3325            '*state': 'int',
3326            '*iotype': 'BlkdebugIOType',
3327            '*errno': 'int',
3328            '*sector': 'int',
3329            '*once': 'bool',
3330            '*immediately': 'bool' } }
3331
3332##
3333# @BlkdebugSetStateOptions:
3334#
3335# Describes a single state-change event for blkdebug.
3336#
3337# @event: trigger event
3338#
3339# @state: the current state identifier blkdebug needs to be in;
3340#         defaults to "any"
3341#
3342# @new_state: the state identifier blkdebug is supposed to assume if
3343#             this event is triggered
3344#
3345# Since: 2.9
3346##
3347{ 'struct': 'BlkdebugSetStateOptions',
3348  'data': { 'event': 'BlkdebugEvent',
3349            '*state': 'int',
3350            'new_state': 'int' } }
3351
3352##
3353# @BlockdevOptionsBlkdebug:
3354#
3355# Driver specific block device options for blkdebug.
3356#
3357# @image: underlying raw block device (or image file)
3358#
3359# @config: filename of the configuration file
3360#
3361# @align: required alignment for requests in bytes, must be
3362#         positive power of 2, or 0 for default
3363#
3364# @max-transfer: maximum size for I/O transfers in bytes, must be
3365#                positive multiple of @align and of the underlying
3366#                file's request alignment (but need not be a power of
3367#                2), or 0 for default (since 2.10)
3368#
3369# @opt-write-zero: preferred alignment for write zero requests in bytes,
3370#                  must be positive multiple of @align and of the
3371#                  underlying file's request alignment (but need not be a
3372#                  power of 2), or 0 for default (since 2.10)
3373#
3374# @max-write-zero: maximum size for write zero requests in bytes, must be
3375#                  positive multiple of @align, of @opt-write-zero, and of
3376#                  the underlying file's request alignment (but need not
3377#                  be a power of 2), or 0 for default (since 2.10)
3378#
3379# @opt-discard: preferred alignment for discard requests in bytes, must
3380#               be positive multiple of @align and of the underlying
3381#               file's request alignment (but need not be a power of
3382#               2), or 0 for default (since 2.10)
3383#
3384# @max-discard: maximum size for discard requests in bytes, must be
3385#               positive multiple of @align, of @opt-discard, and of
3386#               the underlying file's request alignment (but need not
3387#               be a power of 2), or 0 for default (since 2.10)
3388#
3389# @inject-error: array of error injection descriptions
3390#
3391# @set-state: array of state-change descriptions
3392#
3393# @take-child-perms: Permissions to take on @image in addition to what
3394#                    is necessary anyway (which depends on how the
3395#                    blkdebug node is used).  Defaults to none.
3396#                    (since 5.0)
3397#
3398# @unshare-child-perms: Permissions not to share on @image in addition
3399#                       to what cannot be shared anyway (which depends
3400#                       on how the blkdebug node is used).  Defaults
3401#                       to none.  (since 5.0)
3402#
3403# Since: 2.9
3404##
3405{ 'struct': 'BlockdevOptionsBlkdebug',
3406  'data': { 'image': 'BlockdevRef',
3407            '*config': 'str',
3408            '*align': 'int', '*max-transfer': 'int32',
3409            '*opt-write-zero': 'int32', '*max-write-zero': 'int32',
3410            '*opt-discard': 'int32', '*max-discard': 'int32',
3411            '*inject-error': ['BlkdebugInjectErrorOptions'],
3412            '*set-state': ['BlkdebugSetStateOptions'],
3413            '*take-child-perms': ['BlockPermission'],
3414            '*unshare-child-perms': ['BlockPermission'] } }
3415
3416##
3417# @BlockdevOptionsBlklogwrites:
3418#
3419# Driver specific block device options for blklogwrites.
3420#
3421# @file: block device
3422#
3423# @log: block device used to log writes to @file
3424#
3425# @log-sector-size: sector size used in logging writes to @file, determines
3426#                   granularity of offsets and sizes of writes (default: 512)
3427#
3428# @log-append: append to an existing log (default: false)
3429#
3430# @log-super-update-interval: interval of write requests after which the log
3431#                             super block is updated to disk (default: 4096)
3432#
3433# Since: 3.0
3434##
3435{ 'struct': 'BlockdevOptionsBlklogwrites',
3436  'data': { 'file': 'BlockdevRef',
3437            'log': 'BlockdevRef',
3438            '*log-sector-size': 'uint32',
3439            '*log-append': 'bool',
3440            '*log-super-update-interval': 'uint64' } }
3441
3442##
3443# @BlockdevOptionsBlkverify:
3444#
3445# Driver specific block device options for blkverify.
3446#
3447# @test: block device to be tested
3448#
3449# @raw: raw image used for verification
3450#
3451# Since: 2.9
3452##
3453{ 'struct': 'BlockdevOptionsBlkverify',
3454  'data': { 'test': 'BlockdevRef',
3455            'raw': 'BlockdevRef' } }
3456
3457##
3458# @BlockdevOptionsBlkreplay:
3459#
3460# Driver specific block device options for blkreplay.
3461#
3462# @image: disk image which should be controlled with blkreplay
3463#
3464# Since: 4.2
3465##
3466{ 'struct': 'BlockdevOptionsBlkreplay',
3467  'data': { 'image': 'BlockdevRef' } }
3468
3469##
3470# @QuorumReadPattern:
3471#
3472# An enumeration of quorum read patterns.
3473#
3474# @quorum: read all the children and do a quorum vote on reads
3475#
3476# @fifo: read only from the first child that has not failed
3477#
3478# Since: 2.9
3479##
3480{ 'enum': 'QuorumReadPattern', 'data': [ 'quorum', 'fifo' ] }
3481
3482##
3483# @BlockdevOptionsQuorum:
3484#
3485# Driver specific block device options for Quorum
3486#
3487# @blkverify: true if the driver must print content mismatch
3488#                  set to false by default
3489#
3490# @children: the children block devices to use
3491#
3492# @vote-threshold: the vote limit under which a read will fail
3493#
3494# @rewrite-corrupted: rewrite corrupted data when quorum is reached
3495#                     (Since 2.1)
3496#
3497# @read-pattern: choose read pattern and set to quorum by default
3498#                (Since 2.2)
3499#
3500# Since: 2.9
3501##
3502{ 'struct': 'BlockdevOptionsQuorum',
3503  'data': { '*blkverify': 'bool',
3504            'children': [ 'BlockdevRef' ],
3505            'vote-threshold': 'int',
3506            '*rewrite-corrupted': 'bool',
3507            '*read-pattern': 'QuorumReadPattern' } }
3508
3509##
3510# @BlockdevOptionsGluster:
3511#
3512# Driver specific block device options for Gluster
3513#
3514# @volume: name of gluster volume where VM image resides
3515#
3516# @path: absolute path to image file in gluster volume
3517#
3518# @server: gluster servers description
3519#
3520# @debug: libgfapi log level (default '4' which is Error)
3521#         (Since 2.8)
3522#
3523# @logfile: libgfapi log file (default /dev/stderr) (Since 2.8)
3524#
3525# Since: 2.9
3526##
3527{ 'struct': 'BlockdevOptionsGluster',
3528  'data': { 'volume': 'str',
3529            'path': 'str',
3530            'server': ['SocketAddress'],
3531            '*debug': 'int',
3532            '*logfile': 'str' } }
3533
3534##
3535# @IscsiTransport:
3536#
3537# An enumeration of libiscsi transport types
3538#
3539# Since: 2.9
3540##
3541{ 'enum': 'IscsiTransport',
3542  'data': [ 'tcp', 'iser' ] }
3543
3544##
3545# @IscsiHeaderDigest:
3546#
3547# An enumeration of header digests supported by libiscsi
3548#
3549# Since: 2.9
3550##
3551{ 'enum': 'IscsiHeaderDigest',
3552  'prefix': 'QAPI_ISCSI_HEADER_DIGEST',
3553  'data': [ 'crc32c', 'none', 'crc32c-none', 'none-crc32c' ] }
3554
3555##
3556# @BlockdevOptionsIscsi:
3557#
3558# @transport: The iscsi transport type
3559#
3560# @portal: The address of the iscsi portal
3561#
3562# @target: The target iqn name
3563#
3564# @lun: LUN to connect to. Defaults to 0.
3565#
3566# @user: User name to log in with. If omitted, no CHAP
3567#        authentication is performed.
3568#
3569# @password-secret: The ID of a QCryptoSecret object providing
3570#                   the password for the login. This option is required if
3571#                   @user is specified.
3572#
3573# @initiator-name: The iqn name we want to identify to the target
3574#                  as. If this option is not specified, an initiator name is
3575#                  generated automatically.
3576#
3577# @header-digest: The desired header digest. Defaults to
3578#                 none-crc32c.
3579#
3580# @timeout: Timeout in seconds after which a request will
3581#           timeout. 0 means no timeout and is the default.
3582#
3583# Driver specific block device options for iscsi
3584#
3585# Since: 2.9
3586##
3587{ 'struct': 'BlockdevOptionsIscsi',
3588  'data': { 'transport': 'IscsiTransport',
3589            'portal': 'str',
3590            'target': 'str',
3591            '*lun': 'int',
3592            '*user': 'str',
3593            '*password-secret': 'str',
3594            '*initiator-name': 'str',
3595            '*header-digest': 'IscsiHeaderDigest',
3596            '*timeout': 'int' } }
3597
3598
3599##
3600# @RbdAuthMode:
3601#
3602# Since: 3.0
3603##
3604{ 'enum': 'RbdAuthMode',
3605  'data': [ 'cephx', 'none' ] }
3606
3607##
3608# @BlockdevOptionsRbd:
3609#
3610# @pool: Ceph pool name.
3611#
3612# @namespace: Rados namespace name in the Ceph pool. (Since 5.0)
3613#
3614# @image: Image name in the Ceph pool.
3615#
3616# @conf: path to Ceph configuration file.  Values
3617#        in the configuration file will be overridden by
3618#        options specified via QAPI.
3619#
3620# @snapshot: Ceph snapshot name.
3621#
3622# @user: Ceph id name.
3623#
3624# @auth-client-required: Acceptable authentication modes.
3625#                        This maps to Ceph configuration option
3626#                        "auth_client_required".  (Since 3.0)
3627#
3628# @key-secret: ID of a QCryptoSecret object providing a key
3629#              for cephx authentication.
3630#              This maps to Ceph configuration option
3631#              "key".  (Since 3.0)
3632#
3633# @server: Monitor host address and port.  This maps
3634#          to the "mon_host" Ceph option.
3635#
3636# Since: 2.9
3637##
3638{ 'struct': 'BlockdevOptionsRbd',
3639  'data': { 'pool': 'str',
3640            '*namespace': 'str',
3641            'image': 'str',
3642            '*conf': 'str',
3643            '*snapshot': 'str',
3644            '*user': 'str',
3645            '*auth-client-required': ['RbdAuthMode'],
3646            '*key-secret': 'str',
3647            '*server': ['InetSocketAddressBase'] } }
3648
3649##
3650# @BlockdevOptionsSheepdog:
3651#
3652# Driver specific block device options for sheepdog
3653#
3654# @vdi: Virtual disk image name
3655# @server: The Sheepdog server to connect to
3656# @snap-id: Snapshot ID
3657# @tag: Snapshot tag name
3658#
3659# Only one of @snap-id and @tag may be present.
3660#
3661# Since: 2.9
3662##
3663{ 'struct': 'BlockdevOptionsSheepdog',
3664  'data': { 'server': 'SocketAddress',
3665            'vdi': 'str',
3666            '*snap-id': 'uint32',
3667            '*tag': 'str' } }
3668
3669##
3670# @ReplicationMode:
3671#
3672# An enumeration of replication modes.
3673#
3674# @primary: Primary mode, the vm's state will be sent to secondary QEMU.
3675#
3676# @secondary: Secondary mode, receive the vm's state from primary QEMU.
3677#
3678# Since: 2.9
3679##
3680{ 'enum' : 'ReplicationMode', 'data' : [ 'primary', 'secondary' ],
3681  'if': 'defined(CONFIG_REPLICATION)' }
3682
3683##
3684# @BlockdevOptionsReplication:
3685#
3686# Driver specific block device options for replication
3687#
3688# @mode: the replication mode
3689#
3690# @top-id: In secondary mode, node name or device ID of the root
3691#          node who owns the replication node chain. Must not be given in
3692#          primary mode.
3693#
3694# Since: 2.9
3695##
3696{ 'struct': 'BlockdevOptionsReplication',
3697  'base': 'BlockdevOptionsGenericFormat',
3698  'data': { 'mode': 'ReplicationMode',
3699            '*top-id': 'str' },
3700  'if': 'defined(CONFIG_REPLICATION)' }
3701
3702##
3703# @NFSTransport:
3704#
3705# An enumeration of NFS transport types
3706#
3707# @inet: TCP transport
3708#
3709# Since: 2.9
3710##
3711{ 'enum': 'NFSTransport',
3712  'data': [ 'inet' ] }
3713
3714##
3715# @NFSServer:
3716#
3717# Captures the address of the socket
3718#
3719# @type: transport type used for NFS (only TCP supported)
3720#
3721# @host: host address for NFS server
3722#
3723# Since: 2.9
3724##
3725{ 'struct': 'NFSServer',
3726  'data': { 'type': 'NFSTransport',
3727            'host': 'str' } }
3728
3729##
3730# @BlockdevOptionsNfs:
3731#
3732# Driver specific block device option for NFS
3733#
3734# @server: host address
3735#
3736# @path: path of the image on the host
3737#
3738# @user: UID value to use when talking to the
3739#        server (defaults to 65534 on Windows and getuid()
3740#        on unix)
3741#
3742# @group: GID value to use when talking to the
3743#         server (defaults to 65534 on Windows and getgid()
3744#         in unix)
3745#
3746# @tcp-syn-count: number of SYNs during the session
3747#                 establishment (defaults to libnfs default)
3748#
3749# @readahead-size: set the readahead size in bytes (defaults
3750#                  to libnfs default)
3751#
3752# @page-cache-size: set the pagecache size in bytes (defaults
3753#                   to libnfs default)
3754#
3755# @debug: set the NFS debug level (max 2) (defaults
3756#         to libnfs default)
3757#
3758# Since: 2.9
3759##
3760{ 'struct': 'BlockdevOptionsNfs',
3761  'data': { 'server': 'NFSServer',
3762            'path': 'str',
3763            '*user': 'int',
3764            '*group': 'int',
3765            '*tcp-syn-count': 'int',
3766            '*readahead-size': 'int',
3767            '*page-cache-size': 'int',
3768            '*debug': 'int' } }
3769
3770##
3771# @BlockdevOptionsCurlBase:
3772#
3773# Driver specific block device options shared by all protocols supported by the
3774# curl backend.
3775#
3776# @url: URL of the image file
3777#
3778# @readahead: Size of the read-ahead cache; must be a multiple of
3779#             512 (defaults to 256 kB)
3780#
3781# @timeout: Timeout for connections, in seconds (defaults to 5)
3782#
3783# @username: Username for authentication (defaults to none)
3784#
3785# @password-secret: ID of a QCryptoSecret object providing a password
3786#                   for authentication (defaults to no password)
3787#
3788# @proxy-username: Username for proxy authentication (defaults to none)
3789#
3790# @proxy-password-secret: ID of a QCryptoSecret object providing a password
3791#                         for proxy authentication (defaults to no password)
3792#
3793# Since: 2.9
3794##
3795{ 'struct': 'BlockdevOptionsCurlBase',
3796  'data': { 'url': 'str',
3797            '*readahead': 'int',
3798            '*timeout': 'int',
3799            '*username': 'str',
3800            '*password-secret': 'str',
3801            '*proxy-username': 'str',
3802            '*proxy-password-secret': 'str' } }
3803
3804##
3805# @BlockdevOptionsCurlHttp:
3806#
3807# Driver specific block device options for HTTP connections over the curl
3808# backend.  URLs must start with "http://".
3809#
3810# @cookie: List of cookies to set; format is
3811#          "name1=content1; name2=content2;" as explained by
3812#          CURLOPT_COOKIE(3). Defaults to no cookies.
3813#
3814# @cookie-secret: ID of a QCryptoSecret object providing the cookie data in a
3815#                 secure way. See @cookie for the format. (since 2.10)
3816#
3817# Since: 2.9
3818##
3819{ 'struct': 'BlockdevOptionsCurlHttp',
3820  'base': 'BlockdevOptionsCurlBase',
3821  'data': { '*cookie': 'str',
3822            '*cookie-secret': 'str'} }
3823
3824##
3825# @BlockdevOptionsCurlHttps:
3826#
3827# Driver specific block device options for HTTPS connections over the curl
3828# backend.  URLs must start with "https://".
3829#
3830# @cookie: List of cookies to set; format is
3831#          "name1=content1; name2=content2;" as explained by
3832#          CURLOPT_COOKIE(3). Defaults to no cookies.
3833#
3834# @sslverify: Whether to verify the SSL certificate's validity (defaults to
3835#             true)
3836#
3837# @cookie-secret: ID of a QCryptoSecret object providing the cookie data in a
3838#                 secure way. See @cookie for the format. (since 2.10)
3839#
3840# Since: 2.9
3841##
3842{ 'struct': 'BlockdevOptionsCurlHttps',
3843  'base': 'BlockdevOptionsCurlBase',
3844  'data': { '*cookie': 'str',
3845            '*sslverify': 'bool',
3846            '*cookie-secret': 'str'} }
3847
3848##
3849# @BlockdevOptionsCurlFtp:
3850#
3851# Driver specific block device options for FTP connections over the curl
3852# backend.  URLs must start with "ftp://".
3853#
3854# Since: 2.9
3855##
3856{ 'struct': 'BlockdevOptionsCurlFtp',
3857  'base': 'BlockdevOptionsCurlBase',
3858  'data': { } }
3859
3860##
3861# @BlockdevOptionsCurlFtps:
3862#
3863# Driver specific block device options for FTPS connections over the curl
3864# backend.  URLs must start with "ftps://".
3865#
3866# @sslverify: Whether to verify the SSL certificate's validity (defaults to
3867#             true)
3868#
3869# Since: 2.9
3870##
3871{ 'struct': 'BlockdevOptionsCurlFtps',
3872  'base': 'BlockdevOptionsCurlBase',
3873  'data': { '*sslverify': 'bool' } }
3874
3875##
3876# @BlockdevOptionsNbd:
3877#
3878# Driver specific block device options for NBD.
3879#
3880# @server: NBD server address
3881#
3882# @export: export name
3883#
3884# @tls-creds: TLS credentials ID
3885#
3886# @x-dirty-bitmap: A "qemu:dirty-bitmap:NAME" string to query in place of
3887#                  traditional "base:allocation" block status (see
3888#                  NBD_OPT_LIST_META_CONTEXT in the NBD protocol) (since 3.0)
3889#
3890# @reconnect-delay: On an unexpected disconnect, the nbd client tries to
3891#                   connect again until succeeding or encountering a serious
3892#                   error.  During the first @reconnect-delay seconds, all
3893#                   requests are paused and will be rerun on a successful
3894#                   reconnect. After that time, any delayed requests and all
3895#                   future requests before a successful reconnect will
3896#                   immediately fail. Default 0 (Since 4.2)
3897#
3898# Since: 2.9
3899##
3900{ 'struct': 'BlockdevOptionsNbd',
3901  'data': { 'server': 'SocketAddress',
3902            '*export': 'str',
3903            '*tls-creds': 'str',
3904            '*x-dirty-bitmap': 'str',
3905            '*reconnect-delay': 'uint32' } }
3906
3907##
3908# @BlockdevOptionsRaw:
3909#
3910# Driver specific block device options for the raw driver.
3911#
3912# @offset: position where the block device starts
3913# @size: the assumed size of the device
3914#
3915# Since: 2.9
3916##
3917{ 'struct': 'BlockdevOptionsRaw',
3918  'base': 'BlockdevOptionsGenericFormat',
3919  'data': { '*offset': 'int', '*size': 'int' } }
3920
3921##
3922# @BlockdevOptionsThrottle:
3923#
3924# Driver specific block device options for the throttle driver
3925#
3926# @throttle-group: the name of the throttle-group object to use. It
3927#                  must already exist.
3928# @file: reference to or definition of the data source block device
3929# Since: 2.11
3930##
3931{ 'struct': 'BlockdevOptionsThrottle',
3932  'data': { 'throttle-group': 'str',
3933            'file' : 'BlockdevRef'
3934             } }
3935##
3936# @BlockdevOptions:
3937#
3938# Options for creating a block device.  Many options are available for all
3939# block devices, independent of the block driver:
3940#
3941# @driver: block driver name
3942# @node-name: the node name of the new node (Since 2.0).
3943#             This option is required on the top level of blockdev-add.
3944#             Valid node names start with an alphabetic character and may
3945#             contain only alphanumeric characters, '-', '.' and '_'. Their
3946#             maximum length is 31 characters.
3947# @discard: discard-related options (default: ignore)
3948# @cache: cache-related options
3949# @read-only: whether the block device should be read-only (default: false).
3950#             Note that some block drivers support only read-only access,
3951#             either generally or in certain configurations. In this case,
3952#             the default value does not work and the option must be
3953#             specified explicitly.
3954# @auto-read-only: if true and @read-only is false, QEMU may automatically
3955#                  decide not to open the image read-write as requested, but
3956#                  fall back to read-only instead (and switch between the modes
3957#                  later), e.g. depending on whether the image file is writable
3958#                  or whether a writing user is attached to the node
3959#                  (default: false, since 3.1)
3960# @detect-zeroes: detect and optimize zero writes (Since 2.1)
3961#                 (default: off)
3962# @force-share: force share all permission on added nodes.
3963#               Requires read-only=true. (Since 2.10)
3964#
3965# Remaining options are determined by the block driver.
3966#
3967# Since: 2.9
3968##
3969{ 'union': 'BlockdevOptions',
3970  'base': { 'driver': 'BlockdevDriver',
3971            '*node-name': 'str',
3972            '*discard': 'BlockdevDiscardOptions',
3973            '*cache': 'BlockdevCacheOptions',
3974            '*read-only': 'bool',
3975            '*auto-read-only': 'bool',
3976            '*force-share': 'bool',
3977            '*detect-zeroes': 'BlockdevDetectZeroesOptions' },
3978  'discriminator': 'driver',
3979  'data': {
3980      'blkdebug':   'BlockdevOptionsBlkdebug',
3981      'blklogwrites':'BlockdevOptionsBlklogwrites',
3982      'blkverify':  'BlockdevOptionsBlkverify',
3983      'blkreplay':  'BlockdevOptionsBlkreplay',
3984      'bochs':      'BlockdevOptionsGenericFormat',
3985      'cloop':      'BlockdevOptionsGenericFormat',
3986      'compress':   'BlockdevOptionsGenericFormat',
3987      'copy-on-read':'BlockdevOptionsGenericFormat',
3988      'dmg':        'BlockdevOptionsGenericFormat',
3989      'file':       'BlockdevOptionsFile',
3990      'ftp':        'BlockdevOptionsCurlFtp',
3991      'ftps':       'BlockdevOptionsCurlFtps',
3992      'gluster':    'BlockdevOptionsGluster',
3993      'host_cdrom': 'BlockdevOptionsFile',
3994      'host_device':'BlockdevOptionsFile',
3995      'http':       'BlockdevOptionsCurlHttp',
3996      'https':      'BlockdevOptionsCurlHttps',
3997      'iscsi':      'BlockdevOptionsIscsi',
3998      'luks':       'BlockdevOptionsLUKS',
3999      'nbd':        'BlockdevOptionsNbd',
4000      'nfs':        'BlockdevOptionsNfs',
4001      'null-aio':   'BlockdevOptionsNull',
4002      'null-co':    'BlockdevOptionsNull',
4003      'nvme':       'BlockdevOptionsNVMe',
4004      'parallels':  'BlockdevOptionsGenericFormat',
4005      'qcow2':      'BlockdevOptionsQcow2',
4006      'qcow':       'BlockdevOptionsQcow',
4007      'qed':        'BlockdevOptionsGenericCOWFormat',
4008      'quorum':     'BlockdevOptionsQuorum',
4009      'raw':        'BlockdevOptionsRaw',
4010      'rbd':        'BlockdevOptionsRbd',
4011      'replication': { 'type': 'BlockdevOptionsReplication',
4012                       'if': 'defined(CONFIG_REPLICATION)' },
4013      'sheepdog':   'BlockdevOptionsSheepdog',
4014      'ssh':        'BlockdevOptionsSsh',
4015      'throttle':   'BlockdevOptionsThrottle',
4016      'vdi':        'BlockdevOptionsGenericFormat',
4017      'vhdx':       'BlockdevOptionsGenericFormat',
4018      'vmdk':       'BlockdevOptionsGenericCOWFormat',
4019      'vpc':        'BlockdevOptionsGenericFormat',
4020      'vvfat':      'BlockdevOptionsVVFAT'
4021  } }
4022
4023##
4024# @BlockdevRef:
4025#
4026# Reference to a block device.
4027#
4028# @definition: defines a new block device inline
4029# @reference: references the ID of an existing block device
4030#
4031# Since: 2.9
4032##
4033{ 'alternate': 'BlockdevRef',
4034  'data': { 'definition': 'BlockdevOptions',
4035            'reference': 'str' } }
4036
4037##
4038# @BlockdevRefOrNull:
4039#
4040# Reference to a block device.
4041#
4042# @definition: defines a new block device inline
4043# @reference: references the ID of an existing block device.
4044#             An empty string means that no block device should
4045#             be referenced.  Deprecated; use null instead.
4046# @null: No block device should be referenced (since 2.10)
4047#
4048# Since: 2.9
4049##
4050{ 'alternate': 'BlockdevRefOrNull',
4051  'data': { 'definition': 'BlockdevOptions',
4052            'reference': 'str',
4053            'null': 'null' } }
4054
4055##
4056# @blockdev-add:
4057#
4058# Creates a new block device.
4059#
4060# Since: 2.9
4061#
4062# Example:
4063#
4064# 1.
4065# -> { "execute": "blockdev-add",
4066#      "arguments": {
4067#           "driver": "qcow2",
4068#           "node-name": "test1",
4069#           "file": {
4070#               "driver": "file",
4071#               "filename": "test.qcow2"
4072#            }
4073#       }
4074#     }
4075# <- { "return": {} }
4076#
4077# 2.
4078# -> { "execute": "blockdev-add",
4079#      "arguments": {
4080#           "driver": "qcow2",
4081#           "node-name": "node0",
4082#           "discard": "unmap",
4083#           "cache": {
4084#              "direct": true
4085#            },
4086#            "file": {
4087#              "driver": "file",
4088#              "filename": "/tmp/test.qcow2"
4089#            },
4090#            "backing": {
4091#               "driver": "raw",
4092#               "file": {
4093#                  "driver": "file",
4094#                  "filename": "/dev/fdset/4"
4095#                }
4096#            }
4097#        }
4098#      }
4099#
4100# <- { "return": {} }
4101#
4102##
4103{ 'command': 'blockdev-add', 'data': 'BlockdevOptions', 'boxed': true }
4104
4105##
4106# @x-blockdev-reopen:
4107#
4108# Reopens a block device using the given set of options. Any option
4109# not specified will be reset to its default value regardless of its
4110# previous status. If an option cannot be changed or a particular
4111# driver does not support reopening then the command will return an
4112# error.
4113#
4114# The top-level @node-name option (from BlockdevOptions) must be
4115# specified and is used to select the block device to be reopened.
4116# Other @node-name options must be either omitted or set to the
4117# current name of the appropriate node. This command won't change any
4118# node name and any attempt to do it will result in an error.
4119#
4120# In the case of options that refer to child nodes, the behavior of
4121# this command depends on the value:
4122#
4123#  1) A set of options (BlockdevOptions): the child is reopened with
4124#     the specified set of options.
4125#
4126#  2) A reference to the current child: the child is reopened using
4127#     its existing set of options.
4128#
4129#  3) A reference to a different node: the current child is replaced
4130#     with the specified one.
4131#
4132#  4) NULL: the current child (if any) is detached.
4133#
4134# Options (1) and (2) are supported in all cases, but at the moment
4135# only @backing allows replacing or detaching an existing child.
4136#
4137# Unlike with blockdev-add, the @backing option must always be present
4138# unless the node being reopened does not have a backing file and its
4139# image does not have a default backing file name as part of its
4140# metadata.
4141#
4142# Since: 4.0
4143##
4144{ 'command': 'x-blockdev-reopen',
4145  'data': 'BlockdevOptions', 'boxed': true }
4146
4147##
4148# @blockdev-del:
4149#
4150# Deletes a block device that has been added using blockdev-add.
4151# The command will fail if the node is attached to a device or is
4152# otherwise being used.
4153#
4154# @node-name: Name of the graph node to delete.
4155#
4156# Since: 2.9
4157#
4158# Example:
4159#
4160# -> { "execute": "blockdev-add",
4161#      "arguments": {
4162#           "driver": "qcow2",
4163#           "node-name": "node0",
4164#           "file": {
4165#               "driver": "file",
4166#               "filename": "test.qcow2"
4167#           }
4168#      }
4169#    }
4170# <- { "return": {} }
4171#
4172# -> { "execute": "blockdev-del",
4173#      "arguments": { "node-name": "node0" }
4174#    }
4175# <- { "return": {} }
4176#
4177##
4178{ 'command': 'blockdev-del', 'data': { 'node-name': 'str' } }
4179
4180##
4181# @BlockdevCreateOptionsFile:
4182#
4183# Driver specific image creation options for file.
4184#
4185# @filename: Filename for the new image file
4186# @size: Size of the virtual disk in bytes
4187# @preallocation: Preallocation mode for the new image (default: off;
4188#                 allowed values: off,
4189#                 falloc (if defined CONFIG_POSIX_FALLOCATE),
4190#                 full (if defined CONFIG_POSIX))
4191# @nocow: Turn off copy-on-write (valid only on btrfs; default: off)
4192# @extent-size-hint: Extent size hint to add to the image file; 0 for not
4193#                    adding an extent size hint (default: 1 MB, since 5.1)
4194#
4195# Since: 2.12
4196##
4197{ 'struct': 'BlockdevCreateOptionsFile',
4198  'data': { 'filename':             'str',
4199            'size':                 'size',
4200            '*preallocation':       'PreallocMode',
4201            '*nocow':               'bool',
4202            '*extent-size-hint':    'size'} }
4203
4204##
4205# @BlockdevCreateOptionsGluster:
4206#
4207# Driver specific image creation options for gluster.
4208#
4209# @location: Where to store the new image file
4210# @size: Size of the virtual disk in bytes
4211# @preallocation: Preallocation mode for the new image (default: off;
4212#                 allowed values: off,
4213#                 falloc (if defined CONFIG_GLUSTERFS_FALLOCATE),
4214#                 full (if defined CONFIG_GLUSTERFS_ZEROFILL))
4215#
4216# Since: 2.12
4217##
4218{ 'struct': 'BlockdevCreateOptionsGluster',
4219  'data': { 'location':         'BlockdevOptionsGluster',
4220            'size':             'size',
4221            '*preallocation':   'PreallocMode' } }
4222
4223##
4224# @BlockdevCreateOptionsLUKS:
4225#
4226# Driver specific image creation options for LUKS.
4227#
4228# @file: Node to create the image format on
4229# @size: Size of the virtual disk in bytes
4230# @preallocation: Preallocation mode for the new image
4231#                 (since: 4.2)
4232#                 (default: off; allowed values: off, metadata, falloc, full)
4233#
4234# Since: 2.12
4235##
4236{ 'struct': 'BlockdevCreateOptionsLUKS',
4237  'base': 'QCryptoBlockCreateOptionsLUKS',
4238  'data': { 'file':             'BlockdevRef',
4239            'size':             'size',
4240            '*preallocation':   'PreallocMode' } }
4241
4242##
4243# @BlockdevCreateOptionsNfs:
4244#
4245# Driver specific image creation options for NFS.
4246#
4247# @location: Where to store the new image file
4248# @size: Size of the virtual disk in bytes
4249#
4250# Since: 2.12
4251##
4252{ 'struct': 'BlockdevCreateOptionsNfs',
4253  'data': { 'location':         'BlockdevOptionsNfs',
4254            'size':             'size' } }
4255
4256##
4257# @BlockdevCreateOptionsParallels:
4258#
4259# Driver specific image creation options for parallels.
4260#
4261# @file: Node to create the image format on
4262# @size: Size of the virtual disk in bytes
4263# @cluster-size: Cluster size in bytes (default: 1 MB)
4264#
4265# Since: 2.12
4266##
4267{ 'struct': 'BlockdevCreateOptionsParallels',
4268  'data': { 'file':             'BlockdevRef',
4269            'size':             'size',
4270            '*cluster-size':    'size' } }
4271
4272##
4273# @BlockdevCreateOptionsQcow:
4274#
4275# Driver specific image creation options for qcow.
4276#
4277# @file: Node to create the image format on
4278# @size: Size of the virtual disk in bytes
4279# @backing-file: File name of the backing file if a backing file
4280#                should be used
4281# @encrypt: Encryption options if the image should be encrypted
4282#
4283# Since: 2.12
4284##
4285{ 'struct': 'BlockdevCreateOptionsQcow',
4286  'data': { 'file':             'BlockdevRef',
4287            'size':             'size',
4288            '*backing-file':    'str',
4289            '*encrypt':         'QCryptoBlockCreateOptions' } }
4290
4291##
4292# @BlockdevQcow2Version:
4293#
4294# @v2:  The original QCOW2 format as introduced in qemu 0.10 (version 2)
4295# @v3:  The extended QCOW2 format as introduced in qemu 1.1 (version 3)
4296#
4297# Since: 2.12
4298##
4299{ 'enum': 'BlockdevQcow2Version',
4300  'data': [ 'v2', 'v3' ] }
4301
4302
4303##
4304# @Qcow2CompressionType:
4305#
4306# Compression type used in qcow2 image file
4307#
4308# @zlib: zlib compression, see <http://zlib.net/>
4309# @zstd: zstd compression, see <http://github.com/facebook/zstd>
4310#
4311# Since: 5.1
4312##
4313{ 'enum': 'Qcow2CompressionType',
4314  'data': [ 'zlib', { 'name': 'zstd', 'if': 'defined(CONFIG_ZSTD)' } ] }
4315
4316##
4317# @BlockdevCreateOptionsQcow2:
4318#
4319# Driver specific image creation options for qcow2.
4320#
4321# @file: Node to create the image format on
4322# @data-file: Node to use as an external data file in which all guest
4323#             data is stored so that only metadata remains in the qcow2
4324#             file (since: 4.0)
4325# @data-file-raw: True if the external data file must stay valid as a
4326#                 standalone (read-only) raw image without looking at qcow2
4327#                 metadata (default: false; since: 4.0)
4328# @extended-l2: True to make the image have extended L2 entries
4329#               (default: false; since 5.2)
4330# @size: Size of the virtual disk in bytes
4331# @version: Compatibility level (default: v3)
4332# @backing-file: File name of the backing file if a backing file
4333#                should be used
4334# @backing-fmt: Name of the block driver to use for the backing file
4335# @encrypt: Encryption options if the image should be encrypted
4336# @cluster-size: qcow2 cluster size in bytes (default: 65536)
4337# @preallocation: Preallocation mode for the new image (default: off;
4338#                 allowed values: off, falloc, full, metadata)
4339# @lazy-refcounts: True if refcounts may be updated lazily (default: off)
4340# @refcount-bits: Width of reference counts in bits (default: 16)
4341# @compression-type: The image cluster compression method
4342#                    (default: zlib, since 5.1)
4343#
4344# Since: 2.12
4345##
4346{ 'struct': 'BlockdevCreateOptionsQcow2',
4347  'data': { 'file':             'BlockdevRef',
4348            '*data-file':       'BlockdevRef',
4349            '*data-file-raw':   'bool',
4350            '*extended-l2':     'bool',
4351            'size':             'size',
4352            '*version':         'BlockdevQcow2Version',
4353            '*backing-file':    'str',
4354            '*backing-fmt':     'BlockdevDriver',
4355            '*encrypt':         'QCryptoBlockCreateOptions',
4356            '*cluster-size':    'size',
4357            '*preallocation':   'PreallocMode',
4358            '*lazy-refcounts':  'bool',
4359            '*refcount-bits':   'int',
4360            '*compression-type':'Qcow2CompressionType' } }
4361
4362##
4363# @BlockdevCreateOptionsQed:
4364#
4365# Driver specific image creation options for qed.
4366#
4367# @file: Node to create the image format on
4368# @size: Size of the virtual disk in bytes
4369# @backing-file: File name of the backing file if a backing file
4370#                should be used
4371# @backing-fmt: Name of the block driver to use for the backing file
4372# @cluster-size: Cluster size in bytes (default: 65536)
4373# @table-size: L1/L2 table size (in clusters)
4374#
4375# Since: 2.12
4376##
4377{ 'struct': 'BlockdevCreateOptionsQed',
4378  'data': { 'file':             'BlockdevRef',
4379            'size':             'size',
4380            '*backing-file':    'str',
4381            '*backing-fmt':     'BlockdevDriver',
4382            '*cluster-size':    'size',
4383            '*table-size':      'int' } }
4384
4385##
4386# @BlockdevCreateOptionsRbd:
4387#
4388# Driver specific image creation options for rbd/Ceph.
4389#
4390# @location: Where to store the new image file. This location cannot
4391#            point to a snapshot.
4392# @size: Size of the virtual disk in bytes
4393# @cluster-size: RBD object size
4394#
4395# Since: 2.12
4396##
4397{ 'struct': 'BlockdevCreateOptionsRbd',
4398  'data': { 'location':         'BlockdevOptionsRbd',
4399            'size':             'size',
4400            '*cluster-size' :   'size' } }
4401
4402##
4403# @BlockdevVmdkSubformat:
4404#
4405# Subformat options for VMDK images
4406#
4407# @monolithicSparse:     Single file image with sparse cluster allocation
4408#
4409# @monolithicFlat:       Single flat data image and a descriptor file
4410#
4411# @twoGbMaxExtentSparse: Data is split into 2GB (per virtual LBA) sparse extent
4412#                        files, in addition to a descriptor file
4413#
4414# @twoGbMaxExtentFlat:   Data is split into 2GB (per virtual LBA) flat extent
4415#                        files, in addition to a descriptor file
4416#
4417# @streamOptimized:      Single file image sparse cluster allocation, optimized
4418#                        for streaming over network.
4419#
4420# Since: 4.0
4421##
4422{ 'enum': 'BlockdevVmdkSubformat',
4423  'data': [ 'monolithicSparse', 'monolithicFlat', 'twoGbMaxExtentSparse',
4424            'twoGbMaxExtentFlat', 'streamOptimized'] }
4425
4426##
4427# @BlockdevVmdkAdapterType:
4428#
4429# Adapter type info for VMDK images
4430#
4431# Since: 4.0
4432##
4433{ 'enum': 'BlockdevVmdkAdapterType',
4434  'data': [ 'ide', 'buslogic', 'lsilogic', 'legacyESX'] }
4435
4436##
4437# @BlockdevCreateOptionsVmdk:
4438#
4439# Driver specific image creation options for VMDK.
4440#
4441# @file: Where to store the new image file. This refers to the image
4442#        file for monolithcSparse and streamOptimized format, or the
4443#        descriptor file for other formats.
4444# @size: Size of the virtual disk in bytes
4445# @extents: Where to store the data extents. Required for monolithcFlat,
4446#           twoGbMaxExtentSparse and twoGbMaxExtentFlat formats. For
4447#           monolithicFlat, only one entry is required; for
4448#           twoGbMaxExtent* formats, the number of entries required is
4449#           calculated as extent_number = virtual_size / 2GB. Providing
4450#           more extents than will be used is an error.
4451# @subformat: The subformat of the VMDK image. Default: "monolithicSparse".
4452# @backing-file: The path of backing file. Default: no backing file is used.
4453# @adapter-type: The adapter type used to fill in the descriptor. Default: ide.
4454# @hwversion: Hardware version. The meaningful options are "4" or "6".
4455#             Default: "4".
4456# @zeroed-grain: Whether to enable zeroed-grain feature for sparse subformats.
4457#                Default: false.
4458#
4459# Since: 4.0
4460##
4461{ 'struct': 'BlockdevCreateOptionsVmdk',
4462  'data': { 'file':             'BlockdevRef',
4463            'size':             'size',
4464            '*extents':          ['BlockdevRef'],
4465            '*subformat':       'BlockdevVmdkSubformat',
4466            '*backing-file':    'str',
4467            '*adapter-type':    'BlockdevVmdkAdapterType',
4468            '*hwversion':       'str',
4469            '*zeroed-grain':    'bool' } }
4470
4471
4472##
4473# @SheepdogRedundancyType:
4474#
4475# @full: Create a fully replicated vdi with x copies
4476# @erasure-coded: Create an erasure coded vdi with x data strips and
4477#                 y parity strips
4478#
4479# Since: 2.12
4480##
4481{ 'enum': 'SheepdogRedundancyType',
4482  'data': [ 'full', 'erasure-coded' ] }
4483
4484##
4485# @SheepdogRedundancyFull:
4486#
4487# @copies: Number of copies to use (between 1 and 31)
4488#
4489# Since: 2.12
4490##
4491{ 'struct': 'SheepdogRedundancyFull',
4492  'data': { 'copies': 'int' }}
4493
4494##
4495# @SheepdogRedundancyErasureCoded:
4496#
4497# @data-strips: Number of data strips to use (one of {2,4,8,16})
4498# @parity-strips: Number of parity strips to use (between 1 and 15)
4499#
4500# Since: 2.12
4501##
4502{ 'struct': 'SheepdogRedundancyErasureCoded',
4503  'data': { 'data-strips': 'int',
4504            'parity-strips': 'int' }}
4505
4506##
4507# @SheepdogRedundancy:
4508#
4509# Since: 2.12
4510##
4511{ 'union': 'SheepdogRedundancy',
4512  'base': { 'type': 'SheepdogRedundancyType' },
4513  'discriminator': 'type',
4514  'data': { 'full': 'SheepdogRedundancyFull',
4515            'erasure-coded': 'SheepdogRedundancyErasureCoded' } }
4516
4517##
4518# @BlockdevCreateOptionsSheepdog:
4519#
4520# Driver specific image creation options for Sheepdog.
4521#
4522# @location: Where to store the new image file
4523# @size: Size of the virtual disk in bytes
4524# @backing-file: File name of a base image
4525# @preallocation: Preallocation mode for the new image (default: off;
4526#                 allowed values: off, full)
4527# @redundancy: Redundancy of the image
4528# @object-size: Object size of the image
4529#
4530# Since: 2.12
4531##
4532{ 'struct': 'BlockdevCreateOptionsSheepdog',
4533  'data': { 'location':         'BlockdevOptionsSheepdog',
4534            'size':             'size',
4535            '*backing-file':    'str',
4536            '*preallocation':   'PreallocMode',
4537            '*redundancy':      'SheepdogRedundancy',
4538            '*object-size':     'size' } }
4539
4540##
4541# @BlockdevCreateOptionsSsh:
4542#
4543# Driver specific image creation options for SSH.
4544#
4545# @location: Where to store the new image file
4546# @size: Size of the virtual disk in bytes
4547#
4548# Since: 2.12
4549##
4550{ 'struct': 'BlockdevCreateOptionsSsh',
4551  'data': { 'location':         'BlockdevOptionsSsh',
4552            'size':             'size' } }
4553
4554##
4555# @BlockdevCreateOptionsVdi:
4556#
4557# Driver specific image creation options for VDI.
4558#
4559# @file: Node to create the image format on
4560# @size: Size of the virtual disk in bytes
4561# @preallocation: Preallocation mode for the new image (default: off;
4562#                 allowed values: off, metadata)
4563#
4564# Since: 2.12
4565##
4566{ 'struct': 'BlockdevCreateOptionsVdi',
4567  'data': { 'file':             'BlockdevRef',
4568            'size':             'size',
4569            '*preallocation':   'PreallocMode' } }
4570
4571##
4572# @BlockdevVhdxSubformat:
4573#
4574# @dynamic: Growing image file
4575# @fixed:   Preallocated fixed-size image file
4576#
4577# Since: 2.12
4578##
4579{ 'enum': 'BlockdevVhdxSubformat',
4580  'data': [ 'dynamic', 'fixed' ] }
4581
4582##
4583# @BlockdevCreateOptionsVhdx:
4584#
4585# Driver specific image creation options for vhdx.
4586#
4587# @file: Node to create the image format on
4588# @size: Size of the virtual disk in bytes
4589# @log-size: Log size in bytes, must be a multiple of 1 MB
4590#            (default: 1 MB)
4591# @block-size: Block size in bytes, must be a multiple of 1 MB and not
4592#              larger than 256 MB (default: automatically choose a block
4593#              size depending on the image size)
4594# @subformat: vhdx subformat (default: dynamic)
4595# @block-state-zero: Force use of payload blocks of type 'ZERO'. Non-standard,
4596#                    but default.  Do not set to 'off' when using 'qemu-img
4597#                    convert' with subformat=dynamic.
4598#
4599# Since: 2.12
4600##
4601{ 'struct': 'BlockdevCreateOptionsVhdx',
4602  'data': { 'file':                 'BlockdevRef',
4603            'size':                 'size',
4604            '*log-size':            'size',
4605            '*block-size':          'size',
4606            '*subformat':           'BlockdevVhdxSubformat',
4607            '*block-state-zero':    'bool' } }
4608
4609##
4610# @BlockdevVpcSubformat:
4611#
4612# @dynamic: Growing image file
4613# @fixed:   Preallocated fixed-size image file
4614#
4615# Since: 2.12
4616##
4617{ 'enum': 'BlockdevVpcSubformat',
4618  'data': [ 'dynamic', 'fixed' ] }
4619
4620##
4621# @BlockdevCreateOptionsVpc:
4622#
4623# Driver specific image creation options for vpc (VHD).
4624#
4625# @file: Node to create the image format on
4626# @size: Size of the virtual disk in bytes
4627# @subformat: vhdx subformat (default: dynamic)
4628# @force-size: Force use of the exact byte size instead of rounding to the
4629#              next size that can be represented in CHS geometry
4630#              (default: false)
4631#
4632# Since: 2.12
4633##
4634{ 'struct': 'BlockdevCreateOptionsVpc',
4635  'data': { 'file':                 'BlockdevRef',
4636            'size':                 'size',
4637            '*subformat':           'BlockdevVpcSubformat',
4638            '*force-size':          'bool' } }
4639
4640##
4641# @BlockdevCreateOptions:
4642#
4643# Options for creating an image format on a given node.
4644#
4645# @driver: block driver to create the image format
4646#
4647# Since: 2.12
4648##
4649{ 'union': 'BlockdevCreateOptions',
4650  'base': {
4651      'driver':         'BlockdevDriver' },
4652  'discriminator': 'driver',
4653  'data': {
4654      'file':           'BlockdevCreateOptionsFile',
4655      'gluster':        'BlockdevCreateOptionsGluster',
4656      'luks':           'BlockdevCreateOptionsLUKS',
4657      'nfs':            'BlockdevCreateOptionsNfs',
4658      'parallels':      'BlockdevCreateOptionsParallels',
4659      'qcow':           'BlockdevCreateOptionsQcow',
4660      'qcow2':          'BlockdevCreateOptionsQcow2',
4661      'qed':            'BlockdevCreateOptionsQed',
4662      'rbd':            'BlockdevCreateOptionsRbd',
4663      'sheepdog':       'BlockdevCreateOptionsSheepdog',
4664      'ssh':            'BlockdevCreateOptionsSsh',
4665      'vdi':            'BlockdevCreateOptionsVdi',
4666      'vhdx':           'BlockdevCreateOptionsVhdx',
4667      'vmdk':           'BlockdevCreateOptionsVmdk',
4668      'vpc':            'BlockdevCreateOptionsVpc'
4669  } }
4670
4671##
4672# @blockdev-create:
4673#
4674# Starts a job to create an image format on a given node. The job is
4675# automatically finalized, but a manual job-dismiss is required.
4676#
4677# @job-id:          Identifier for the newly created job.
4678#
4679# @options:         Options for the image creation.
4680#
4681# Since: 3.0
4682##
4683{ 'command': 'blockdev-create',
4684  'data': { 'job-id': 'str',
4685            'options': 'BlockdevCreateOptions' } }
4686
4687##
4688# @BlockdevAmendOptionsLUKS:
4689#
4690# Driver specific image amend options for LUKS.
4691#
4692# Since: 5.1
4693##
4694{ 'struct': 'BlockdevAmendOptionsLUKS',
4695  'base': 'QCryptoBlockAmendOptionsLUKS',
4696  'data': { }
4697}
4698
4699##
4700# @BlockdevAmendOptionsQcow2:
4701#
4702# Driver specific image amend options for qcow2.
4703# For now, only encryption options can be amended
4704#
4705# @encrypt          Encryption options to be amended
4706#
4707# Since: 5.1
4708##
4709{ 'struct': 'BlockdevAmendOptionsQcow2',
4710  'data': { '*encrypt':         'QCryptoBlockAmendOptions' } }
4711
4712##
4713# @BlockdevAmendOptions:
4714#
4715# Options for amending an image format
4716#
4717# @driver:          Block driver of the node to amend.
4718#
4719# Since: 5.1
4720##
4721{ 'union': 'BlockdevAmendOptions',
4722  'base': {
4723      'driver':         'BlockdevDriver' },
4724  'discriminator': 'driver',
4725  'data': {
4726      'luks':           'BlockdevAmendOptionsLUKS',
4727      'qcow2':          'BlockdevAmendOptionsQcow2' } }
4728
4729##
4730# @x-blockdev-amend:
4731#
4732# Starts a job to amend format specific options of an existing open block device
4733# The job is automatically finalized, but a manual job-dismiss is required.
4734#
4735# @job-id:          Identifier for the newly created job.
4736#
4737# @node-name:       Name of the block node to work on
4738#
4739# @options:         Options (driver specific)
4740#
4741# @force:           Allow unsafe operations, format specific
4742#                   For luks that allows erase of the last active keyslot
4743#                   (permanent loss of data),
4744#                   and replacement of an active keyslot
4745#                   (possible loss of data if IO error happens)
4746#
4747# Since: 5.1
4748##
4749{ 'command': 'x-blockdev-amend',
4750  'data': { 'job-id': 'str',
4751            'node-name': 'str',
4752            'options': 'BlockdevAmendOptions',
4753            '*force': 'bool' } }
4754
4755##
4756# @BlockErrorAction:
4757#
4758# An enumeration of action that has been taken when a DISK I/O occurs
4759#
4760# @ignore: error has been ignored
4761#
4762# @report: error has been reported to the device
4763#
4764# @stop: error caused VM to be stopped
4765#
4766# Since: 2.1
4767##
4768{ 'enum': 'BlockErrorAction',
4769  'data': [ 'ignore', 'report', 'stop' ] }
4770
4771
4772##
4773# @BLOCK_IMAGE_CORRUPTED:
4774#
4775# Emitted when a disk image is being marked corrupt. The image can be
4776# identified by its device or node name. The 'device' field is always
4777# present for compatibility reasons, but it can be empty ("") if the
4778# image does not have a device name associated.
4779#
4780# @device: device name. This is always present for compatibility
4781#          reasons, but it can be empty ("") if the image does not
4782#          have a device name associated.
4783#
4784# @node-name: node name (Since: 2.4)
4785#
4786# @msg: informative message for human consumption, such as the kind of
4787#       corruption being detected. It should not be parsed by machine as it is
4788#       not guaranteed to be stable
4789#
4790# @offset: if the corruption resulted from an image access, this is
4791#          the host's access offset into the image
4792#
4793# @size: if the corruption resulted from an image access, this is
4794#        the access size
4795#
4796# @fatal: if set, the image is marked corrupt and therefore unusable after this
4797#         event and must be repaired (Since 2.2; before, every
4798#         BLOCK_IMAGE_CORRUPTED event was fatal)
4799#
4800# Note: If action is "stop", a STOP event will eventually follow the
4801#       BLOCK_IO_ERROR event.
4802#
4803# Example:
4804#
4805# <- { "event": "BLOCK_IMAGE_CORRUPTED",
4806#      "data": { "device": "ide0-hd0", "node-name": "node0",
4807#                "msg": "Prevented active L1 table overwrite", "offset": 196608,
4808#                "size": 65536 },
4809#      "timestamp": { "seconds": 1378126126, "microseconds": 966463 } }
4810#
4811# Since: 1.7
4812##
4813{ 'event': 'BLOCK_IMAGE_CORRUPTED',
4814  'data': { 'device'     : 'str',
4815            '*node-name' : 'str',
4816            'msg'        : 'str',
4817            '*offset'    : 'int',
4818            '*size'      : 'int',
4819            'fatal'      : 'bool' } }
4820
4821##
4822# @BLOCK_IO_ERROR:
4823#
4824# Emitted when a disk I/O error occurs
4825#
4826# @device: device name. This is always present for compatibility
4827#          reasons, but it can be empty ("") if the image does not
4828#          have a device name associated.
4829#
4830# @node-name: node name. Note that errors may be reported for the root node
4831#             that is directly attached to a guest device rather than for the
4832#             node where the error occurred. The node name is not present if
4833#             the drive is empty. (Since: 2.8)
4834#
4835# @operation: I/O operation
4836#
4837# @action: action that has been taken
4838#
4839# @nospace: true if I/O error was caused due to a no-space
4840#           condition. This key is only present if query-block's
4841#           io-status is present, please see query-block documentation
4842#           for more information (since: 2.2)
4843#
4844# @reason: human readable string describing the error cause.
4845#          (This field is a debugging aid for humans, it should not
4846#          be parsed by applications) (since: 2.2)
4847#
4848# Note: If action is "stop", a STOP event will eventually follow the
4849#       BLOCK_IO_ERROR event
4850#
4851# Since: 0.13.0
4852#
4853# Example:
4854#
4855# <- { "event": "BLOCK_IO_ERROR",
4856#      "data": { "device": "ide0-hd1",
4857#                "node-name": "#block212",
4858#                "operation": "write",
4859#                "action": "stop" },
4860#      "timestamp": { "seconds": 1265044230, "microseconds": 450486 } }
4861#
4862##
4863{ 'event': 'BLOCK_IO_ERROR',
4864  'data': { 'device': 'str', '*node-name': 'str',
4865            'operation': 'IoOperationType',
4866            'action': 'BlockErrorAction', '*nospace': 'bool',
4867            'reason': 'str' } }
4868
4869##
4870# @BLOCK_JOB_COMPLETED:
4871#
4872# Emitted when a block job has completed
4873#
4874# @type: job type
4875#
4876# @device: The job identifier. Originally the device name but other
4877#          values are allowed since QEMU 2.7
4878#
4879# @len: maximum progress value
4880#
4881# @offset: current progress value. On success this is equal to len.
4882#          On failure this is less than len
4883#
4884# @speed: rate limit, bytes per second
4885#
4886# @error: error message. Only present on failure. This field
4887#         contains a human-readable error message. There are no semantics
4888#         other than that streaming has failed and clients should not try to
4889#         interpret the error string
4890#
4891# Since: 1.1
4892#
4893# Example:
4894#
4895# <- { "event": "BLOCK_JOB_COMPLETED",
4896#      "data": { "type": "stream", "device": "virtio-disk0",
4897#                "len": 10737418240, "offset": 10737418240,
4898#                "speed": 0 },
4899#      "timestamp": { "seconds": 1267061043, "microseconds": 959568 } }
4900#
4901##
4902{ 'event': 'BLOCK_JOB_COMPLETED',
4903  'data': { 'type'  : 'JobType',
4904            'device': 'str',
4905            'len'   : 'int',
4906            'offset': 'int',
4907            'speed' : 'int',
4908            '*error': 'str' } }
4909
4910##
4911# @BLOCK_JOB_CANCELLED:
4912#
4913# Emitted when a block job has been cancelled
4914#
4915# @type: job type
4916#
4917# @device: The job identifier. Originally the device name but other
4918#          values are allowed since QEMU 2.7
4919#
4920# @len: maximum progress value
4921#
4922# @offset: current progress value. On success this is equal to len.
4923#          On failure this is less than len
4924#
4925# @speed: rate limit, bytes per second
4926#
4927# Since: 1.1
4928#
4929# Example:
4930#
4931# <- { "event": "BLOCK_JOB_CANCELLED",
4932#      "data": { "type": "stream", "device": "virtio-disk0",
4933#                "len": 10737418240, "offset": 134217728,
4934#                "speed": 0 },
4935#      "timestamp": { "seconds": 1267061043, "microseconds": 959568 } }
4936#
4937##
4938{ 'event': 'BLOCK_JOB_CANCELLED',
4939  'data': { 'type'  : 'JobType',
4940            'device': 'str',
4941            'len'   : 'int',
4942            'offset': 'int',
4943            'speed' : 'int' } }
4944
4945##
4946# @BLOCK_JOB_ERROR:
4947#
4948# Emitted when a block job encounters an error
4949#
4950# @device: The job identifier. Originally the device name but other
4951#          values are allowed since QEMU 2.7
4952#
4953# @operation: I/O operation
4954#
4955# @action: action that has been taken
4956#
4957# Since: 1.3
4958#
4959# Example:
4960#
4961# <- { "event": "BLOCK_JOB_ERROR",
4962#      "data": { "device": "ide0-hd1",
4963#                "operation": "write",
4964#                "action": "stop" },
4965#      "timestamp": { "seconds": 1265044230, "microseconds": 450486 } }
4966#
4967##
4968{ 'event': 'BLOCK_JOB_ERROR',
4969  'data': { 'device'   : 'str',
4970            'operation': 'IoOperationType',
4971            'action'   : 'BlockErrorAction' } }
4972
4973##
4974# @BLOCK_JOB_READY:
4975#
4976# Emitted when a block job is ready to complete
4977#
4978# @type: job type
4979#
4980# @device: The job identifier. Originally the device name but other
4981#          values are allowed since QEMU 2.7
4982#
4983# @len: maximum progress value
4984#
4985# @offset: current progress value. On success this is equal to len.
4986#          On failure this is less than len
4987#
4988# @speed: rate limit, bytes per second
4989#
4990# Note: The "ready to complete" status is always reset by a @BLOCK_JOB_ERROR
4991#       event
4992#
4993# Since: 1.3
4994#
4995# Example:
4996#
4997# <- { "event": "BLOCK_JOB_READY",
4998#      "data": { "device": "drive0", "type": "mirror", "speed": 0,
4999#                "len": 2097152, "offset": 2097152 }
5000#      "timestamp": { "seconds": 1265044230, "microseconds": 450486 } }
5001#
5002##
5003{ 'event': 'BLOCK_JOB_READY',
5004  'data': { 'type'  : 'JobType',
5005            'device': 'str',
5006            'len'   : 'int',
5007            'offset': 'int',
5008            'speed' : 'int' } }
5009
5010##
5011# @BLOCK_JOB_PENDING:
5012#
5013# Emitted when a block job is awaiting explicit authorization to finalize graph
5014# changes via @block-job-finalize. If this job is part of a transaction, it will
5015# not emit this event until the transaction has converged first.
5016#
5017# @type: job type
5018#
5019# @id: The job identifier.
5020#
5021# Since: 2.12
5022#
5023# Example:
5024#
5025# <- { "event": "BLOCK_JOB_WAITING",
5026#      "data": { "device": "drive0", "type": "mirror" },
5027#      "timestamp": { "seconds": 1265044230, "microseconds": 450486 } }
5028#
5029##
5030{ 'event': 'BLOCK_JOB_PENDING',
5031  'data': { 'type'  : 'JobType',
5032            'id'    : 'str' } }
5033
5034##
5035# @PreallocMode:
5036#
5037# Preallocation mode of QEMU image file
5038#
5039# @off: no preallocation
5040# @metadata: preallocate only for metadata
5041# @falloc: like @full preallocation but allocate disk space by
5042#          posix_fallocate() rather than writing data.
5043# @full: preallocate all data by writing it to the device to ensure
5044#        disk space is really available. This data may or may not be
5045#        zero, depending on the image format and storage.
5046#        @full preallocation also sets up metadata correctly.
5047#
5048# Since: 2.2
5049##
5050{ 'enum': 'PreallocMode',
5051  'data': [ 'off', 'metadata', 'falloc', 'full' ] }
5052
5053##
5054# @BLOCK_WRITE_THRESHOLD:
5055#
5056# Emitted when writes on block device reaches or exceeds the
5057# configured write threshold. For thin-provisioned devices, this
5058# means the device should be extended to avoid pausing for
5059# disk exhaustion.
5060# The event is one shot. Once triggered, it needs to be
5061# re-registered with another block-set-write-threshold command.
5062#
5063# @node-name: graph node name on which the threshold was exceeded.
5064#
5065# @amount-exceeded: amount of data which exceeded the threshold, in bytes.
5066#
5067# @write-threshold: last configured threshold, in bytes.
5068#
5069# Since: 2.3
5070##
5071{ 'event': 'BLOCK_WRITE_THRESHOLD',
5072  'data': { 'node-name': 'str',
5073            'amount-exceeded': 'uint64',
5074            'write-threshold': 'uint64' } }
5075
5076##
5077# @block-set-write-threshold:
5078#
5079# Change the write threshold for a block drive. An event will be
5080# delivered if a write to this block drive crosses the configured
5081# threshold.  The threshold is an offset, thus must be
5082# non-negative. Default is no write threshold. Setting the threshold
5083# to zero disables it.
5084#
5085# This is useful to transparently resize thin-provisioned drives without
5086# the guest OS noticing.
5087#
5088# @node-name: graph node name on which the threshold must be set.
5089#
5090# @write-threshold: configured threshold for the block device, bytes.
5091#                   Use 0 to disable the threshold.
5092#
5093# Since: 2.3
5094#
5095# Example:
5096#
5097# -> { "execute": "block-set-write-threshold",
5098#      "arguments": { "node-name": "mydev",
5099#                     "write-threshold": 17179869184 } }
5100# <- { "return": {} }
5101#
5102##
5103{ 'command': 'block-set-write-threshold',
5104  'data': { 'node-name': 'str', 'write-threshold': 'uint64' } }
5105
5106##
5107# @x-blockdev-change:
5108#
5109# Dynamically reconfigure the block driver state graph. It can be used
5110# to add, remove, insert or replace a graph node. Currently only the
5111# Quorum driver implements this feature to add or remove its child. This
5112# is useful to fix a broken quorum child.
5113#
5114# If @node is specified, it will be inserted under @parent. @child
5115# may not be specified in this case. If both @parent and @child are
5116# specified but @node is not, @child will be detached from @parent.
5117#
5118# @parent: the id or name of the parent node.
5119#
5120# @child: the name of a child under the given parent node.
5121#
5122# @node: the name of the node that will be added.
5123#
5124# Note: this command is experimental, and its API is not stable. It
5125#       does not support all kinds of operations, all kinds of children, nor
5126#       all block drivers.
5127#
5128#       FIXME Removing children from a quorum node means introducing gaps in the
5129#       child indices. This cannot be represented in the 'children' list of
5130#       BlockdevOptionsQuorum, as returned by .bdrv_refresh_filename().
5131#
5132#       Warning: The data in a new quorum child MUST be consistent with that of
5133#       the rest of the array.
5134#
5135# Since: 2.7
5136#
5137# Example:
5138#
5139# 1. Add a new node to a quorum
5140# -> { "execute": "blockdev-add",
5141#      "arguments": {
5142#          "driver": "raw",
5143#          "node-name": "new_node",
5144#          "file": { "driver": "file",
5145#                    "filename": "test.raw" } } }
5146# <- { "return": {} }
5147# -> { "execute": "x-blockdev-change",
5148#      "arguments": { "parent": "disk1",
5149#                     "node": "new_node" } }
5150# <- { "return": {} }
5151#
5152# 2. Delete a quorum's node
5153# -> { "execute": "x-blockdev-change",
5154#      "arguments": { "parent": "disk1",
5155#                     "child": "children.1" } }
5156# <- { "return": {} }
5157#
5158##
5159{ 'command': 'x-blockdev-change',
5160  'data' : { 'parent': 'str',
5161             '*child': 'str',
5162             '*node': 'str' } }
5163
5164##
5165# @x-blockdev-set-iothread:
5166#
5167# Move @node and its children into the @iothread.  If @iothread is null then
5168# move @node and its children into the main loop.
5169#
5170# The node must not be attached to a BlockBackend.
5171#
5172# @node-name: the name of the block driver node
5173#
5174# @iothread: the name of the IOThread object or null for the main loop
5175#
5176# @force: true if the node and its children should be moved when a BlockBackend
5177#         is already attached
5178#
5179# Note: this command is experimental and intended for test cases that need
5180#       control over IOThreads only.
5181#
5182# Since: 2.12
5183#
5184# Example:
5185#
5186# 1. Move a node into an IOThread
5187# -> { "execute": "x-blockdev-set-iothread",
5188#      "arguments": { "node-name": "disk1",
5189#                     "iothread": "iothread0" } }
5190# <- { "return": {} }
5191#
5192# 2. Move a node into the main loop
5193# -> { "execute": "x-blockdev-set-iothread",
5194#      "arguments": { "node-name": "disk1",
5195#                     "iothread": null } }
5196# <- { "return": {} }
5197#
5198##
5199{ 'command': 'x-blockdev-set-iothread',
5200  'data' : { 'node-name': 'str',
5201             'iothread': 'StrOrNull',
5202             '*force': 'bool' } }
5203
5204##
5205# @QuorumOpType:
5206#
5207# An enumeration of the quorum operation types
5208#
5209# @read: read operation
5210#
5211# @write: write operation
5212#
5213# @flush: flush operation
5214#
5215# Since: 2.6
5216##
5217{ 'enum': 'QuorumOpType',
5218  'data': [ 'read', 'write', 'flush' ] }
5219
5220##
5221# @QUORUM_FAILURE:
5222#
5223# Emitted by the Quorum block driver if it fails to establish a quorum
5224#
5225# @reference: device name if defined else node name
5226#
5227# @sector-num: number of the first sector of the failed read operation
5228#
5229# @sectors-count: failed read operation sector count
5230#
5231# Note: This event is rate-limited.
5232#
5233# Since: 2.0
5234#
5235# Example:
5236#
5237# <- { "event": "QUORUM_FAILURE",
5238#      "data": { "reference": "usr1", "sector-num": 345435, "sectors-count": 5 },
5239#      "timestamp": { "seconds": 1344522075, "microseconds": 745528 } }
5240#
5241##
5242{ 'event': 'QUORUM_FAILURE',
5243  'data': { 'reference': 'str', 'sector-num': 'int', 'sectors-count': 'int' } }
5244
5245##
5246# @QUORUM_REPORT_BAD:
5247#
5248# Emitted to report a corruption of a Quorum file
5249#
5250# @type: quorum operation type (Since 2.6)
5251#
5252# @error: error message. Only present on failure. This field
5253#         contains a human-readable error message. There are no semantics other
5254#         than that the block layer reported an error and clients should not
5255#         try to interpret the error string.
5256#
5257# @node-name: the graph node name of the block driver state
5258#
5259# @sector-num: number of the first sector of the failed read operation
5260#
5261# @sectors-count: failed read operation sector count
5262#
5263# Note: This event is rate-limited.
5264#
5265# Since: 2.0
5266#
5267# Example:
5268#
5269# 1. Read operation
5270#
5271# { "event": "QUORUM_REPORT_BAD",
5272#      "data": { "node-name": "node0", "sector-num": 345435, "sectors-count": 5,
5273#                "type": "read" },
5274#      "timestamp": { "seconds": 1344522075, "microseconds": 745528 } }
5275#
5276# 2. Flush operation
5277#
5278# { "event": "QUORUM_REPORT_BAD",
5279#      "data": { "node-name": "node0", "sector-num": 0, "sectors-count": 2097120,
5280#                "type": "flush", "error": "Broken pipe" },
5281#      "timestamp": { "seconds": 1456406829, "microseconds": 291763 } }
5282#
5283##
5284{ 'event': 'QUORUM_REPORT_BAD',
5285  'data': { 'type': 'QuorumOpType', '*error': 'str', 'node-name': 'str',
5286            'sector-num': 'int', 'sectors-count': 'int' } }
5287
5288##
5289# @BlockdevSnapshotInternal:
5290#
5291# @device: the device name or node-name of a root node to generate the snapshot
5292#          from
5293#
5294# @name: the name of the internal snapshot to be created
5295#
5296# Notes: In transaction, if @name is empty, or any snapshot matching @name
5297#        exists, the operation will fail. Only some image formats support it,
5298#        for example, qcow2, rbd, and sheepdog.
5299#
5300# Since: 1.7
5301##
5302{ 'struct': 'BlockdevSnapshotInternal',
5303  'data': { 'device': 'str', 'name': 'str' } }
5304
5305##
5306# @blockdev-snapshot-internal-sync:
5307#
5308# Synchronously take an internal snapshot of a block device, when the
5309# format of the image used supports it. If the name is an empty
5310# string, or a snapshot with name already exists, the operation will
5311# fail.
5312#
5313# For the arguments, see the documentation of BlockdevSnapshotInternal.
5314#
5315# Returns: - nothing on success
5316#          - If @device is not a valid block device, GenericError
5317#          - If any snapshot matching @name exists, or @name is empty,
5318#            GenericError
5319#          - If the format of the image used does not support it,
5320#            BlockFormatFeatureNotSupported
5321#
5322# Since: 1.7
5323#
5324# Example:
5325#
5326# -> { "execute": "blockdev-snapshot-internal-sync",
5327#      "arguments": { "device": "ide-hd0",
5328#                     "name": "snapshot0" }
5329#    }
5330# <- { "return": {} }
5331#
5332##
5333{ 'command': 'blockdev-snapshot-internal-sync',
5334  'data': 'BlockdevSnapshotInternal' }
5335
5336##
5337# @blockdev-snapshot-delete-internal-sync:
5338#
5339# Synchronously delete an internal snapshot of a block device, when the format
5340# of the image used support it. The snapshot is identified by name or id or
5341# both. One of the name or id is required. Return SnapshotInfo for the
5342# successfully deleted snapshot.
5343#
5344# @device: the device name or node-name of a root node to delete the snapshot
5345#          from
5346#
5347# @id: optional the snapshot's ID to be deleted
5348#
5349# @name: optional the snapshot's name to be deleted
5350#
5351# Returns: - SnapshotInfo on success
5352#          - If @device is not a valid block device, GenericError
5353#          - If snapshot not found, GenericError
5354#          - If the format of the image used does not support it,
5355#            BlockFormatFeatureNotSupported
5356#          - If @id and @name are both not specified, GenericError
5357#
5358# Since: 1.7
5359#
5360# Example:
5361#
5362# -> { "execute": "blockdev-snapshot-delete-internal-sync",
5363#      "arguments": { "device": "ide-hd0",
5364#                     "name": "snapshot0" }
5365#    }
5366# <- { "return": {
5367#                    "id": "1",
5368#                    "name": "snapshot0",
5369#                    "vm-state-size": 0,
5370#                    "date-sec": 1000012,
5371#                    "date-nsec": 10,
5372#                    "vm-clock-sec": 100,
5373#                    "vm-clock-nsec": 20,
5374#                    "icount": 220414
5375#      }
5376#    }
5377#
5378##
5379{ 'command': 'blockdev-snapshot-delete-internal-sync',
5380  'data': { 'device': 'str', '*id': 'str', '*name': 'str'},
5381  'returns': 'SnapshotInfo' }
5382