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