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