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