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