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