xref: /qemu/qapi/block-core.json (revision 4b58554a)
1# -*- Mode: Python -*-
2#
3# QAPI block core definitions (vm unrelated)
4
5# QAPI common definitions
6{ 'include': 'common.json' }
7
8##
9# @SnapshotInfo
10#
11# @id: unique snapshot id
12#
13# @name: user chosen name
14#
15# @vm-state-size: size of the VM state
16#
17# @date-sec: UTC date of the snapshot in seconds
18#
19# @date-nsec: fractional part in nano seconds to be used with date-sec
20#
21# @vm-clock-sec: VM clock relative to boot in seconds
22#
23# @vm-clock-nsec: fractional part in nano seconds to be used with vm-clock-sec
24#
25# Since: 1.3
26#
27##
28
29{ 'type': 'SnapshotInfo',
30  'data': { 'id': 'str', 'name': 'str', 'vm-state-size': 'int',
31            'date-sec': 'int', 'date-nsec': 'int',
32            'vm-clock-sec': 'int', 'vm-clock-nsec': 'int' } }
33
34##
35# @ImageInfoSpecificQCow2:
36#
37# @compat: compatibility level
38#
39# @lazy-refcounts: #optional on or off; only valid for compat >= 1.1
40#
41# @corrupt: #optional true if the image has been marked corrupt; only valid for
42#           compat >= 1.1 (since 2.2)
43#
44# Since: 1.7
45##
46{ 'type': 'ImageInfoSpecificQCow2',
47  'data': {
48      'compat': 'str',
49      '*lazy-refcounts': 'bool',
50      '*corrupt': 'bool'
51  } }
52
53##
54# @ImageInfoSpecificVmdk:
55#
56# @create-type: The create type of VMDK image
57#
58# @cid: Content id of image
59#
60# @parent-cid: Parent VMDK image's cid
61#
62# @extents: List of extent files
63#
64# Since: 1.7
65##
66{ 'type': 'ImageInfoSpecificVmdk',
67  'data': {
68      'create-type': 'str',
69      'cid': 'int',
70      'parent-cid': 'int',
71      'extents': ['ImageInfo']
72  } }
73
74##
75# @ImageInfoSpecific:
76#
77# A discriminated record of image format specific information structures.
78#
79# Since: 1.7
80##
81
82{ 'union': 'ImageInfoSpecific',
83  'data': {
84      'qcow2': 'ImageInfoSpecificQCow2',
85      'vmdk': 'ImageInfoSpecificVmdk'
86  } }
87
88##
89# @ImageInfo:
90#
91# Information about a QEMU image file
92#
93# @filename: name of the image file
94#
95# @format: format of the image file
96#
97# @virtual-size: maximum capacity in bytes of the image
98#
99# @actual-size: #optional actual size on disk in bytes of the image
100#
101# @dirty-flag: #optional true if image is not cleanly closed
102#
103# @cluster-size: #optional size of a cluster in bytes
104#
105# @encrypted: #optional true if the image is encrypted
106#
107# @compressed: #optional true if the image is compressed (Since 1.7)
108#
109# @backing-filename: #optional name of the backing file
110#
111# @full-backing-filename: #optional full path of the backing file
112#
113# @backing-filename-format: #optional the format of the backing file
114#
115# @snapshots: #optional list of VM snapshots
116#
117# @backing-image: #optional info of the backing image (since 1.6)
118#
119# @format-specific: #optional structure supplying additional format-specific
120# information (since 1.7)
121#
122# Since: 1.3
123#
124##
125
126{ 'type': 'ImageInfo',
127  'data': {'filename': 'str', 'format': 'str', '*dirty-flag': 'bool',
128           '*actual-size': 'int', 'virtual-size': 'int',
129           '*cluster-size': 'int', '*encrypted': 'bool', '*compressed': 'bool',
130           '*backing-filename': 'str', '*full-backing-filename': 'str',
131           '*backing-filename-format': 'str', '*snapshots': ['SnapshotInfo'],
132           '*backing-image': 'ImageInfo',
133           '*format-specific': 'ImageInfoSpecific' } }
134
135##
136# @ImageCheck:
137#
138# Information about a QEMU image file check
139#
140# @filename: name of the image file checked
141#
142# @format: format of the image file checked
143#
144# @check-errors: number of unexpected errors occurred during check
145#
146# @image-end-offset: #optional offset (in bytes) where the image ends, this
147#                    field is present if the driver for the image format
148#                    supports it
149#
150# @corruptions: #optional number of corruptions found during the check if any
151#
152# @leaks: #optional number of leaks found during the check if any
153#
154# @corruptions-fixed: #optional number of corruptions fixed during the check
155#                     if any
156#
157# @leaks-fixed: #optional number of leaks fixed during the check if any
158#
159# @total-clusters: #optional total number of clusters, this field is present
160#                  if the driver for the image format supports it
161#
162# @allocated-clusters: #optional total number of allocated clusters, this
163#                      field is present if the driver for the image format
164#                      supports it
165#
166# @fragmented-clusters: #optional total number of fragmented clusters, this
167#                       field is present if the driver for the image format
168#                       supports it
169#
170# @compressed-clusters: #optional total number of compressed clusters, this
171#                       field is present if the driver for the image format
172#                       supports it
173#
174# Since: 1.4
175#
176##
177
178{ 'type': 'ImageCheck',
179  'data': {'filename': 'str', 'format': 'str', 'check-errors': 'int',
180           '*image-end-offset': 'int', '*corruptions': 'int', '*leaks': 'int',
181           '*corruptions-fixed': 'int', '*leaks-fixed': 'int',
182           '*total-clusters': 'int', '*allocated-clusters': 'int',
183           '*fragmented-clusters': 'int', '*compressed-clusters': 'int' } }
184
185##
186# @BlockDeviceInfo:
187#
188# Information about the backing device for a block device.
189#
190# @file: the filename of the backing device
191#
192# @node-name: #optional the name of the block driver node (Since 2.0)
193#
194# @ro: true if the backing device was open read-only
195#
196# @drv: the name of the block format used to open the backing device. As of
197#       0.14.0 this can be: 'blkdebug', 'bochs', 'cloop', 'cow', 'dmg',
198#       'file', 'file', 'ftp', 'ftps', 'host_cdrom', 'host_device',
199#       'host_floppy', 'http', 'https', 'nbd', 'parallels', 'qcow',
200#       'qcow2', 'raw', 'tftp', 'vdi', 'vmdk', 'vpc', 'vvfat'
201#       2.2: 'archipelago' added, 'cow' dropped
202#
203# @backing_file: #optional the name of the backing file (for copy-on-write)
204#
205# @backing_file_depth: number of files in the backing file chain (since: 1.2)
206#
207# @encrypted: true if the backing device is encrypted
208#
209# @encryption_key_missing: true if the backing device is encrypted but an
210#                          valid encryption key is missing
211#
212# @detect_zeroes: detect and optimize zero writes (Since 2.1)
213#
214# @bps: total throughput limit in bytes per second is specified
215#
216# @bps_rd: read throughput limit in bytes per second is specified
217#
218# @bps_wr: write throughput limit in bytes per second is specified
219#
220# @iops: total I/O operations per second is specified
221#
222# @iops_rd: read I/O operations per second is specified
223#
224# @iops_wr: write I/O operations per second is specified
225#
226# @image: the info of image used (since: 1.6)
227#
228# @bps_max: #optional total max in bytes (Since 1.7)
229#
230# @bps_rd_max: #optional read max in bytes (Since 1.7)
231#
232# @bps_wr_max: #optional write max in bytes (Since 1.7)
233#
234# @iops_max: #optional total I/O operations max (Since 1.7)
235#
236# @iops_rd_max: #optional read I/O operations max (Since 1.7)
237#
238# @iops_wr_max: #optional write I/O operations max (Since 1.7)
239#
240# @iops_size: #optional an I/O size in bytes (Since 1.7)
241#
242# Since: 0.14.0
243#
244##
245{ 'type': 'BlockDeviceInfo',
246  'data': { 'file': 'str', '*node-name': 'str', 'ro': 'bool', 'drv': 'str',
247            '*backing_file': 'str', 'backing_file_depth': 'int',
248            'encrypted': 'bool', 'encryption_key_missing': 'bool',
249            'detect_zeroes': 'BlockdevDetectZeroesOptions',
250            'bps': 'int', 'bps_rd': 'int', 'bps_wr': 'int',
251            'iops': 'int', 'iops_rd': 'int', 'iops_wr': 'int',
252            'image': 'ImageInfo',
253            '*bps_max': 'int', '*bps_rd_max': 'int',
254            '*bps_wr_max': 'int', '*iops_max': 'int',
255            '*iops_rd_max': 'int', '*iops_wr_max': 'int',
256            '*iops_size': 'int' } }
257
258##
259# @BlockDeviceIoStatus:
260#
261# An enumeration of block device I/O status.
262#
263# @ok: The last I/O operation has succeeded
264#
265# @failed: The last I/O operation has failed
266#
267# @nospace: The last I/O operation has failed due to a no-space condition
268#
269# Since: 1.0
270##
271{ 'enum': 'BlockDeviceIoStatus', 'data': [ 'ok', 'failed', 'nospace' ] }
272
273##
274# @BlockDeviceMapEntry:
275#
276# Entry in the metadata map of the device (returned by "qemu-img map")
277#
278# @start: Offset in the image of the first byte described by this entry
279#         (in bytes)
280#
281# @length: Length of the range described by this entry (in bytes)
282#
283# @depth: Number of layers (0 = top image, 1 = top image's backing file, etc.)
284#         before reaching one for which the range is allocated.  The value is
285#         in the range 0 to the depth of the image chain - 1.
286#
287# @zero: the sectors in this range read as zeros
288#
289# @data: reading the image will actually read data from a file (in particular,
290#        if @offset is present this means that the sectors are not simply
291#        preallocated, but contain actual data in raw format)
292#
293# @offset: if present, the image file stores the data for this range in
294#          raw format at the given offset.
295#
296# Since 1.7
297##
298{ 'type': 'BlockDeviceMapEntry',
299  'data': { 'start': 'int', 'length': 'int', 'depth': 'int', 'zero': 'bool',
300            'data': 'bool', '*offset': 'int' } }
301
302##
303# @BlockDirtyInfo:
304#
305# Block dirty bitmap information.
306#
307# @count: number of dirty bytes according to the dirty bitmap
308#
309# @granularity: granularity of the dirty bitmap in bytes (since 1.4)
310#
311# Since: 1.3
312##
313{ 'type': 'BlockDirtyInfo',
314  'data': {'count': 'int', 'granularity': 'int'} }
315
316##
317# @BlockInfo:
318#
319# Block device information.  This structure describes a virtual device and
320# the backing device associated with it.
321#
322# @device: The device name associated with the virtual device.
323#
324# @type: This field is returned only for compatibility reasons, it should
325#        not be used (always returns 'unknown')
326#
327# @removable: True if the device supports removable media.
328#
329# @locked: True if the guest has locked this device from having its media
330#          removed
331#
332# @tray_open: #optional True if the device has a tray and it is open
333#             (only present if removable is true)
334#
335# @dirty-bitmaps: #optional dirty bitmaps information (only present if the
336#                 driver has one or more dirty bitmaps) (Since 2.0)
337#
338# @io-status: #optional @BlockDeviceIoStatus. Only present if the device
339#             supports it and the VM is configured to stop on errors
340#             (supported device models: virtio-blk, ide, scsi-disk)
341#
342# @inserted: #optional @BlockDeviceInfo describing the device if media is
343#            present
344#
345# Since:  0.14.0
346##
347{ 'type': 'BlockInfo',
348  'data': {'device': 'str', 'type': 'str', 'removable': 'bool',
349           'locked': 'bool', '*inserted': 'BlockDeviceInfo',
350           '*tray_open': 'bool', '*io-status': 'BlockDeviceIoStatus',
351           '*dirty-bitmaps': ['BlockDirtyInfo'] } }
352
353##
354# @query-block:
355#
356# Get a list of BlockInfo for all virtual block devices.
357#
358# Returns: a list of @BlockInfo describing each virtual block device
359#
360# Since: 0.14.0
361##
362{ 'command': 'query-block', 'returns': ['BlockInfo'] }
363
364##
365# @BlockDeviceStats:
366#
367# Statistics of a virtual block device or a block backing device.
368#
369# @rd_bytes:      The number of bytes read by the device.
370#
371# @wr_bytes:      The number of bytes written by the device.
372#
373# @rd_operations: The number of read operations performed by the device.
374#
375# @wr_operations: The number of write operations performed by the device.
376#
377# @flush_operations: The number of cache flush operations performed by the
378#                    device (since 0.15.0)
379#
380# @flush_total_time_ns: Total time spend on cache flushes in nano-seconds
381#                       (since 0.15.0).
382#
383# @wr_total_time_ns: Total time spend on writes in nano-seconds (since 0.15.0).
384#
385# @rd_total_time_ns: Total_time_spend on reads in nano-seconds (since 0.15.0).
386#
387# @wr_highest_offset: The offset after the greatest byte written to the
388#                     device.  The intended use of this information is for
389#                     growable sparse files (like qcow2) that are used on top
390#                     of a physical device.
391#
392# Since: 0.14.0
393##
394{ 'type': 'BlockDeviceStats',
395  'data': {'rd_bytes': 'int', 'wr_bytes': 'int', 'rd_operations': 'int',
396           'wr_operations': 'int', 'flush_operations': 'int',
397           'flush_total_time_ns': 'int', 'wr_total_time_ns': 'int',
398           'rd_total_time_ns': 'int', 'wr_highest_offset': 'int' } }
399
400##
401# @BlockStats:
402#
403# Statistics of a virtual block device or a block backing device.
404#
405# @device: #optional If the stats are for a virtual block device, the name
406#          corresponding to the virtual block device.
407#
408# @device: #optional The node name of the device. (Since 2.3)
409#
410# @stats:  A @BlockDeviceStats for the device.
411#
412# @parent: #optional This describes the file block device if it has one.
413#
414# @backing: #optional This describes the backing block device if it has one.
415#           (Since 2.0)
416#
417# Since: 0.14.0
418##
419{ 'type': 'BlockStats',
420  'data': {'*device': 'str', '*node-name': 'str',
421           'stats': 'BlockDeviceStats',
422           '*parent': 'BlockStats',
423           '*backing': 'BlockStats'} }
424
425##
426# @query-blockstats:
427#
428# Query the @BlockStats for all virtual block devices.
429#
430# @query-nodes: #optional If true, the command will query all the block nodes
431#               that have a node name, in a list which will include "parent"
432#               information, but not "backing".
433#               If false or omitted, the behavior is as before - query all the
434#               device backends, recursively including their "parent" and
435#               "backing". (Since 2.3)
436#
437# Returns: A list of @BlockStats for each virtual block devices.
438#
439# Since: 0.14.0
440##
441{ 'command': 'query-blockstats',
442  'data': { '*query-nodes': 'bool' },
443  'returns': ['BlockStats'] }
444
445##
446# @BlockdevOnError:
447#
448# An enumeration of possible behaviors for errors on I/O operations.
449# The exact meaning depends on whether the I/O was initiated by a guest
450# or by a block job
451#
452# @report: for guest operations, report the error to the guest;
453#          for jobs, cancel the job
454#
455# @ignore: ignore the error, only report a QMP event (BLOCK_IO_ERROR
456#          or BLOCK_JOB_ERROR)
457#
458# @enospc: same as @stop on ENOSPC, same as @report otherwise.
459#
460# @stop: for guest operations, stop the virtual machine;
461#        for jobs, pause the job
462#
463# Since: 1.3
464##
465{ 'enum': 'BlockdevOnError',
466  'data': ['report', 'ignore', 'enospc', 'stop'] }
467
468##
469# @MirrorSyncMode:
470#
471# An enumeration of possible behaviors for the initial synchronization
472# phase of storage mirroring.
473#
474# @top: copies data in the topmost image to the destination
475#
476# @full: copies data from all images to the destination
477#
478# @none: only copy data written from now on
479#
480# Since: 1.3
481##
482{ 'enum': 'MirrorSyncMode',
483  'data': ['top', 'full', 'none'] }
484
485##
486# @BlockJobType:
487#
488# Type of a block job.
489#
490# @commit: block commit job type, see "block-commit"
491#
492# @stream: block stream job type, see "block-stream"
493#
494# @mirror: drive mirror job type, see "drive-mirror"
495#
496# @backup: drive backup job type, see "drive-backup"
497#
498# Since: 1.7
499##
500{ 'enum': 'BlockJobType',
501  'data': ['commit', 'stream', 'mirror', 'backup'] }
502
503##
504# @BlockJobInfo:
505#
506# Information about a long-running block device operation.
507#
508# @type: the job type ('stream' for image streaming)
509#
510# @device: the block device name
511#
512# @len: the maximum progress value
513#
514# @busy: false if the job is known to be in a quiescent state, with
515#        no pending I/O.  Since 1.3.
516#
517# @paused: whether the job is paused or, if @busy is true, will
518#          pause itself as soon as possible.  Since 1.3.
519#
520# @offset: the current progress value
521#
522# @speed: the rate limit, bytes per second
523#
524# @io-status: the status of the job (since 1.3)
525#
526# @ready: true if the job may be completed (since 2.2)
527#
528# Since: 1.1
529##
530{ 'type': 'BlockJobInfo',
531  'data': {'type': 'str', 'device': 'str', 'len': 'int',
532           'offset': 'int', 'busy': 'bool', 'paused': 'bool', 'speed': 'int',
533           'io-status': 'BlockDeviceIoStatus', 'ready': 'bool'} }
534
535##
536# @query-block-jobs:
537#
538# Return information about long-running block device operations.
539#
540# Returns: a list of @BlockJobInfo for each active block job
541#
542# Since: 1.1
543##
544{ 'command': 'query-block-jobs', 'returns': ['BlockJobInfo'] }
545
546##
547# @block_passwd:
548#
549# This command sets the password of a block device that has not been open
550# with a password and requires one.
551#
552# The two cases where this can happen are a block device is created through
553# QEMU's initial command line or a block device is changed through the legacy
554# @change interface.
555#
556# In the event that the block device is created through the initial command
557# line, the VM will start in the stopped state regardless of whether '-S' is
558# used.  The intention is for a management tool to query the block devices to
559# determine which ones are encrypted, set the passwords with this command, and
560# then start the guest with the @cont command.
561#
562# Either @device or @node-name must be set but not both.
563#
564# @device: #optional the name of the block backend device to set the password on
565#
566# @node-name: #optional graph node name to set the password on (Since 2.0)
567#
568# @password: the password to use for the device
569#
570# Returns: nothing on success
571#          If @device is not a valid block device, DeviceNotFound
572#          If @device is not encrypted, DeviceNotEncrypted
573#
574# Notes:  Not all block formats support encryption and some that do are not
575#         able to validate that a password is correct.  Disk corruption may
576#         occur if an invalid password is specified.
577#
578# Since: 0.14.0
579##
580{ 'command': 'block_passwd', 'data': {'*device': 'str',
581                                      '*node-name': 'str', 'password': 'str'} }
582
583##
584# @block_resize
585#
586# Resize a block image while a guest is running.
587#
588# Either @device or @node-name must be set but not both.
589#
590# @device: #optional the name of the device to get the image resized
591#
592# @node-name: #optional graph node name to get the image resized (Since 2.0)
593#
594# @size:  new image size in bytes
595#
596# Returns: nothing on success
597#          If @device is not a valid block device, DeviceNotFound
598#
599# Since: 0.14.0
600##
601{ 'command': 'block_resize', 'data': { '*device': 'str',
602                                       '*node-name': 'str',
603                                       'size': 'int' }}
604
605##
606# @NewImageMode
607#
608# An enumeration that tells QEMU how to set the backing file path in
609# a new image file.
610#
611# @existing: QEMU should look for an existing image file.
612#
613# @absolute-paths: QEMU should create a new image with absolute paths
614# for the backing file. If there is no backing file available, the new
615# image will not be backed either.
616#
617# Since: 1.1
618##
619{ 'enum': 'NewImageMode',
620  'data': [ 'existing', 'absolute-paths' ] }
621
622##
623# @BlockdevSnapshot
624#
625# Either @device or @node-name must be set but not both.
626#
627# @device: #optional the name of the device to generate the snapshot from.
628#
629# @node-name: #optional graph node name to generate the snapshot from (Since 2.0)
630#
631# @snapshot-file: the target of the new image. A new file will be created.
632#
633# @snapshot-node-name: #optional the graph node name of the new image (Since 2.0)
634#
635# @format: #optional the format of the snapshot image, default is 'qcow2'.
636#
637# @mode: #optional whether and how QEMU should create a new image, default is
638#        'absolute-paths'.
639##
640{ 'type': 'BlockdevSnapshot',
641  'data': { '*device': 'str', '*node-name': 'str',
642            'snapshot-file': 'str', '*snapshot-node-name': 'str',
643            '*format': 'str', '*mode': 'NewImageMode' } }
644
645##
646# @DriveBackup
647#
648# @device: the name of the device which should be copied.
649#
650# @target: the target of the new image. If the file exists, or if it
651#          is a device, the existing file/device will be used as the new
652#          destination.  If it does not exist, a new file will be created.
653#
654# @format: #optional the format of the new destination, default is to
655#          probe if @mode is 'existing', else the format of the source
656#
657# @sync: what parts of the disk image should be copied to the destination
658#        (all the disk, only the sectors allocated in the topmost image, or
659#        only new I/O).
660#
661# @mode: #optional whether and how QEMU should create a new image, default is
662#        'absolute-paths'.
663#
664# @speed: #optional the maximum speed, in bytes per second
665#
666# @on-source-error: #optional the action to take on an error on the source,
667#                   default 'report'.  'stop' and 'enospc' can only be used
668#                   if the block device supports io-status (see BlockInfo).
669#
670# @on-target-error: #optional the action to take on an error on the target,
671#                   default 'report' (no limitations, since this applies to
672#                   a different block device than @device).
673#
674# Note that @on-source-error and @on-target-error only affect background I/O.
675# If an error occurs during a guest write request, the device's rerror/werror
676# actions will be used.
677#
678# Since: 1.6
679##
680{ 'type': 'DriveBackup',
681  'data': { 'device': 'str', 'target': 'str', '*format': 'str',
682            'sync': 'MirrorSyncMode', '*mode': 'NewImageMode',
683            '*speed': 'int',
684            '*on-source-error': 'BlockdevOnError',
685            '*on-target-error': 'BlockdevOnError' } }
686
687##
688# @blockdev-snapshot-sync
689#
690# Generates a synchronous snapshot of a block device.
691#
692# For the arguments, see the documentation of BlockdevSnapshot.
693#
694# Returns: nothing on success
695#          If @device is not a valid block device, DeviceNotFound
696#
697# Since 0.14.0
698##
699{ 'command': 'blockdev-snapshot-sync',
700  'data': 'BlockdevSnapshot' }
701
702##
703# @change-backing-file
704#
705# Change the backing file in the image file metadata.  This does not
706# cause QEMU to reopen the image file to reparse the backing filename
707# (it may, however, perform a reopen to change permissions from
708# r/o -> r/w -> r/o, if needed). The new backing file string is written
709# into the image file metadata, and the QEMU internal strings are
710# updated.
711#
712# @image-node-name: The name of the block driver state node of the
713#                   image to modify.
714#
715# @device:          The name of the device that owns image-node-name.
716#
717# @backing-file:    The string to write as the backing file.  This
718#                   string is not validated, so care should be taken
719#                   when specifying the string or the image chain may
720#                   not be able to be reopened again.
721#
722# Since: 2.1
723##
724{ 'command': 'change-backing-file',
725  'data': { 'device': 'str', 'image-node-name': 'str',
726            'backing-file': 'str' } }
727
728##
729# @block-commit
730#
731# Live commit of data from overlay image nodes into backing nodes - i.e.,
732# writes data between 'top' and 'base' into 'base'.
733#
734# @device:  the name of the device
735#
736# @base:   #optional The file name of the backing image to write data into.
737#                    If not specified, this is the deepest backing image
738#
739# @top:    #optional The file name of the backing image within the image chain,
740#                    which contains the topmost data to be committed down. If
741#                    not specified, this is the active layer.
742#
743# @backing-file:  #optional The backing file string to write into the overlay
744#                           image of 'top'.  If 'top' is the active layer,
745#                           specifying a backing file string is an error. This
746#                           filename is not validated.
747#
748#                           If a pathname string is such that it cannot be
749#                           resolved by QEMU, that means that subsequent QMP or
750#                           HMP commands must use node-names for the image in
751#                           question, as filename lookup methods will fail.
752#
753#                           If not specified, QEMU will automatically determine
754#                           the backing file string to use, or error out if
755#                           there is no obvious choice. Care should be taken
756#                           when specifying the string, to specify a valid
757#                           filename or protocol.
758#                           (Since 2.1)
759#
760#                    If top == base, that is an error.
761#                    If top == active, the job will not be completed by itself,
762#                    user needs to complete the job with the block-job-complete
763#                    command after getting the ready event. (Since 2.0)
764#
765#                    If the base image is smaller than top, then the base image
766#                    will be resized to be the same size as top.  If top is
767#                    smaller than the base image, the base will not be
768#                    truncated.  If you want the base image size to match the
769#                    size of the smaller top, you can safely truncate it
770#                    yourself once the commit operation successfully completes.
771#
772# @speed:  #optional the maximum speed, in bytes per second
773#
774# Returns: Nothing on success
775#          If commit or stream is already active on this device, DeviceInUse
776#          If @device does not exist, DeviceNotFound
777#          If image commit is not supported by this device, NotSupported
778#          If @base or @top is invalid, a generic error is returned
779#          If @speed is invalid, InvalidParameter
780#
781# Since: 1.3
782#
783##
784{ 'command': 'block-commit',
785  'data': { 'device': 'str', '*base': 'str', '*top': 'str',
786            '*backing-file': 'str', '*speed': 'int' } }
787
788##
789# @drive-backup
790#
791# Start a point-in-time copy of a block device to a new destination.  The
792# status of ongoing drive-backup operations can be checked with
793# query-block-jobs where the BlockJobInfo.type field has the value 'backup'.
794# The operation can be stopped before it has completed using the
795# block-job-cancel command.
796#
797# For the arguments, see the documentation of DriveBackup.
798#
799# Returns: nothing on success
800#          If @device is not a valid block device, DeviceNotFound
801#
802# Since 1.6
803##
804{ 'command': 'drive-backup', 'data': 'DriveBackup' }
805
806##
807# @query-named-block-nodes
808#
809# Get the named block driver list
810#
811# Returns: the list of BlockDeviceInfo
812#
813# Since 2.0
814##
815{ 'command': 'query-named-block-nodes', 'returns': [ 'BlockDeviceInfo' ] }
816
817##
818# @drive-mirror
819#
820# Start mirroring a block device's writes to a new destination.
821#
822# @device:  the name of the device whose writes should be mirrored.
823#
824# @target: the target of the new image. If the file exists, or if it
825#          is a device, the existing file/device will be used as the new
826#          destination.  If it does not exist, a new file will be created.
827#
828# @format: #optional the format of the new destination, default is to
829#          probe if @mode is 'existing', else the format of the source
830#
831# @node-name: #optional the new block driver state node name in the graph
832#             (Since 2.1)
833#
834# @replaces: #optional with sync=full graph node name to be replaced by the new
835#            image when a whole image copy is done. This can be used to repair
836#            broken Quorum files. (Since 2.1)
837#
838# @mode: #optional whether and how QEMU should create a new image, default is
839#        'absolute-paths'.
840#
841# @speed:  #optional the maximum speed, in bytes per second
842#
843# @sync: what parts of the disk image should be copied to the destination
844#        (all the disk, only the sectors allocated in the topmost image, or
845#        only new I/O).
846#
847# @granularity: #optional granularity of the dirty bitmap, default is 64K
848#               if the image format doesn't have clusters, 4K if the clusters
849#               are smaller than that, else the cluster size.  Must be a
850#               power of 2 between 512 and 64M (since 1.4).
851#
852# @buf-size: #optional maximum amount of data in flight from source to
853#            target (since 1.4).
854#
855# @on-source-error: #optional the action to take on an error on the source,
856#                   default 'report'.  'stop' and 'enospc' can only be used
857#                   if the block device supports io-status (see BlockInfo).
858#
859# @on-target-error: #optional the action to take on an error on the target,
860#                   default 'report' (no limitations, since this applies to
861#                   a different block device than @device).
862#
863# Returns: nothing on success
864#          If @device is not a valid block device, DeviceNotFound
865#
866# Since 1.3
867##
868{ 'command': 'drive-mirror',
869  'data': { 'device': 'str', 'target': 'str', '*format': 'str',
870            '*node-name': 'str', '*replaces': 'str',
871            'sync': 'MirrorSyncMode', '*mode': 'NewImageMode',
872            '*speed': 'int', '*granularity': 'uint32',
873            '*buf-size': 'int', '*on-source-error': 'BlockdevOnError',
874            '*on-target-error': 'BlockdevOnError' } }
875
876##
877# @block_set_io_throttle:
878#
879# Change I/O throttle limits for a block drive.
880#
881# @device: The name of the device
882#
883# @bps: total throughput limit in bytes per second
884#
885# @bps_rd: read throughput limit in bytes per second
886#
887# @bps_wr: write throughput limit in bytes per second
888#
889# @iops: total I/O operations per second
890#
891# @ops_rd: read I/O operations per second
892#
893# @iops_wr: write I/O operations per second
894#
895# @bps_max: #optional total max in bytes (Since 1.7)
896#
897# @bps_rd_max: #optional read max in bytes (Since 1.7)
898#
899# @bps_wr_max: #optional write max in bytes (Since 1.7)
900#
901# @iops_max: #optional total I/O operations max (Since 1.7)
902#
903# @iops_rd_max: #optional read I/O operations max (Since 1.7)
904#
905# @iops_wr_max: #optional write I/O operations max (Since 1.7)
906#
907# @iops_size: #optional an I/O size in bytes (Since 1.7)
908#
909# Returns: Nothing on success
910#          If @device is not a valid block device, DeviceNotFound
911#
912# Since: 1.1
913##
914{ 'command': 'block_set_io_throttle',
915  'data': { 'device': 'str', 'bps': 'int', 'bps_rd': 'int', 'bps_wr': 'int',
916            'iops': 'int', 'iops_rd': 'int', 'iops_wr': 'int',
917            '*bps_max': 'int', '*bps_rd_max': 'int',
918            '*bps_wr_max': 'int', '*iops_max': 'int',
919            '*iops_rd_max': 'int', '*iops_wr_max': 'int',
920            '*iops_size': 'int' } }
921
922##
923# @block-stream:
924#
925# Copy data from a backing file into a block device.
926#
927# The block streaming operation is performed in the background until the entire
928# backing file has been copied.  This command returns immediately once streaming
929# has started.  The status of ongoing block streaming operations can be checked
930# with query-block-jobs.  The operation can be stopped before it has completed
931# using the block-job-cancel command.
932#
933# If a base file is specified then sectors are not copied from that base file and
934# its backing chain.  When streaming completes the image file will have the base
935# file as its backing file.  This can be used to stream a subset of the backing
936# file chain instead of flattening the entire image.
937#
938# On successful completion the image file is updated to drop the backing file
939# and the BLOCK_JOB_COMPLETED event is emitted.
940#
941# @device: the device name
942#
943# @base:   #optional the common backing file name
944#
945# @backing-file: #optional The backing file string to write into the active
946#                          layer. This filename is not validated.
947#
948#                          If a pathname string is such that it cannot be
949#                          resolved by QEMU, that means that subsequent QMP or
950#                          HMP commands must use node-names for the image in
951#                          question, as filename lookup methods will fail.
952#
953#                          If not specified, QEMU will automatically determine
954#                          the backing file string to use, or error out if there
955#                          is no obvious choice.  Care should be taken when
956#                          specifying the string, to specify a valid filename or
957#                          protocol.
958#                          (Since 2.1)
959#
960# @speed:  #optional the maximum speed, in bytes per second
961#
962# @on-error: #optional the action to take on an error (default report).
963#            'stop' and 'enospc' can only be used if the block device
964#            supports io-status (see BlockInfo).  Since 1.3.
965#
966# Returns: Nothing on success
967#          If @device does not exist, DeviceNotFound
968#
969# Since: 1.1
970##
971{ 'command': 'block-stream',
972  'data': { 'device': 'str', '*base': 'str', '*backing-file': 'str',
973            '*speed': 'int', '*on-error': 'BlockdevOnError' } }
974
975##
976# @block-job-set-speed:
977#
978# Set maximum speed for a background block operation.
979#
980# This command can only be issued when there is an active block job.
981#
982# Throttling can be disabled by setting the speed to 0.
983#
984# @device: the device name
985#
986# @speed:  the maximum speed, in bytes per second, or 0 for unlimited.
987#          Defaults to 0.
988#
989# Returns: Nothing on success
990#          If no background operation is active on this device, DeviceNotActive
991#
992# Since: 1.1
993##
994{ 'command': 'block-job-set-speed',
995  'data': { 'device': 'str', 'speed': 'int' } }
996
997##
998# @block-job-cancel:
999#
1000# Stop an active background block operation.
1001#
1002# This command returns immediately after marking the active background block
1003# operation for cancellation.  It is an error to call this command if no
1004# operation is in progress.
1005#
1006# The operation will cancel as soon as possible and then emit the
1007# BLOCK_JOB_CANCELLED event.  Before that happens the job is still visible when
1008# enumerated using query-block-jobs.
1009#
1010# For streaming, the image file retains its backing file unless the streaming
1011# operation happens to complete just as it is being cancelled.  A new streaming
1012# operation can be started at a later time to finish copying all data from the
1013# backing file.
1014#
1015# @device: the device name
1016#
1017# @force: #optional whether to allow cancellation of a paused job (default
1018#         false).  Since 1.3.
1019#
1020# Returns: Nothing on success
1021#          If no background operation is active on this device, DeviceNotActive
1022#
1023# Since: 1.1
1024##
1025{ 'command': 'block-job-cancel', 'data': { 'device': 'str', '*force': 'bool' } }
1026
1027##
1028# @block-job-pause:
1029#
1030# Pause an active background block operation.
1031#
1032# This command returns immediately after marking the active background block
1033# operation for pausing.  It is an error to call this command if no
1034# operation is in progress.  Pausing an already paused job has no cumulative
1035# effect; a single block-job-resume command will resume the job.
1036#
1037# The operation will pause as soon as possible.  No event is emitted when
1038# the operation is actually paused.  Cancelling a paused job automatically
1039# resumes it.
1040#
1041# @device: the device name
1042#
1043# Returns: Nothing on success
1044#          If no background operation is active on this device, DeviceNotActive
1045#
1046# Since: 1.3
1047##
1048{ 'command': 'block-job-pause', 'data': { 'device': 'str' } }
1049
1050##
1051# @block-job-resume:
1052#
1053# Resume an active background block operation.
1054#
1055# This command returns immediately after resuming a paused background block
1056# operation.  It is an error to call this command if no operation is in
1057# progress.  Resuming an already running job is not an error.
1058#
1059# This command also clears the error status of the job.
1060#
1061# @device: the device name
1062#
1063# Returns: Nothing on success
1064#          If no background operation is active on this device, DeviceNotActive
1065#
1066# Since: 1.3
1067##
1068{ 'command': 'block-job-resume', 'data': { 'device': 'str' } }
1069
1070##
1071# @block-job-complete:
1072#
1073# Manually trigger completion of an active background block operation.  This
1074# is supported for drive mirroring, where it also switches the device to
1075# write to the target path only.  The ability to complete is signaled with
1076# a BLOCK_JOB_READY event.
1077#
1078# This command completes an active background block operation synchronously.
1079# The ordering of this command's return with the BLOCK_JOB_COMPLETED event
1080# is not defined.  Note that if an I/O error occurs during the processing of
1081# this command: 1) the command itself will fail; 2) the error will be processed
1082# according to the rerror/werror arguments that were specified when starting
1083# the operation.
1084#
1085# A cancelled or paused job cannot be completed.
1086#
1087# @device: the device name
1088#
1089# Returns: Nothing on success
1090#          If no background operation is active on this device, DeviceNotActive
1091#
1092# Since: 1.3
1093##
1094{ 'command': 'block-job-complete', 'data': { 'device': 'str' } }
1095
1096##
1097# @BlockdevDiscardOptions
1098#
1099# Determines how to handle discard requests.
1100#
1101# @ignore:      Ignore the request
1102# @unmap:       Forward as an unmap request
1103#
1104# Since: 1.7
1105##
1106{ 'enum': 'BlockdevDiscardOptions',
1107  'data': [ 'ignore', 'unmap' ] }
1108
1109##
1110# @BlockdevDetectZeroesOptions
1111#
1112# Describes the operation mode for the automatic conversion of plain
1113# zero writes by the OS to driver specific optimized zero write commands.
1114#
1115# @off:      Disabled (default)
1116# @on:       Enabled
1117# @unmap:    Enabled and even try to unmap blocks if possible. This requires
1118#            also that @BlockdevDiscardOptions is set to unmap for this device.
1119#
1120# Since: 2.1
1121##
1122{ 'enum': 'BlockdevDetectZeroesOptions',
1123  'data': [ 'off', 'on', 'unmap' ] }
1124
1125##
1126# @BlockdevAioOptions
1127#
1128# Selects the AIO backend to handle I/O requests
1129#
1130# @threads:     Use qemu's thread pool
1131# @native:      Use native AIO backend (only Linux and Windows)
1132#
1133# Since: 1.7
1134##
1135{ 'enum': 'BlockdevAioOptions',
1136  'data': [ 'threads', 'native' ] }
1137
1138##
1139# @BlockdevCacheOptions
1140#
1141# Includes cache-related options for block devices
1142#
1143# @writeback:   #optional enables writeback mode for any caches (default: true)
1144# @direct:      #optional enables use of O_DIRECT (bypass the host page cache;
1145#               default: false)
1146# @no-flush:    #optional ignore any flush requests for the device (default:
1147#               false)
1148#
1149# Since: 1.7
1150##
1151{ 'type': 'BlockdevCacheOptions',
1152  'data': { '*writeback': 'bool',
1153            '*direct': 'bool',
1154            '*no-flush': 'bool' } }
1155
1156##
1157# @BlockdevDriver
1158#
1159# Drivers that are supported in block device operations.
1160#
1161# @host_device, @host_cdrom, @host_floppy: Since 2.1
1162#
1163# Since: 2.0
1164##
1165{ 'enum': 'BlockdevDriver',
1166  'data': [ 'archipelago', 'blkdebug', 'blkverify', 'bochs', 'cloop',
1167            'dmg', 'file', 'ftp', 'ftps', 'host_cdrom', 'host_device',
1168            'host_floppy', 'http', 'https', 'null-aio', 'null-co', 'parallels',
1169            'qcow', 'qcow2', 'qed', 'quorum', 'raw', 'tftp', 'vdi', 'vhdx',
1170            'vmdk', 'vpc', 'vvfat' ] }
1171
1172##
1173# @BlockdevOptionsBase
1174#
1175# Options that are available for all block devices, independent of the block
1176# driver.
1177#
1178# @driver:        block driver name
1179# @id:            #optional id by which the new block device can be referred to.
1180#                 This is a required option on the top level of blockdev-add, and
1181#                 currently not allowed on any other level.
1182# @node-name:     #optional the name of a block driver state node (Since 2.0)
1183# @discard:       #optional discard-related options (default: ignore)
1184# @cache:         #optional cache-related options
1185# @aio:           #optional AIO backend (default: threads)
1186# @rerror:        #optional how to handle read errors on the device
1187#                 (default: report)
1188# @werror:        #optional how to handle write errors on the device
1189#                 (default: enospc)
1190# @read-only:     #optional whether the block device should be read-only
1191#                 (default: false)
1192# @detect-zeroes: #optional detect and optimize zero writes (Since 2.1)
1193#                 (default: off)
1194#
1195# Since: 1.7
1196##
1197{ 'type': 'BlockdevOptionsBase',
1198  'data': { 'driver': 'BlockdevDriver',
1199            '*id': 'str',
1200            '*node-name': 'str',
1201            '*discard': 'BlockdevDiscardOptions',
1202            '*cache': 'BlockdevCacheOptions',
1203            '*aio': 'BlockdevAioOptions',
1204            '*rerror': 'BlockdevOnError',
1205            '*werror': 'BlockdevOnError',
1206            '*read-only': 'bool',
1207            '*detect-zeroes': 'BlockdevDetectZeroesOptions' } }
1208
1209##
1210# @BlockdevOptionsFile
1211#
1212# Driver specific block device options for the file backend and similar
1213# protocols.
1214#
1215# @filename:    path to the image file
1216#
1217# Since: 1.7
1218##
1219{ 'type': 'BlockdevOptionsFile',
1220  'data': { 'filename': 'str' } }
1221
1222##
1223# @BlockdevOptionsNull
1224#
1225# Driver specific block device options for the null backend.
1226#
1227# @size:    #optional size of the device in bytes.
1228#
1229# Since: 2.2
1230##
1231{ 'type': 'BlockdevOptionsNull',
1232  'data': { '*size': 'int' } }
1233
1234##
1235# @BlockdevOptionsVVFAT
1236#
1237# Driver specific block device options for the vvfat protocol.
1238#
1239# @dir:         directory to be exported as FAT image
1240# @fat-type:    #optional FAT type: 12, 16 or 32
1241# @floppy:      #optional whether to export a floppy image (true) or
1242#               partitioned hard disk (false; default)
1243# @rw:          #optional whether to allow write operations (default: false)
1244#
1245# Since: 1.7
1246##
1247{ 'type': 'BlockdevOptionsVVFAT',
1248  'data': { 'dir': 'str', '*fat-type': 'int', '*floppy': 'bool',
1249            '*rw': 'bool' } }
1250
1251##
1252# @BlockdevOptionsGenericFormat
1253#
1254# Driver specific block device options for image format that have no option
1255# besides their data source.
1256#
1257# @file:        reference to or definition of the data source block device
1258#
1259# Since: 1.7
1260##
1261{ 'type': 'BlockdevOptionsGenericFormat',
1262  'data': { 'file': 'BlockdevRef' } }
1263
1264##
1265# @BlockdevOptionsGenericCOWFormat
1266#
1267# Driver specific block device options for image format that have no option
1268# besides their data source and an optional backing file.
1269#
1270# @backing:     #optional reference to or definition of the backing file block
1271#               device (if missing, taken from the image file content). It is
1272#               allowed to pass an empty string here in order to disable the
1273#               default backing file.
1274#
1275# Since: 1.7
1276##
1277{ 'type': 'BlockdevOptionsGenericCOWFormat',
1278  'base': 'BlockdevOptionsGenericFormat',
1279  'data': { '*backing': 'BlockdevRef' } }
1280
1281##
1282# @Qcow2OverlapCheckMode
1283#
1284# General overlap check modes.
1285#
1286# @none:        Do not perform any checks
1287#
1288# @constant:    Perform only checks which can be done in constant time and
1289#               without reading anything from disk
1290#
1291# @cached:      Perform only checks which can be done without reading anything
1292#               from disk
1293#
1294# @all:         Perform all available overlap checks
1295#
1296# Since: 2.2
1297##
1298{ 'enum': 'Qcow2OverlapCheckMode',
1299  'data': [ 'none', 'constant', 'cached', 'all' ] }
1300
1301##
1302# @Qcow2OverlapCheckFlags
1303#
1304# Structure of flags for each metadata structure. Setting a field to 'true'
1305# makes qemu guard that structure against unintended overwriting. The default
1306# value is chosen according to the template given.
1307#
1308# @template: Specifies a template mode which can be adjusted using the other
1309#            flags, defaults to 'cached'
1310#
1311# Since: 2.2
1312##
1313{ 'type': 'Qcow2OverlapCheckFlags',
1314  'data': { '*template':       'Qcow2OverlapCheckMode',
1315            '*main-header':    'bool',
1316            '*active-l1':      'bool',
1317            '*active-l2':      'bool',
1318            '*refcount-table': 'bool',
1319            '*refcount-block': 'bool',
1320            '*snapshot-table': 'bool',
1321            '*inactive-l1':    'bool',
1322            '*inactive-l2':    'bool' } }
1323
1324##
1325# @Qcow2OverlapChecks
1326#
1327# Specifies which metadata structures should be guarded against unintended
1328# overwriting.
1329#
1330# @flags:   set of flags for separate specification of each metadata structure
1331#           type
1332#
1333# @mode:    named mode which chooses a specific set of flags
1334#
1335# Since: 2.2
1336##
1337{ 'union': 'Qcow2OverlapChecks',
1338  'discriminator': {},
1339  'data': { 'flags': 'Qcow2OverlapCheckFlags',
1340            'mode':  'Qcow2OverlapCheckMode' } }
1341
1342##
1343# @BlockdevOptionsQcow2
1344#
1345# Driver specific block device options for qcow2.
1346#
1347# @lazy-refcounts:        #optional whether to enable the lazy refcounts
1348#                         feature (default is taken from the image file)
1349#
1350# @pass-discard-request:  #optional whether discard requests to the qcow2
1351#                         device should be forwarded to the data source
1352#
1353# @pass-discard-snapshot: #optional whether discard requests for the data source
1354#                         should be issued when a snapshot operation (e.g.
1355#                         deleting a snapshot) frees clusters in the qcow2 file
1356#
1357# @pass-discard-other:    #optional whether discard requests for the data source
1358#                         should be issued on other occasions where a cluster
1359#                         gets freed
1360#
1361# @overlap-check:         #optional which overlap checks to perform for writes
1362#                         to the image, defaults to 'cached' (since 2.2)
1363#
1364# @cache-size:            #optional the maximum total size of the L2 table and
1365#                         refcount block caches in bytes (since 2.2)
1366#
1367# @l2-cache-size:         #optional the maximum size of the L2 table cache in
1368#                         bytes (since 2.2)
1369#
1370# @refcount-cache-size:   #optional the maximum size of the refcount block cache
1371#                         in bytes (since 2.2)
1372#
1373# Since: 1.7
1374##
1375{ 'type': 'BlockdevOptionsQcow2',
1376  'base': 'BlockdevOptionsGenericCOWFormat',
1377  'data': { '*lazy-refcounts': 'bool',
1378            '*pass-discard-request': 'bool',
1379            '*pass-discard-snapshot': 'bool',
1380            '*pass-discard-other': 'bool',
1381            '*overlap-check': 'Qcow2OverlapChecks',
1382            '*cache-size': 'int',
1383            '*l2-cache-size': 'int',
1384            '*refcount-cache-size': 'int' } }
1385
1386
1387##
1388# @BlockdevOptionsArchipelago
1389#
1390# Driver specific block device options for Archipelago.
1391#
1392# @volume:              Name of the Archipelago volume image
1393#
1394# @mport:               #optional The port number on which mapperd is
1395#                       listening. This is optional
1396#                       and if not specified, QEMU will make Archipelago
1397#                       use the default port (1001).
1398#
1399# @vport:               #optional The port number on which vlmcd is
1400#                       listening. This is optional
1401#                       and if not specified, QEMU will make Archipelago
1402#                       use the default port (501).
1403#
1404# @segment:             #optional The name of the shared memory segment
1405#                       Archipelago stack is using. This is optional
1406#                       and if not specified, QEMU will make Archipelago
1407#                       use the default value, 'archipelago'.
1408# Since: 2.2
1409##
1410{ 'type': 'BlockdevOptionsArchipelago',
1411  'data': { 'volume': 'str',
1412            '*mport': 'int',
1413            '*vport': 'int',
1414            '*segment': 'str' } }
1415
1416
1417##
1418# @BlkdebugEvent
1419#
1420# Trigger events supported by blkdebug.
1421##
1422{ 'enum': 'BlkdebugEvent',
1423  'data': [ 'l1_update', 'l1_grow.alloc_table', 'l1_grow.write_table',
1424            'l1_grow.activate_table', 'l2_load', 'l2_update',
1425            'l2_update_compressed', 'l2_alloc.cow_read', 'l2_alloc.write',
1426            'read_aio', 'read_backing_aio', 'read_compressed', 'write_aio',
1427            'write_compressed', 'vmstate_load', 'vmstate_save', 'cow_read',
1428            'cow_write', 'reftable_load', 'reftable_grow', 'reftable_update',
1429            'refblock_load', 'refblock_update', 'refblock_update_part',
1430            'refblock_alloc', 'refblock_alloc.hookup', 'refblock_alloc.write',
1431            'refblock_alloc.write_blocks', 'refblock_alloc.write_table',
1432            'refblock_alloc.switch_table', 'cluster_alloc',
1433            'cluster_alloc_bytes', 'cluster_free', 'flush_to_os',
1434            'flush_to_disk', 'pwritev_rmw.head', 'pwritev_rmw.after_head',
1435            'pwritev_rmw.tail', 'pwritev_rmw.after_tail', 'pwritev',
1436            'pwritev_zero', 'pwritev_done', 'empty_image_prepare' ] }
1437
1438##
1439# @BlkdebugInjectErrorOptions
1440#
1441# Describes a single error injection for blkdebug.
1442#
1443# @event:       trigger event
1444#
1445# @state:       #optional the state identifier blkdebug needs to be in to
1446#               actually trigger the event; defaults to "any"
1447#
1448# @errno:       #optional error identifier (errno) to be returned; defaults to
1449#               EIO
1450#
1451# @sector:      #optional specifies the sector index which has to be affected
1452#               in order to actually trigger the event; defaults to "any
1453#               sector"
1454#
1455# @once:        #optional disables further events after this one has been
1456#               triggered; defaults to false
1457#
1458# @immediately: #optional fail immediately; defaults to false
1459#
1460# Since: 2.0
1461##
1462{ 'type': 'BlkdebugInjectErrorOptions',
1463  'data': { 'event': 'BlkdebugEvent',
1464            '*state': 'int',
1465            '*errno': 'int',
1466            '*sector': 'int',
1467            '*once': 'bool',
1468            '*immediately': 'bool' } }
1469
1470##
1471# @BlkdebugSetStateOptions
1472#
1473# Describes a single state-change event for blkdebug.
1474#
1475# @event:       trigger event
1476#
1477# @state:       #optional the current state identifier blkdebug needs to be in;
1478#               defaults to "any"
1479#
1480# @new_state:   the state identifier blkdebug is supposed to assume if
1481#               this event is triggered
1482#
1483# Since: 2.0
1484##
1485{ 'type': 'BlkdebugSetStateOptions',
1486  'data': { 'event': 'BlkdebugEvent',
1487            '*state': 'int',
1488            'new_state': 'int' } }
1489
1490##
1491# @BlockdevOptionsBlkdebug
1492#
1493# Driver specific block device options for blkdebug.
1494#
1495# @image:           underlying raw block device (or image file)
1496#
1497# @config:          #optional filename of the configuration file
1498#
1499# @align:           #optional required alignment for requests in bytes
1500#
1501# @inject-error:    #optional array of error injection descriptions
1502#
1503# @set-state:       #optional array of state-change descriptions
1504#
1505# Since: 2.0
1506##
1507{ 'type': 'BlockdevOptionsBlkdebug',
1508  'data': { 'image': 'BlockdevRef',
1509            '*config': 'str',
1510            '*align': 'int',
1511            '*inject-error': ['BlkdebugInjectErrorOptions'],
1512            '*set-state': ['BlkdebugSetStateOptions'] } }
1513
1514##
1515# @BlockdevOptionsBlkverify
1516#
1517# Driver specific block device options for blkverify.
1518#
1519# @test:    block device to be tested
1520#
1521# @raw:     raw image used for verification
1522#
1523# Since: 2.0
1524##
1525{ 'type': 'BlockdevOptionsBlkverify',
1526  'data': { 'test': 'BlockdevRef',
1527            'raw': 'BlockdevRef' } }
1528
1529##
1530# @QuorumReadPattern
1531#
1532# An enumeration of quorum read patterns.
1533#
1534# @quorum: read all the children and do a quorum vote on reads
1535#
1536# @fifo: read only from the first child that has not failed
1537#
1538# Since: 2.2
1539##
1540{ 'enum': 'QuorumReadPattern', 'data': [ 'quorum', 'fifo' ] }
1541
1542##
1543# @BlockdevOptionsQuorum
1544#
1545# Driver specific block device options for Quorum
1546#
1547# @blkverify:      #optional true if the driver must print content mismatch
1548#                  set to false by default
1549#
1550# @children:       the children block devices to use
1551#
1552# @vote-threshold: the vote limit under which a read will fail
1553#
1554# @rewrite-corrupted: #optional rewrite corrupted data when quorum is reached
1555#                     (Since 2.1)
1556#
1557# @read-pattern: #optional choose read pattern and set to quorum by default
1558#                (Since 2.2)
1559#
1560# Since: 2.0
1561##
1562{ 'type': 'BlockdevOptionsQuorum',
1563  'data': { '*blkverify': 'bool',
1564            'children': [ 'BlockdevRef' ],
1565            'vote-threshold': 'int',
1566            '*rewrite-corrupted': 'bool',
1567            '*read-pattern': 'QuorumReadPattern' } }
1568
1569##
1570# @BlockdevOptions
1571#
1572# Options for creating a block device.
1573#
1574# Since: 1.7
1575##
1576{ 'union': 'BlockdevOptions',
1577  'base': 'BlockdevOptionsBase',
1578  'discriminator': 'driver',
1579  'data': {
1580      'archipelago':'BlockdevOptionsArchipelago',
1581      'blkdebug':   'BlockdevOptionsBlkdebug',
1582      'blkverify':  'BlockdevOptionsBlkverify',
1583      'bochs':      'BlockdevOptionsGenericFormat',
1584      'cloop':      'BlockdevOptionsGenericFormat',
1585      'dmg':        'BlockdevOptionsGenericFormat',
1586      'file':       'BlockdevOptionsFile',
1587      'ftp':        'BlockdevOptionsFile',
1588      'ftps':       'BlockdevOptionsFile',
1589# TODO gluster: Wait for structured options
1590      'host_cdrom': 'BlockdevOptionsFile',
1591      'host_device':'BlockdevOptionsFile',
1592      'host_floppy':'BlockdevOptionsFile',
1593      'http':       'BlockdevOptionsFile',
1594      'https':      'BlockdevOptionsFile',
1595# TODO iscsi: Wait for structured options
1596# TODO nbd: Should take InetSocketAddress for 'host'?
1597# TODO nfs: Wait for structured options
1598      'null-aio':   'BlockdevOptionsNull',
1599      'null-co':    'BlockdevOptionsNull',
1600      'parallels':  'BlockdevOptionsGenericFormat',
1601      'qcow2':      'BlockdevOptionsQcow2',
1602      'qcow':       'BlockdevOptionsGenericCOWFormat',
1603      'qed':        'BlockdevOptionsGenericCOWFormat',
1604      'quorum':     'BlockdevOptionsQuorum',
1605      'raw':        'BlockdevOptionsGenericFormat',
1606# TODO rbd: Wait for structured options
1607# TODO sheepdog: Wait for structured options
1608# TODO ssh: Should take InetSocketAddress for 'host'?
1609      'tftp':       'BlockdevOptionsFile',
1610      'vdi':        'BlockdevOptionsGenericFormat',
1611      'vhdx':       'BlockdevOptionsGenericFormat',
1612      'vmdk':       'BlockdevOptionsGenericCOWFormat',
1613      'vpc':        'BlockdevOptionsGenericFormat',
1614      'vvfat':      'BlockdevOptionsVVFAT'
1615  } }
1616
1617##
1618# @BlockdevRef
1619#
1620# Reference to a block device.
1621#
1622# @definition:      defines a new block device inline
1623# @reference:       references the ID of an existing block device. An
1624#                   empty string means that no block device should be
1625#                   referenced.
1626#
1627# Since: 1.7
1628##
1629{ 'union': 'BlockdevRef',
1630  'discriminator': {},
1631  'data': { 'definition': 'BlockdevOptions',
1632            'reference': 'str' } }
1633
1634##
1635# @blockdev-add:
1636#
1637# Creates a new block device.
1638#
1639# @options: block device options for the new device
1640#
1641# Since: 1.7
1642##
1643{ 'command': 'blockdev-add', 'data': { 'options': 'BlockdevOptions' } }
1644
1645
1646##
1647# @BlockErrorAction
1648#
1649# An enumeration of action that has been taken when a DISK I/O occurs
1650#
1651# @ignore: error has been ignored
1652#
1653# @report: error has been reported to the device
1654#
1655# @stop: error caused VM to be stopped
1656#
1657# Since: 2.1
1658##
1659{ 'enum': 'BlockErrorAction',
1660  'data': [ 'ignore', 'report', 'stop' ] }
1661
1662
1663##
1664# @BLOCK_IMAGE_CORRUPTED
1665#
1666# Emitted when a corruption has been detected in a disk image
1667#
1668# @device: device name
1669#
1670# @msg: informative message for human consumption, such as the kind of
1671#       corruption being detected. It should not be parsed by machine as it is
1672#       not guaranteed to be stable
1673#
1674# @offset: #optional, if the corruption resulted from an image access, this is
1675#          the access offset into the image
1676#
1677# @size: #optional, if the corruption resulted from an image access, this is
1678#        the access size
1679#
1680# fatal: if set, the image is marked corrupt and therefore unusable after this
1681#        event and must be repaired (Since 2.2; before, every
1682#        BLOCK_IMAGE_CORRUPTED event was fatal)
1683#
1684# Since: 1.7
1685##
1686{ 'event': 'BLOCK_IMAGE_CORRUPTED',
1687  'data': { 'device' : 'str',
1688            'msg'    : 'str',
1689            '*offset': 'int',
1690            '*size'  : 'int',
1691            'fatal'  : 'bool' } }
1692
1693##
1694# @BLOCK_IO_ERROR
1695#
1696# Emitted when a disk I/O error occurs
1697#
1698# @device: device name
1699#
1700# @operation: I/O operation
1701#
1702# @action: action that has been taken
1703#
1704# @nospace: #optional true if I/O error was caused due to a no-space
1705#           condition. This key is only present if query-block's
1706#           io-status is present, please see query-block documentation
1707#           for more information (since: 2.2)
1708#
1709# @reason: human readable string describing the error cause.
1710#          (This field is a debugging aid for humans, it should not
1711#           be parsed by applications) (since: 2.2)
1712#
1713# Note: If action is "stop", a STOP event will eventually follow the
1714# BLOCK_IO_ERROR event
1715#
1716# Since: 0.13.0
1717##
1718{ 'event': 'BLOCK_IO_ERROR',
1719  'data': { 'device': 'str', 'operation': 'IoOperationType',
1720            'action': 'BlockErrorAction', '*nospace': 'bool',
1721            'reason': 'str' } }
1722
1723##
1724# @BLOCK_JOB_COMPLETED
1725#
1726# Emitted when a block job has completed
1727#
1728# @type: job type
1729#
1730# @device: device name
1731#
1732# @len: maximum progress value
1733#
1734# @offset: current progress value. On success this is equal to len.
1735#          On failure this is less than len
1736#
1737# @speed: rate limit, bytes per second
1738#
1739# @error: #optional, error message. Only present on failure. This field
1740#         contains a human-readable error message. There are no semantics
1741#         other than that streaming has failed and clients should not try to
1742#         interpret the error string
1743#
1744# Since: 1.1
1745##
1746{ 'event': 'BLOCK_JOB_COMPLETED',
1747  'data': { 'type'  : 'BlockJobType',
1748            'device': 'str',
1749            'len'   : 'int',
1750            'offset': 'int',
1751            'speed' : 'int',
1752            '*error': 'str' } }
1753
1754##
1755# @BLOCK_JOB_CANCELLED
1756#
1757# Emitted when a block job has been cancelled
1758#
1759# @type: job type
1760#
1761# @device: device name
1762#
1763# @len: maximum progress value
1764#
1765# @offset: current progress value. On success this is equal to len.
1766#          On failure this is less than len
1767#
1768# @speed: rate limit, bytes per second
1769#
1770# Since: 1.1
1771##
1772{ 'event': 'BLOCK_JOB_CANCELLED',
1773  'data': { 'type'  : 'BlockJobType',
1774            'device': 'str',
1775            'len'   : 'int',
1776            'offset': 'int',
1777            'speed' : 'int' } }
1778
1779##
1780# @BLOCK_JOB_ERROR
1781#
1782# Emitted when a block job encounters an error
1783#
1784# @device: device name
1785#
1786# @operation: I/O operation
1787#
1788# @action: action that has been taken
1789#
1790# Since: 1.3
1791##
1792{ 'event': 'BLOCK_JOB_ERROR',
1793  'data': { 'device'   : 'str',
1794            'operation': 'IoOperationType',
1795            'action'   : 'BlockErrorAction' } }
1796
1797##
1798# @BLOCK_JOB_READY
1799#
1800# Emitted when a block job is ready to complete
1801#
1802# @type: job type
1803#
1804# @device: device name
1805#
1806# @len: maximum progress value
1807#
1808# @offset: current progress value. On success this is equal to len.
1809#          On failure this is less than len
1810#
1811# @speed: rate limit, bytes per second
1812#
1813# Note: The "ready to complete" status is always reset by a @BLOCK_JOB_ERROR
1814# event
1815#
1816# Since: 1.3
1817##
1818{ 'event': 'BLOCK_JOB_READY',
1819  'data': { 'type'  : 'BlockJobType',
1820            'device': 'str',
1821            'len'   : 'int',
1822            'offset': 'int',
1823            'speed' : 'int' } }
1824
1825# @PreallocMode
1826#
1827# Preallocation mode of QEMU image file
1828#
1829# @off: no preallocation
1830# @metadata: preallocate only for metadata
1831# @falloc: like @full preallocation but allocate disk space by
1832#          posix_fallocate() rather than writing zeros.
1833# @full: preallocate all data by writing zeros to device to ensure disk
1834#        space is really available. @full preallocation also sets up
1835#        metadata correctly.
1836#
1837# Since 2.2
1838##
1839{ 'enum': 'PreallocMode',
1840  'data': [ 'off', 'metadata', 'falloc', 'full' ] }
1841