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