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