3 # QAPI block core definitions (vm unrelated)
5 # QAPI common definitions
6 { 'include': 'common.json' }
11 # @id: unique snapshot id
13 # @name: user chosen name
15 # @vm-state-size: size of the VM state
17 # @date-sec: UTC date of the snapshot in seconds
19 # @date-nsec: fractional part in nano seconds to be used with date-sec
21 # @vm-clock-sec: VM clock relative to boot in seconds
23 # @vm-clock-nsec: fractional part in nano seconds to be used with vm-clock-sec
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' } }
35 # @ImageInfoSpecificQCow2:
37 # @compat: compatibility level
39 # @lazy-refcounts: #optional on or off; only valid for compat >= 1.1
43 { 'type': 'ImageInfoSpecificQCow2',
46 '*lazy-refcounts': 'bool'
50 # @ImageInfoSpecificVmdk:
52 # @create-type: The create type of VMDK image
54 # @cid: Content id of image
56 # @parent-cid: Parent VMDK image's cid
58 # @extents: List of extent files
62 { 'type': 'ImageInfoSpecificVmdk',
67 'extents': ['ImageInfo']
73 # A discriminated record of image format specific information structures.
78 { 'union': 'ImageInfoSpecific',
80 'qcow2': 'ImageInfoSpecificQCow2',
81 'vmdk': 'ImageInfoSpecificVmdk'
87 # Information about a QEMU image file
89 # @filename: name of the image file
91 # @format: format of the image file
93 # @virtual-size: maximum capacity in bytes of the image
95 # @actual-size: #optional actual size on disk in bytes of the image
97 # @dirty-flag: #optional true if image is not cleanly closed
99 # @cluster-size: #optional size of a cluster in bytes
101 # @encrypted: #optional true if the image is encrypted
103 # @compressed: #optional true if the image is compressed (Since 1.7)
105 # @backing-filename: #optional name of the backing file
107 # @full-backing-filename: #optional full path of the backing file
109 # @backing-filename-format: #optional the format of the backing file
111 # @snapshots: #optional list of VM snapshots
113 # @backing-image: #optional info of the backing image (since 1.6)
115 # @format-specific: #optional structure supplying additional format-specific
116 # information (since 1.7)
122 { 'type': 'ImageInfo',
123 'data': {'filename': 'str', 'format': 'str', '*dirty-flag': 'bool',
124 '*actual-size': 'int', 'virtual-size': 'int',
125 '*cluster-size': 'int', '*encrypted': 'bool', '*compressed': 'bool',
126 '*backing-filename': 'str', '*full-backing-filename': 'str',
127 '*backing-filename-format': 'str', '*snapshots': ['SnapshotInfo'],
128 '*backing-image': 'ImageInfo',
129 '*format-specific': 'ImageInfoSpecific' } }
134 # Information about a QEMU image file check
136 # @filename: name of the image file checked
138 # @format: format of the image file checked
140 # @check-errors: number of unexpected errors occurred during check
142 # @image-end-offset: #optional offset (in bytes) where the image ends, this
143 # field is present if the driver for the image format
146 # @corruptions: #optional number of corruptions found during the check if any
148 # @leaks: #optional number of leaks found during the check if any
150 # @corruptions-fixed: #optional number of corruptions fixed during the check
153 # @leaks-fixed: #optional number of leaks fixed during the check if any
155 # @total-clusters: #optional total number of clusters, this field is present
156 # if the driver for the image format supports it
158 # @allocated-clusters: #optional total number of allocated clusters, this
159 # field is present if the driver for the image format
162 # @fragmented-clusters: #optional total number of fragmented clusters, this
163 # field is present if the driver for the image format
166 # @compressed-clusters: #optional total number of compressed clusters, this
167 # field is present if the driver for the image format
174 { 'type': 'ImageCheck',
175 'data': {'filename': 'str', 'format': 'str', 'check-errors': 'int',
176 '*image-end-offset': 'int', '*corruptions': 'int', '*leaks': 'int',
177 '*corruptions-fixed': 'int', '*leaks-fixed': 'int',
178 '*total-clusters': 'int', '*allocated-clusters': 'int',
179 '*fragmented-clusters': 'int', '*compressed-clusters': 'int' } }
184 # Information about the backing device for a block device.
186 # @file: the filename of the backing device
188 # @node-name: #optional the name of the block driver node (Since 2.0)
190 # @ro: true if the backing device was open read-only
192 # @drv: the name of the block format used to open the backing device. As of
193 # 0.14.0 this can be: 'blkdebug', 'bochs', 'cloop', 'cow', 'dmg',
194 # 'file', 'file', 'ftp', 'ftps', 'host_cdrom', 'host_device',
195 # 'host_floppy', 'http', 'https', 'nbd', 'parallels', 'qcow',
196 # 'qcow2', 'raw', 'tftp', 'vdi', 'vmdk', 'vpc', 'vvfat'
198 # @backing_file: #optional the name of the backing file (for copy-on-write)
200 # @backing_file_depth: number of files in the backing file chain (since: 1.2)
202 # @encrypted: true if the backing device is encrypted
204 # @encryption_key_missing: true if the backing device is encrypted but an
205 # valid encryption key is missing
207 # @detect_zeroes: detect and optimize zero writes (Since 2.1)
209 # @bps: total throughput limit in bytes per second is specified
211 # @bps_rd: read throughput limit in bytes per second is specified
213 # @bps_wr: write throughput limit in bytes per second is specified
215 # @iops: total I/O operations per second is specified
217 # @iops_rd: read I/O operations per second is specified
219 # @iops_wr: write I/O operations per second is specified
221 # @image: the info of image used (since: 1.6)
223 # @bps_max: #optional total max in bytes (Since 1.7)
225 # @bps_rd_max: #optional read max in bytes (Since 1.7)
227 # @bps_wr_max: #optional write max in bytes (Since 1.7)
229 # @iops_max: #optional total I/O operations max (Since 1.7)
231 # @iops_rd_max: #optional read I/O operations max (Since 1.7)
233 # @iops_wr_max: #optional write I/O operations max (Since 1.7)
235 # @iops_size: #optional an I/O size in bytes (Since 1.7)
240 { 'type': 'BlockDeviceInfo',
241 'data': { 'file': 'str', '*node-name': 'str', 'ro': 'bool', 'drv': 'str',
242 '*backing_file': 'str', 'backing_file_depth': 'int',
243 'encrypted': 'bool', 'encryption_key_missing': 'bool',
244 'detect_zeroes': 'BlockdevDetectZeroesOptions',
245 'bps': 'int', 'bps_rd': 'int', 'bps_wr': 'int',
246 'iops': 'int', 'iops_rd': 'int', 'iops_wr': 'int',
247 'image': 'ImageInfo',
248 '*bps_max': 'int', '*bps_rd_max': 'int',
249 '*bps_wr_max': 'int', '*iops_max': 'int',
250 '*iops_rd_max': 'int', '*iops_wr_max': 'int',
251 '*iops_size': 'int' } }
254 # @BlockDeviceIoStatus:
256 # An enumeration of block device I/O status.
258 # @ok: The last I/O operation has succeeded
260 # @failed: The last I/O operation has failed
262 # @nospace: The last I/O operation has failed due to a no-space condition
266 { 'enum': 'BlockDeviceIoStatus', 'data': [ 'ok', 'failed', 'nospace' ] }
269 # @BlockDeviceMapEntry:
271 # Entry in the metadata map of the device (returned by "qemu-img map")
273 # @start: Offset in the image of the first byte described by this entry
276 # @length: Length of the range described by this entry (in bytes)
278 # @depth: Number of layers (0 = top image, 1 = top image's backing file, etc.)
279 # before reaching one for which the range is allocated. The value is
280 # in the range 0 to the depth of the image chain - 1.
282 # @zero: the sectors in this range read as zeros
284 # @data: reading the image will actually read data from a file (in particular,
285 # if @offset is present this means that the sectors are not simply
286 # preallocated, but contain actual data in raw format)
288 # @offset: if present, the image file stores the data for this range in
289 # raw format at the given offset.
293 { 'type': 'BlockDeviceMapEntry',
294 'data': { 'start': 'int', 'length': 'int', 'depth': 'int', 'zero': 'bool',
295 'data': 'bool', '*offset': 'int' } }
300 # Block dirty bitmap information.
302 # @count: number of dirty bytes according to the dirty bitmap
304 # @granularity: granularity of the dirty bitmap in bytes (since 1.4)
308 { 'type': 'BlockDirtyInfo',
309 'data': {'count': 'int', 'granularity': 'int'} }
314 # Block device information. This structure describes a virtual device and
315 # the backing device associated with it.
317 # @device: The device name associated with the virtual device.
319 # @type: This field is returned only for compatibility reasons, it should
320 # not be used (always returns 'unknown')
322 # @removable: True if the device supports removable media.
324 # @locked: True if the guest has locked this device from having its media
327 # @tray_open: #optional True if the device has a tray and it is open
328 # (only present if removable is true)
330 # @dirty-bitmaps: #optional dirty bitmaps information (only present if the
331 # driver has one or more dirty bitmaps) (Since 2.0)
333 # @io-status: #optional @BlockDeviceIoStatus. Only present if the device
334 # supports it and the VM is configured to stop on errors
336 # @inserted: #optional @BlockDeviceInfo describing the device if media is
341 { 'type': 'BlockInfo',
342 'data': {'device': 'str', 'type': 'str', 'removable': 'bool',
343 'locked': 'bool', '*inserted': 'BlockDeviceInfo',
344 '*tray_open': 'bool', '*io-status': 'BlockDeviceIoStatus',
345 '*dirty-bitmaps': ['BlockDirtyInfo'] } }
350 # Get a list of BlockInfo for all virtual block devices.
352 # Returns: a list of @BlockInfo describing each virtual block device
356 { 'command': 'query-block', 'returns': ['BlockInfo'] }
361 # Statistics of a virtual block device or a block backing device.
363 # @rd_bytes: The number of bytes read by the device.
365 # @wr_bytes: The number of bytes written by the device.
367 # @rd_operations: The number of read operations performed by the device.
369 # @wr_operations: The number of write operations performed by the device.
371 # @flush_operations: The number of cache flush operations performed by the
372 # device (since 0.15.0)
374 # @flush_total_time_ns: Total time spend on cache flushes in nano-seconds
377 # @wr_total_time_ns: Total time spend on writes in nano-seconds (since 0.15.0).
379 # @rd_total_time_ns: Total_time_spend on reads in nano-seconds (since 0.15.0).
381 # @wr_highest_offset: The offset after the greatest byte written to the
382 # device. The intended use of this information is for
383 # growable sparse files (like qcow2) that are used on top
384 # of a physical device.
388 { 'type': 'BlockDeviceStats',
389 'data': {'rd_bytes': 'int', 'wr_bytes': 'int', 'rd_operations': 'int',
390 'wr_operations': 'int', 'flush_operations': 'int',
391 'flush_total_time_ns': 'int', 'wr_total_time_ns': 'int',
392 'rd_total_time_ns': 'int', 'wr_highest_offset': 'int' } }
397 # Statistics of a virtual block device or a block backing device.
399 # @device: #optional If the stats are for a virtual block device, the name
400 # corresponding to the virtual block device.
402 # @stats: A @BlockDeviceStats for the device.
404 # @parent: #optional This describes the file block device if it has one.
406 # @backing: #optional This describes the backing block device if it has one.
411 { 'type': 'BlockStats',
412 'data': {'*device': 'str', 'stats': 'BlockDeviceStats',
413 '*parent': 'BlockStats',
414 '*backing': 'BlockStats'} }
419 # Query the @BlockStats for all virtual block devices.
421 # Returns: A list of @BlockStats for each virtual block devices.
425 { 'command': 'query-blockstats', 'returns': ['BlockStats'] }
430 # An enumeration of possible behaviors for errors on I/O operations.
431 # The exact meaning depends on whether the I/O was initiated by a guest
434 # @report: for guest operations, report the error to the guest;
435 # for jobs, cancel the job
437 # @ignore: ignore the error, only report a QMP event (BLOCK_IO_ERROR
438 # or BLOCK_JOB_ERROR)
440 # @enospc: same as @stop on ENOSPC, same as @report otherwise.
442 # @stop: for guest operations, stop the virtual machine;
443 # for jobs, pause the job
447 { 'enum': 'BlockdevOnError',
448 'data': ['report', 'ignore', 'enospc', 'stop'] }
453 # An enumeration of possible behaviors for the initial synchronization
454 # phase of storage mirroring.
456 # @top: copies data in the topmost image to the destination
458 # @full: copies data from all images to the destination
460 # @none: only copy data written from now on
464 { 'enum': 'MirrorSyncMode',
465 'data': ['top', 'full', 'none'] }
470 # Type of a block job.
472 # @commit: block commit job type, see "block-commit"
474 # @stream: block stream job type, see "block-stream"
476 # @mirror: drive mirror job type, see "drive-mirror"
478 # @backup: drive backup job type, see "drive-backup"
482 { 'enum': 'BlockJobType',
483 'data': ['commit', 'stream', 'mirror', 'backup'] }
488 # Information about a long-running block device operation.
490 # @type: the job type ('stream' for image streaming)
492 # @device: the block device name
494 # @len: the maximum progress value
496 # @busy: false if the job is known to be in a quiescent state, with
497 # no pending I/O. Since 1.3.
499 # @paused: whether the job is paused or, if @busy is true, will
500 # pause itself as soon as possible. Since 1.3.
502 # @offset: the current progress value
504 # @speed: the rate limit, bytes per second
506 # @io-status: the status of the job (since 1.3)
510 { 'type': 'BlockJobInfo',
511 'data': {'type': 'str', 'device': 'str', 'len': 'int',
512 'offset': 'int', 'busy': 'bool', 'paused': 'bool', 'speed': 'int',
513 'io-status': 'BlockDeviceIoStatus'} }
518 # Return information about long-running block device operations.
520 # Returns: a list of @BlockJobInfo for each active block job
524 { 'command': 'query-block-jobs', 'returns': ['BlockJobInfo'] }
529 # This command sets the password of a block device that has not been open
530 # with a password and requires one.
532 # The two cases where this can happen are a block device is created through
533 # QEMU's initial command line or a block device is changed through the legacy
536 # In the event that the block device is created through the initial command
537 # line, the VM will start in the stopped state regardless of whether '-S' is
538 # used. The intention is for a management tool to query the block devices to
539 # determine which ones are encrypted, set the passwords with this command, and
540 # then start the guest with the @cont command.
542 # Either @device or @node-name must be set but not both.
544 # @device: #optional the name of the block backend device to set the password on
546 # @node-name: #optional graph node name to set the password on (Since 2.0)
548 # @password: the password to use for the device
550 # Returns: nothing on success
551 # If @device is not a valid block device, DeviceNotFound
552 # If @device is not encrypted, DeviceNotEncrypted
554 # Notes: Not all block formats support encryption and some that do are not
555 # able to validate that a password is correct. Disk corruption may
556 # occur if an invalid password is specified.
560 { 'command': 'block_passwd', 'data': {'*device': 'str',
561 '*node-name': 'str', 'password': 'str'} }
566 # Resize a block image while a guest is running.
568 # Either @device or @node-name must be set but not both.
570 # @device: #optional the name of the device to get the image resized
572 # @node-name: #optional graph node name to get the image resized (Since 2.0)
574 # @size: new image size in bytes
576 # Returns: nothing on success
577 # If @device is not a valid block device, DeviceNotFound
581 { 'command': 'block_resize', 'data': { '*device': 'str',
588 # An enumeration that tells QEMU how to set the backing file path in
591 # @existing: QEMU should look for an existing image file.
593 # @absolute-paths: QEMU should create a new image with absolute paths
594 # for the backing file. If there is no backing file available, the new
595 # image will not be backed either.
599 { 'enum': 'NewImageMode',
600 'data': [ 'existing', 'absolute-paths' ] }
605 # Either @device or @node-name must be set but not both.
607 # @device: #optional the name of the device to generate the snapshot from.
609 # @node-name: #optional graph node name to generate the snapshot from (Since 2.0)
611 # @snapshot-file: the target of the new image. A new file will be created.
613 # @snapshot-node-name: #optional the graph node name of the new image (Since 2.0)
615 # @format: #optional the format of the snapshot image, default is 'qcow2'.
617 # @mode: #optional whether and how QEMU should create a new image, default is
620 { 'type': 'BlockdevSnapshot',
621 'data': { '*device': 'str', '*node-name': 'str',
622 'snapshot-file': 'str', '*snapshot-node-name': 'str',
623 '*format': 'str', '*mode': 'NewImageMode' } }
628 # @device: the name of the device which should be copied.
630 # @target: the target of the new image. If the file exists, or if it
631 # is a device, the existing file/device will be used as the new
632 # destination. If it does not exist, a new file will be created.
634 # @format: #optional the format of the new destination, default is to
635 # probe if @mode is 'existing', else the format of the source
637 # @sync: what parts of the disk image should be copied to the destination
638 # (all the disk, only the sectors allocated in the topmost image, or
641 # @mode: #optional whether and how QEMU should create a new image, default is
644 # @speed: #optional the maximum speed, in bytes per second
646 # @on-source-error: #optional the action to take on an error on the source,
647 # default 'report'. 'stop' and 'enospc' can only be used
648 # if the block device supports io-status (see BlockInfo).
650 # @on-target-error: #optional the action to take on an error on the target,
651 # default 'report' (no limitations, since this applies to
652 # a different block device than @device).
654 # Note that @on-source-error and @on-target-error only affect background I/O.
655 # If an error occurs during a guest write request, the device's rerror/werror
656 # actions will be used.
660 { 'type': 'DriveBackup',
661 'data': { 'device': 'str', 'target': 'str', '*format': 'str',
662 'sync': 'MirrorSyncMode', '*mode': 'NewImageMode',
664 '*on-source-error': 'BlockdevOnError',
665 '*on-target-error': 'BlockdevOnError' } }
668 # @blockdev-snapshot-sync
670 # Generates a synchronous snapshot of a block device.
672 # For the arguments, see the documentation of BlockdevSnapshot.
674 # Returns: nothing on success
675 # If @device is not a valid block device, DeviceNotFound
679 { 'command': 'blockdev-snapshot-sync',
680 'data': 'BlockdevSnapshot' }
683 # @change-backing-file
685 # Change the backing file in the image file metadata. This does not
686 # cause QEMU to reopen the image file to reparse the backing filename
687 # (it may, however, perform a reopen to change permissions from
688 # r/o -> r/w -> r/o, if needed). The new backing file string is written
689 # into the image file metadata, and the QEMU internal strings are
692 # @image-node-name: The name of the block driver state node of the
695 # @device: The name of the device that owns image-node-name.
697 # @backing-file: The string to write as the backing file. This
698 # string is not validated, so care should be taken
699 # when specifying the string or the image chain may
700 # not be able to be reopened again.
704 { 'command': 'change-backing-file',
705 'data': { 'device': 'str', 'image-node-name': 'str',
706 'backing-file': 'str' } }
711 # Live commit of data from overlay image nodes into backing nodes - i.e.,
712 # writes data between 'top' and 'base' into 'base'.
714 # @device: the name of the device
716 # @base: #optional The file name of the backing image to write data into.
717 # If not specified, this is the deepest backing image
719 # @top: #optional The file name of the backing image within the image chain,
720 # which contains the topmost data to be committed down. If
721 # not specified, this is the active layer.
723 # @backing-file: #optional The backing file string to write into the overlay
724 # image of 'top'. If 'top' is the active layer,
725 # specifying a backing file string is an error. This
726 # filename is not validated.
728 # If a pathname string is such that it cannot be
729 # resolved by QEMU, that means that subsequent QMP or
730 # HMP commands must use node-names for the image in
731 # question, as filename lookup methods will fail.
733 # If not specified, QEMU will automatically determine
734 # the backing file string to use, or error out if
735 # there is no obvious choice. Care should be taken
736 # when specifying the string, to specify a valid
737 # filename or protocol.
740 # If top == base, that is an error.
741 # If top == active, the job will not be completed by itself,
742 # user needs to complete the job with the block-job-complete
743 # command after getting the ready event. (Since 2.0)
745 # If the base image is smaller than top, then the base image
746 # will be resized to be the same size as top. If top is
747 # smaller than the base image, the base will not be
748 # truncated. If you want the base image size to match the
749 # size of the smaller top, you can safely truncate it
750 # yourself once the commit operation successfully completes.
752 # @speed: #optional the maximum speed, in bytes per second
754 # Returns: Nothing on success
755 # If commit or stream is already active on this device, DeviceInUse
756 # If @device does not exist, DeviceNotFound
757 # If image commit is not supported by this device, NotSupported
758 # If @base or @top is invalid, a generic error is returned
759 # If @speed is invalid, InvalidParameter
764 { 'command': 'block-commit',
765 'data': { 'device': 'str', '*base': 'str', '*top': 'str',
766 '*backing-file': 'str', '*speed': 'int' } }
771 # Start a point-in-time copy of a block device to a new destination. The
772 # status of ongoing drive-backup operations can be checked with
773 # query-block-jobs where the BlockJobInfo.type field has the value 'backup'.
774 # The operation can be stopped before it has completed using the
775 # block-job-cancel command.
777 # For the arguments, see the documentation of DriveBackup.
779 # Returns: nothing on success
780 # If @device is not a valid block device, DeviceNotFound
784 { 'command': 'drive-backup', 'data': 'DriveBackup' }
787 # @query-named-block-nodes
789 # Get the named block driver list
791 # Returns: the list of BlockDeviceInfo
795 { 'command': 'query-named-block-nodes', 'returns': [ 'BlockDeviceInfo' ] }
800 # Start mirroring a block device's writes to a new destination.
802 # @device: the name of the device whose writes should be mirrored.
804 # @target: the target of the new image. If the file exists, or if it
805 # is a device, the existing file/device will be used as the new
806 # destination. If it does not exist, a new file will be created.
808 # @format: #optional the format of the new destination, default is to
809 # probe if @mode is 'existing', else the format of the source
811 # @node-name: #optional the new block driver state node name in the graph
814 # @replaces: #optional with sync=full graph node name to be replaced by the new
815 # image when a whole image copy is done. This can be used to repair
816 # broken Quorum files. (Since 2.1)
818 # @mode: #optional whether and how QEMU should create a new image, default is
821 # @speed: #optional the maximum speed, in bytes per second
823 # @sync: what parts of the disk image should be copied to the destination
824 # (all the disk, only the sectors allocated in the topmost image, or
827 # @granularity: #optional granularity of the dirty bitmap, default is 64K
828 # if the image format doesn't have clusters, 4K if the clusters
829 # are smaller than that, else the cluster size. Must be a
830 # power of 2 between 512 and 64M (since 1.4).
832 # @buf-size: #optional maximum amount of data in flight from source to
833 # target (since 1.4).
835 # @on-source-error: #optional the action to take on an error on the source,
836 # default 'report'. 'stop' and 'enospc' can only be used
837 # if the block device supports io-status (see BlockInfo).
839 # @on-target-error: #optional the action to take on an error on the target,
840 # default 'report' (no limitations, since this applies to
841 # a different block device than @device).
843 # Returns: nothing on success
844 # If @device is not a valid block device, DeviceNotFound
848 { 'command': 'drive-mirror',
849 'data': { 'device': 'str', 'target': 'str', '*format': 'str',
850 '*node-name': 'str', '*replaces': 'str',
851 'sync': 'MirrorSyncMode', '*mode': 'NewImageMode',
852 '*speed': 'int', '*granularity': 'uint32',
853 '*buf-size': 'int', '*on-source-error': 'BlockdevOnError',
854 '*on-target-error': 'BlockdevOnError' } }
857 # @block_set_io_throttle:
859 # Change I/O throttle limits for a block drive.
861 # @device: The name of the device
863 # @bps: total throughput limit in bytes per second
865 # @bps_rd: read throughput limit in bytes per second
867 # @bps_wr: write throughput limit in bytes per second
869 # @iops: total I/O operations per second
871 # @ops_rd: read I/O operations per second
873 # @iops_wr: write I/O operations per second
875 # @bps_max: #optional total max in bytes (Since 1.7)
877 # @bps_rd_max: #optional read max in bytes (Since 1.7)
879 # @bps_wr_max: #optional write max in bytes (Since 1.7)
881 # @iops_max: #optional total I/O operations max (Since 1.7)
883 # @iops_rd_max: #optional read I/O operations max (Since 1.7)
885 # @iops_wr_max: #optional write I/O operations max (Since 1.7)
887 # @iops_size: #optional an I/O size in bytes (Since 1.7)
889 # Returns: Nothing on success
890 # If @device is not a valid block device, DeviceNotFound
894 { 'command': 'block_set_io_throttle',
895 'data': { 'device': 'str', 'bps': 'int', 'bps_rd': 'int', 'bps_wr': 'int',
896 'iops': 'int', 'iops_rd': 'int', 'iops_wr': 'int',
897 '*bps_max': 'int', '*bps_rd_max': 'int',
898 '*bps_wr_max': 'int', '*iops_max': 'int',
899 '*iops_rd_max': 'int', '*iops_wr_max': 'int',
900 '*iops_size': 'int' } }
905 # Copy data from a backing file into a block device.
907 # The block streaming operation is performed in the background until the entire
908 # backing file has been copied. This command returns immediately once streaming
909 # has started. The status of ongoing block streaming operations can be checked
910 # with query-block-jobs. The operation can be stopped before it has completed
911 # using the block-job-cancel command.
913 # If a base file is specified then sectors are not copied from that base file and
914 # its backing chain. When streaming completes the image file will have the base
915 # file as its backing file. This can be used to stream a subset of the backing
916 # file chain instead of flattening the entire image.
918 # On successful completion the image file is updated to drop the backing file
919 # and the BLOCK_JOB_COMPLETED event is emitted.
921 # @device: the device name
923 # @base: #optional the common backing file name
925 # @backing-file: #optional The backing file string to write into the active
926 # layer. This filename is not validated.
928 # If a pathname string is such that it cannot be
929 # resolved by QEMU, that means that subsequent QMP or
930 # HMP commands must use node-names for the image in
931 # question, as filename lookup methods will fail.
933 # If not specified, QEMU will automatically determine
934 # the backing file string to use, or error out if there
935 # is no obvious choice. Care should be taken when
936 # specifying the string, to specify a valid filename or
940 # @speed: #optional the maximum speed, in bytes per second
942 # @on-error: #optional the action to take on an error (default report).
943 # 'stop' and 'enospc' can only be used if the block device
944 # supports io-status (see BlockInfo). Since 1.3.
946 # Returns: Nothing on success
947 # If @device does not exist, DeviceNotFound
951 { 'command': 'block-stream',
952 'data': { 'device': 'str', '*base': 'str', '*backing-file': 'str',
953 '*speed': 'int', '*on-error': 'BlockdevOnError' } }
956 # @block-job-set-speed:
958 # Set maximum speed for a background block operation.
960 # This command can only be issued when there is an active block job.
962 # Throttling can be disabled by setting the speed to 0.
964 # @device: the device name
966 # @speed: the maximum speed, in bytes per second, or 0 for unlimited.
969 # Returns: Nothing on success
970 # If no background operation is active on this device, DeviceNotActive
974 { 'command': 'block-job-set-speed',
975 'data': { 'device': 'str', 'speed': 'int' } }
980 # Stop an active background block operation.
982 # This command returns immediately after marking the active background block
983 # operation for cancellation. It is an error to call this command if no
984 # operation is in progress.
986 # The operation will cancel as soon as possible and then emit the
987 # BLOCK_JOB_CANCELLED event. Before that happens the job is still visible when
988 # enumerated using query-block-jobs.
990 # For streaming, the image file retains its backing file unless the streaming
991 # operation happens to complete just as it is being cancelled. A new streaming
992 # operation can be started at a later time to finish copying all data from the
995 # @device: the device name
997 # @force: #optional whether to allow cancellation of a paused job (default
1000 # Returns: Nothing on success
1001 # If no background operation is active on this device, DeviceNotActive
1005 { 'command': 'block-job-cancel', 'data': { 'device': 'str', '*force': 'bool' } }
1010 # Pause an active background block operation.
1012 # This command returns immediately after marking the active background block
1013 # operation for pausing. It is an error to call this command if no
1014 # operation is in progress. Pausing an already paused job has no cumulative
1015 # effect; a single block-job-resume command will resume the job.
1017 # The operation will pause as soon as possible. No event is emitted when
1018 # the operation is actually paused. Cancelling a paused job automatically
1021 # @device: the device name
1023 # Returns: Nothing on success
1024 # If no background operation is active on this device, DeviceNotActive
1028 { 'command': 'block-job-pause', 'data': { 'device': 'str' } }
1031 # @block-job-resume:
1033 # Resume an active background block operation.
1035 # This command returns immediately after resuming a paused background block
1036 # operation. It is an error to call this command if no operation is in
1037 # progress. Resuming an already running job is not an error.
1039 # This command also clears the error status of the job.
1041 # @device: the device name
1043 # Returns: Nothing on success
1044 # If no background operation is active on this device, DeviceNotActive
1048 { 'command': 'block-job-resume', 'data': { 'device': 'str' } }
1051 # @block-job-complete:
1053 # Manually trigger completion of an active background block operation. This
1054 # is supported for drive mirroring, where it also switches the device to
1055 # write to the target path only. The ability to complete is signaled with
1056 # a BLOCK_JOB_READY event.
1058 # This command completes an active background block operation synchronously.
1059 # The ordering of this command's return with the BLOCK_JOB_COMPLETED event
1060 # is not defined. Note that if an I/O error occurs during the processing of
1061 # this command: 1) the command itself will fail; 2) the error will be processed
1062 # according to the rerror/werror arguments that were specified when starting
1065 # A cancelled or paused job cannot be completed.
1067 # @device: the device name
1069 # Returns: Nothing on success
1070 # If no background operation is active on this device, DeviceNotActive
1074 { 'command': 'block-job-complete', 'data': { 'device': 'str' } }
1077 # @BlockdevDiscardOptions
1079 # Determines how to handle discard requests.
1081 # @ignore: Ignore the request
1082 # @unmap: Forward as an unmap request
1086 { 'enum': 'BlockdevDiscardOptions',
1087 'data': [ 'ignore', 'unmap' ] }
1090 # @BlockdevDetectZeroesOptions
1092 # Describes the operation mode for the automatic conversion of plain
1093 # zero writes by the OS to driver specific optimized zero write commands.
1095 # @off: Disabled (default)
1097 # @unmap: Enabled and even try to unmap blocks if possible. This requires
1098 # also that @BlockdevDiscardOptions is set to unmap for this device.
1102 { 'enum': 'BlockdevDetectZeroesOptions',
1103 'data': [ 'off', 'on', 'unmap' ] }
1106 # @BlockdevAioOptions
1108 # Selects the AIO backend to handle I/O requests
1110 # @threads: Use qemu's thread pool
1111 # @native: Use native AIO backend (only Linux and Windows)
1115 { 'enum': 'BlockdevAioOptions',
1116 'data': [ 'threads', 'native' ] }
1119 # @BlockdevCacheOptions
1121 # Includes cache-related options for block devices
1123 # @writeback: #optional enables writeback mode for any caches (default: true)
1124 # @direct: #optional enables use of O_DIRECT (bypass the host page cache;
1126 # @no-flush: #optional ignore any flush requests for the device (default:
1131 { 'type': 'BlockdevCacheOptions',
1132 'data': { '*writeback': 'bool',
1134 '*no-flush': 'bool' } }
1139 # Drivers that are supported in block device operations.
1141 # @host_device, @host_cdrom, @host_floppy: Since 2.1
1145 { 'enum': 'BlockdevDriver',
1146 'data': [ 'file', 'host_device', 'host_cdrom', 'host_floppy',
1147 'http', 'https', 'ftp', 'ftps', 'tftp', 'vvfat', 'blkdebug',
1148 'blkverify', 'bochs', 'cloop', 'cow', 'dmg', 'parallels', 'qcow',
1149 'qcow2', 'qed', 'raw', 'vdi', 'vhdx', 'vmdk', 'vpc', 'quorum' ] }
1152 # @BlockdevOptionsBase
1154 # Options that are available for all block devices, independent of the block
1157 # @driver: block driver name
1158 # @id: #optional id by which the new block device can be referred to.
1159 # This is a required option on the top level of blockdev-add, and
1160 # currently not allowed on any other level.
1161 # @node-name: #optional the name of a block driver state node (Since 2.0)
1162 # @discard: #optional discard-related options (default: ignore)
1163 # @cache: #optional cache-related options
1164 # @aio: #optional AIO backend (default: threads)
1165 # @rerror: #optional how to handle read errors on the device
1167 # @werror: #optional how to handle write errors on the device
1169 # @read-only: #optional whether the block device should be read-only
1171 # @detect-zeroes: #optional detect and optimize zero writes (Since 2.1)
1176 { 'type': 'BlockdevOptionsBase',
1177 'data': { 'driver': 'BlockdevDriver',
1179 '*node-name': 'str',
1180 '*discard': 'BlockdevDiscardOptions',
1181 '*cache': 'BlockdevCacheOptions',
1182 '*aio': 'BlockdevAioOptions',
1183 '*rerror': 'BlockdevOnError',
1184 '*werror': 'BlockdevOnError',
1185 '*read-only': 'bool',
1186 '*detect-zeroes': 'BlockdevDetectZeroesOptions' } }
1189 # @BlockdevOptionsFile
1191 # Driver specific block device options for the file backend and similar
1194 # @filename: path to the image file
1198 { 'type': 'BlockdevOptionsFile',
1199 'data': { 'filename': 'str' } }
1202 # @BlockdevOptionsVVFAT
1204 # Driver specific block device options for the vvfat protocol.
1206 # @dir: directory to be exported as FAT image
1207 # @fat-type: #optional FAT type: 12, 16 or 32
1208 # @floppy: #optional whether to export a floppy image (true) or
1209 # partitioned hard disk (false; default)
1210 # @rw: #optional whether to allow write operations (default: false)
1214 { 'type': 'BlockdevOptionsVVFAT',
1215 'data': { 'dir': 'str', '*fat-type': 'int', '*floppy': 'bool',
1219 # @BlockdevOptionsGenericFormat
1221 # Driver specific block device options for image format that have no option
1222 # besides their data source.
1224 # @file: reference to or definition of the data source block device
1228 { 'type': 'BlockdevOptionsGenericFormat',
1229 'data': { 'file': 'BlockdevRef' } }
1232 # @BlockdevOptionsGenericCOWFormat
1234 # Driver specific block device options for image format that have no option
1235 # besides their data source and an optional backing file.
1237 # @backing: #optional reference to or definition of the backing file block
1238 # device (if missing, taken from the image file content). It is
1239 # allowed to pass an empty string here in order to disable the
1240 # default backing file.
1244 { 'type': 'BlockdevOptionsGenericCOWFormat',
1245 'base': 'BlockdevOptionsGenericFormat',
1246 'data': { '*backing': 'BlockdevRef' } }
1249 # @BlockdevOptionsQcow2
1251 # Driver specific block device options for qcow2.
1253 # @lazy-refcounts: #optional whether to enable the lazy refcounts
1254 # feature (default is taken from the image file)
1256 # @pass-discard-request: #optional whether discard requests to the qcow2
1257 # device should be forwarded to the data source
1259 # @pass-discard-snapshot: #optional whether discard requests for the data source
1260 # should be issued when a snapshot operation (e.g.
1261 # deleting a snapshot) frees clusters in the qcow2 file
1263 # @pass-discard-other: #optional whether discard requests for the data source
1264 # should be issued on other occasions where a cluster
1269 { 'type': 'BlockdevOptionsQcow2',
1270 'base': 'BlockdevOptionsGenericCOWFormat',
1271 'data': { '*lazy-refcounts': 'bool',
1272 '*pass-discard-request': 'bool',
1273 '*pass-discard-snapshot': 'bool',
1274 '*pass-discard-other': 'bool' } }
1279 # Trigger events supported by blkdebug.
1281 { 'enum': 'BlkdebugEvent',
1282 'data': [ 'l1_update', 'l1_grow.alloc_table', 'l1_grow.write_table',
1283 'l1_grow.activate_table', 'l2_load', 'l2_update',
1284 'l2_update_compressed', 'l2_alloc.cow_read', 'l2_alloc.write',
1285 'read_aio', 'read_backing_aio', 'read_compressed', 'write_aio',
1286 'write_compressed', 'vmstate_load', 'vmstate_save', 'cow_read',
1287 'cow_write', 'reftable_load', 'reftable_grow', 'reftable_update',
1288 'refblock_load', 'refblock_update', 'refblock_update_part',
1289 'refblock_alloc', 'refblock_alloc.hookup', 'refblock_alloc.write',
1290 'refblock_alloc.write_blocks', 'refblock_alloc.write_table',
1291 'refblock_alloc.switch_table', 'cluster_alloc',
1292 'cluster_alloc_bytes', 'cluster_free', 'flush_to_os',
1296 # @BlkdebugInjectErrorOptions
1298 # Describes a single error injection for blkdebug.
1300 # @event: trigger event
1302 # @state: #optional the state identifier blkdebug needs to be in to
1303 # actually trigger the event; defaults to "any"
1305 # @errno: #optional error identifier (errno) to be returned; defaults to
1308 # @sector: #optional specifies the sector index which has to be affected
1309 # in order to actually trigger the event; defaults to "any
1312 # @once: #optional disables further events after this one has been
1313 # triggered; defaults to false
1315 # @immediately: #optional fail immediately; defaults to false
1319 { 'type': 'BlkdebugInjectErrorOptions',
1320 'data': { 'event': 'BlkdebugEvent',
1325 '*immediately': 'bool' } }
1328 # @BlkdebugSetStateOptions
1330 # Describes a single state-change event for blkdebug.
1332 # @event: trigger event
1334 # @state: #optional the current state identifier blkdebug needs to be in;
1337 # @new_state: the state identifier blkdebug is supposed to assume if
1338 # this event is triggered
1342 { 'type': 'BlkdebugSetStateOptions',
1343 'data': { 'event': 'BlkdebugEvent',
1345 'new_state': 'int' } }
1348 # @BlockdevOptionsBlkdebug
1350 # Driver specific block device options for blkdebug.
1352 # @image: underlying raw block device (or image file)
1354 # @config: #optional filename of the configuration file
1356 # @align: #optional required alignment for requests in bytes
1358 # @inject-error: #optional array of error injection descriptions
1360 # @set-state: #optional array of state-change descriptions
1364 { 'type': 'BlockdevOptionsBlkdebug',
1365 'data': { 'image': 'BlockdevRef',
1368 '*inject-error': ['BlkdebugInjectErrorOptions'],
1369 '*set-state': ['BlkdebugSetStateOptions'] } }
1372 # @BlockdevOptionsBlkverify
1374 # Driver specific block device options for blkverify.
1376 # @test: block device to be tested
1378 # @raw: raw image used for verification
1382 { 'type': 'BlockdevOptionsBlkverify',
1383 'data': { 'test': 'BlockdevRef',
1384 'raw': 'BlockdevRef' } }
1387 # @BlockdevOptionsQuorum
1389 # Driver specific block device options for Quorum
1391 # @blkverify: #optional true if the driver must print content mismatch
1392 # set to false by default
1394 # @children: the children block devices to use
1396 # @vote-threshold: the vote limit under which a read will fail
1398 # @rewrite-corrupted: #optional rewrite corrupted data when quorum is reached
1403 { 'type': 'BlockdevOptionsQuorum',
1404 'data': { '*blkverify': 'bool',
1405 'children': [ 'BlockdevRef' ],
1406 'vote-threshold': 'int', '*rewrite-corrupted': 'bool' } }
1411 # Options for creating a block device.
1415 { 'union': 'BlockdevOptions',
1416 'base': 'BlockdevOptionsBase',
1417 'discriminator': 'driver',
1419 'file': 'BlockdevOptionsFile',
1420 'host_device':'BlockdevOptionsFile',
1421 'host_cdrom': 'BlockdevOptionsFile',
1422 'host_floppy':'BlockdevOptionsFile',
1423 'http': 'BlockdevOptionsFile',
1424 'https': 'BlockdevOptionsFile',
1425 'ftp': 'BlockdevOptionsFile',
1426 'ftps': 'BlockdevOptionsFile',
1427 'tftp': 'BlockdevOptionsFile',
1428 # TODO gluster: Wait for structured options
1429 # TODO iscsi: Wait for structured options
1430 # TODO nbd: Should take InetSocketAddress for 'host'?
1431 # TODO nfs: Wait for structured options
1432 # TODO rbd: Wait for structured options
1433 # TODO sheepdog: Wait for structured options
1434 # TODO ssh: Should take InetSocketAddress for 'host'?
1435 'vvfat': 'BlockdevOptionsVVFAT',
1436 'blkdebug': 'BlockdevOptionsBlkdebug',
1437 'blkverify': 'BlockdevOptionsBlkverify',
1438 'bochs': 'BlockdevOptionsGenericFormat',
1439 'cloop': 'BlockdevOptionsGenericFormat',
1440 'cow': 'BlockdevOptionsGenericCOWFormat',
1441 'dmg': 'BlockdevOptionsGenericFormat',
1442 'parallels': 'BlockdevOptionsGenericFormat',
1443 'qcow': 'BlockdevOptionsGenericCOWFormat',
1444 'qcow2': 'BlockdevOptionsQcow2',
1445 'qed': 'BlockdevOptionsGenericCOWFormat',
1446 'raw': 'BlockdevOptionsGenericFormat',
1447 'vdi': 'BlockdevOptionsGenericFormat',
1448 'vhdx': 'BlockdevOptionsGenericFormat',
1449 'vmdk': 'BlockdevOptionsGenericCOWFormat',
1450 'vpc': 'BlockdevOptionsGenericFormat',
1451 'quorum': 'BlockdevOptionsQuorum'
1457 # Reference to a block device.
1459 # @definition: defines a new block device inline
1460 # @reference: references the ID of an existing block device. An
1461 # empty string means that no block device should be
1466 { 'union': 'BlockdevRef',
1467 'discriminator': {},
1468 'data': { 'definition': 'BlockdevOptions',
1469 'reference': 'str' } }
1474 # Creates a new block device.
1476 # @options: block device options for the new device
1480 { 'command': 'blockdev-add', 'data': { 'options': 'BlockdevOptions' } }
1486 # An enumeration of action that has been taken when a DISK I/O occurs
1488 # @ignore: error has been ignored
1490 # @report: error has been reported to the device
1492 # @stop: error caused VM to be stopped
1496 { 'enum': 'BlockErrorAction',
1497 'data': [ 'ignore', 'report', 'stop' ] }
1501 # @BLOCK_IMAGE_CORRUPTED
1503 # Emitted when a disk image is being marked corrupt
1505 # @device: device name
1507 # @msg: informative message for human consumption, such as the kind of
1508 # corruption being detected. It should not be parsed by machine as it is
1509 # not guaranteed to be stable
1511 # @offset: #optional, if the corruption resulted from an image access, this is
1512 # the access offset into the image
1514 # @size: #optional, if the corruption resulted from an image access, this is
1519 { 'event': 'BLOCK_IMAGE_CORRUPTED',
1520 'data': { 'device' : 'str',
1528 # Emitted when a disk I/O error occurs
1530 # @device: device name
1532 # @operation: I/O operation
1534 # @action: action that has been taken
1536 # Note: If action is "stop", a STOP event will eventually follow the
1537 # BLOCK_IO_ERROR event
1541 { 'event': 'BLOCK_IO_ERROR',
1542 'data': { 'device': 'str', 'operation': 'IoOperationType',
1543 'action': 'BlockErrorAction' } }
1546 # @BLOCK_JOB_COMPLETED
1548 # Emitted when a block job has completed
1552 # @device: device name
1554 # @len: maximum progress value
1556 # @offset: current progress value. On success this is equal to len.
1557 # On failure this is less than len
1559 # @speed: rate limit, bytes per second
1561 # @error: #optional, error message. Only present on failure. This field
1562 # contains a human-readable error message. There are no semantics
1563 # other than that streaming has failed and clients should not try to
1564 # interpret the error string
1568 { 'event': 'BLOCK_JOB_COMPLETED',
1569 'data': { 'type' : 'BlockJobType',
1577 # @BLOCK_JOB_CANCELLED
1579 # Emitted when a block job has been cancelled
1583 # @device: device name
1585 # @len: maximum progress value
1587 # @offset: current progress value. On success this is equal to len.
1588 # On failure this is less than len
1590 # @speed: rate limit, bytes per second
1594 { 'event': 'BLOCK_JOB_CANCELLED',
1595 'data': { 'type' : 'BlockJobType',
1604 # Emitted when a block job encounters an error
1606 # @device: device name
1608 # @operation: I/O operation
1610 # @action: action that has been taken
1614 { 'event': 'BLOCK_JOB_ERROR',
1615 'data': { 'device' : 'str',
1616 'operation': 'IoOperationType',
1617 'action' : 'BlockErrorAction' } }
1622 # Emitted when a block job is ready to complete
1626 # @device: device name
1628 # @len: maximum progress value
1630 # @offset: current progress value. On success this is equal to len.
1631 # On failure this is less than len
1633 # @speed: rate limit, bytes per second
1635 # Note: The "ready to complete" status is always reset by a @BLOCK_JOB_ERROR
1640 { 'event': 'BLOCK_JOB_READY',
1641 'data': { 'type' : 'BlockJobType',