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