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)
118 # @nocow: #optional info of whether NOCOW flag is set or not. (since 2.2)
124 { 'type': 'ImageInfo',
125 'data': {'filename': 'str', 'format': 'str', '*dirty-flag': 'bool',
126 '*actual-size': 'int', 'virtual-size': 'int',
127 '*cluster-size': 'int', '*encrypted': 'bool', '*compressed': 'bool',
128 '*backing-filename': 'str', '*full-backing-filename': 'str',
129 '*backing-filename-format': 'str', '*snapshots': ['SnapshotInfo'],
130 '*backing-image': 'ImageInfo',
131 '*format-specific': 'ImageInfoSpecific',
137 # Information about a QEMU image file check
139 # @filename: name of the image file checked
141 # @format: format of the image file checked
143 # @check-errors: number of unexpected errors occurred during check
145 # @image-end-offset: #optional offset (in bytes) where the image ends, this
146 # field is present if the driver for the image format
149 # @corruptions: #optional number of corruptions found during the check if any
151 # @leaks: #optional number of leaks found during the check if any
153 # @corruptions-fixed: #optional number of corruptions fixed during the check
156 # @leaks-fixed: #optional number of leaks fixed during the check if any
158 # @total-clusters: #optional total number of clusters, this field is present
159 # if the driver for the image format supports it
161 # @allocated-clusters: #optional total number of allocated clusters, this
162 # field is present if the driver for the image format
165 # @fragmented-clusters: #optional total number of fragmented clusters, this
166 # field is present if the driver for the image format
169 # @compressed-clusters: #optional total number of compressed clusters, this
170 # field is present if the driver for the image format
177 { 'type': 'ImageCheck',
178 'data': {'filename': 'str', 'format': 'str', 'check-errors': 'int',
179 '*image-end-offset': 'int', '*corruptions': 'int', '*leaks': 'int',
180 '*corruptions-fixed': 'int', '*leaks-fixed': 'int',
181 '*total-clusters': 'int', '*allocated-clusters': 'int',
182 '*fragmented-clusters': 'int', '*compressed-clusters': 'int' } }
187 # Information about the backing device for a block device.
189 # @file: the filename of the backing device
191 # @node-name: #optional the name of the block driver node (Since 2.0)
193 # @ro: true if the backing device was open read-only
195 # @drv: the name of the block format used to open the backing device. As of
196 # 0.14.0 this can be: 'blkdebug', 'bochs', 'cloop', 'cow', 'dmg',
197 # 'file', 'file', 'ftp', 'ftps', 'host_cdrom', 'host_device',
198 # 'host_floppy', 'http', 'https', 'nbd', 'parallels', 'qcow',
199 # 'qcow2', 'raw', 'tftp', 'vdi', 'vmdk', 'vpc', 'vvfat'
202 # @backing_file: #optional the name of the backing file (for copy-on-write)
204 # @backing_file_depth: number of files in the backing file chain (since: 1.2)
206 # @encrypted: true if the backing device is encrypted
208 # @encryption_key_missing: true if the backing device is encrypted but an
209 # valid encryption key is missing
211 # @detect_zeroes: detect and optimize zero writes (Since 2.1)
213 # @bps: total throughput limit in bytes per second is specified
215 # @bps_rd: read throughput limit in bytes per second is specified
217 # @bps_wr: write throughput limit in bytes per second is specified
219 # @iops: total I/O operations per second is specified
221 # @iops_rd: read I/O operations per second is specified
223 # @iops_wr: write I/O operations per second is specified
225 # @image: the info of image used (since: 1.6)
227 # @bps_max: #optional total max in bytes (Since 1.7)
229 # @bps_rd_max: #optional read max in bytes (Since 1.7)
231 # @bps_wr_max: #optional write max in bytes (Since 1.7)
233 # @iops_max: #optional total I/O operations max (Since 1.7)
235 # @iops_rd_max: #optional read I/O operations max (Since 1.7)
237 # @iops_wr_max: #optional write I/O operations max (Since 1.7)
239 # @iops_size: #optional an I/O size in bytes (Since 1.7)
244 { 'type': 'BlockDeviceInfo',
245 'data': { 'file': 'str', '*node-name': 'str', 'ro': 'bool', 'drv': 'str',
246 '*backing_file': 'str', 'backing_file_depth': 'int',
247 'encrypted': 'bool', 'encryption_key_missing': 'bool',
248 'detect_zeroes': 'BlockdevDetectZeroesOptions',
249 'bps': 'int', 'bps_rd': 'int', 'bps_wr': 'int',
250 'iops': 'int', 'iops_rd': 'int', 'iops_wr': 'int',
251 'image': 'ImageInfo',
252 '*bps_max': 'int', '*bps_rd_max': 'int',
253 '*bps_wr_max': 'int', '*iops_max': 'int',
254 '*iops_rd_max': 'int', '*iops_wr_max': 'int',
255 '*iops_size': 'int' } }
258 # @BlockDeviceIoStatus:
260 # An enumeration of block device I/O status.
262 # @ok: The last I/O operation has succeeded
264 # @failed: The last I/O operation has failed
266 # @nospace: The last I/O operation has failed due to a no-space condition
270 { 'enum': 'BlockDeviceIoStatus', 'data': [ 'ok', 'failed', 'nospace' ] }
273 # @BlockDeviceMapEntry:
275 # Entry in the metadata map of the device (returned by "qemu-img map")
277 # @start: Offset in the image of the first byte described by this entry
280 # @length: Length of the range described by this entry (in bytes)
282 # @depth: Number of layers (0 = top image, 1 = top image's backing file, etc.)
283 # before reaching one for which the range is allocated. The value is
284 # in the range 0 to the depth of the image chain - 1.
286 # @zero: the sectors in this range read as zeros
288 # @data: reading the image will actually read data from a file (in particular,
289 # if @offset is present this means that the sectors are not simply
290 # preallocated, but contain actual data in raw format)
292 # @offset: if present, the image file stores the data for this range in
293 # raw format at the given offset.
297 { 'type': 'BlockDeviceMapEntry',
298 'data': { 'start': 'int', 'length': 'int', 'depth': 'int', 'zero': 'bool',
299 'data': 'bool', '*offset': 'int' } }
304 # Block dirty bitmap information.
306 # @count: number of dirty bytes according to the dirty bitmap
308 # @granularity: granularity of the dirty bitmap in bytes (since 1.4)
312 { 'type': 'BlockDirtyInfo',
313 'data': {'count': 'int', 'granularity': 'int'} }
318 # Block device information. This structure describes a virtual device and
319 # the backing device associated with it.
321 # @device: The device name associated with the virtual device.
323 # @type: This field is returned only for compatibility reasons, it should
324 # not be used (always returns 'unknown')
326 # @removable: True if the device supports removable media.
328 # @locked: True if the guest has locked this device from having its media
331 # @tray_open: #optional True if the device has a tray and it is open
332 # (only present if removable is true)
334 # @dirty-bitmaps: #optional dirty bitmaps information (only present if the
335 # driver has one or more dirty bitmaps) (Since 2.0)
337 # @io-status: #optional @BlockDeviceIoStatus. Only present if the device
338 # supports it and the VM is configured to stop on errors
340 # @inserted: #optional @BlockDeviceInfo describing the device if media is
345 { 'type': 'BlockInfo',
346 'data': {'device': 'str', 'type': 'str', 'removable': 'bool',
347 'locked': 'bool', '*inserted': 'BlockDeviceInfo',
348 '*tray_open': 'bool', '*io-status': 'BlockDeviceIoStatus',
349 '*dirty-bitmaps': ['BlockDirtyInfo'] } }
354 # Get a list of BlockInfo for all virtual block devices.
356 # Returns: a list of @BlockInfo describing each virtual block device
360 { 'command': 'query-block', 'returns': ['BlockInfo'] }
365 # Statistics of a virtual block device or a block backing device.
367 # @rd_bytes: The number of bytes read by the device.
369 # @wr_bytes: The number of bytes written by the device.
371 # @rd_operations: The number of read operations performed by the device.
373 # @wr_operations: The number of write operations performed by the device.
375 # @flush_operations: The number of cache flush operations performed by the
376 # device (since 0.15.0)
378 # @flush_total_time_ns: Total time spend on cache flushes in nano-seconds
381 # @wr_total_time_ns: Total time spend on writes in nano-seconds (since 0.15.0).
383 # @rd_total_time_ns: Total_time_spend on reads in nano-seconds (since 0.15.0).
385 # @wr_highest_offset: The offset after the greatest byte written to the
386 # device. The intended use of this information is for
387 # growable sparse files (like qcow2) that are used on top
388 # of a physical device.
392 { 'type': 'BlockDeviceStats',
393 'data': {'rd_bytes': 'int', 'wr_bytes': 'int', 'rd_operations': 'int',
394 'wr_operations': 'int', 'flush_operations': 'int',
395 'flush_total_time_ns': 'int', 'wr_total_time_ns': 'int',
396 'rd_total_time_ns': 'int', 'wr_highest_offset': 'int' } }
401 # Statistics of a virtual block device or a block backing device.
403 # @device: #optional If the stats are for a virtual block device, the name
404 # corresponding to the virtual block device.
406 # @stats: A @BlockDeviceStats for the device.
408 # @parent: #optional This describes the file block device if it has one.
410 # @backing: #optional This describes the backing block device if it has one.
415 { 'type': 'BlockStats',
416 'data': {'*device': 'str', 'stats': 'BlockDeviceStats',
417 '*parent': 'BlockStats',
418 '*backing': 'BlockStats'} }
423 # Query the @BlockStats for all virtual block devices.
425 # Returns: A list of @BlockStats for each virtual block devices.
429 { 'command': 'query-blockstats', 'returns': ['BlockStats'] }
434 # An enumeration of possible behaviors for errors on I/O operations.
435 # The exact meaning depends on whether the I/O was initiated by a guest
438 # @report: for guest operations, report the error to the guest;
439 # for jobs, cancel the job
441 # @ignore: ignore the error, only report a QMP event (BLOCK_IO_ERROR
442 # or BLOCK_JOB_ERROR)
444 # @enospc: same as @stop on ENOSPC, same as @report otherwise.
446 # @stop: for guest operations, stop the virtual machine;
447 # for jobs, pause the job
451 { 'enum': 'BlockdevOnError',
452 'data': ['report', 'ignore', 'enospc', 'stop'] }
457 # An enumeration of possible behaviors for the initial synchronization
458 # phase of storage mirroring.
460 # @top: copies data in the topmost image to the destination
462 # @full: copies data from all images to the destination
464 # @none: only copy data written from now on
468 { 'enum': 'MirrorSyncMode',
469 'data': ['top', 'full', 'none'] }
474 # Type of a block job.
476 # @commit: block commit job type, see "block-commit"
478 # @stream: block stream job type, see "block-stream"
480 # @mirror: drive mirror job type, see "drive-mirror"
482 # @backup: drive backup job type, see "drive-backup"
486 { 'enum': 'BlockJobType',
487 'data': ['commit', 'stream', 'mirror', 'backup'] }
492 # Information about a long-running block device operation.
494 # @type: the job type ('stream' for image streaming)
496 # @device: the block device name
498 # @len: the maximum progress value
500 # @busy: false if the job is known to be in a quiescent state, with
501 # no pending I/O. Since 1.3.
503 # @paused: whether the job is paused or, if @busy is true, will
504 # pause itself as soon as possible. Since 1.3.
506 # @offset: the current progress value
508 # @speed: the rate limit, bytes per second
510 # @io-status: the status of the job (since 1.3)
514 { 'type': 'BlockJobInfo',
515 'data': {'type': 'str', 'device': 'str', 'len': 'int',
516 'offset': 'int', 'busy': 'bool', 'paused': 'bool', 'speed': 'int',
517 'io-status': 'BlockDeviceIoStatus'} }
522 # Return information about long-running block device operations.
524 # Returns: a list of @BlockJobInfo for each active block job
528 { 'command': 'query-block-jobs', 'returns': ['BlockJobInfo'] }
533 # This command sets the password of a block device that has not been open
534 # with a password and requires one.
536 # The two cases where this can happen are a block device is created through
537 # QEMU's initial command line or a block device is changed through the legacy
540 # In the event that the block device is created through the initial command
541 # line, the VM will start in the stopped state regardless of whether '-S' is
542 # used. The intention is for a management tool to query the block devices to
543 # determine which ones are encrypted, set the passwords with this command, and
544 # then start the guest with the @cont command.
546 # Either @device or @node-name must be set but not both.
548 # @device: #optional the name of the block backend device to set the password on
550 # @node-name: #optional graph node name to set the password on (Since 2.0)
552 # @password: the password to use for the device
554 # Returns: nothing on success
555 # If @device is not a valid block device, DeviceNotFound
556 # If @device is not encrypted, DeviceNotEncrypted
558 # Notes: Not all block formats support encryption and some that do are not
559 # able to validate that a password is correct. Disk corruption may
560 # occur if an invalid password is specified.
564 { 'command': 'block_passwd', 'data': {'*device': 'str',
565 '*node-name': 'str', 'password': 'str'} }
570 # Resize a block image while a guest is running.
572 # Either @device or @node-name must be set but not both.
574 # @device: #optional the name of the device to get the image resized
576 # @node-name: #optional graph node name to get the image resized (Since 2.0)
578 # @size: new image size in bytes
580 # Returns: nothing on success
581 # If @device is not a valid block device, DeviceNotFound
585 { 'command': 'block_resize', 'data': { '*device': 'str',
592 # An enumeration that tells QEMU how to set the backing file path in
595 # @existing: QEMU should look for an existing image file.
597 # @absolute-paths: QEMU should create a new image with absolute paths
598 # for the backing file. If there is no backing file available, the new
599 # image will not be backed either.
603 { 'enum': 'NewImageMode',
604 'data': [ 'existing', 'absolute-paths' ] }
609 # Either @device or @node-name must be set but not both.
611 # @device: #optional the name of the device to generate the snapshot from.
613 # @node-name: #optional graph node name to generate the snapshot from (Since 2.0)
615 # @snapshot-file: the target of the new image. A new file will be created.
617 # @snapshot-node-name: #optional the graph node name of the new image (Since 2.0)
619 # @format: #optional the format of the snapshot image, default is 'qcow2'.
621 # @mode: #optional whether and how QEMU should create a new image, default is
624 { 'type': 'BlockdevSnapshot',
625 'data': { '*device': 'str', '*node-name': 'str',
626 'snapshot-file': 'str', '*snapshot-node-name': 'str',
627 '*format': 'str', '*mode': 'NewImageMode' } }
632 # @device: the name of the device which should be copied.
634 # @target: the target of the new image. If the file exists, or if it
635 # is a device, the existing file/device will be used as the new
636 # destination. If it does not exist, a new file will be created.
638 # @format: #optional the format of the new destination, default is to
639 # probe if @mode is 'existing', else the format of the source
641 # @sync: what parts of the disk image should be copied to the destination
642 # (all the disk, only the sectors allocated in the topmost image, or
645 # @mode: #optional whether and how QEMU should create a new image, default is
648 # @speed: #optional the maximum speed, in bytes per second
650 # @on-source-error: #optional the action to take on an error on the source,
651 # default 'report'. 'stop' and 'enospc' can only be used
652 # if the block device supports io-status (see BlockInfo).
654 # @on-target-error: #optional the action to take on an error on the target,
655 # default 'report' (no limitations, since this applies to
656 # a different block device than @device).
658 # Note that @on-source-error and @on-target-error only affect background I/O.
659 # If an error occurs during a guest write request, the device's rerror/werror
660 # actions will be used.
664 { 'type': 'DriveBackup',
665 'data': { 'device': 'str', 'target': 'str', '*format': 'str',
666 'sync': 'MirrorSyncMode', '*mode': 'NewImageMode',
668 '*on-source-error': 'BlockdevOnError',
669 '*on-target-error': 'BlockdevOnError' } }
672 # @blockdev-snapshot-sync
674 # Generates a synchronous snapshot of a block device.
676 # For the arguments, see the documentation of BlockdevSnapshot.
678 # Returns: nothing on success
679 # If @device is not a valid block device, DeviceNotFound
683 { 'command': 'blockdev-snapshot-sync',
684 'data': 'BlockdevSnapshot' }
687 # @change-backing-file
689 # Change the backing file in the image file metadata. This does not
690 # cause QEMU to reopen the image file to reparse the backing filename
691 # (it may, however, perform a reopen to change permissions from
692 # r/o -> r/w -> r/o, if needed). The new backing file string is written
693 # into the image file metadata, and the QEMU internal strings are
696 # @image-node-name: The name of the block driver state node of the
699 # @device: The name of the device that owns image-node-name.
701 # @backing-file: The string to write as the backing file. This
702 # string is not validated, so care should be taken
703 # when specifying the string or the image chain may
704 # not be able to be reopened again.
708 { 'command': 'change-backing-file',
709 'data': { 'device': 'str', 'image-node-name': 'str',
710 'backing-file': 'str' } }
715 # Live commit of data from overlay image nodes into backing nodes - i.e.,
716 # writes data between 'top' and 'base' into 'base'.
718 # @device: the name of the device
720 # @base: #optional The file name of the backing image to write data into.
721 # If not specified, this is the deepest backing image
723 # @top: #optional The file name of the backing image within the image chain,
724 # which contains the topmost data to be committed down. If
725 # not specified, this is the active layer.
727 # @backing-file: #optional The backing file string to write into the overlay
728 # image of 'top'. If 'top' is the active layer,
729 # specifying a backing file string is an error. This
730 # filename is not validated.
732 # If a pathname string is such that it cannot be
733 # resolved by QEMU, that means that subsequent QMP or
734 # HMP commands must use node-names for the image in
735 # question, as filename lookup methods will fail.
737 # If not specified, QEMU will automatically determine
738 # the backing file string to use, or error out if
739 # there is no obvious choice. Care should be taken
740 # when specifying the string, to specify a valid
741 # filename or protocol.
744 # If top == base, that is an error.
745 # If top == active, the job will not be completed by itself,
746 # user needs to complete the job with the block-job-complete
747 # command after getting the ready event. (Since 2.0)
749 # If the base image is smaller than top, then the base image
750 # will be resized to be the same size as top. If top is
751 # smaller than the base image, the base will not be
752 # truncated. If you want the base image size to match the
753 # size of the smaller top, you can safely truncate it
754 # yourself once the commit operation successfully completes.
756 # @speed: #optional the maximum speed, in bytes per second
758 # Returns: Nothing on success
759 # If commit or stream is already active on this device, DeviceInUse
760 # If @device does not exist, DeviceNotFound
761 # If image commit is not supported by this device, NotSupported
762 # If @base or @top is invalid, a generic error is returned
763 # If @speed is invalid, InvalidParameter
768 { 'command': 'block-commit',
769 'data': { 'device': 'str', '*base': 'str', '*top': 'str',
770 '*backing-file': 'str', '*speed': 'int' } }
775 # Start a point-in-time copy of a block device to a new destination. The
776 # status of ongoing drive-backup operations can be checked with
777 # query-block-jobs where the BlockJobInfo.type field has the value 'backup'.
778 # The operation can be stopped before it has completed using the
779 # block-job-cancel command.
781 # For the arguments, see the documentation of DriveBackup.
783 # Returns: nothing on success
784 # If @device is not a valid block device, DeviceNotFound
788 { 'command': 'drive-backup', 'data': 'DriveBackup' }
791 # @query-named-block-nodes
793 # Get the named block driver list
795 # Returns: the list of BlockDeviceInfo
799 { 'command': 'query-named-block-nodes', 'returns': [ 'BlockDeviceInfo' ] }
804 # Start mirroring a block device's writes to a new destination.
806 # @device: the name of the device whose writes should be mirrored.
808 # @target: the target of the new image. If the file exists, or if it
809 # is a device, the existing file/device will be used as the new
810 # destination. If it does not exist, a new file will be created.
812 # @format: #optional the format of the new destination, default is to
813 # probe if @mode is 'existing', else the format of the source
815 # @node-name: #optional the new block driver state node name in the graph
818 # @replaces: #optional with sync=full graph node name to be replaced by the new
819 # image when a whole image copy is done. This can be used to repair
820 # broken Quorum files. (Since 2.1)
822 # @mode: #optional whether and how QEMU should create a new image, default is
825 # @speed: #optional the maximum speed, in bytes per second
827 # @sync: what parts of the disk image should be copied to the destination
828 # (all the disk, only the sectors allocated in the topmost image, or
831 # @granularity: #optional granularity of the dirty bitmap, default is 64K
832 # if the image format doesn't have clusters, 4K if the clusters
833 # are smaller than that, else the cluster size. Must be a
834 # power of 2 between 512 and 64M (since 1.4).
836 # @buf-size: #optional maximum amount of data in flight from source to
837 # target (since 1.4).
839 # @on-source-error: #optional the action to take on an error on the source,
840 # default 'report'. 'stop' and 'enospc' can only be used
841 # if the block device supports io-status (see BlockInfo).
843 # @on-target-error: #optional the action to take on an error on the target,
844 # default 'report' (no limitations, since this applies to
845 # a different block device than @device).
847 # Returns: nothing on success
848 # If @device is not a valid block device, DeviceNotFound
852 { 'command': 'drive-mirror',
853 'data': { 'device': 'str', 'target': 'str', '*format': 'str',
854 '*node-name': 'str', '*replaces': 'str',
855 'sync': 'MirrorSyncMode', '*mode': 'NewImageMode',
856 '*speed': 'int', '*granularity': 'uint32',
857 '*buf-size': 'int', '*on-source-error': 'BlockdevOnError',
858 '*on-target-error': 'BlockdevOnError' } }
861 # @block_set_io_throttle:
863 # Change I/O throttle limits for a block drive.
865 # @device: The name of the device
867 # @bps: total throughput limit in bytes per second
869 # @bps_rd: read throughput limit in bytes per second
871 # @bps_wr: write throughput limit in bytes per second
873 # @iops: total I/O operations per second
875 # @ops_rd: read I/O operations per second
877 # @iops_wr: write I/O operations per second
879 # @bps_max: #optional total max in bytes (Since 1.7)
881 # @bps_rd_max: #optional read max in bytes (Since 1.7)
883 # @bps_wr_max: #optional write max in bytes (Since 1.7)
885 # @iops_max: #optional total I/O operations max (Since 1.7)
887 # @iops_rd_max: #optional read I/O operations max (Since 1.7)
889 # @iops_wr_max: #optional write I/O operations max (Since 1.7)
891 # @iops_size: #optional an I/O size in bytes (Since 1.7)
893 # Returns: Nothing on success
894 # If @device is not a valid block device, DeviceNotFound
898 { 'command': 'block_set_io_throttle',
899 'data': { 'device': 'str', 'bps': 'int', 'bps_rd': 'int', 'bps_wr': 'int',
900 'iops': 'int', 'iops_rd': 'int', 'iops_wr': 'int',
901 '*bps_max': 'int', '*bps_rd_max': 'int',
902 '*bps_wr_max': 'int', '*iops_max': 'int',
903 '*iops_rd_max': 'int', '*iops_wr_max': 'int',
904 '*iops_size': 'int' } }
909 # Copy data from a backing file into a block device.
911 # The block streaming operation is performed in the background until the entire
912 # backing file has been copied. This command returns immediately once streaming
913 # has started. The status of ongoing block streaming operations can be checked
914 # with query-block-jobs. The operation can be stopped before it has completed
915 # using the block-job-cancel command.
917 # If a base file is specified then sectors are not copied from that base file and
918 # its backing chain. When streaming completes the image file will have the base
919 # file as its backing file. This can be used to stream a subset of the backing
920 # file chain instead of flattening the entire image.
922 # On successful completion the image file is updated to drop the backing file
923 # and the BLOCK_JOB_COMPLETED event is emitted.
925 # @device: the device name
927 # @base: #optional the common backing file name
929 # @backing-file: #optional The backing file string to write into the active
930 # layer. This filename is not validated.
932 # If a pathname string is such that it cannot be
933 # resolved by QEMU, that means that subsequent QMP or
934 # HMP commands must use node-names for the image in
935 # question, as filename lookup methods will fail.
937 # If not specified, QEMU will automatically determine
938 # the backing file string to use, or error out if there
939 # is no obvious choice. Care should be taken when
940 # specifying the string, to specify a valid filename or
944 # @speed: #optional the maximum speed, in bytes per second
946 # @on-error: #optional the action to take on an error (default report).
947 # 'stop' and 'enospc' can only be used if the block device
948 # supports io-status (see BlockInfo). Since 1.3.
950 # Returns: Nothing on success
951 # If @device does not exist, DeviceNotFound
955 { 'command': 'block-stream',
956 'data': { 'device': 'str', '*base': 'str', '*backing-file': 'str',
957 '*speed': 'int', '*on-error': 'BlockdevOnError' } }
960 # @block-job-set-speed:
962 # Set maximum speed for a background block operation.
964 # This command can only be issued when there is an active block job.
966 # Throttling can be disabled by setting the speed to 0.
968 # @device: the device name
970 # @speed: the maximum speed, in bytes per second, or 0 for unlimited.
973 # Returns: Nothing on success
974 # If no background operation is active on this device, DeviceNotActive
978 { 'command': 'block-job-set-speed',
979 'data': { 'device': 'str', 'speed': 'int' } }
984 # Stop an active background block operation.
986 # This command returns immediately after marking the active background block
987 # operation for cancellation. It is an error to call this command if no
988 # operation is in progress.
990 # The operation will cancel as soon as possible and then emit the
991 # BLOCK_JOB_CANCELLED event. Before that happens the job is still visible when
992 # enumerated using query-block-jobs.
994 # For streaming, the image file retains its backing file unless the streaming
995 # operation happens to complete just as it is being cancelled. A new streaming
996 # operation can be started at a later time to finish copying all data from the
999 # @device: the device name
1001 # @force: #optional whether to allow cancellation of a paused job (default
1002 # false). Since 1.3.
1004 # Returns: Nothing on success
1005 # If no background operation is active on this device, DeviceNotActive
1009 { 'command': 'block-job-cancel', 'data': { 'device': 'str', '*force': 'bool' } }
1014 # Pause an active background block operation.
1016 # This command returns immediately after marking the active background block
1017 # operation for pausing. It is an error to call this command if no
1018 # operation is in progress. Pausing an already paused job has no cumulative
1019 # effect; a single block-job-resume command will resume the job.
1021 # The operation will pause as soon as possible. No event is emitted when
1022 # the operation is actually paused. Cancelling a paused job automatically
1025 # @device: the device name
1027 # Returns: Nothing on success
1028 # If no background operation is active on this device, DeviceNotActive
1032 { 'command': 'block-job-pause', 'data': { 'device': 'str' } }
1035 # @block-job-resume:
1037 # Resume an active background block operation.
1039 # This command returns immediately after resuming a paused background block
1040 # operation. It is an error to call this command if no operation is in
1041 # progress. Resuming an already running job is not an error.
1043 # This command also clears the error status of the job.
1045 # @device: the device name
1047 # Returns: Nothing on success
1048 # If no background operation is active on this device, DeviceNotActive
1052 { 'command': 'block-job-resume', 'data': { 'device': 'str' } }
1055 # @block-job-complete:
1057 # Manually trigger completion of an active background block operation. This
1058 # is supported for drive mirroring, where it also switches the device to
1059 # write to the target path only. The ability to complete is signaled with
1060 # a BLOCK_JOB_READY event.
1062 # This command completes an active background block operation synchronously.
1063 # The ordering of this command's return with the BLOCK_JOB_COMPLETED event
1064 # is not defined. Note that if an I/O error occurs during the processing of
1065 # this command: 1) the command itself will fail; 2) the error will be processed
1066 # according to the rerror/werror arguments that were specified when starting
1069 # A cancelled or paused job cannot be completed.
1071 # @device: the device name
1073 # Returns: Nothing on success
1074 # If no background operation is active on this device, DeviceNotActive
1078 { 'command': 'block-job-complete', 'data': { 'device': 'str' } }
1081 # @BlockdevDiscardOptions
1083 # Determines how to handle discard requests.
1085 # @ignore: Ignore the request
1086 # @unmap: Forward as an unmap request
1090 { 'enum': 'BlockdevDiscardOptions',
1091 'data': [ 'ignore', 'unmap' ] }
1094 # @BlockdevDetectZeroesOptions
1096 # Describes the operation mode for the automatic conversion of plain
1097 # zero writes by the OS to driver specific optimized zero write commands.
1099 # @off: Disabled (default)
1101 # @unmap: Enabled and even try to unmap blocks if possible. This requires
1102 # also that @BlockdevDiscardOptions is set to unmap for this device.
1106 { 'enum': 'BlockdevDetectZeroesOptions',
1107 'data': [ 'off', 'on', 'unmap' ] }
1110 # @BlockdevAioOptions
1112 # Selects the AIO backend to handle I/O requests
1114 # @threads: Use qemu's thread pool
1115 # @native: Use native AIO backend (only Linux and Windows)
1119 { 'enum': 'BlockdevAioOptions',
1120 'data': [ 'threads', 'native' ] }
1123 # @BlockdevCacheOptions
1125 # Includes cache-related options for block devices
1127 # @writeback: #optional enables writeback mode for any caches (default: true)
1128 # @direct: #optional enables use of O_DIRECT (bypass the host page cache;
1130 # @no-flush: #optional ignore any flush requests for the device (default:
1135 { 'type': 'BlockdevCacheOptions',
1136 'data': { '*writeback': 'bool',
1138 '*no-flush': 'bool' } }
1143 # Drivers that are supported in block device operations.
1145 # @host_device, @host_cdrom, @host_floppy: Since 2.1
1149 { 'enum': 'BlockdevDriver',
1150 'data': [ 'archipelago', 'file', 'host_device', 'host_cdrom', 'host_floppy',
1151 'http', 'https', 'ftp', 'ftps', 'tftp', 'vvfat', 'blkdebug',
1152 'blkverify', 'bochs', 'cloop', 'cow', 'dmg', 'parallels', 'qcow',
1153 'qcow2', 'qed', 'raw', 'vdi', 'vhdx', 'vmdk', 'vpc', 'quorum' ] }
1156 # @BlockdevOptionsBase
1158 # Options that are available for all block devices, independent of the block
1161 # @driver: block driver name
1162 # @id: #optional id by which the new block device can be referred to.
1163 # This is a required option on the top level of blockdev-add, and
1164 # currently not allowed on any other level.
1165 # @node-name: #optional the name of a block driver state node (Since 2.0)
1166 # @discard: #optional discard-related options (default: ignore)
1167 # @cache: #optional cache-related options
1168 # @aio: #optional AIO backend (default: threads)
1169 # @rerror: #optional how to handle read errors on the device
1171 # @werror: #optional how to handle write errors on the device
1173 # @read-only: #optional whether the block device should be read-only
1175 # @detect-zeroes: #optional detect and optimize zero writes (Since 2.1)
1180 { 'type': 'BlockdevOptionsBase',
1181 'data': { 'driver': 'BlockdevDriver',
1183 '*node-name': 'str',
1184 '*discard': 'BlockdevDiscardOptions',
1185 '*cache': 'BlockdevCacheOptions',
1186 '*aio': 'BlockdevAioOptions',
1187 '*rerror': 'BlockdevOnError',
1188 '*werror': 'BlockdevOnError',
1189 '*read-only': 'bool',
1190 '*detect-zeroes': 'BlockdevDetectZeroesOptions' } }
1193 # @BlockdevOptionsFile
1195 # Driver specific block device options for the file backend and similar
1198 # @filename: path to the image file
1202 { 'type': 'BlockdevOptionsFile',
1203 'data': { 'filename': 'str' } }
1206 # @BlockdevOptionsVVFAT
1208 # Driver specific block device options for the vvfat protocol.
1210 # @dir: directory to be exported as FAT image
1211 # @fat-type: #optional FAT type: 12, 16 or 32
1212 # @floppy: #optional whether to export a floppy image (true) or
1213 # partitioned hard disk (false; default)
1214 # @rw: #optional whether to allow write operations (default: false)
1218 { 'type': 'BlockdevOptionsVVFAT',
1219 'data': { 'dir': 'str', '*fat-type': 'int', '*floppy': 'bool',
1223 # @BlockdevOptionsGenericFormat
1225 # Driver specific block device options for image format that have no option
1226 # besides their data source.
1228 # @file: reference to or definition of the data source block device
1232 { 'type': 'BlockdevOptionsGenericFormat',
1233 'data': { 'file': 'BlockdevRef' } }
1236 # @BlockdevOptionsGenericCOWFormat
1238 # Driver specific block device options for image format that have no option
1239 # besides their data source and an optional backing file.
1241 # @backing: #optional reference to or definition of the backing file block
1242 # device (if missing, taken from the image file content). It is
1243 # allowed to pass an empty string here in order to disable the
1244 # default backing file.
1248 { 'type': 'BlockdevOptionsGenericCOWFormat',
1249 'base': 'BlockdevOptionsGenericFormat',
1250 'data': { '*backing': 'BlockdevRef' } }
1253 # @BlockdevOptionsQcow2
1255 # Driver specific block device options for qcow2.
1257 # @lazy-refcounts: #optional whether to enable the lazy refcounts
1258 # feature (default is taken from the image file)
1260 # @pass-discard-request: #optional whether discard requests to the qcow2
1261 # device should be forwarded to the data source
1263 # @pass-discard-snapshot: #optional whether discard requests for the data source
1264 # should be issued when a snapshot operation (e.g.
1265 # deleting a snapshot) frees clusters in the qcow2 file
1267 # @pass-discard-other: #optional whether discard requests for the data source
1268 # should be issued on other occasions where a cluster
1273 { 'type': 'BlockdevOptionsQcow2',
1274 'base': 'BlockdevOptionsGenericCOWFormat',
1275 'data': { '*lazy-refcounts': 'bool',
1276 '*pass-discard-request': 'bool',
1277 '*pass-discard-snapshot': 'bool',
1278 '*pass-discard-other': 'bool' } }
1282 # @BlockdevOptionsArchipelago
1284 # Driver specific block device options for Archipelago.
1286 # @volume: Name of the Archipelago volume image
1288 # @mport: #optional The port number on which mapperd is
1289 # listening. This is optional
1290 # and if not specified, QEMU will make Archipelago
1291 # use the default port (1001).
1293 # @vport: #optional The port number on which vlmcd is
1294 # listening. This is optional
1295 # and if not specified, QEMU will make Archipelago
1296 # use the default port (501).
1298 # @segment: #optional The name of the shared memory segment
1299 # Archipelago stack is using. This is optional
1300 # and if not specified, QEMU will make Archipelago
1301 # use the default value, 'archipelago'.
1304 { 'type': 'BlockdevOptionsArchipelago',
1305 'data': { 'volume': 'str',
1308 '*segment': 'str' } }
1314 # Trigger events supported by blkdebug.
1316 { 'enum': 'BlkdebugEvent',
1317 'data': [ 'l1_update', 'l1_grow.alloc_table', 'l1_grow.write_table',
1318 'l1_grow.activate_table', 'l2_load', 'l2_update',
1319 'l2_update_compressed', 'l2_alloc.cow_read', 'l2_alloc.write',
1320 'read_aio', 'read_backing_aio', 'read_compressed', 'write_aio',
1321 'write_compressed', 'vmstate_load', 'vmstate_save', 'cow_read',
1322 'cow_write', 'reftable_load', 'reftable_grow', 'reftable_update',
1323 'refblock_load', 'refblock_update', 'refblock_update_part',
1324 'refblock_alloc', 'refblock_alloc.hookup', 'refblock_alloc.write',
1325 'refblock_alloc.write_blocks', 'refblock_alloc.write_table',
1326 'refblock_alloc.switch_table', 'cluster_alloc',
1327 'cluster_alloc_bytes', 'cluster_free', 'flush_to_os',
1331 # @BlkdebugInjectErrorOptions
1333 # Describes a single error injection for blkdebug.
1335 # @event: trigger event
1337 # @state: #optional the state identifier blkdebug needs to be in to
1338 # actually trigger the event; defaults to "any"
1340 # @errno: #optional error identifier (errno) to be returned; defaults to
1343 # @sector: #optional specifies the sector index which has to be affected
1344 # in order to actually trigger the event; defaults to "any
1347 # @once: #optional disables further events after this one has been
1348 # triggered; defaults to false
1350 # @immediately: #optional fail immediately; defaults to false
1354 { 'type': 'BlkdebugInjectErrorOptions',
1355 'data': { 'event': 'BlkdebugEvent',
1360 '*immediately': 'bool' } }
1363 # @BlkdebugSetStateOptions
1365 # Describes a single state-change event for blkdebug.
1367 # @event: trigger event
1369 # @state: #optional the current state identifier blkdebug needs to be in;
1372 # @new_state: the state identifier blkdebug is supposed to assume if
1373 # this event is triggered
1377 { 'type': 'BlkdebugSetStateOptions',
1378 'data': { 'event': 'BlkdebugEvent',
1380 'new_state': 'int' } }
1383 # @BlockdevOptionsBlkdebug
1385 # Driver specific block device options for blkdebug.
1387 # @image: underlying raw block device (or image file)
1389 # @config: #optional filename of the configuration file
1391 # @align: #optional required alignment for requests in bytes
1393 # @inject-error: #optional array of error injection descriptions
1395 # @set-state: #optional array of state-change descriptions
1399 { 'type': 'BlockdevOptionsBlkdebug',
1400 'data': { 'image': 'BlockdevRef',
1403 '*inject-error': ['BlkdebugInjectErrorOptions'],
1404 '*set-state': ['BlkdebugSetStateOptions'] } }
1407 # @BlockdevOptionsBlkverify
1409 # Driver specific block device options for blkverify.
1411 # @test: block device to be tested
1413 # @raw: raw image used for verification
1417 { 'type': 'BlockdevOptionsBlkverify',
1418 'data': { 'test': 'BlockdevRef',
1419 'raw': 'BlockdevRef' } }
1422 # @BlockdevOptionsQuorum
1424 # Driver specific block device options for Quorum
1426 # @blkverify: #optional true if the driver must print content mismatch
1427 # set to false by default
1429 # @children: the children block devices to use
1431 # @vote-threshold: the vote limit under which a read will fail
1433 # @rewrite-corrupted: #optional rewrite corrupted data when quorum is reached
1438 { 'type': 'BlockdevOptionsQuorum',
1439 'data': { '*blkverify': 'bool',
1440 'children': [ 'BlockdevRef' ],
1441 'vote-threshold': 'int', '*rewrite-corrupted': 'bool' } }
1446 # Options for creating a block device.
1450 { 'union': 'BlockdevOptions',
1451 'base': 'BlockdevOptionsBase',
1452 'discriminator': 'driver',
1454 'archipelago':'BlockdevOptionsArchipelago',
1455 'file': 'BlockdevOptionsFile',
1456 'host_device':'BlockdevOptionsFile',
1457 'host_cdrom': 'BlockdevOptionsFile',
1458 'host_floppy':'BlockdevOptionsFile',
1459 'http': 'BlockdevOptionsFile',
1460 'https': 'BlockdevOptionsFile',
1461 'ftp': 'BlockdevOptionsFile',
1462 'ftps': 'BlockdevOptionsFile',
1463 'tftp': 'BlockdevOptionsFile',
1464 # TODO gluster: Wait for structured options
1465 # TODO iscsi: Wait for structured options
1466 # TODO nbd: Should take InetSocketAddress for 'host'?
1467 # TODO nfs: Wait for structured options
1468 # TODO rbd: Wait for structured options
1469 # TODO sheepdog: Wait for structured options
1470 # TODO ssh: Should take InetSocketAddress for 'host'?
1471 'vvfat': 'BlockdevOptionsVVFAT',
1472 'blkdebug': 'BlockdevOptionsBlkdebug',
1473 'blkverify': 'BlockdevOptionsBlkverify',
1474 'bochs': 'BlockdevOptionsGenericFormat',
1475 'cloop': 'BlockdevOptionsGenericFormat',
1476 'cow': 'BlockdevOptionsGenericCOWFormat',
1477 'dmg': 'BlockdevOptionsGenericFormat',
1478 'parallels': 'BlockdevOptionsGenericFormat',
1479 'qcow': 'BlockdevOptionsGenericCOWFormat',
1480 'qcow2': 'BlockdevOptionsQcow2',
1481 'qed': 'BlockdevOptionsGenericCOWFormat',
1482 'raw': 'BlockdevOptionsGenericFormat',
1483 'vdi': 'BlockdevOptionsGenericFormat',
1484 'vhdx': 'BlockdevOptionsGenericFormat',
1485 'vmdk': 'BlockdevOptionsGenericCOWFormat',
1486 'vpc': 'BlockdevOptionsGenericFormat',
1487 'quorum': 'BlockdevOptionsQuorum'
1493 # Reference to a block device.
1495 # @definition: defines a new block device inline
1496 # @reference: references the ID of an existing block device. An
1497 # empty string means that no block device should be
1502 { 'union': 'BlockdevRef',
1503 'discriminator': {},
1504 'data': { 'definition': 'BlockdevOptions',
1505 'reference': 'str' } }
1510 # Creates a new block device.
1512 # @options: block device options for the new device
1516 { 'command': 'blockdev-add', 'data': { 'options': 'BlockdevOptions' } }
1522 # An enumeration of action that has been taken when a DISK I/O occurs
1524 # @ignore: error has been ignored
1526 # @report: error has been reported to the device
1528 # @stop: error caused VM to be stopped
1532 { 'enum': 'BlockErrorAction',
1533 'data': [ 'ignore', 'report', 'stop' ] }
1537 # @BLOCK_IMAGE_CORRUPTED
1539 # Emitted when a disk image is being marked corrupt
1541 # @device: device name
1543 # @msg: informative message for human consumption, such as the kind of
1544 # corruption being detected. It should not be parsed by machine as it is
1545 # not guaranteed to be stable
1547 # @offset: #optional, if the corruption resulted from an image access, this is
1548 # the access offset into the image
1550 # @size: #optional, if the corruption resulted from an image access, this is
1555 { 'event': 'BLOCK_IMAGE_CORRUPTED',
1556 'data': { 'device' : 'str',
1564 # Emitted when a disk I/O error occurs
1566 # @device: device name
1568 # @operation: I/O operation
1570 # @action: action that has been taken
1572 # Note: If action is "stop", a STOP event will eventually follow the
1573 # BLOCK_IO_ERROR event
1577 { 'event': 'BLOCK_IO_ERROR',
1578 'data': { 'device': 'str', 'operation': 'IoOperationType',
1579 'action': 'BlockErrorAction' } }
1582 # @BLOCK_JOB_COMPLETED
1584 # Emitted when a block job has completed
1588 # @device: device name
1590 # @len: maximum progress value
1592 # @offset: current progress value. On success this is equal to len.
1593 # On failure this is less than len
1595 # @speed: rate limit, bytes per second
1597 # @error: #optional, error message. Only present on failure. This field
1598 # contains a human-readable error message. There are no semantics
1599 # other than that streaming has failed and clients should not try to
1600 # interpret the error string
1604 { 'event': 'BLOCK_JOB_COMPLETED',
1605 'data': { 'type' : 'BlockJobType',
1613 # @BLOCK_JOB_CANCELLED
1615 # Emitted when a block job has been cancelled
1619 # @device: device name
1621 # @len: maximum progress value
1623 # @offset: current progress value. On success this is equal to len.
1624 # On failure this is less than len
1626 # @speed: rate limit, bytes per second
1630 { 'event': 'BLOCK_JOB_CANCELLED',
1631 'data': { 'type' : 'BlockJobType',
1640 # Emitted when a block job encounters an error
1642 # @device: device name
1644 # @operation: I/O operation
1646 # @action: action that has been taken
1650 { 'event': 'BLOCK_JOB_ERROR',
1651 'data': { 'device' : 'str',
1652 'operation': 'IoOperationType',
1653 'action' : 'BlockErrorAction' } }
1658 # Emitted when a block job is ready to complete
1662 # @device: device name
1664 # @len: maximum progress value
1666 # @offset: current progress value. On success this is equal to len.
1667 # On failure this is less than len
1669 # @speed: rate limit, bytes per second
1671 # Note: The "ready to complete" status is always reset by a @BLOCK_JOB_ERROR
1676 { 'event': 'BLOCK_JOB_READY',
1677 'data': { 'type' : 'BlockJobType',