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