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