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