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