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