]> git.proxmox.com Git - mirror_qemu.git/blame - qapi/block-core.json
qmp-commands: move 'change-backing-file' doc to schema
[mirror_qemu.git] / qapi / block-core.json
CommitLineData
5db15096 1# -*- Mode: Python -*-
d3a48372
MAL
2
3##
4# == QAPI block core definitions (vm unrelated)
5##
5db15096
BC
6
7# QAPI common definitions
8{ 'include': 'common.json' }
1ad166b6
BC
9
10##
5072f7b3 11# @SnapshotInfo:
1ad166b6
BC
12#
13# @id: unique snapshot id
14#
15# @name: user chosen name
16#
17# @vm-state-size: size of the VM state
18#
19# @date-sec: UTC date of the snapshot in seconds
20#
21# @date-nsec: fractional part in nano seconds to be used with date-sec
22#
23# @vm-clock-sec: VM clock relative to boot in seconds
24#
25# @vm-clock-nsec: fractional part in nano seconds to be used with vm-clock-sec
26#
27# Since: 1.3
28#
29##
895a2a80 30{ 'struct': 'SnapshotInfo',
1ad166b6
BC
31 'data': { 'id': 'str', 'name': 'str', 'vm-state-size': 'int',
32 'date-sec': 'int', 'date-nsec': 'int',
33 'vm-clock-sec': 'int', 'vm-clock-nsec': 'int' } }
34
35##
36# @ImageInfoSpecificQCow2:
37#
38# @compat: compatibility level
39#
40# @lazy-refcounts: #optional on or off; only valid for compat >= 1.1
41#
9009b196
HR
42# @corrupt: #optional true if the image has been marked corrupt; only valid for
43# compat >= 1.1 (since 2.2)
44#
0709c5a1
HR
45# @refcount-bits: width of a refcount entry in bits (since 2.3)
46#
1ad166b6
BC
47# Since: 1.7
48##
895a2a80 49{ 'struct': 'ImageInfoSpecificQCow2',
1ad166b6
BC
50 'data': {
51 'compat': 'str',
9009b196 52 '*lazy-refcounts': 'bool',
0709c5a1
HR
53 '*corrupt': 'bool',
54 'refcount-bits': 'int'
1ad166b6
BC
55 } }
56
57##
58# @ImageInfoSpecificVmdk:
59#
60# @create-type: The create type of VMDK image
61#
62# @cid: Content id of image
63#
64# @parent-cid: Parent VMDK image's cid
65#
66# @extents: List of extent files
67#
68# Since: 1.7
69##
895a2a80 70{ 'struct': 'ImageInfoSpecificVmdk',
1ad166b6
BC
71 'data': {
72 'create-type': 'str',
73 'cid': 'int',
74 'parent-cid': 'int',
75 'extents': ['ImageInfo']
76 } }
77
78##
79# @ImageInfoSpecific:
80#
81# A discriminated record of image format specific information structures.
82#
83# Since: 1.7
84##
1ad166b6
BC
85{ 'union': 'ImageInfoSpecific',
86 'data': {
87 'qcow2': 'ImageInfoSpecificQCow2',
c7c4cf49
DB
88 'vmdk': 'ImageInfoSpecificVmdk',
89 # If we need to add block driver specific parameters for
90 # LUKS in future, then we'll subclass QCryptoBlockInfoLUKS
91 # to define a ImageInfoSpecificLUKS
92 'luks': 'QCryptoBlockInfoLUKS'
1ad166b6
BC
93 } }
94
95##
96# @ImageInfo:
97#
98# Information about a QEMU image file
99#
100# @filename: name of the image file
101#
102# @format: format of the image file
103#
104# @virtual-size: maximum capacity in bytes of the image
105#
106# @actual-size: #optional actual size on disk in bytes of the image
107#
108# @dirty-flag: #optional true if image is not cleanly closed
109#
110# @cluster-size: #optional size of a cluster in bytes
111#
112# @encrypted: #optional true if the image is encrypted
113#
114# @compressed: #optional true if the image is compressed (Since 1.7)
115#
116# @backing-filename: #optional name of the backing file
117#
118# @full-backing-filename: #optional full path of the backing file
119#
120# @backing-filename-format: #optional the format of the backing file
121#
122# @snapshots: #optional list of VM snapshots
123#
124# @backing-image: #optional info of the backing image (since 1.6)
125#
126# @format-specific: #optional structure supplying additional format-specific
127# information (since 1.7)
128#
129# Since: 1.3
130#
131##
895a2a80 132{ 'struct': 'ImageInfo',
1ad166b6
BC
133 'data': {'filename': 'str', 'format': 'str', '*dirty-flag': 'bool',
134 '*actual-size': 'int', 'virtual-size': 'int',
135 '*cluster-size': 'int', '*encrypted': 'bool', '*compressed': 'bool',
136 '*backing-filename': 'str', '*full-backing-filename': 'str',
137 '*backing-filename-format': 'str', '*snapshots': ['SnapshotInfo'],
138 '*backing-image': 'ImageInfo',
24bf10da 139 '*format-specific': 'ImageInfoSpecific' } }
1ad166b6
BC
140
141##
142# @ImageCheck:
143#
144# Information about a QEMU image file check
145#
146# @filename: name of the image file checked
147#
148# @format: format of the image file checked
149#
150# @check-errors: number of unexpected errors occurred during check
151#
152# @image-end-offset: #optional offset (in bytes) where the image ends, this
153# field is present if the driver for the image format
154# supports it
155#
156# @corruptions: #optional number of corruptions found during the check if any
157#
158# @leaks: #optional number of leaks found during the check if any
159#
160# @corruptions-fixed: #optional number of corruptions fixed during the check
161# if any
162#
163# @leaks-fixed: #optional number of leaks fixed during the check if any
164#
165# @total-clusters: #optional total number of clusters, this field is present
166# if the driver for the image format supports it
167#
168# @allocated-clusters: #optional total number of allocated clusters, this
169# field is present if the driver for the image format
170# supports it
171#
172# @fragmented-clusters: #optional total number of fragmented clusters, this
173# field is present if the driver for the image format
174# supports it
175#
176# @compressed-clusters: #optional total number of compressed clusters, this
177# field is present if the driver for the image format
178# supports it
179#
180# Since: 1.4
181#
182##
895a2a80 183{ 'struct': 'ImageCheck',
1ad166b6
BC
184 'data': {'filename': 'str', 'format': 'str', 'check-errors': 'int',
185 '*image-end-offset': 'int', '*corruptions': 'int', '*leaks': 'int',
186 '*corruptions-fixed': 'int', '*leaks-fixed': 'int',
187 '*total-clusters': 'int', '*allocated-clusters': 'int',
188 '*fragmented-clusters': 'int', '*compressed-clusters': 'int' } }
189
16b0d555
FZ
190##
191# @MapEntry:
192#
193# Mapping information from a virtual block range to a host file range
194#
195# @start: the start byte of the mapped virtual range
196#
197# @length: the number of bytes of the mapped virtual range
198#
199# @data: whether the mapped range has data
200#
201# @zero: whether the virtual blocks are zeroed
202#
203# @depth: the depth of the mapping
204#
205# @offset: #optional the offset in file that the virtual sectors are mapped to
206#
207# @filename: #optional filename that is referred to by @offset
208#
209# Since: 2.6
210#
211##
212{ 'struct': 'MapEntry',
213 'data': {'start': 'int', 'length': 'int', 'data': 'bool',
214 'zero': 'bool', 'depth': 'int', '*offset': 'int',
215 '*filename': 'str' } }
216
9e193c5a 217##
5072f7b3 218# @BlockdevCacheInfo:
9e193c5a
KW
219#
220# Cache mode information for a block device
221#
222# @writeback: true if writeback mode is enabled
223# @direct: true if the host page cache is bypassed (O_DIRECT)
224# @no-flush: true if flush requests are ignored for the device
225#
226# Since: 2.3
227##
895a2a80 228{ 'struct': 'BlockdevCacheInfo',
9e193c5a
KW
229 'data': { 'writeback': 'bool',
230 'direct': 'bool',
231 'no-flush': 'bool' } }
232
1ad166b6
BC
233##
234# @BlockDeviceInfo:
235#
236# Information about the backing device for a block device.
237#
238# @file: the filename of the backing device
239#
240# @node-name: #optional the name of the block driver node (Since 2.0)
241#
242# @ro: true if the backing device was open read-only
243#
244# @drv: the name of the block format used to open the backing device. As of
245# 0.14.0 this can be: 'blkdebug', 'bochs', 'cloop', 'cow', 'dmg',
246# 'file', 'file', 'ftp', 'ftps', 'host_cdrom', 'host_device',
78368575 247# 'http', 'https', 'luks', 'nbd', 'parallels', 'qcow',
23dce387 248# 'qcow2', 'raw', 'vdi', 'vmdk', 'vpc', 'vvfat'
550830f9 249# 2.2: 'archipelago' added, 'cow' dropped
92a539d2 250# 2.3: 'host_floppy' deprecated
f709623b 251# 2.5: 'host_floppy' dropped
78368575 252# 2.6: 'luks' added
23dce387 253# 2.8: 'replication' added, 'tftp' dropped
1ad166b6
BC
254#
255# @backing_file: #optional the name of the backing file (for copy-on-write)
256#
257# @backing_file_depth: number of files in the backing file chain (since: 1.2)
258#
259# @encrypted: true if the backing device is encrypted
260#
261# @encryption_key_missing: true if the backing device is encrypted but an
262# valid encryption key is missing
263#
264# @detect_zeroes: detect and optimize zero writes (Since 2.1)
265#
266# @bps: total throughput limit in bytes per second is specified
267#
268# @bps_rd: read throughput limit in bytes per second is specified
269#
270# @bps_wr: write throughput limit in bytes per second is specified
271#
272# @iops: total I/O operations per second is specified
273#
274# @iops_rd: read I/O operations per second is specified
275#
276# @iops_wr: write I/O operations per second is specified
277#
278# @image: the info of image used (since: 1.6)
279#
398befdf
AG
280# @bps_max: #optional total throughput limit during bursts,
281# in bytes (Since 1.7)
1ad166b6 282#
398befdf
AG
283# @bps_rd_max: #optional read throughput limit during bursts,
284# in bytes (Since 1.7)
1ad166b6 285#
398befdf
AG
286# @bps_wr_max: #optional write throughput limit during bursts,
287# in bytes (Since 1.7)
1ad166b6 288#
398befdf
AG
289# @iops_max: #optional total I/O operations per second during bursts,
290# in bytes (Since 1.7)
1ad166b6 291#
398befdf
AG
292# @iops_rd_max: #optional read I/O operations per second during bursts,
293# in bytes (Since 1.7)
1ad166b6 294#
398befdf
AG
295# @iops_wr_max: #optional write I/O operations per second during bursts,
296# in bytes (Since 1.7)
297#
298# @bps_max_length: #optional maximum length of the @bps_max burst
299# period, in seconds. (Since 2.6)
300#
301# @bps_rd_max_length: #optional maximum length of the @bps_rd_max
302# burst period, in seconds. (Since 2.6)
303#
304# @bps_wr_max_length: #optional maximum length of the @bps_wr_max
305# burst period, in seconds. (Since 2.6)
306#
307# @iops_max_length: #optional maximum length of the @iops burst
308# period, in seconds. (Since 2.6)
309#
310# @iops_rd_max_length: #optional maximum length of the @iops_rd_max
311# burst period, in seconds. (Since 2.6)
312#
313# @iops_wr_max_length: #optional maximum length of the @iops_wr_max
314# burst period, in seconds. (Since 2.6)
1ad166b6
BC
315#
316# @iops_size: #optional an I/O size in bytes (Since 1.7)
317#
b8fe1694
AG
318# @group: #optional throttle group name (Since 2.4)
319#
9e193c5a
KW
320# @cache: the cache mode used for the block device (since: 2.3)
321#
e2462113
FR
322# @write_threshold: configured write threshold for the device.
323# 0 if disabled. (Since 2.3)
324#
1ad166b6
BC
325# Since: 0.14.0
326#
327##
895a2a80 328{ 'struct': 'BlockDeviceInfo',
1ad166b6
BC
329 'data': { 'file': 'str', '*node-name': 'str', 'ro': 'bool', 'drv': 'str',
330 '*backing_file': 'str', 'backing_file_depth': 'int',
331 'encrypted': 'bool', 'encryption_key_missing': 'bool',
332 'detect_zeroes': 'BlockdevDetectZeroesOptions',
333 'bps': 'int', 'bps_rd': 'int', 'bps_wr': 'int',
334 'iops': 'int', 'iops_rd': 'int', 'iops_wr': 'int',
335 'image': 'ImageInfo',
336 '*bps_max': 'int', '*bps_rd_max': 'int',
337 '*bps_wr_max': 'int', '*iops_max': 'int',
338 '*iops_rd_max': 'int', '*iops_wr_max': 'int',
398befdf
AG
339 '*bps_max_length': 'int', '*bps_rd_max_length': 'int',
340 '*bps_wr_max_length': 'int', '*iops_max_length': 'int',
341 '*iops_rd_max_length': 'int', '*iops_wr_max_length': 'int',
b8fe1694 342 '*iops_size': 'int', '*group': 'str', 'cache': 'BlockdevCacheInfo',
e2462113 343 'write_threshold': 'int' } }
1ad166b6
BC
344
345##
346# @BlockDeviceIoStatus:
347#
348# An enumeration of block device I/O status.
349#
350# @ok: The last I/O operation has succeeded
351#
352# @failed: The last I/O operation has failed
353#
354# @nospace: The last I/O operation has failed due to a no-space condition
355#
356# Since: 1.0
357##
358{ 'enum': 'BlockDeviceIoStatus', 'data': [ 'ok', 'failed', 'nospace' ] }
359
360##
361# @BlockDeviceMapEntry:
362#
363# Entry in the metadata map of the device (returned by "qemu-img map")
364#
365# @start: Offset in the image of the first byte described by this entry
366# (in bytes)
367#
368# @length: Length of the range described by this entry (in bytes)
369#
370# @depth: Number of layers (0 = top image, 1 = top image's backing file, etc.)
371# before reaching one for which the range is allocated. The value is
372# in the range 0 to the depth of the image chain - 1.
373#
374# @zero: the sectors in this range read as zeros
375#
376# @data: reading the image will actually read data from a file (in particular,
377# if @offset is present this means that the sectors are not simply
378# preallocated, but contain actual data in raw format)
379#
380# @offset: if present, the image file stores the data for this range in
381# raw format at the given offset.
382#
5072f7b3 383# Since: 1.7
1ad166b6 384##
895a2a80 385{ 'struct': 'BlockDeviceMapEntry',
1ad166b6
BC
386 'data': { 'start': 'int', 'length': 'int', 'depth': 'int', 'zero': 'bool',
387 'data': 'bool', '*offset': 'int' } }
388
9abe3bdc
JS
389##
390# @DirtyBitmapStatus:
391#
392# An enumeration of possible states that a dirty bitmap can report to the user.
393#
394# @frozen: The bitmap is currently in-use by a backup operation or block job,
395# and is immutable.
396#
397# @disabled: The bitmap is currently in-use by an internal operation and is
398# read-only. It can still be deleted.
399#
400# @active: The bitmap is actively monitoring for new writes, and can be cleared,
401# deleted, or used for backup operations.
402#
403# Since: 2.4
404##
405{ 'enum': 'DirtyBitmapStatus',
406 'data': ['active', 'disabled', 'frozen'] }
407
1ad166b6
BC
408##
409# @BlockDirtyInfo:
410#
411# Block dirty bitmap information.
412#
0db6e54a
FZ
413# @name: #optional the name of the dirty bitmap (Since 2.4)
414#
1ad166b6
BC
415# @count: number of dirty bytes according to the dirty bitmap
416#
417# @granularity: granularity of the dirty bitmap in bytes (since 1.4)
418#
9abe3bdc 419# @status: current status of the dirty bitmap (since 2.4)
a113534f 420#
1ad166b6
BC
421# Since: 1.3
422##
895a2a80 423{ 'struct': 'BlockDirtyInfo',
a113534f 424 'data': {'*name': 'str', 'count': 'int', 'granularity': 'uint32',
9abe3bdc 425 'status': 'DirtyBitmapStatus'} }
1ad166b6
BC
426
427##
428# @BlockInfo:
429#
430# Block device information. This structure describes a virtual device and
431# the backing device associated with it.
432#
433# @device: The device name associated with the virtual device.
434#
435# @type: This field is returned only for compatibility reasons, it should
436# not be used (always returns 'unknown')
437#
438# @removable: True if the device supports removable media.
439#
440# @locked: True if the guest has locked this device from having its media
441# removed
442#
327032ce
HR
443# @tray_open: #optional True if the device's tray is open
444# (only present if it has a tray)
1ad166b6
BC
445#
446# @dirty-bitmaps: #optional dirty bitmaps information (only present if the
447# driver has one or more dirty bitmaps) (Since 2.0)
448#
449# @io-status: #optional @BlockDeviceIoStatus. Only present if the device
450# supports it and the VM is configured to stop on errors
c7c2ff0c 451# (supported device models: virtio-blk, ide, scsi-disk)
1ad166b6
BC
452#
453# @inserted: #optional @BlockDeviceInfo describing the device if media is
454# present
455#
456# Since: 0.14.0
457##
895a2a80 458{ 'struct': 'BlockInfo',
1ad166b6
BC
459 'data': {'device': 'str', 'type': 'str', 'removable': 'bool',
460 'locked': 'bool', '*inserted': 'BlockDeviceInfo',
461 '*tray_open': 'bool', '*io-status': 'BlockDeviceIoStatus',
462 '*dirty-bitmaps': ['BlockDirtyInfo'] } }
463
464##
465# @query-block:
466#
467# Get a list of BlockInfo for all virtual block devices.
468#
469# Returns: a list of @BlockInfo describing each virtual block device
470#
471# Since: 0.14.0
978cceab
MAL
472#
473# Example:
474#
475# -> { "execute": "query-block" }
476# <- {
477# "return":[
478# {
479# "io-status": "ok",
480# "device":"ide0-hd0",
481# "locked":false,
482# "removable":false,
483# "inserted":{
484# "ro":false,
485# "drv":"qcow2",
486# "encrypted":false,
487# "file":"disks/test.qcow2",
488# "backing_file_depth":1,
489# "bps":1000000,
490# "bps_rd":0,
491# "bps_wr":0,
492# "iops":1000000,
493# "iops_rd":0,
494# "iops_wr":0,
495# "bps_max": 8000000,
496# "bps_rd_max": 0,
497# "bps_wr_max": 0,
498# "iops_max": 0,
499# "iops_rd_max": 0,
500# "iops_wr_max": 0,
501# "iops_size": 0,
502# "detect_zeroes": "on",
503# "write_threshold": 0,
504# "image":{
505# "filename":"disks/test.qcow2",
506# "format":"qcow2",
507# "virtual-size":2048000,
508# "backing_file":"base.qcow2",
509# "full-backing-filename":"disks/base.qcow2",
510# "backing-filename-format":"qcow2",
511# "snapshots":[
512# {
513# "id": "1",
514# "name": "snapshot1",
515# "vm-state-size": 0,
516# "date-sec": 10000200,
517# "date-nsec": 12,
518# "vm-clock-sec": 206,
519# "vm-clock-nsec": 30
520# }
521# ],
522# "backing-image":{
523# "filename":"disks/base.qcow2",
524# "format":"qcow2",
525# "virtual-size":2048000
526# }
527# }
528# },
529# "type":"unknown"
530# },
531# {
532# "io-status": "ok",
533# "device":"ide1-cd0",
534# "locked":false,
535# "removable":true,
536# "type":"unknown"
537# },
538# {
539# "device":"floppy0",
540# "locked":false,
541# "removable":true,
542# "type":"unknown"
543# },
544# {
545# "device":"sd0",
546# "locked":false,
547# "removable":true,
548# "type":"unknown"
549# }
550# ]
551# }
552#
1ad166b6
BC
553##
554{ 'command': 'query-block', 'returns': ['BlockInfo'] }
555
979e9b03
AG
556
557##
558# @BlockDeviceTimedStats:
559#
560# Statistics of a block device during a given interval of time.
561#
562# @interval_length: Interval used for calculating the statistics,
563# in seconds.
564#
565# @min_rd_latency_ns: Minimum latency of read operations in the
566# defined interval, in nanoseconds.
567#
568# @min_wr_latency_ns: Minimum latency of write operations in the
569# defined interval, in nanoseconds.
570#
571# @min_flush_latency_ns: Minimum latency of flush operations in the
572# defined interval, in nanoseconds.
573#
574# @max_rd_latency_ns: Maximum latency of read operations in the
575# defined interval, in nanoseconds.
576#
577# @max_wr_latency_ns: Maximum latency of write operations in the
578# defined interval, in nanoseconds.
579#
580# @max_flush_latency_ns: Maximum latency of flush operations in the
581# defined interval, in nanoseconds.
582#
583# @avg_rd_latency_ns: Average latency of read operations in the
584# defined interval, in nanoseconds.
585#
586# @avg_wr_latency_ns: Average latency of write operations in the
587# defined interval, in nanoseconds.
588#
589# @avg_flush_latency_ns: Average latency of flush operations in the
590# defined interval, in nanoseconds.
591#
96e4deda
AG
592# @avg_rd_queue_depth: Average number of pending read operations
593# in the defined interval.
594#
595# @avg_wr_queue_depth: Average number of pending write operations
596# in the defined interval.
597#
979e9b03
AG
598# Since: 2.5
599##
979e9b03
AG
600{ 'struct': 'BlockDeviceTimedStats',
601 'data': { 'interval_length': 'int', 'min_rd_latency_ns': 'int',
602 'max_rd_latency_ns': 'int', 'avg_rd_latency_ns': 'int',
603 'min_wr_latency_ns': 'int', 'max_wr_latency_ns': 'int',
604 'avg_wr_latency_ns': 'int', 'min_flush_latency_ns': 'int',
96e4deda
AG
605 'max_flush_latency_ns': 'int', 'avg_flush_latency_ns': 'int',
606 'avg_rd_queue_depth': 'number', 'avg_wr_queue_depth': 'number' } }
979e9b03 607
1ad166b6
BC
608##
609# @BlockDeviceStats:
610#
611# Statistics of a virtual block device or a block backing device.
612#
613# @rd_bytes: The number of bytes read by the device.
614#
615# @wr_bytes: The number of bytes written by the device.
616#
617# @rd_operations: The number of read operations performed by the device.
618#
619# @wr_operations: The number of write operations performed by the device.
620#
621# @flush_operations: The number of cache flush operations performed by the
622# device (since 0.15.0)
623#
624# @flush_total_time_ns: Total time spend on cache flushes in nano-seconds
625# (since 0.15.0).
626#
627# @wr_total_time_ns: Total time spend on writes in nano-seconds (since 0.15.0).
628#
629# @rd_total_time_ns: Total_time_spend on reads in nano-seconds (since 0.15.0).
630#
631# @wr_highest_offset: The offset after the greatest byte written to the
632# device. The intended use of this information is for
633# growable sparse files (like qcow2) that are used on top
634# of a physical device.
635#
f4564d53
PL
636# @rd_merged: Number of read requests that have been merged into another
637# request (Since 2.3).
638#
639# @wr_merged: Number of write requests that have been merged into another
640# request (Since 2.3).
641#
cb38fffb
AG
642# @idle_time_ns: #optional Time since the last I/O operation, in
643# nanoseconds. If the field is absent it means that
644# there haven't been any operations yet (Since 2.5).
645#
7ee12daf
AG
646# @failed_rd_operations: The number of failed read operations
647# performed by the device (Since 2.5)
648#
649# @failed_wr_operations: The number of failed write operations
650# performed by the device (Since 2.5)
651#
652# @failed_flush_operations: The number of failed flush operations
653# performed by the device (Since 2.5)
654#
655# @invalid_rd_operations: The number of invalid read operations
656# performed by the device (Since 2.5)
657#
658# @invalid_wr_operations: The number of invalid write operations
659# performed by the device (Since 2.5)
660#
661# @invalid_flush_operations: The number of invalid flush operations
662# performed by the device (Since 2.5)
663#
362e9299
AG
664# @account_invalid: Whether invalid operations are included in the
665# last access statistics (Since 2.5)
666#
667# @account_failed: Whether failed operations are included in the
668# latency and last access statistics (Since 2.5)
669#
979e9b03
AG
670# @timed_stats: Statistics specific to the set of previously defined
671# intervals of time (Since 2.5)
672#
1ad166b6
BC
673# Since: 0.14.0
674##
895a2a80 675{ 'struct': 'BlockDeviceStats',
1ad166b6
BC
676 'data': {'rd_bytes': 'int', 'wr_bytes': 'int', 'rd_operations': 'int',
677 'wr_operations': 'int', 'flush_operations': 'int',
678 'flush_total_time_ns': 'int', 'wr_total_time_ns': 'int',
f4564d53 679 'rd_total_time_ns': 'int', 'wr_highest_offset': 'int',
7ee12daf
AG
680 'rd_merged': 'int', 'wr_merged': 'int', '*idle_time_ns': 'int',
681 'failed_rd_operations': 'int', 'failed_wr_operations': 'int',
682 'failed_flush_operations': 'int', 'invalid_rd_operations': 'int',
362e9299 683 'invalid_wr_operations': 'int', 'invalid_flush_operations': 'int',
979e9b03
AG
684 'account_invalid': 'bool', 'account_failed': 'bool',
685 'timed_stats': ['BlockDeviceTimedStats'] } }
1ad166b6
BC
686
687##
688# @BlockStats:
689#
690# Statistics of a virtual block device or a block backing device.
691#
692# @device: #optional If the stats are for a virtual block device, the name
693# corresponding to the virtual block device.
694#
a06e4355 695# @node-name: #optional The node name of the device. (Since 2.3)
4875a779 696#
1ad166b6
BC
697# @stats: A @BlockDeviceStats for the device.
698#
699# @parent: #optional This describes the file block device if it has one.
f2eaea18
MAL
700# Contains recursively the statistics of the underlying
701# protocol (e.g. the host file for a qcow2 image). If there is
702# no underlying protocol, this field is omitted
1ad166b6
BC
703#
704# @backing: #optional This describes the backing block device if it has one.
705# (Since 2.0)
706#
707# Since: 0.14.0
708##
895a2a80 709{ 'struct': 'BlockStats',
4875a779
FZ
710 'data': {'*device': 'str', '*node-name': 'str',
711 'stats': 'BlockDeviceStats',
1ad166b6
BC
712 '*parent': 'BlockStats',
713 '*backing': 'BlockStats'} }
714
715##
716# @query-blockstats:
717#
718# Query the @BlockStats for all virtual block devices.
719#
f71eaa74
FZ
720# @query-nodes: #optional If true, the command will query all the block nodes
721# that have a node name, in a list which will include "parent"
722# information, but not "backing".
723# If false or omitted, the behavior is as before - query all the
724# device backends, recursively including their "parent" and
725# "backing". (Since 2.3)
726#
1ad166b6
BC
727# Returns: A list of @BlockStats for each virtual block devices.
728#
729# Since: 0.14.0
f2eaea18
MAL
730#
731# Example:
732#
733# -> { "execute": "query-blockstats" }
734# <- {
735# "return":[
736# {
737# "device":"ide0-hd0",
738# "parent":{
739# "stats":{
740# "wr_highest_offset":3686448128,
741# "wr_bytes":9786368,
742# "wr_operations":751,
743# "rd_bytes":122567168,
744# "rd_operations":36772
745# "wr_total_times_ns":313253456
746# "rd_total_times_ns":3465673657
747# "flush_total_times_ns":49653
748# "flush_operations":61,
749# "rd_merged":0,
750# "wr_merged":0,
751# "idle_time_ns":2953431879,
752# "account_invalid":true,
753# "account_failed":false
754# }
755# },
756# "stats":{
757# "wr_highest_offset":2821110784,
758# "wr_bytes":9786368,
759# "wr_operations":692,
760# "rd_bytes":122739200,
761# "rd_operations":36604
762# "flush_operations":51,
763# "wr_total_times_ns":313253456
764# "rd_total_times_ns":3465673657
765# "flush_total_times_ns":49653,
766# "rd_merged":0,
767# "wr_merged":0,
768# "idle_time_ns":2953431879,
769# "account_invalid":true,
770# "account_failed":false
771# }
772# },
773# {
774# "device":"ide1-cd0",
775# "stats":{
776# "wr_highest_offset":0,
777# "wr_bytes":0,
778# "wr_operations":0,
779# "rd_bytes":0,
780# "rd_operations":0
781# "flush_operations":0,
782# "wr_total_times_ns":0
783# "rd_total_times_ns":0
784# "flush_total_times_ns":0,
785# "rd_merged":0,
786# "wr_merged":0,
787# "account_invalid":false,
788# "account_failed":false
789# }
790# },
791# {
792# "device":"floppy0",
793# "stats":{
794# "wr_highest_offset":0,
795# "wr_bytes":0,
796# "wr_operations":0,
797# "rd_bytes":0,
798# "rd_operations":0
799# "flush_operations":0,
800# "wr_total_times_ns":0
801# "rd_total_times_ns":0
802# "flush_total_times_ns":0,
803# "rd_merged":0,
804# "wr_merged":0,
805# "account_invalid":false,
806# "account_failed":false
807# }
808# },
809# {
810# "device":"sd0",
811# "stats":{
812# "wr_highest_offset":0,
813# "wr_bytes":0,
814# "wr_operations":0,
815# "rd_bytes":0,
816# "rd_operations":0
817# "flush_operations":0,
818# "wr_total_times_ns":0
819# "rd_total_times_ns":0
820# "flush_total_times_ns":0,
821# "rd_merged":0,
822# "wr_merged":0,
823# "account_invalid":false,
824# "account_failed":false
825# }
826# }
827# ]
828# }
829#
1ad166b6 830##
f71eaa74
FZ
831{ 'command': 'query-blockstats',
832 'data': { '*query-nodes': 'bool' },
833 'returns': ['BlockStats'] }
1ad166b6
BC
834
835##
836# @BlockdevOnError:
837#
838# An enumeration of possible behaviors for errors on I/O operations.
839# The exact meaning depends on whether the I/O was initiated by a guest
840# or by a block job
841#
842# @report: for guest operations, report the error to the guest;
843# for jobs, cancel the job
844#
845# @ignore: ignore the error, only report a QMP event (BLOCK_IO_ERROR
846# or BLOCK_JOB_ERROR)
847#
848# @enospc: same as @stop on ENOSPC, same as @report otherwise.
849#
850# @stop: for guest operations, stop the virtual machine;
851# for jobs, pause the job
852#
8c398252
KW
853# @auto: inherit the error handling policy of the backend (since: 2.7)
854#
1ad166b6
BC
855# Since: 1.3
856##
857{ 'enum': 'BlockdevOnError',
8c398252 858 'data': ['report', 'ignore', 'enospc', 'stop', 'auto'] }
1ad166b6
BC
859
860##
861# @MirrorSyncMode:
862#
863# An enumeration of possible behaviors for the initial synchronization
864# phase of storage mirroring.
865#
866# @top: copies data in the topmost image to the destination
867#
868# @full: copies data from all images to the destination
869#
870# @none: only copy data written from now on
871#
4b80ab2b 872# @incremental: only copy data described by the dirty bitmap. Since: 2.4
d58d8453 873#
1ad166b6
BC
874# Since: 1.3
875##
876{ 'enum': 'MirrorSyncMode',
4b80ab2b 877 'data': ['top', 'full', 'none', 'incremental'] }
1ad166b6
BC
878
879##
880# @BlockJobType:
881#
882# Type of a block job.
883#
884# @commit: block commit job type, see "block-commit"
885#
886# @stream: block stream job type, see "block-stream"
887#
888# @mirror: drive mirror job type, see "drive-mirror"
889#
890# @backup: drive backup job type, see "drive-backup"
891#
892# Since: 1.7
893##
894{ 'enum': 'BlockJobType',
895 'data': ['commit', 'stream', 'mirror', 'backup'] }
896
897##
898# @BlockJobInfo:
899#
900# Information about a long-running block device operation.
901#
902# @type: the job type ('stream' for image streaming)
903#
6aae5be6
AG
904# @device: The job identifier. Originally the device name but other
905# values are allowed since QEMU 2.7
1ad166b6
BC
906#
907# @len: the maximum progress value
908#
909# @busy: false if the job is known to be in a quiescent state, with
910# no pending I/O. Since 1.3.
911#
912# @paused: whether the job is paused or, if @busy is true, will
913# pause itself as soon as possible. Since 1.3.
914#
915# @offset: the current progress value
916#
917# @speed: the rate limit, bytes per second
918#
919# @io-status: the status of the job (since 1.3)
920#
ef6dbf1e
HR
921# @ready: true if the job may be completed (since 2.2)
922#
1ad166b6
BC
923# Since: 1.1
924##
895a2a80 925{ 'struct': 'BlockJobInfo',
1ad166b6
BC
926 'data': {'type': 'str', 'device': 'str', 'len': 'int',
927 'offset': 'int', 'busy': 'bool', 'paused': 'bool', 'speed': 'int',
ef6dbf1e 928 'io-status': 'BlockDeviceIoStatus', 'ready': 'bool'} }
1ad166b6
BC
929
930##
931# @query-block-jobs:
932#
933# Return information about long-running block device operations.
934#
935# Returns: a list of @BlockJobInfo for each active block job
936#
937# Since: 1.1
938##
939{ 'command': 'query-block-jobs', 'returns': ['BlockJobInfo'] }
940
941##
942# @block_passwd:
943#
944# This command sets the password of a block device that has not been open
945# with a password and requires one.
946#
947# The two cases where this can happen are a block device is created through
948# QEMU's initial command line or a block device is changed through the legacy
949# @change interface.
950#
951# In the event that the block device is created through the initial command
952# line, the VM will start in the stopped state regardless of whether '-S' is
953# used. The intention is for a management tool to query the block devices to
954# determine which ones are encrypted, set the passwords with this command, and
955# then start the guest with the @cont command.
956#
957# Either @device or @node-name must be set but not both.
958#
959# @device: #optional the name of the block backend device to set the password on
960#
961# @node-name: #optional graph node name to set the password on (Since 2.0)
962#
963# @password: the password to use for the device
964#
965# Returns: nothing on success
966# If @device is not a valid block device, DeviceNotFound
967# If @device is not encrypted, DeviceNotEncrypted
968#
969# Notes: Not all block formats support encryption and some that do are not
970# able to validate that a password is correct. Disk corruption may
971# occur if an invalid password is specified.
972#
973# Since: 0.14.0
91f96b64
MAL
974#
975# Example:
976#
977# -> { "execute": "block_passwd", "arguments": { "device": "ide0-hd0",
978# "password": "12345" } }
979# <- { "return": {} }
980#
1ad166b6
BC
981##
982{ 'command': 'block_passwd', 'data': {'*device': 'str',
983 '*node-name': 'str', 'password': 'str'} }
984
985##
5072f7b3 986# @block_resize:
1ad166b6
BC
987#
988# Resize a block image while a guest is running.
989#
990# Either @device or @node-name must be set but not both.
991#
992# @device: #optional the name of the device to get the image resized
993#
994# @node-name: #optional graph node name to get the image resized (Since 2.0)
995#
996# @size: new image size in bytes
997#
998# Returns: nothing on success
999# If @device is not a valid block device, DeviceNotFound
1000#
1001# Since: 0.14.0
0dc869cf
MAL
1002#
1003# Example:
1004#
1005# -> { "execute": "block_resize",
1006# "arguments": { "device": "scratch", "size": 1073741824 } }
1007# <- { "return": {} }
1008#
1ad166b6
BC
1009##
1010{ 'command': 'block_resize', 'data': { '*device': 'str',
1011 '*node-name': 'str',
1012 'size': 'int' }}
1013
1014##
5072f7b3 1015# @NewImageMode:
1ad166b6
BC
1016#
1017# An enumeration that tells QEMU how to set the backing file path in
1018# a new image file.
1019#
1020# @existing: QEMU should look for an existing image file.
1021#
1022# @absolute-paths: QEMU should create a new image with absolute paths
1023# for the backing file. If there is no backing file available, the new
1024# image will not be backed either.
1025#
1026# Since: 1.1
1027##
1028{ 'enum': 'NewImageMode',
1029 'data': [ 'existing', 'absolute-paths' ] }
1030
1031##
5072f7b3 1032# @BlockdevSnapshotSync:
1ad166b6
BC
1033#
1034# Either @device or @node-name must be set but not both.
1035#
1036# @device: #optional the name of the device to generate the snapshot from.
1037#
1038# @node-name: #optional graph node name to generate the snapshot from (Since 2.0)
1039#
b4039d8d
MAL
1040# @snapshot-file: the target of the new image. If the file exists, or
1041# if it is a device, the snapshot will be created in the existing
1042# file/device. Otherwise, a new file will be created.
1ad166b6
BC
1043#
1044# @snapshot-node-name: #optional the graph node name of the new image (Since 2.0)
1045#
1046# @format: #optional the format of the snapshot image, default is 'qcow2'.
1047#
1048# @mode: #optional whether and how QEMU should create a new image, default is
1049# 'absolute-paths'.
1050##
a911e6ae 1051{ 'struct': 'BlockdevSnapshotSync',
1ad166b6
BC
1052 'data': { '*device': 'str', '*node-name': 'str',
1053 'snapshot-file': 'str', '*snapshot-node-name': 'str',
1054 '*format': 'str', '*mode': 'NewImageMode' } }
1055
43de7e2d 1056##
5072f7b3 1057# @BlockdevSnapshot:
43de7e2d
AG
1058#
1059# @node: device or node name that will have a snapshot created.
1060#
1061# @overlay: reference to the existing block device that will become
1062# the overlay of @node, as part of creating the snapshot.
1063# It must not have a current backing file (this can be
1064# achieved by passing "backing": "" to blockdev-add).
1065#
5072f7b3 1066# Since: 2.5
43de7e2d
AG
1067##
1068{ 'struct': 'BlockdevSnapshot',
1069 'data': { 'node': 'str', 'overlay': 'str' } }
1070
1ad166b6 1071##
5072f7b3 1072# @DriveBackup:
1ad166b6 1073#
70559d49
AG
1074# @job-id: #optional identifier for the newly-created block job. If
1075# omitted, the device name will be used. (Since 2.7)
1076#
b7e4fa22 1077# @device: the device name or node-name of a root node which should be copied.
1ad166b6
BC
1078#
1079# @target: the target of the new image. If the file exists, or if it
1080# is a device, the existing file/device will be used as the new
1081# destination. If it does not exist, a new file will be created.
1082#
1083# @format: #optional the format of the new destination, default is to
1084# probe if @mode is 'existing', else the format of the source
1085#
1086# @sync: what parts of the disk image should be copied to the destination
d58d8453
JS
1087# (all the disk, only the sectors allocated in the topmost image, from a
1088# dirty bitmap, or only new I/O).
1ad166b6
BC
1089#
1090# @mode: #optional whether and how QEMU should create a new image, default is
1091# 'absolute-paths'.
1092#
1093# @speed: #optional the maximum speed, in bytes per second
1094#
4b80ab2b
JS
1095# @bitmap: #optional the name of dirty bitmap if sync is "incremental".
1096# Must be present if sync is "incremental", must NOT be present
d58d8453
JS
1097# otherwise. (Since 2.4)
1098#
13b9414b 1099# @compress: #optional true to compress data, if the target format supports it.
6bed0280 1100# (default: false) (since 2.8)
13b9414b 1101#
1ad166b6
BC
1102# @on-source-error: #optional the action to take on an error on the source,
1103# default 'report'. 'stop' and 'enospc' can only be used
1104# if the block device supports io-status (see BlockInfo).
1105#
1106# @on-target-error: #optional the action to take on an error on the target,
1107# default 'report' (no limitations, since this applies to
1108# a different block device than @device).
1109#
5072f7b3
MAL
1110# Note: @on-source-error and @on-target-error only affect background
1111# I/O. If an error occurs during a guest write request, the device's
1112# rerror/werror actions will be used.
1ad166b6
BC
1113#
1114# Since: 1.6
1115##
895a2a80 1116{ 'struct': 'DriveBackup',
70559d49
AG
1117 'data': { '*job-id': 'str', 'device': 'str', 'target': 'str',
1118 '*format': 'str', 'sync': 'MirrorSyncMode', '*mode': 'NewImageMode',
13b9414b 1119 '*speed': 'int', '*bitmap': 'str', '*compress': 'bool',
1ad166b6
BC
1120 '*on-source-error': 'BlockdevOnError',
1121 '*on-target-error': 'BlockdevOnError' } }
1122
c29c1dd3 1123##
5072f7b3 1124# @BlockdevBackup:
c29c1dd3 1125#
70559d49
AG
1126# @job-id: #optional identifier for the newly-created block job. If
1127# omitted, the device name will be used. (Since 2.7)
1128#
cef34eeb 1129# @device: the device name or node-name of a root node which should be copied.
c29c1dd3 1130#
39d990ac 1131# @target: the device name or node-name of the backup target node.
c29c1dd3
FZ
1132#
1133# @sync: what parts of the disk image should be copied to the destination
1134# (all the disk, only the sectors allocated in the topmost image, or
1135# only new I/O).
1136#
1137# @speed: #optional the maximum speed, in bytes per second. The default is 0,
1138# for unlimited.
1139#
3b7b1236 1140# @compress: #optional true to compress data, if the target format supports it.
6bed0280 1141# (default: false) (since 2.8)
3b7b1236 1142#
c29c1dd3
FZ
1143# @on-source-error: #optional the action to take on an error on the source,
1144# default 'report'. 'stop' and 'enospc' can only be used
1145# if the block device supports io-status (see BlockInfo).
1146#
1147# @on-target-error: #optional the action to take on an error on the target,
1148# default 'report' (no limitations, since this applies to
1149# a different block device than @device).
1150#
5072f7b3
MAL
1151# Note: @on-source-error and @on-target-error only affect background
1152# I/O. If an error occurs during a guest write request, the device's
1153# rerror/werror actions will be used.
c29c1dd3
FZ
1154#
1155# Since: 2.3
1156##
895a2a80 1157{ 'struct': 'BlockdevBackup',
70559d49 1158 'data': { '*job-id': 'str', 'device': 'str', 'target': 'str',
c29c1dd3
FZ
1159 'sync': 'MirrorSyncMode',
1160 '*speed': 'int',
3b7b1236 1161 '*compress': 'bool',
c29c1dd3
FZ
1162 '*on-source-error': 'BlockdevOnError',
1163 '*on-target-error': 'BlockdevOnError' } }
1164
1ad166b6 1165##
5072f7b3 1166# @blockdev-snapshot-sync:
1ad166b6
BC
1167#
1168# Generates a synchronous snapshot of a block device.
1169#
a911e6ae 1170# For the arguments, see the documentation of BlockdevSnapshotSync.
1ad166b6
BC
1171#
1172# Returns: nothing on success
1173# If @device is not a valid block device, DeviceNotFound
1174#
5072f7b3 1175# Since: 0.14.0
b4039d8d
MAL
1176#
1177# Example:
1178#
1179# -> { "execute": "blockdev-snapshot-sync",
1180# "arguments": { "device": "ide-hd0",
1181# "snapshot-file":
1182# "/some/place/my-image",
1183# "format": "qcow2" } }
1184# <- { "return": {} }
1185#
1ad166b6
BC
1186##
1187{ 'command': 'blockdev-snapshot-sync',
a911e6ae 1188 'data': 'BlockdevSnapshotSync' }
1ad166b6 1189
43de7e2d
AG
1190
1191##
5072f7b3 1192# @blockdev-snapshot:
43de7e2d
AG
1193#
1194# Generates a snapshot of a block device.
1195#
3282eca4
MAL
1196# Create a snapshot, by installing 'node' as the backing image of
1197# 'overlay'. Additionally, if 'node' is associated with a block
1198# device, the block device changes to using 'overlay' as its new active
1199# image.
1200#
43de7e2d
AG
1201# For the arguments, see the documentation of BlockdevSnapshot.
1202#
5072f7b3 1203# Since: 2.5
3282eca4
MAL
1204#
1205# Example:
1206#
1207# -> { "execute": "blockdev-add",
1208# "arguments": { "options": { "driver": "qcow2",
1209# "node-name": "node1534",
1210# "file": { "driver": "file",
1211# "filename": "hd1.qcow2" },
1212# "backing": "" } } }
1213#
1214# <- { "return": {} }
1215#
1216# -> { "execute": "blockdev-snapshot",
1217# "arguments": { "node": "ide-hd0",
1218# "overlay": "node1534" } }
1219# <- { "return": {} }
1220#
43de7e2d
AG
1221##
1222{ 'command': 'blockdev-snapshot',
1223 'data': 'BlockdevSnapshot' }
1224
fa40e656 1225##
5072f7b3 1226# @change-backing-file:
fa40e656
JC
1227#
1228# Change the backing file in the image file metadata. This does not
1229# cause QEMU to reopen the image file to reparse the backing filename
1230# (it may, however, perform a reopen to change permissions from
1231# r/o -> r/w -> r/o, if needed). The new backing file string is written
1232# into the image file metadata, and the QEMU internal strings are
1233# updated.
1234#
1235# @image-node-name: The name of the block driver state node of the
280c4b3c
MAL
1236# image to modify. The "device" argument is used
1237# to verify "image-node-name" is in the chain
1238# described by "device".
fa40e656 1239#
7b5dca3f
KW
1240# @device: The device name or node-name of the root node that owns
1241# image-node-name.
fa40e656
JC
1242#
1243# @backing-file: The string to write as the backing file. This
1244# string is not validated, so care should be taken
1245# when specifying the string or the image chain may
1246# not be able to be reopened again.
1247#
280c4b3c
MAL
1248# Returns: Nothing on success
1249#
1250# If "device" does not exist or cannot be determined, DeviceNotFound
1251#
fa40e656
JC
1252# Since: 2.1
1253##
1254{ 'command': 'change-backing-file',
1255 'data': { 'device': 'str', 'image-node-name': 'str',
1256 'backing-file': 'str' } }
1257
1ad166b6 1258##
5072f7b3 1259# @block-commit:
1ad166b6
BC
1260#
1261# Live commit of data from overlay image nodes into backing nodes - i.e.,
1262# writes data between 'top' and 'base' into 'base'.
1263#
fd62c609
AG
1264# @job-id: #optional identifier for the newly-created block job. If
1265# omitted, the device name will be used. (Since 2.7)
1266#
1d13b167 1267# @device: the device name or node-name of a root node
1ad166b6
BC
1268#
1269# @base: #optional The file name of the backing image to write data into.
1270# If not specified, this is the deepest backing image
1271#
7676e2c5
JC
1272# @top: #optional The file name of the backing image within the image chain,
1273# which contains the topmost data to be committed down. If
1274# not specified, this is the active layer.
1ad166b6 1275#
54e26900
JC
1276# @backing-file: #optional The backing file string to write into the overlay
1277# image of 'top'. If 'top' is the active layer,
1278# specifying a backing file string is an error. This
1279# filename is not validated.
1280#
1281# If a pathname string is such that it cannot be
1282# resolved by QEMU, that means that subsequent QMP or
1283# HMP commands must use node-names for the image in
1284# question, as filename lookup methods will fail.
1285#
1286# If not specified, QEMU will automatically determine
1287# the backing file string to use, or error out if
1288# there is no obvious choice. Care should be taken
1289# when specifying the string, to specify a valid
1290# filename or protocol.
1291# (Since 2.1)
1292#
1ad166b6
BC
1293# If top == base, that is an error.
1294# If top == active, the job will not be completed by itself,
1295# user needs to complete the job with the block-job-complete
1296# command after getting the ready event. (Since 2.0)
1297#
1298# If the base image is smaller than top, then the base image
1299# will be resized to be the same size as top. If top is
1300# smaller than the base image, the base will not be
1301# truncated. If you want the base image size to match the
1302# size of the smaller top, you can safely truncate it
1303# yourself once the commit operation successfully completes.
1304#
1ad166b6
BC
1305# @speed: #optional the maximum speed, in bytes per second
1306#
1307# Returns: Nothing on success
1308# If commit or stream is already active on this device, DeviceInUse
1309# If @device does not exist, DeviceNotFound
1310# If image commit is not supported by this device, NotSupported
1311# If @base or @top is invalid, a generic error is returned
1312# If @speed is invalid, InvalidParameter
1313#
1314# Since: 1.3
1315#
1316##
1317{ 'command': 'block-commit',
fd62c609 1318 'data': { '*job-id': 'str', 'device': 'str', '*base': 'str', '*top': 'str',
54e26900 1319 '*backing-file': 'str', '*speed': 'int' } }
1ad166b6
BC
1320
1321##
5072f7b3 1322# @drive-backup:
1ad166b6
BC
1323#
1324# Start a point-in-time copy of a block device to a new destination. The
1325# status of ongoing drive-backup operations can be checked with
1326# query-block-jobs where the BlockJobInfo.type field has the value 'backup'.
1327# The operation can be stopped before it has completed using the
1328# block-job-cancel command.
1329#
1330# For the arguments, see the documentation of DriveBackup.
1331#
1332# Returns: nothing on success
b7e4fa22 1333# If @device is not a valid block device, GenericError
1ad166b6 1334#
5072f7b3 1335# Since: 1.6
1ad166b6 1336##
81206a89
PB
1337{ 'command': 'drive-backup', 'boxed': true,
1338 'data': 'DriveBackup' }
1ad166b6 1339
c29c1dd3 1340##
5072f7b3 1341# @blockdev-backup:
c29c1dd3
FZ
1342#
1343# Start a point-in-time copy of a block device to a new destination. The
1344# status of ongoing blockdev-backup operations can be checked with
1345# query-block-jobs where the BlockJobInfo.type field has the value 'backup'.
1346# The operation can be stopped before it has completed using the
1347# block-job-cancel command.
1348#
1349# For the arguments, see the documentation of BlockdevBackup.
1350#
dc7a4a9e
PB
1351# Returns: nothing on success
1352# If @device is not a valid block device, DeviceNotFound
1353#
5072f7b3 1354# Since: 2.3
c29c1dd3 1355##
dc7a4a9e
PB
1356{ 'command': 'blockdev-backup', 'boxed': true,
1357 'data': 'BlockdevBackup' }
c29c1dd3
FZ
1358
1359
1ad166b6 1360##
5072f7b3 1361# @query-named-block-nodes:
1ad166b6
BC
1362#
1363# Get the named block driver list
1364#
1365# Returns: the list of BlockDeviceInfo
1366#
5072f7b3 1367# Since: 2.0
1ad166b6
BC
1368##
1369{ 'command': 'query-named-block-nodes', 'returns': [ 'BlockDeviceInfo' ] }
1370
1371##
5072f7b3 1372# @drive-mirror:
1ad166b6
BC
1373#
1374# Start mirroring a block device's writes to a new destination.
1375#
faecd40a
EB
1376# See DriveMirror for parameter descriptions
1377#
1378# Returns: nothing on success
0524e93a 1379# If @device is not a valid block device, GenericError
faecd40a 1380#
5072f7b3 1381# Since: 1.3
faecd40a
EB
1382##
1383{ 'command': 'drive-mirror', 'boxed': true,
1384 'data': 'DriveMirror' }
1385
1386##
5072f7b3 1387# @DriveMirror:
faecd40a
EB
1388#
1389# A set of parameters describing drive mirror setup.
1390#
71aa9867
AG
1391# @job-id: #optional identifier for the newly-created block job. If
1392# omitted, the device name will be used. (Since 2.7)
1393#
0524e93a
KW
1394# @device: the device name or node-name of a root node whose writes should be
1395# mirrored.
1ad166b6
BC
1396#
1397# @target: the target of the new image. If the file exists, or if it
1398# is a device, the existing file/device will be used as the new
1399# destination. If it does not exist, a new file will be created.
1400#
1401# @format: #optional the format of the new destination, default is to
1402# probe if @mode is 'existing', else the format of the source
1403#
4c828dc6
BC
1404# @node-name: #optional the new block driver state node name in the graph
1405# (Since 2.1)
1406#
09158f00
BC
1407# @replaces: #optional with sync=full graph node name to be replaced by the new
1408# image when a whole image copy is done. This can be used to repair
1409# broken Quorum files. (Since 2.1)
1410#
1ad166b6
BC
1411# @mode: #optional whether and how QEMU should create a new image, default is
1412# 'absolute-paths'.
1413#
1414# @speed: #optional the maximum speed, in bytes per second
1415#
1416# @sync: what parts of the disk image should be copied to the destination
1417# (all the disk, only the sectors allocated in the topmost image, or
1418# only new I/O).
1419#
1420# @granularity: #optional granularity of the dirty bitmap, default is 64K
1421# if the image format doesn't have clusters, 4K if the clusters
1422# are smaller than that, else the cluster size. Must be a
1423# power of 2 between 512 and 64M (since 1.4).
1424#
1425# @buf-size: #optional maximum amount of data in flight from source to
1426# target (since 1.4).
1427#
1428# @on-source-error: #optional the action to take on an error on the source,
1429# default 'report'. 'stop' and 'enospc' can only be used
1430# if the block device supports io-status (see BlockInfo).
1431#
1432# @on-target-error: #optional the action to take on an error on the target,
1433# default 'report' (no limitations, since this applies to
1434# a different block device than @device).
0fc9f8ea
FZ
1435# @unmap: #optional Whether to try to unmap target sectors where source has
1436# only zero. If true, and target unallocated sectors will read as zero,
1437# target image sectors will be unmapped; otherwise, zeroes will be
1438# written. Both will result in identical contents.
1439# Default is true. (Since 2.4)
1ad166b6 1440#
5072f7b3 1441# Since: 1.3
1ad166b6 1442##
faecd40a 1443{ 'struct': 'DriveMirror',
71aa9867
AG
1444 'data': { '*job-id': 'str', 'device': 'str', 'target': 'str',
1445 '*format': 'str', '*node-name': 'str', '*replaces': 'str',
1ad166b6
BC
1446 'sync': 'MirrorSyncMode', '*mode': 'NewImageMode',
1447 '*speed': 'int', '*granularity': 'uint32',
1448 '*buf-size': 'int', '*on-source-error': 'BlockdevOnError',
0fc9f8ea
FZ
1449 '*on-target-error': 'BlockdevOnError',
1450 '*unmap': 'bool' } }
1ad166b6 1451
341ebc2f 1452##
5072f7b3 1453# @BlockDirtyBitmap:
341ebc2f
JS
1454#
1455# @node: name of device/node which the bitmap is tracking
1456#
1457# @name: name of the dirty bitmap
1458#
5072f7b3 1459# Since: 2.4
341ebc2f 1460##
895a2a80 1461{ 'struct': 'BlockDirtyBitmap',
341ebc2f
JS
1462 'data': { 'node': 'str', 'name': 'str' } }
1463
1464##
5072f7b3 1465# @BlockDirtyBitmapAdd:
341ebc2f
JS
1466#
1467# @node: name of device/node which the bitmap is tracking
1468#
1469# @name: name of the dirty bitmap
1470#
1471# @granularity: #optional the bitmap granularity, default is 64k for
1472# block-dirty-bitmap-add
1473#
5072f7b3 1474# Since: 2.4
341ebc2f 1475##
895a2a80 1476{ 'struct': 'BlockDirtyBitmapAdd',
341ebc2f
JS
1477 'data': { 'node': 'str', 'name': 'str', '*granularity': 'uint32' } }
1478
1479##
5072f7b3 1480# @block-dirty-bitmap-add:
341ebc2f
JS
1481#
1482# Create a dirty bitmap with a name on the node
1483#
1484# Returns: nothing on success
1485# If @node is not a valid block device or node, DeviceNotFound
1486# If @name is already taken, GenericError with an explanation
1487#
5072f7b3 1488# Since: 2.4
341ebc2f
JS
1489##
1490{ 'command': 'block-dirty-bitmap-add',
1491 'data': 'BlockDirtyBitmapAdd' }
1492
1493##
5072f7b3 1494# @block-dirty-bitmap-remove:
341ebc2f
JS
1495#
1496# Remove a dirty bitmap on the node
1497#
1498# Returns: nothing on success
1499# If @node is not a valid block device or node, DeviceNotFound
1500# If @name is not found, GenericError with an explanation
9bd2b08f 1501# if @name is frozen by an operation, GenericError
341ebc2f 1502#
5072f7b3 1503# Since: 2.4
341ebc2f
JS
1504##
1505{ 'command': 'block-dirty-bitmap-remove',
1506 'data': 'BlockDirtyBitmap' }
1507
e74e6b78 1508##
5072f7b3 1509# @block-dirty-bitmap-clear:
e74e6b78
JS
1510#
1511# Clear (reset) a dirty bitmap on the device
1512#
1513# Returns: nothing on success
1514# If @node is not a valid block device, DeviceNotFound
1515# If @name is not found, GenericError with an explanation
1516#
5072f7b3 1517# Since: 2.4
e74e6b78
JS
1518##
1519{ 'command': 'block-dirty-bitmap-clear',
1520 'data': 'BlockDirtyBitmap' }
1521
df92562e 1522##
5072f7b3 1523# @blockdev-mirror:
df92562e
FZ
1524#
1525# Start mirroring a block device's writes to a new destination.
1526#
71aa9867
AG
1527# @job-id: #optional identifier for the newly-created block job. If
1528# omitted, the device name will be used. (Since 2.7)
1529#
07eec652
KW
1530# @device: The device name or node-name of a root node whose writes should be
1531# mirrored.
df92562e
FZ
1532#
1533# @target: the id or node-name of the block device to mirror to. This mustn't be
1534# attached to guest.
1535#
1536# @replaces: #optional with sync=full graph node name to be replaced by the new
1537# image when a whole image copy is done. This can be used to repair
1538# broken Quorum files.
1539#
1540# @speed: #optional the maximum speed, in bytes per second
1541#
1542# @sync: what parts of the disk image should be copied to the destination
1543# (all the disk, only the sectors allocated in the topmost image, or
1544# only new I/O).
1545#
1546# @granularity: #optional granularity of the dirty bitmap, default is 64K
1547# if the image format doesn't have clusters, 4K if the clusters
1548# are smaller than that, else the cluster size. Must be a
1549# power of 2 between 512 and 64M
1550#
1551# @buf-size: #optional maximum amount of data in flight from source to
1552# target
1553#
1554# @on-source-error: #optional the action to take on an error on the source,
1555# default 'report'. 'stop' and 'enospc' can only be used
1556# if the block device supports io-status (see BlockInfo).
1557#
1558# @on-target-error: #optional the action to take on an error on the target,
1559# default 'report' (no limitations, since this applies to
1560# a different block device than @device).
1561#
1562# Returns: nothing on success.
1563#
5072f7b3 1564# Since: 2.6
df92562e
FZ
1565##
1566{ 'command': 'blockdev-mirror',
71aa9867 1567 'data': { '*job-id': 'str', 'device': 'str', 'target': 'str',
df92562e
FZ
1568 '*replaces': 'str',
1569 'sync': 'MirrorSyncMode',
1570 '*speed': 'int', '*granularity': 'uint32',
1571 '*buf-size': 'int', '*on-source-error': 'BlockdevOnError',
1572 '*on-target-error': 'BlockdevOnError' } }
1573
1ad166b6
BC
1574##
1575# @block_set_io_throttle:
1576#
1577# Change I/O throttle limits for a block drive.
1578#
76f4afb4
AG
1579# Since QEMU 2.4, each device with I/O limits is member of a throttle
1580# group.
1581#
1582# If two or more devices are members of the same group, the limits
1583# will apply to the combined I/O of the whole group in a round-robin
1584# fashion. Therefore, setting new I/O limits to a device will affect
1585# the whole group.
1586#
1587# The name of the group can be specified using the 'group' parameter.
1588# If the parameter is unset, it is assumed to be the current group of
1589# that device. If it's not in any group yet, the name of the device
1590# will be used as the name for its group.
1591#
1592# The 'group' parameter can also be used to move a device to a
1593# different group. In this case the limits specified in the parameters
1594# will be applied to the new group only.
1595#
1596# I/O limits can be disabled by setting all of them to 0. In this case
1597# the device will be removed from its group and the rest of its
6b932c0a 1598# members will not be affected. The 'group' parameter is ignored.
76f4afb4 1599#
4dc9397b
EB
1600# See BlockIOThrottle for parameter descriptions.
1601#
1602# Returns: Nothing on success
1603# If @device is not a valid block device, DeviceNotFound
1604#
1605# Since: 1.1
1606##
1607{ 'command': 'block_set_io_throttle', 'boxed': true,
1608 'data': 'BlockIOThrottle' }
1609
1610##
5072f7b3 1611# @BlockIOThrottle:
4dc9397b
EB
1612#
1613# A set of parameters describing block throttling.
1614#
7a9877a0
KW
1615# @device: #optional Block device name (deprecated, use @id instead)
1616#
1617# @id: #optional The name or QOM path of the guest device (since: 2.8)
1ad166b6
BC
1618#
1619# @bps: total throughput limit in bytes per second
1620#
1621# @bps_rd: read throughput limit in bytes per second
1622#
1623# @bps_wr: write throughput limit in bytes per second
1624#
1625# @iops: total I/O operations per second
1626#
f5a845fd 1627# @iops_rd: read I/O operations per second
1ad166b6
BC
1628#
1629# @iops_wr: write I/O operations per second
1630#
dce13204
AG
1631# @bps_max: #optional total throughput limit during bursts,
1632# in bytes (Since 1.7)
1ad166b6 1633#
dce13204
AG
1634# @bps_rd_max: #optional read throughput limit during bursts,
1635# in bytes (Since 1.7)
1ad166b6 1636#
dce13204
AG
1637# @bps_wr_max: #optional write throughput limit during bursts,
1638# in bytes (Since 1.7)
1ad166b6 1639#
dce13204
AG
1640# @iops_max: #optional total I/O operations per second during bursts,
1641# in bytes (Since 1.7)
1ad166b6 1642#
dce13204
AG
1643# @iops_rd_max: #optional read I/O operations per second during bursts,
1644# in bytes (Since 1.7)
1ad166b6 1645#
dce13204
AG
1646# @iops_wr_max: #optional write I/O operations per second during bursts,
1647# in bytes (Since 1.7)
1648#
1649# @bps_max_length: #optional maximum length of the @bps_max burst
1650# period, in seconds. It must only
1651# be set if @bps_max is set as well.
1652# Defaults to 1. (Since 2.6)
1653#
1654# @bps_rd_max_length: #optional maximum length of the @bps_rd_max
1655# burst period, in seconds. It must only
1656# be set if @bps_rd_max is set as well.
1657# Defaults to 1. (Since 2.6)
1658#
1659# @bps_wr_max_length: #optional maximum length of the @bps_wr_max
1660# burst period, in seconds. It must only
1661# be set if @bps_wr_max is set as well.
1662# Defaults to 1. (Since 2.6)
1663#
1664# @iops_max_length: #optional maximum length of the @iops burst
1665# period, in seconds. It must only
1666# be set if @iops_max is set as well.
1667# Defaults to 1. (Since 2.6)
1668#
1669# @iops_rd_max_length: #optional maximum length of the @iops_rd_max
1670# burst period, in seconds. It must only
1671# be set if @iops_rd_max is set as well.
1672# Defaults to 1. (Since 2.6)
1673#
1674# @iops_wr_max_length: #optional maximum length of the @iops_wr_max
1675# burst period, in seconds. It must only
1676# be set if @iops_wr_max is set as well.
1677# Defaults to 1. (Since 2.6)
1ad166b6
BC
1678#
1679# @iops_size: #optional an I/O size in bytes (Since 1.7)
1680#
76f4afb4
AG
1681# @group: #optional throttle group name (Since 2.4)
1682#
1ad166b6
BC
1683# Since: 1.1
1684##
4dc9397b 1685{ 'struct': 'BlockIOThrottle',
7a9877a0
KW
1686 'data': { '*device': 'str', '*id': 'str', 'bps': 'int', 'bps_rd': 'int',
1687 'bps_wr': 'int', 'iops': 'int', 'iops_rd': 'int', 'iops_wr': 'int',
1ad166b6
BC
1688 '*bps_max': 'int', '*bps_rd_max': 'int',
1689 '*bps_wr_max': 'int', '*iops_max': 'int',
1690 '*iops_rd_max': 'int', '*iops_wr_max': 'int',
dce13204
AG
1691 '*bps_max_length': 'int', '*bps_rd_max_length': 'int',
1692 '*bps_wr_max_length': 'int', '*iops_max_length': 'int',
1693 '*iops_rd_max_length': 'int', '*iops_wr_max_length': 'int',
76f4afb4 1694 '*iops_size': 'int', '*group': 'str' } }
1ad166b6
BC
1695
1696##
1697# @block-stream:
1698#
1699# Copy data from a backing file into a block device.
1700#
1701# The block streaming operation is performed in the background until the entire
1702# backing file has been copied. This command returns immediately once streaming
1703# has started. The status of ongoing block streaming operations can be checked
1704# with query-block-jobs. The operation can be stopped before it has completed
1705# using the block-job-cancel command.
1706#
554b6147
AG
1707# The node that receives the data is called the top image, can be located in
1708# any part of the chain (but always above the base image; see below) and can be
1709# specified using its device or node name. Earlier qemu versions only allowed
1710# 'device' to name the top level node; presence of the 'base-node' parameter
1711# during introspection can be used as a witness of the enhanced semantics
1712# of 'device'.
1713#
1ad166b6
BC
1714# If a base file is specified then sectors are not copied from that base file and
1715# its backing chain. When streaming completes the image file will have the base
1716# file as its backing file. This can be used to stream a subset of the backing
1717# file chain instead of flattening the entire image.
1718#
1719# On successful completion the image file is updated to drop the backing file
1720# and the BLOCK_JOB_COMPLETED event is emitted.
1721#
2323322e
AG
1722# @job-id: #optional identifier for the newly-created block job. If
1723# omitted, the device name will be used. (Since 2.7)
1724#
554b6147 1725# @device: the device or node name of the top image
1ad166b6 1726#
312fe09c
AG
1727# @base: #optional the common backing file name.
1728# It cannot be set if @base-node is also set.
1729#
1730# @base-node: #optional the node name of the backing file.
1731# It cannot be set if @base is also set. (Since 2.8)
1ad166b6 1732#
554b6147
AG
1733# @backing-file: #optional The backing file string to write into the top
1734# image. This filename is not validated.
13d8cc51
JC
1735#
1736# If a pathname string is such that it cannot be
1737# resolved by QEMU, that means that subsequent QMP or
1738# HMP commands must use node-names for the image in
1739# question, as filename lookup methods will fail.
1740#
1741# If not specified, QEMU will automatically determine
1742# the backing file string to use, or error out if there
1743# is no obvious choice. Care should be taken when
1744# specifying the string, to specify a valid filename or
1745# protocol.
1746# (Since 2.1)
1747#
1ad166b6
BC
1748# @speed: #optional the maximum speed, in bytes per second
1749#
1750# @on-error: #optional the action to take on an error (default report).
1751# 'stop' and 'enospc' can only be used if the block device
1752# supports io-status (see BlockInfo). Since 1.3.
1753#
1ad166b6
BC
1754# Since: 1.1
1755##
1756{ 'command': 'block-stream',
2323322e 1757 'data': { '*job-id': 'str', 'device': 'str', '*base': 'str',
312fe09c 1758 '*base-node': 'str', '*backing-file': 'str', '*speed': 'int',
2323322e 1759 '*on-error': 'BlockdevOnError' } }
1ad166b6
BC
1760
1761##
1762# @block-job-set-speed:
1763#
1764# Set maximum speed for a background block operation.
1765#
1766# This command can only be issued when there is an active block job.
1767#
1768# Throttling can be disabled by setting the speed to 0.
1769#
6aae5be6
AG
1770# @device: The job identifier. This used to be a device name (hence
1771# the name of the parameter), but since QEMU 2.7 it can have
1772# other values.
1ad166b6
BC
1773#
1774# @speed: the maximum speed, in bytes per second, or 0 for unlimited.
1775# Defaults to 0.
1776#
1777# Returns: Nothing on success
1778# If no background operation is active on this device, DeviceNotActive
1779#
1780# Since: 1.1
1781##
1782{ 'command': 'block-job-set-speed',
1783 'data': { 'device': 'str', 'speed': 'int' } }
1784
1785##
1786# @block-job-cancel:
1787#
1788# Stop an active background block operation.
1789#
1790# This command returns immediately after marking the active background block
1791# operation for cancellation. It is an error to call this command if no
1792# operation is in progress.
1793#
1794# The operation will cancel as soon as possible and then emit the
1795# BLOCK_JOB_CANCELLED event. Before that happens the job is still visible when
1796# enumerated using query-block-jobs.
1797#
1798# For streaming, the image file retains its backing file unless the streaming
1799# operation happens to complete just as it is being cancelled. A new streaming
1800# operation can be started at a later time to finish copying all data from the
1801# backing file.
1802#
6aae5be6
AG
1803# @device: The job identifier. This used to be a device name (hence
1804# the name of the parameter), but since QEMU 2.7 it can have
1805# other values.
1ad166b6
BC
1806#
1807# @force: #optional whether to allow cancellation of a paused job (default
1808# false). Since 1.3.
1809#
1810# Returns: Nothing on success
1811# If no background operation is active on this device, DeviceNotActive
1812#
1813# Since: 1.1
1814##
1815{ 'command': 'block-job-cancel', 'data': { 'device': 'str', '*force': 'bool' } }
1816
1817##
1818# @block-job-pause:
1819#
1820# Pause an active background block operation.
1821#
1822# This command returns immediately after marking the active background block
1823# operation for pausing. It is an error to call this command if no
1824# operation is in progress. Pausing an already paused job has no cumulative
1825# effect; a single block-job-resume command will resume the job.
1826#
1827# The operation will pause as soon as possible. No event is emitted when
1828# the operation is actually paused. Cancelling a paused job automatically
1829# resumes it.
1830#
6aae5be6
AG
1831# @device: The job identifier. This used to be a device name (hence
1832# the name of the parameter), but since QEMU 2.7 it can have
1833# other values.
1ad166b6
BC
1834#
1835# Returns: Nothing on success
1836# If no background operation is active on this device, DeviceNotActive
1837#
1838# Since: 1.3
1839##
1840{ 'command': 'block-job-pause', 'data': { 'device': 'str' } }
1841
1842##
1843# @block-job-resume:
1844#
1845# Resume an active background block operation.
1846#
1847# This command returns immediately after resuming a paused background block
1848# operation. It is an error to call this command if no operation is in
1849# progress. Resuming an already running job is not an error.
1850#
1851# This command also clears the error status of the job.
1852#
6aae5be6
AG
1853# @device: The job identifier. This used to be a device name (hence
1854# the name of the parameter), but since QEMU 2.7 it can have
1855# other values.
1ad166b6
BC
1856#
1857# Returns: Nothing on success
1858# If no background operation is active on this device, DeviceNotActive
1859#
1860# Since: 1.3
1861##
1862{ 'command': 'block-job-resume', 'data': { 'device': 'str' } }
1863
1864##
1865# @block-job-complete:
1866#
1867# Manually trigger completion of an active background block operation. This
1868# is supported for drive mirroring, where it also switches the device to
1869# write to the target path only. The ability to complete is signaled with
1870# a BLOCK_JOB_READY event.
1871#
1872# This command completes an active background block operation synchronously.
1873# The ordering of this command's return with the BLOCK_JOB_COMPLETED event
1874# is not defined. Note that if an I/O error occurs during the processing of
1875# this command: 1) the command itself will fail; 2) the error will be processed
1876# according to the rerror/werror arguments that were specified when starting
1877# the operation.
1878#
1879# A cancelled or paused job cannot be completed.
1880#
6aae5be6
AG
1881# @device: The job identifier. This used to be a device name (hence
1882# the name of the parameter), but since QEMU 2.7 it can have
1883# other values.
1ad166b6
BC
1884#
1885# Returns: Nothing on success
1886# If no background operation is active on this device, DeviceNotActive
1887#
1888# Since: 1.3
1889##
1890{ 'command': 'block-job-complete', 'data': { 'device': 'str' } }
1891
1892##
5072f7b3 1893# @BlockdevDiscardOptions:
1ad166b6
BC
1894#
1895# Determines how to handle discard requests.
1896#
1897# @ignore: Ignore the request
1898# @unmap: Forward as an unmap request
1899#
1900# Since: 1.7
1901##
1902{ 'enum': 'BlockdevDiscardOptions',
1903 'data': [ 'ignore', 'unmap' ] }
1904
1905##
5072f7b3 1906# @BlockdevDetectZeroesOptions:
1ad166b6
BC
1907#
1908# Describes the operation mode for the automatic conversion of plain
1909# zero writes by the OS to driver specific optimized zero write commands.
1910#
1911# @off: Disabled (default)
1912# @on: Enabled
1913# @unmap: Enabled and even try to unmap blocks if possible. This requires
1914# also that @BlockdevDiscardOptions is set to unmap for this device.
1915#
1916# Since: 2.1
1917##
1918{ 'enum': 'BlockdevDetectZeroesOptions',
1919 'data': [ 'off', 'on', 'unmap' ] }
1920
1921##
5072f7b3 1922# @BlockdevAioOptions:
1ad166b6
BC
1923#
1924# Selects the AIO backend to handle I/O requests
1925#
1926# @threads: Use qemu's thread pool
1927# @native: Use native AIO backend (only Linux and Windows)
1928#
1929# Since: 1.7
1930##
1931{ 'enum': 'BlockdevAioOptions',
1932 'data': [ 'threads', 'native' ] }
1933
1934##
5072f7b3 1935# @BlockdevCacheOptions:
1ad166b6
BC
1936#
1937# Includes cache-related options for block devices
1938#
1ad166b6
BC
1939# @direct: #optional enables use of O_DIRECT (bypass the host page cache;
1940# default: false)
1941# @no-flush: #optional ignore any flush requests for the device (default:
1942# false)
1943#
1944# Since: 1.7
1945##
895a2a80 1946{ 'struct': 'BlockdevCacheOptions',
aaa436f9 1947 'data': { '*direct': 'bool',
1ad166b6
BC
1948 '*no-flush': 'bool' } }
1949
1950##
5072f7b3 1951# @BlockdevDriver:
1ad166b6
BC
1952#
1953# Drivers that are supported in block device operations.
1954#
9f2a70e4
MAL
1955# @host_device: Since 2.1
1956# @host_cdrom: Since 2.1
0a189ffb 1957# @gluster: Since 2.7
9f2a70e4
MAL
1958# @nbd: Since 2.8
1959# @nfs: Since 2.8
1960# @replication: Since 2.8
1961# @ssh: Since 2.8
1ad166b6
BC
1962#
1963# Since: 2.0
1964##
1965{ 'enum': 'BlockdevDriver',
550830f9 1966 'data': [ 'archipelago', 'blkdebug', 'blkverify', 'bochs', 'cloop',
7edac2dd 1967 'dmg', 'file', 'ftp', 'ftps', 'gluster', 'host_cdrom',
aa2623d8 1968 'host_device', 'http', 'https', 'luks', 'nbd', 'nfs', 'null-aio',
6b02b1f0 1969 'null-co', 'parallels', 'qcow', 'qcow2', 'qed', 'quorum', 'raw',
23dce387 1970 'replication', 'ssh', 'vdi', 'vhdx', 'vmdk', 'vpc',
ad0e90a6 1971 'vvfat' ] }
1ad166b6 1972
1ad166b6 1973##
5072f7b3 1974# @BlockdevOptionsFile:
1ad166b6 1975#
68555285 1976# Driver specific block device options for the file backend.
1ad166b6
BC
1977#
1978# @filename: path to the image file
0a4279d9 1979# @aio: #optional AIO backend (default: threads) (since: 2.8)
1ad166b6
BC
1980#
1981# Since: 1.7
1982##
895a2a80 1983{ 'struct': 'BlockdevOptionsFile',
0a4279d9
KW
1984 'data': { 'filename': 'str',
1985 '*aio': 'BlockdevAioOptions' } }
1ad166b6 1986
e819ab22 1987##
5072f7b3 1988# @BlockdevOptionsNull:
e819ab22
FZ
1989#
1990# Driver specific block device options for the null backend.
1991#
1992# @size: #optional size of the device in bytes.
e5e51dd3
FZ
1993# @latency-ns: #optional emulated latency (in nanoseconds) in processing
1994# requests. Default to zero which completes requests immediately.
1995# (Since 2.4)
e819ab22
FZ
1996#
1997# Since: 2.2
1998##
895a2a80 1999{ 'struct': 'BlockdevOptionsNull',
e5e51dd3 2000 'data': { '*size': 'int', '*latency-ns': 'uint64' } }
e819ab22 2001
1ad166b6 2002##
5072f7b3 2003# @BlockdevOptionsVVFAT:
1ad166b6
BC
2004#
2005# Driver specific block device options for the vvfat protocol.
2006#
2007# @dir: directory to be exported as FAT image
2008# @fat-type: #optional FAT type: 12, 16 or 32
2009# @floppy: #optional whether to export a floppy image (true) or
2010# partitioned hard disk (false; default)
d5941dda
WB
2011# @label: #optional set the volume label, limited to 11 bytes. FAT16 and
2012# FAT32 traditionally have some restrictions on labels, which are
2013# ignored by most operating systems. Defaults to "QEMU VVFAT".
2014# (since 2.4)
1ad166b6
BC
2015# @rw: #optional whether to allow write operations (default: false)
2016#
2017# Since: 1.7
2018##
895a2a80 2019{ 'struct': 'BlockdevOptionsVVFAT',
1ad166b6 2020 'data': { 'dir': 'str', '*fat-type': 'int', '*floppy': 'bool',
d5941dda 2021 '*label': 'str', '*rw': 'bool' } }
1ad166b6
BC
2022
2023##
5072f7b3 2024# @BlockdevOptionsGenericFormat:
1ad166b6
BC
2025#
2026# Driver specific block device options for image format that have no option
2027# besides their data source.
2028#
2029# @file: reference to or definition of the data source block device
2030#
2031# Since: 1.7
2032##
895a2a80 2033{ 'struct': 'BlockdevOptionsGenericFormat',
1ad166b6
BC
2034 'data': { 'file': 'BlockdevRef' } }
2035
78368575 2036##
5072f7b3 2037# @BlockdevOptionsLUKS:
78368575
DB
2038#
2039# Driver specific block device options for LUKS.
2040#
2041# @key-secret: #optional the ID of a QCryptoSecret object providing
2042# the decryption key (since 2.6). Mandatory except when
2043# doing a metadata-only probe of the image.
2044#
2045# Since: 2.6
2046##
2047{ 'struct': 'BlockdevOptionsLUKS',
2048 'base': 'BlockdevOptionsGenericFormat',
2049 'data': { '*key-secret': 'str' } }
2050
2051
1ad166b6 2052##
5072f7b3 2053# @BlockdevOptionsGenericCOWFormat:
1ad166b6
BC
2054#
2055# Driver specific block device options for image format that have no option
2056# besides their data source and an optional backing file.
2057#
2058# @backing: #optional reference to or definition of the backing file block
2059# device (if missing, taken from the image file content). It is
2060# allowed to pass an empty string here in order to disable the
2061# default backing file.
2062#
2063# Since: 1.7
2064##
895a2a80 2065{ 'struct': 'BlockdevOptionsGenericCOWFormat',
1ad166b6
BC
2066 'base': 'BlockdevOptionsGenericFormat',
2067 'data': { '*backing': 'BlockdevRef' } }
2068
f6585811 2069##
5072f7b3 2070# @Qcow2OverlapCheckMode:
f6585811
HR
2071#
2072# General overlap check modes.
2073#
2074# @none: Do not perform any checks
2075#
2076# @constant: Perform only checks which can be done in constant time and
2077# without reading anything from disk
2078#
2079# @cached: Perform only checks which can be done without reading anything
2080# from disk
2081#
2082# @all: Perform all available overlap checks
2083#
2084# Since: 2.2
2085##
2086{ 'enum': 'Qcow2OverlapCheckMode',
2087 'data': [ 'none', 'constant', 'cached', 'all' ] }
2088
2089##
5072f7b3 2090# @Qcow2OverlapCheckFlags:
f6585811
HR
2091#
2092# Structure of flags for each metadata structure. Setting a field to 'true'
2093# makes qemu guard that structure against unintended overwriting. The default
2094# value is chosen according to the template given.
2095#
2096# @template: Specifies a template mode which can be adjusted using the other
2097# flags, defaults to 'cached'
2098#
2099# Since: 2.2
2100##
895a2a80 2101{ 'struct': 'Qcow2OverlapCheckFlags',
f6585811
HR
2102 'data': { '*template': 'Qcow2OverlapCheckMode',
2103 '*main-header': 'bool',
2104 '*active-l1': 'bool',
2105 '*active-l2': 'bool',
2106 '*refcount-table': 'bool',
2107 '*refcount-block': 'bool',
2108 '*snapshot-table': 'bool',
2109 '*inactive-l1': 'bool',
2110 '*inactive-l2': 'bool' } }
2111
2112##
5072f7b3 2113# @Qcow2OverlapChecks:
f6585811
HR
2114#
2115# Specifies which metadata structures should be guarded against unintended
2116# overwriting.
2117#
2118# @flags: set of flags for separate specification of each metadata structure
2119# type
2120#
2121# @mode: named mode which chooses a specific set of flags
2122#
2123# Since: 2.2
2124##
ab916fad 2125{ 'alternate': 'Qcow2OverlapChecks',
f6585811
HR
2126 'data': { 'flags': 'Qcow2OverlapCheckFlags',
2127 'mode': 'Qcow2OverlapCheckMode' } }
2128
1ad166b6 2129##
5072f7b3 2130# @BlockdevOptionsQcow2:
1ad166b6
BC
2131#
2132# Driver specific block device options for qcow2.
2133#
2134# @lazy-refcounts: #optional whether to enable the lazy refcounts
2135# feature (default is taken from the image file)
2136#
2137# @pass-discard-request: #optional whether discard requests to the qcow2
2138# device should be forwarded to the data source
2139#
2140# @pass-discard-snapshot: #optional whether discard requests for the data source
2141# should be issued when a snapshot operation (e.g.
2142# deleting a snapshot) frees clusters in the qcow2 file
2143#
2144# @pass-discard-other: #optional whether discard requests for the data source
2145# should be issued on other occasions where a cluster
2146# gets freed
2147#
f6585811
HR
2148# @overlap-check: #optional which overlap checks to perform for writes
2149# to the image, defaults to 'cached' (since 2.2)
2150#
2151# @cache-size: #optional the maximum total size of the L2 table and
2152# refcount block caches in bytes (since 2.2)
2153#
2154# @l2-cache-size: #optional the maximum size of the L2 table cache in
2155# bytes (since 2.2)
2156#
2157# @refcount-cache-size: #optional the maximum size of the refcount block cache
2158# in bytes (since 2.2)
2159#
279621c0
AG
2160# @cache-clean-interval: #optional clean unused entries in the L2 and refcount
2161# caches. The interval is in seconds. The default value
2162# is 0 and it disables this feature (since 2.5)
2163#
1ad166b6
BC
2164# Since: 1.7
2165##
895a2a80 2166{ 'struct': 'BlockdevOptionsQcow2',
1ad166b6
BC
2167 'base': 'BlockdevOptionsGenericCOWFormat',
2168 'data': { '*lazy-refcounts': 'bool',
2169 '*pass-discard-request': 'bool',
2170 '*pass-discard-snapshot': 'bool',
f6585811
HR
2171 '*pass-discard-other': 'bool',
2172 '*overlap-check': 'Qcow2OverlapChecks',
2173 '*cache-size': 'int',
2174 '*l2-cache-size': 'int',
279621c0
AG
2175 '*refcount-cache-size': 'int',
2176 '*cache-clean-interval': 'int' } }
1ad166b6 2177
b1de5f43
CN
2178
2179##
5072f7b3 2180# @BlockdevOptionsArchipelago:
b1de5f43
CN
2181#
2182# Driver specific block device options for Archipelago.
2183#
2184# @volume: Name of the Archipelago volume image
2185#
2186# @mport: #optional The port number on which mapperd is
2187# listening. This is optional
2188# and if not specified, QEMU will make Archipelago
2189# use the default port (1001).
2190#
2191# @vport: #optional The port number on which vlmcd is
2192# listening. This is optional
2193# and if not specified, QEMU will make Archipelago
2194# use the default port (501).
2195#
2196# @segment: #optional The name of the shared memory segment
2197# Archipelago stack is using. This is optional
2198# and if not specified, QEMU will make Archipelago
2199# use the default value, 'archipelago'.
2200# Since: 2.2
2201##
895a2a80 2202{ 'struct': 'BlockdevOptionsArchipelago',
b1de5f43
CN
2203 'data': { 'volume': 'str',
2204 '*mport': 'int',
2205 '*vport': 'int',
2206 '*segment': 'str' } }
2207
ad0e90a6 2208##
5072f7b3 2209# @BlockdevOptionsSsh:
ad0e90a6
AA
2210#
2211# @server: host address
2212#
2213# @path: path to the image on the host
2214#
2215# @user: #optional user as which to connect, defaults to current
2216# local user name
2217#
2218# TODO: Expose the host_key_check option in QMP
2219#
5072f7b3 2220# Since: 2.8
ad0e90a6
AA
2221##
2222{ 'struct': 'BlockdevOptionsSsh',
2223 'data': { 'server': 'InetSocketAddress',
2224 'path': 'str',
2225 '*user': 'str' } }
2226
b1de5f43 2227
1ad166b6 2228##
5072f7b3 2229# @BlkdebugEvent:
1ad166b6
BC
2230#
2231# Trigger events supported by blkdebug.
a31939e6
EB
2232#
2233# Since: 2.0
1ad166b6 2234##
a31939e6 2235{ 'enum': 'BlkdebugEvent', 'prefix': 'BLKDBG',
5be5b776
EB
2236 'data': [ 'l1_update', 'l1_grow_alloc_table', 'l1_grow_write_table',
2237 'l1_grow_activate_table', 'l2_load', 'l2_update',
2238 'l2_update_compressed', 'l2_alloc_cow_read', 'l2_alloc_write',
1ad166b6
BC
2239 'read_aio', 'read_backing_aio', 'read_compressed', 'write_aio',
2240 'write_compressed', 'vmstate_load', 'vmstate_save', 'cow_read',
2241 'cow_write', 'reftable_load', 'reftable_grow', 'reftable_update',
2242 'refblock_load', 'refblock_update', 'refblock_update_part',
5be5b776
EB
2243 'refblock_alloc', 'refblock_alloc_hookup', 'refblock_alloc_write',
2244 'refblock_alloc_write_blocks', 'refblock_alloc_write_table',
2245 'refblock_alloc_switch_table', 'cluster_alloc',
1ad166b6 2246 'cluster_alloc_bytes', 'cluster_free', 'flush_to_os',
5be5b776
EB
2247 'flush_to_disk', 'pwritev_rmw_head', 'pwritev_rmw_after_head',
2248 'pwritev_rmw_tail', 'pwritev_rmw_after_tail', 'pwritev',
d21de4d9 2249 'pwritev_zero', 'pwritev_done', 'empty_image_prepare' ] }
1ad166b6
BC
2250
2251##
5072f7b3 2252# @BlkdebugInjectErrorOptions:
1ad166b6
BC
2253#
2254# Describes a single error injection for blkdebug.
2255#
2256# @event: trigger event
2257#
2258# @state: #optional the state identifier blkdebug needs to be in to
2259# actually trigger the event; defaults to "any"
2260#
2261# @errno: #optional error identifier (errno) to be returned; defaults to
2262# EIO
2263#
2264# @sector: #optional specifies the sector index which has to be affected
2265# in order to actually trigger the event; defaults to "any
2266# sector"
2267#
2268# @once: #optional disables further events after this one has been
2269# triggered; defaults to false
2270#
2271# @immediately: #optional fail immediately; defaults to false
2272#
2273# Since: 2.0
2274##
895a2a80 2275{ 'struct': 'BlkdebugInjectErrorOptions',
1ad166b6
BC
2276 'data': { 'event': 'BlkdebugEvent',
2277 '*state': 'int',
2278 '*errno': 'int',
2279 '*sector': 'int',
2280 '*once': 'bool',
2281 '*immediately': 'bool' } }
2282
2283##
5072f7b3 2284# @BlkdebugSetStateOptions:
1ad166b6
BC
2285#
2286# Describes a single state-change event for blkdebug.
2287#
2288# @event: trigger event
2289#
2290# @state: #optional the current state identifier blkdebug needs to be in;
2291# defaults to "any"
2292#
2293# @new_state: the state identifier blkdebug is supposed to assume if
2294# this event is triggered
2295#
2296# Since: 2.0
2297##
895a2a80 2298{ 'struct': 'BlkdebugSetStateOptions',
1ad166b6
BC
2299 'data': { 'event': 'BlkdebugEvent',
2300 '*state': 'int',
2301 'new_state': 'int' } }
2302
2303##
5072f7b3 2304# @BlockdevOptionsBlkdebug:
1ad166b6
BC
2305#
2306# Driver specific block device options for blkdebug.
2307#
2308# @image: underlying raw block device (or image file)
2309#
2310# @config: #optional filename of the configuration file
2311#
835db3ee
EB
2312# @align: #optional required alignment for requests in bytes,
2313# must be power of 2, or 0 for default
1ad166b6
BC
2314#
2315# @inject-error: #optional array of error injection descriptions
2316#
2317# @set-state: #optional array of state-change descriptions
2318#
2319# Since: 2.0
2320##
895a2a80 2321{ 'struct': 'BlockdevOptionsBlkdebug',
1ad166b6
BC
2322 'data': { 'image': 'BlockdevRef',
2323 '*config': 'str',
2324 '*align': 'int',
2325 '*inject-error': ['BlkdebugInjectErrorOptions'],
2326 '*set-state': ['BlkdebugSetStateOptions'] } }
2327
2328##
5072f7b3 2329# @BlockdevOptionsBlkverify:
1ad166b6
BC
2330#
2331# Driver specific block device options for blkverify.
2332#
2333# @test: block device to be tested
2334#
2335# @raw: raw image used for verification
2336#
2337# Since: 2.0
2338##
895a2a80 2339{ 'struct': 'BlockdevOptionsBlkverify',
1ad166b6
BC
2340 'data': { 'test': 'BlockdevRef',
2341 'raw': 'BlockdevRef' } }
2342
62c6031f 2343##
5072f7b3 2344# @QuorumReadPattern:
62c6031f
LY
2345#
2346# An enumeration of quorum read patterns.
2347#
2348# @quorum: read all the children and do a quorum vote on reads
2349#
2350# @fifo: read only from the first child that has not failed
2351#
2352# Since: 2.2
2353##
2354{ 'enum': 'QuorumReadPattern', 'data': [ 'quorum', 'fifo' ] }
2355
1ad166b6 2356##
5072f7b3 2357# @BlockdevOptionsQuorum:
1ad166b6
BC
2358#
2359# Driver specific block device options for Quorum
2360#
2361# @blkverify: #optional true if the driver must print content mismatch
2362# set to false by default
2363#
2364# @children: the children block devices to use
2365#
2366# @vote-threshold: the vote limit under which a read will fail
2367#
cf29a570
BC
2368# @rewrite-corrupted: #optional rewrite corrupted data when quorum is reached
2369# (Since 2.1)
2370#
62c6031f
LY
2371# @read-pattern: #optional choose read pattern and set to quorum by default
2372# (Since 2.2)
2373#
1ad166b6
BC
2374# Since: 2.0
2375##
895a2a80 2376{ 'struct': 'BlockdevOptionsQuorum',
1ad166b6
BC
2377 'data': { '*blkverify': 'bool',
2378 'children': [ 'BlockdevRef' ],
62c6031f
LY
2379 'vote-threshold': 'int',
2380 '*rewrite-corrupted': 'bool',
2381 '*read-pattern': 'QuorumReadPattern' } }
1ad166b6 2382
7edac2dd 2383##
5072f7b3 2384# @GlusterTransport:
7edac2dd
PKK
2385#
2386# An enumeration of Gluster transport types
2387#
2388# @tcp: TCP - Transmission Control Protocol
2389#
2390# @unix: UNIX - Unix domain socket
2391#
2392# Since: 2.7
2393##
2394{ 'enum': 'GlusterTransport',
2395 'data': [ 'unix', 'tcp' ] }
2396
2397
2398##
5072f7b3 2399# @GlusterServer:
7edac2dd
PKK
2400#
2401# Captures the address of a socket
2402#
2403# Details for connecting to a gluster server
2404#
2405# @type: Transport type used for gluster connection
2406#
c76d7aab
PKK
2407# This is similar to SocketAddress, only distinction:
2408#
2409# 1. GlusterServer is a flat union, SocketAddress is a simple union.
2410# A flat union is nicer than simple because it avoids nesting
2411# (i.e. more {}) on the wire.
2412#
2413# 2. GlusterServer lacks case 'fd', since gluster doesn't let you
2414# pass in a file descriptor.
2415#
2416# GlusterServer is actually not Gluster-specific, its a
2417# compatibility evolved into an alternate for SocketAddress.
2418#
7edac2dd
PKK
2419# Since: 2.7
2420##
2421{ 'union': 'GlusterServer',
2422 'base': { 'type': 'GlusterTransport' },
2423 'discriminator': 'type',
2424 'data': { 'unix': 'UnixSocketAddress',
2425 'tcp': 'InetSocketAddress' } }
2426
2427##
5072f7b3 2428# @BlockdevOptionsGluster:
7edac2dd
PKK
2429#
2430# Driver specific block device options for Gluster
2431#
2432# @volume: name of gluster volume where VM image resides
2433#
2434# @path: absolute path to image file in gluster volume
2435#
0a189ffb 2436# @server: gluster servers description
7edac2dd 2437#
1a417e46 2438# @debug: #optional libgfapi log level (default '4' which is Error)
4230e5d1 2439# (Since 2.8)
7edac2dd 2440#
05fce20d 2441# @logfile: #optional libgfapi log file (default /dev/stderr) (Since 2.8)
e9db8ff3 2442#
7edac2dd
PKK
2443# Since: 2.7
2444##
2445{ 'struct': 'BlockdevOptionsGluster',
2446 'data': { 'volume': 'str',
2447 'path': 'str',
6c7189bb 2448 'server': ['GlusterServer'],
1a417e46 2449 '*debug': 'int',
e9db8ff3 2450 '*logfile': 'str' } }
7edac2dd 2451
190b9a8b 2452##
5072f7b3 2453# @ReplicationMode:
190b9a8b
CX
2454#
2455# An enumeration of replication modes.
2456#
2457# @primary: Primary mode, the vm's state will be sent to secondary QEMU.
2458#
2459# @secondary: Secondary mode, receive the vm's state from primary QEMU.
2460#
2461# Since: 2.8
2462##
2463{ 'enum' : 'ReplicationMode', 'data' : [ 'primary', 'secondary' ] }
2464
82ac5543 2465##
5072f7b3 2466# @BlockdevOptionsReplication:
82ac5543
WC
2467#
2468# Driver specific block device options for replication
2469#
2470# @mode: the replication mode
2471#
2472# @top-id: #optional In secondary mode, node name or device ID of the root
f4f2539b
CX
2473# node who owns the replication node chain. Must not be given in
2474# primary mode.
82ac5543
WC
2475#
2476# Since: 2.8
2477##
2478{ 'struct': 'BlockdevOptionsReplication',
2479 'base': 'BlockdevOptionsGenericFormat',
2480 'data': { 'mode': 'ReplicationMode',
2481 '*top-id': 'str' } }
2482
aa2623d8 2483##
5072f7b3 2484# @NFSTransport:
aa2623d8
AA
2485#
2486# An enumeration of NFS transport types
2487#
2488# @inet: TCP transport
2489#
5072f7b3 2490# Since: 2.8
aa2623d8
AA
2491##
2492{ 'enum': 'NFSTransport',
2493 'data': [ 'inet' ] }
2494
2495##
5072f7b3 2496# @NFSServer:
aa2623d8
AA
2497#
2498# Captures the address of the socket
2499#
2500# @type: transport type used for NFS (only TCP supported)
2501#
2502# @host: host address for NFS server
2503#
5072f7b3 2504# Since: 2.8
aa2623d8
AA
2505##
2506{ 'struct': 'NFSServer',
2507 'data': { 'type': 'NFSTransport',
2508 'host': 'str' } }
2509
2510##
5072f7b3 2511# @BlockdevOptionsNfs:
aa2623d8
AA
2512#
2513# Driver specific block device option for NFS
2514#
2515# @server: host address
2516#
2517# @path: path of the image on the host
2518#
2519# @user: #optional UID value to use when talking to the
2520# server (defaults to 65534 on Windows and getuid()
2521# on unix)
2522#
2523# @group: #optional GID value to use when talking to the
2524# server (defaults to 65534 on Windows and getgid()
2525# in unix)
2526#
2527# @tcp-syn-count: #optional number of SYNs during the session
2528# establishment (defaults to libnfs default)
2529#
2530# @readahead-size: #optional set the readahead size in bytes (defaults
2531# to libnfs default)
2532#
2533# @page-cache-size: #optional set the pagecache size in bytes (defaults
2534# to libnfs default)
2535#
7103d916 2536# @debug: #optional set the NFS debug level (max 2) (defaults
aa2623d8
AA
2537# to libnfs default)
2538#
5072f7b3 2539# Since: 2.8
aa2623d8
AA
2540##
2541{ 'struct': 'BlockdevOptionsNfs',
2542 'data': { 'server': 'NFSServer',
2543 'path': 'str',
2544 '*user': 'int',
2545 '*group': 'int',
2546 '*tcp-syn-count': 'int',
2547 '*readahead-size': 'int',
2548 '*page-cache-size': 'int',
7103d916 2549 '*debug': 'int' } }
aa2623d8 2550
68555285 2551##
5072f7b3 2552# @BlockdevOptionsCurl:
68555285
KW
2553#
2554# Driver specific block device options for the curl backend.
2555#
2556# @filename: path to the image file
2557#
2558# Since: 1.7
2559##
2560{ 'struct': 'BlockdevOptionsCurl',
2561 'data': { 'filename': 'str' } }
2562
6b02b1f0 2563##
5072f7b3 2564# @BlockdevOptionsNbd:
6b02b1f0
HR
2565#
2566# Driver specific block device options for NBD.
2567#
2568# @server: NBD server address
2569#
2570# @export: #optional export name
2571#
2572# @tls-creds: #optional TLS credentials ID
2573#
2574# Since: 2.8
2575##
2576{ 'struct': 'BlockdevOptionsNbd',
2577 'data': { 'server': 'SocketAddress',
2578 '*export': 'str',
2579 '*tls-creds': 'str' } }
2580
2fdc7045 2581##
5072f7b3 2582# @BlockdevOptionsRaw:
2fdc7045
TG
2583#
2584# Driver specific block device options for the raw driver.
2585#
2586# @offset: #optional position where the block device starts
2587# @size: #optional the assumed size of the device
2588#
2589# Since: 2.8
2590##
2591{ 'struct': 'BlockdevOptionsRaw',
2592 'base': 'BlockdevOptionsGenericFormat',
2593 'data': { '*offset': 'int', '*size': 'int' } }
2594
1ad166b6 2595##
5072f7b3 2596# @BlockdevOptions:
1ad166b6 2597#
3666a97f
EB
2598# Options for creating a block device. Many options are available for all
2599# block devices, independent of the block driver:
2600#
2601# @driver: block driver name
9ec8873e
KW
2602# @node-name: #optional the node name of the new node (Since 2.0).
2603# This option is required on the top level of blockdev-add.
3666a97f
EB
2604# @discard: #optional discard-related options (default: ignore)
2605# @cache: #optional cache-related options
3666a97f
EB
2606# @read-only: #optional whether the block device should be read-only
2607# (default: false)
3666a97f
EB
2608# @detect-zeroes: #optional detect and optimize zero writes (Since 2.1)
2609# (default: off)
2610#
2611# Remaining options are determined by the block driver.
1ad166b6
BC
2612#
2613# Since: 1.7
2614##
2615{ 'union': 'BlockdevOptions',
3666a97f 2616 'base': { 'driver': 'BlockdevDriver',
3666a97f
EB
2617 '*node-name': 'str',
2618 '*discard': 'BlockdevDiscardOptions',
2619 '*cache': 'BlockdevCacheOptions',
3666a97f 2620 '*read-only': 'bool',
3666a97f 2621 '*detect-zeroes': 'BlockdevDetectZeroesOptions' },
1ad166b6
BC
2622 'discriminator': 'driver',
2623 'data': {
b1de5f43 2624 'archipelago':'BlockdevOptionsArchipelago',
db866be9
FZ
2625 'blkdebug': 'BlockdevOptionsBlkdebug',
2626 'blkverify': 'BlockdevOptionsBlkverify',
2627 'bochs': 'BlockdevOptionsGenericFormat',
2628 'cloop': 'BlockdevOptionsGenericFormat',
db866be9 2629 'dmg': 'BlockdevOptionsGenericFormat',
1ad166b6 2630 'file': 'BlockdevOptionsFile',
68555285
KW
2631 'ftp': 'BlockdevOptionsCurl',
2632 'ftps': 'BlockdevOptionsCurl',
7edac2dd 2633 'gluster': 'BlockdevOptionsGluster',
1ad166b6 2634 'host_cdrom': 'BlockdevOptionsFile',
db866be9 2635 'host_device':'BlockdevOptionsFile',
68555285
KW
2636 'http': 'BlockdevOptionsCurl',
2637 'https': 'BlockdevOptionsCurl',
1ad166b6 2638# TODO iscsi: Wait for structured options
78368575 2639 'luks': 'BlockdevOptionsLUKS',
6b02b1f0 2640 'nbd': 'BlockdevOptionsNbd',
aa2623d8 2641 'nfs': 'BlockdevOptionsNfs',
db866be9
FZ
2642 'null-aio': 'BlockdevOptionsNull',
2643 'null-co': 'BlockdevOptionsNull',
1ad166b6 2644 'parallels': 'BlockdevOptionsGenericFormat',
1ad166b6 2645 'qcow2': 'BlockdevOptionsQcow2',
db866be9 2646 'qcow': 'BlockdevOptionsGenericCOWFormat',
1ad166b6 2647 'qed': 'BlockdevOptionsGenericCOWFormat',
db866be9 2648 'quorum': 'BlockdevOptionsQuorum',
2fdc7045 2649 'raw': 'BlockdevOptionsRaw',
db866be9 2650# TODO rbd: Wait for structured options
82ac5543 2651 'replication':'BlockdevOptionsReplication',
db866be9 2652# TODO sheepdog: Wait for structured options
ad0e90a6 2653 'ssh': 'BlockdevOptionsSsh',
1ad166b6
BC
2654 'vdi': 'BlockdevOptionsGenericFormat',
2655 'vhdx': 'BlockdevOptionsGenericFormat',
2656 'vmdk': 'BlockdevOptionsGenericCOWFormat',
2657 'vpc': 'BlockdevOptionsGenericFormat',
db866be9 2658 'vvfat': 'BlockdevOptionsVVFAT'
1ad166b6
BC
2659 } }
2660
2661##
5072f7b3 2662# @BlockdevRef:
1ad166b6
BC
2663#
2664# Reference to a block device.
2665#
2666# @definition: defines a new block device inline
2667# @reference: references the ID of an existing block device. An
2668# empty string means that no block device should be
2669# referenced.
2670#
2671# Since: 1.7
2672##
ab916fad 2673{ 'alternate': 'BlockdevRef',
1ad166b6
BC
2674 'data': { 'definition': 'BlockdevOptions',
2675 'reference': 'str' } }
2676
2677##
2678# @blockdev-add:
2679#
be4b67bc
HR
2680# Creates a new block device. If the @id option is given at the top level, a
2681# BlockBackend will be created; otherwise, @node-name is mandatory at the top
2682# level and no BlockBackend will be created.
1ad166b6 2683#
7a305384
MAL
2684# For the arguments, see the documentation of BlockdevOptions.
2685#
2686# Note: This command is still a work in progress. It doesn't support all
81b936ae
AG
2687# block drivers among other things. Stay away from it unless you want
2688# to help with its development.
da2cf4e8 2689#
1ad166b6
BC
2690# Since: 1.7
2691##
0153d2f5 2692{ 'command': 'blockdev-add', 'data': 'BlockdevOptions', 'boxed': true }
1ad166b6 2693
81b936ae
AG
2694##
2695# @x-blockdev-del:
2696#
2697# Deletes a block device that has been added using blockdev-add.
9ec8873e
KW
2698# The command will fail if the node is attached to a device or is
2699# otherwise being used.
81b936ae 2700#
7a305384
MAL
2701# @node-name: Name of the graph node to delete.
2702#
2703# Note: This command is still a work in progress and is considered
81b936ae
AG
2704# experimental. Stay away from it unless you want to help with its
2705# development.
2706#
81b936ae
AG
2707# Since: 2.5
2708##
9ec8873e 2709{ 'command': 'x-blockdev-del', 'data': { 'node-name': 'str' } }
81b936ae 2710
7d8a9f71
HR
2711##
2712# @blockdev-open-tray:
2713#
2714# Opens a block device's tray. If there is a block driver state tree inserted as
2715# a medium, it will become inaccessible to the guest (but it will remain
2716# associated to the block device, so closing the tray will make it accessible
2717# again).
2718#
2719# If the tray was already open before, this will be a no-op.
2720#
2721# Once the tray opens, a DEVICE_TRAY_MOVED event is emitted. There are cases in
2722# which no such event will be generated, these include:
2723# - if the guest has locked the tray, @force is false and the guest does not
2724# respond to the eject request
2725# - if the BlockBackend denoted by @device does not have a guest device attached
2726# to it
12c7ec87 2727# - if the guest device does not have an actual tray
7d8a9f71 2728#
b33945cf
KW
2729# @device: #optional Block device name (deprecated, use @id instead)
2730#
2731# @id: #optional The name or QOM path of the guest device (since: 2.8)
7d8a9f71
HR
2732#
2733# @force: #optional if false (the default), an eject request will be sent to
2734# the guest if it has locked the tray (and the tray will not be opened
2735# immediately); if true, the tray will be opened regardless of whether
2736# it is locked
2737#
2738# Since: 2.5
2739##
2740{ 'command': 'blockdev-open-tray',
b33945cf
KW
2741 'data': { '*device': 'str',
2742 '*id': 'str',
7d8a9f71
HR
2743 '*force': 'bool' } }
2744
abaaf59d
HR
2745##
2746# @blockdev-close-tray:
2747#
2748# Closes a block device's tray. If there is a block driver state tree associated
2749# with the block device (which is currently ejected), that tree will be loaded
2750# as the medium.
2751#
2752# If the tray was already closed before, this will be a no-op.
2753#
b33945cf
KW
2754# @device: #optional Block device name (deprecated, use @id instead)
2755#
2756# @id: #optional The name or QOM path of the guest device (since: 2.8)
abaaf59d
HR
2757#
2758# Since: 2.5
2759##
2760{ 'command': 'blockdev-close-tray',
b33945cf
KW
2761 'data': { '*device': 'str',
2762 '*id': 'str' } }
abaaf59d 2763
2814f672 2764##
6e0abc25 2765# @x-blockdev-remove-medium:
2814f672
HR
2766#
2767# Removes a medium (a block driver state tree) from a block device. That block
2768# device's tray must currently be open (unless there is no attached guest
2769# device).
2770#
2771# If the tray is open and there is no medium inserted, this will be a no-op.
2772#
00949bab
KW
2773# @device: #optional Block device name (deprecated, use @id instead)
2774#
2775# @id: #optional The name or QOM path of the guest device (since: 2.8)
2814f672 2776#
7a305384
MAL
2777# Note: This command is still a work in progress and is considered experimental.
2778# Stay away from it unless you want to help with its development.
2779#
2814f672
HR
2780# Since: 2.5
2781##
6e0abc25 2782{ 'command': 'x-blockdev-remove-medium',
00949bab
KW
2783 'data': { '*device': 'str',
2784 '*id': 'str' } }
2814f672 2785
d1299882 2786##
6e0abc25 2787# @x-blockdev-insert-medium:
d1299882
HR
2788#
2789# Inserts a medium (a block driver state tree) into a block device. That block
2790# device's tray must currently be open (unless there is no attached guest
2791# device) and there must be no medium inserted already.
2792#
716df217
KW
2793# @device: #optional Block device name (deprecated, use @id instead)
2794#
2795# @id: #optional The name or QOM path of the guest device (since: 2.8)
d1299882
HR
2796#
2797# @node-name: name of a node in the block driver state graph
2798#
7a305384
MAL
2799# Note: This command is still a work in progress and is considered experimental.
2800# Stay away from it unless you want to help with its development.
2801#
d1299882
HR
2802# Since: 2.5
2803##
6e0abc25 2804{ 'command': 'x-blockdev-insert-medium',
716df217
KW
2805 'data': { '*device': 'str',
2806 '*id': 'str',
d1299882
HR
2807 'node-name': 'str'} }
2808
a589569f 2809
39ff43d9
HR
2810##
2811# @BlockdevChangeReadOnlyMode:
2812#
2813# Specifies the new read-only mode of a block device subject to the
2814# @blockdev-change-medium command.
2815#
2816# @retain: Retains the current read-only mode
2817#
2818# @read-only: Makes the device read-only
2819#
2820# @read-write: Makes the device writable
2821#
2822# Since: 2.3
2823##
2824{ 'enum': 'BlockdevChangeReadOnlyMode',
2825 'data': ['retain', 'read-only', 'read-write'] }
2826
2827
24fb4133
HR
2828##
2829# @blockdev-change-medium:
2830#
2831# Changes the medium inserted into a block device by ejecting the current medium
2832# and loading a new image file which is inserted as the new medium (this command
6e0abc25
HR
2833# combines blockdev-open-tray, x-blockdev-remove-medium,
2834# x-blockdev-insert-medium and blockdev-close-tray).
24fb4133 2835#
70e2cb3b
KW
2836# @device: #optional Block device name (deprecated, use @id instead)
2837#
2838# @id: #optional The name or QOM path of the guest device
2839# (since: 2.8)
24fb4133
HR
2840#
2841# @filename: filename of the new image to be loaded
2842#
2843# @format: #optional, format to open the new image with (defaults to
2844# the probed format)
2845#
39ff43d9
HR
2846# @read-only-mode: #optional, change the read-only mode of the device; defaults
2847# to 'retain'
2848#
24fb4133
HR
2849# Since: 2.5
2850##
2851{ 'command': 'blockdev-change-medium',
70e2cb3b
KW
2852 'data': { '*device': 'str',
2853 '*id': 'str',
24fb4133 2854 'filename': 'str',
39ff43d9
HR
2855 '*format': 'str',
2856 '*read-only-mode': 'BlockdevChangeReadOnlyMode' } }
24fb4133
HR
2857
2858
a589569f 2859##
5072f7b3 2860# @BlockErrorAction:
a589569f
WX
2861#
2862# An enumeration of action that has been taken when a DISK I/O occurs
2863#
2864# @ignore: error has been ignored
2865#
2866# @report: error has been reported to the device
2867#
2868# @stop: error caused VM to be stopped
2869#
2870# Since: 2.1
2871##
2872{ 'enum': 'BlockErrorAction',
2873 'data': [ 'ignore', 'report', 'stop' ] }
5a2d2cbd
WX
2874
2875
c120f0fa 2876##
5072f7b3 2877# @BLOCK_IMAGE_CORRUPTED:
c120f0fa 2878#
9bf040b9 2879# Emitted when a corruption has been detected in a disk image
c120f0fa 2880#
dc881b44
AG
2881# @device: device name. This is always present for compatibility
2882# reasons, but it can be empty ("") if the image does not
2883# have a device name associated.
2884#
2885# @node-name: #optional node name (Since: 2.4)
c120f0fa
WX
2886#
2887# @msg: informative message for human consumption, such as the kind of
2f44a08b
WX
2888# corruption being detected. It should not be parsed by machine as it is
2889# not guaranteed to be stable
c120f0fa
WX
2890#
2891# @offset: #optional, if the corruption resulted from an image access, this is
0caef8f6 2892# the host's access offset into the image
c120f0fa
WX
2893#
2894# @size: #optional, if the corruption resulted from an image access, this is
2895# the access size
2896#
9bf040b9
HR
2897# fatal: if set, the image is marked corrupt and therefore unusable after this
2898# event and must be repaired (Since 2.2; before, every
2899# BLOCK_IMAGE_CORRUPTED event was fatal)
2900#
c120f0fa
WX
2901# Since: 1.7
2902##
2903{ 'event': 'BLOCK_IMAGE_CORRUPTED',
dc881b44
AG
2904 'data': { 'device' : 'str',
2905 '*node-name' : 'str',
2906 'msg' : 'str',
2907 '*offset' : 'int',
2908 '*size' : 'int',
2909 'fatal' : 'bool' } }
c120f0fa 2910
5a2d2cbd 2911##
5072f7b3 2912# @BLOCK_IO_ERROR:
5a2d2cbd
WX
2913#
2914# Emitted when a disk I/O error occurs
2915#
2bf7e10f
KW
2916# @device: device name. This is always present for compatibility
2917# reasons, but it can be empty ("") if the image does not
2918# have a device name associated.
2919#
2920# @node-name: node name. Note that errors may be reported for the root node
2921# that is directly attached to a guest device rather than for the
2922# node where the error occurred. (Since: 2.8)
5a2d2cbd
WX
2923#
2924# @operation: I/O operation
2925#
2926# @action: action that has been taken
2927#
c7c2ff0c
LC
2928# @nospace: #optional true if I/O error was caused due to a no-space
2929# condition. This key is only present if query-block's
2930# io-status is present, please see query-block documentation
2931# for more information (since: 2.2)
2932#
624ff573
LC
2933# @reason: human readable string describing the error cause.
2934# (This field is a debugging aid for humans, it should not
2935# be parsed by applications) (since: 2.2)
2936#
5a2d2cbd
WX
2937# Note: If action is "stop", a STOP event will eventually follow the
2938# BLOCK_IO_ERROR event
2939#
2940# Since: 0.13.0
2941##
2942{ 'event': 'BLOCK_IO_ERROR',
2bf7e10f 2943 'data': { 'device': 'str', 'node-name': 'str', 'operation': 'IoOperationType',
624ff573
LC
2944 'action': 'BlockErrorAction', '*nospace': 'bool',
2945 'reason': 'str' } }
5a2d2cbd 2946
bcada37b 2947##
5072f7b3 2948# @BLOCK_JOB_COMPLETED:
bcada37b
WX
2949#
2950# Emitted when a block job has completed
2951#
2952# @type: job type
2953#
6aae5be6
AG
2954# @device: The job identifier. Originally the device name but other
2955# values are allowed since QEMU 2.7
bcada37b
WX
2956#
2957# @len: maximum progress value
2958#
2959# @offset: current progress value. On success this is equal to len.
2960# On failure this is less than len
2961#
2962# @speed: rate limit, bytes per second
2963#
2964# @error: #optional, error message. Only present on failure. This field
2965# contains a human-readable error message. There are no semantics
2966# other than that streaming has failed and clients should not try to
2967# interpret the error string
2968#
2969# Since: 1.1
2970##
2971{ 'event': 'BLOCK_JOB_COMPLETED',
2972 'data': { 'type' : 'BlockJobType',
2973 'device': 'str',
2974 'len' : 'int',
2975 'offset': 'int',
2976 'speed' : 'int',
2977 '*error': 'str' } }
2978
2979##
5072f7b3 2980# @BLOCK_JOB_CANCELLED:
bcada37b
WX
2981#
2982# Emitted when a block job has been cancelled
2983#
2984# @type: job type
2985#
6aae5be6
AG
2986# @device: The job identifier. Originally the device name but other
2987# values are allowed since QEMU 2.7
bcada37b
WX
2988#
2989# @len: maximum progress value
2990#
2991# @offset: current progress value. On success this is equal to len.
2992# On failure this is less than len
2993#
2994# @speed: rate limit, bytes per second
2995#
2996# Since: 1.1
2997##
2998{ 'event': 'BLOCK_JOB_CANCELLED',
2999 'data': { 'type' : 'BlockJobType',
3000 'device': 'str',
3001 'len' : 'int',
3002 'offset': 'int',
3003 'speed' : 'int' } }
3004
5a2d2cbd 3005##
5072f7b3 3006# @BLOCK_JOB_ERROR:
5a2d2cbd
WX
3007#
3008# Emitted when a block job encounters an error
3009#
6aae5be6
AG
3010# @device: The job identifier. Originally the device name but other
3011# values are allowed since QEMU 2.7
5a2d2cbd
WX
3012#
3013# @operation: I/O operation
3014#
3015# @action: action that has been taken
3016#
3017# Since: 1.3
3018##
3019{ 'event': 'BLOCK_JOB_ERROR',
3020 'data': { 'device' : 'str',
3021 'operation': 'IoOperationType',
823c6863 3022 'action' : 'BlockErrorAction' } }
bcada37b
WX
3023
3024##
5072f7b3 3025# @BLOCK_JOB_READY:
bcada37b
WX
3026#
3027# Emitted when a block job is ready to complete
3028#
518848a2
MA
3029# @type: job type
3030#
6aae5be6
AG
3031# @device: The job identifier. Originally the device name but other
3032# values are allowed since QEMU 2.7
bcada37b 3033#
518848a2
MA
3034# @len: maximum progress value
3035#
3036# @offset: current progress value. On success this is equal to len.
3037# On failure this is less than len
3038#
3039# @speed: rate limit, bytes per second
3040#
bcada37b
WX
3041# Note: The "ready to complete" status is always reset by a @BLOCK_JOB_ERROR
3042# event
3043#
3044# Since: 1.3
3045##
3046{ 'event': 'BLOCK_JOB_READY',
518848a2
MA
3047 'data': { 'type' : 'BlockJobType',
3048 'device': 'str',
3049 'len' : 'int',
3050 'offset': 'int',
3051 'speed' : 'int' } }
ffeaac9b 3052
49687ace 3053##
5072f7b3 3054# @PreallocMode:
ffeaac9b
HT
3055#
3056# Preallocation mode of QEMU image file
3057#
3058# @off: no preallocation
3059# @metadata: preallocate only for metadata
3060# @falloc: like @full preallocation but allocate disk space by
3061# posix_fallocate() rather than writing zeros.
3062# @full: preallocate all data by writing zeros to device to ensure disk
3063# space is really available. @full preallocation also sets up
3064# metadata correctly.
3065#
5072f7b3 3066# Since: 2.2
ffeaac9b
HT
3067##
3068{ 'enum': 'PreallocMode',
3069 'data': [ 'off', 'metadata', 'falloc', 'full' ] }
e2462113
FR
3070
3071##
5072f7b3 3072# @BLOCK_WRITE_THRESHOLD:
e2462113
FR
3073#
3074# Emitted when writes on block device reaches or exceeds the
3075# configured write threshold. For thin-provisioned devices, this
3076# means the device should be extended to avoid pausing for
3077# disk exhaustion.
3078# The event is one shot. Once triggered, it needs to be
3079# re-registered with another block-set-threshold command.
3080#
3081# @node-name: graph node name on which the threshold was exceeded.
3082#
3083# @amount-exceeded: amount of data which exceeded the threshold, in bytes.
3084#
3085# @write-threshold: last configured threshold, in bytes.
3086#
3087# Since: 2.3
3088##
3089{ 'event': 'BLOCK_WRITE_THRESHOLD',
3090 'data': { 'node-name': 'str',
3091 'amount-exceeded': 'uint64',
3092 'write-threshold': 'uint64' } }
3093
3094##
5072f7b3 3095# @block-set-write-threshold:
e2462113
FR
3096#
3097# Change the write threshold for a block drive. An event will be delivered
3098# if a write to this block drive crosses the configured threshold.
3099# This is useful to transparently resize thin-provisioned drives without
3100# the guest OS noticing.
3101#
3102# @node-name: graph node name on which the threshold must be set.
3103#
3104# @write-threshold: configured threshold for the block device, bytes.
3105# Use 0 to disable the threshold.
3106#
e2462113
FR
3107# Since: 2.3
3108##
3109{ 'command': 'block-set-write-threshold',
3110 'data': { 'node-name': 'str', 'write-threshold': 'uint64' } }
7f821597
WC
3111
3112##
5072f7b3 3113# @x-blockdev-change:
7f821597
WC
3114#
3115# Dynamically reconfigure the block driver state graph. It can be used
3116# to add, remove, insert or replace a graph node. Currently only the
3117# Quorum driver implements this feature to add or remove its child. This
3118# is useful to fix a broken quorum child.
3119#
3120# If @node is specified, it will be inserted under @parent. @child
3121# may not be specified in this case. If both @parent and @child are
3122# specified but @node is not, @child will be detached from @parent.
3123#
3124# @parent: the id or name of the parent node.
3125#
3126# @child: #optional the name of a child under the given parent node.
3127#
3128# @node: #optional the name of the node that will be added.
3129#
3130# Note: this command is experimental, and its API is not stable. It
3131# does not support all kinds of operations, all kinds of children, nor
3132# all block drivers.
3133#
3134# Warning: The data in a new quorum child MUST be consistent with that of
3135# the rest of the array.
3136#
3137# Since: 2.7
3138##
3139{ 'command': 'x-blockdev-change',
3140 'data' : { 'parent': 'str',
3141 '*child': 'str',
3142 '*node': 'str' } }