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