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