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