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