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