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