]> git.ipfire.org Git - thirdparty/qemu.git/blame - qapi/block-core.json
commit: Add filter-node-name to block-commit
[thirdparty/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.
f44fb58f 1270# If not specified, this is the deepest backing image.
1ad166b6 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#
0db832f4
KW
1307# @filter-node-name: #optional the node name that should be assigned to the
1308# filter driver that the commit job inserts into the graph
1309# above @top. If this option is not given, a node name is
1310# autogenerated. (Since: 2.9)
1311#
1ad166b6
BC
1312# Returns: Nothing on success
1313# If commit or stream is already active on this device, DeviceInUse
1314# If @device does not exist, DeviceNotFound
1315# If image commit is not supported by this device, NotSupported
1316# If @base or @top is invalid, a generic error is returned
1317# If @speed is invalid, InvalidParameter
1318#
1319# Since: 1.3
1320#
f44fb58f
MAL
1321# Example:
1322#
1323# -> { "execute": "block-commit",
1324# "arguments": { "device": "virtio0",
1325# "top": "/tmp/snap1.qcow2" } }
1326# <- { "return": {} }
1327#
1ad166b6
BC
1328##
1329{ 'command': 'block-commit',
fd62c609 1330 'data': { '*job-id': 'str', 'device': 'str', '*base': 'str', '*top': 'str',
0db832f4
KW
1331 '*backing-file': 'str', '*speed': 'int',
1332 '*filter-node-name': 'str' } }
1ad166b6
BC
1333
1334##
5072f7b3 1335# @drive-backup:
1ad166b6
BC
1336#
1337# Start a point-in-time copy of a block device to a new destination. The
1338# status of ongoing drive-backup operations can be checked with
1339# query-block-jobs where the BlockJobInfo.type field has the value 'backup'.
1340# The operation can be stopped before it has completed using the
1341# block-job-cancel command.
1342#
1343# For the arguments, see the documentation of DriveBackup.
1344#
1345# Returns: nothing on success
b7e4fa22 1346# If @device is not a valid block device, GenericError
1ad166b6 1347#
5072f7b3 1348# Since: 1.6
b0336412
MAL
1349#
1350# Example:
1351#
1352# -> { "execute": "drive-backup",
1353# "arguments": { "device": "drive0",
1354# "sync": "full",
1355# "target": "backup.img" } }
1356# <- { "return": {} }
1357#
1ad166b6 1358##
81206a89
PB
1359{ 'command': 'drive-backup', 'boxed': true,
1360 'data': 'DriveBackup' }
1ad166b6 1361
c29c1dd3 1362##
5072f7b3 1363# @blockdev-backup:
c29c1dd3
FZ
1364#
1365# Start a point-in-time copy of a block device to a new destination. The
1366# status of ongoing blockdev-backup operations can be checked with
1367# query-block-jobs where the BlockJobInfo.type field has the value 'backup'.
1368# The operation can be stopped before it has completed using the
1369# block-job-cancel command.
1370#
1371# For the arguments, see the documentation of BlockdevBackup.
1372#
dc7a4a9e
PB
1373# Returns: nothing on success
1374# If @device is not a valid block device, DeviceNotFound
1375#
5072f7b3 1376# Since: 2.3
1cf75113
MAL
1377#
1378# Example:
1379# -> { "execute": "blockdev-backup",
1380# "arguments": { "device": "src-id",
1381# "sync": "full",
1382# "target": "tgt-id" } }
1383# <- { "return": {} }
1384#
c29c1dd3 1385##
dc7a4a9e
PB
1386{ 'command': 'blockdev-backup', 'boxed': true,
1387 'data': 'BlockdevBackup' }
c29c1dd3
FZ
1388
1389
1ad166b6 1390##
5072f7b3 1391# @query-named-block-nodes:
1ad166b6
BC
1392#
1393# Get the named block driver list
1394#
1395# Returns: the list of BlockDeviceInfo
1396#
5072f7b3 1397# Since: 2.0
e1f34cb2
MAL
1398#
1399# Example:
1400#
1401# -> { "execute": "query-named-block-nodes" }
1402# <- { "return": [ { "ro":false,
1403# "drv":"qcow2",
1404# "encrypted":false,
1405# "file":"disks/test.qcow2",
1406# "node-name": "my-node",
1407# "backing_file_depth":1,
1408# "bps":1000000,
1409# "bps_rd":0,
1410# "bps_wr":0,
1411# "iops":1000000,
1412# "iops_rd":0,
1413# "iops_wr":0,
1414# "bps_max": 8000000,
1415# "bps_rd_max": 0,
1416# "bps_wr_max": 0,
1417# "iops_max": 0,
1418# "iops_rd_max": 0,
1419# "iops_wr_max": 0,
1420# "iops_size": 0,
1421# "write_threshold": 0,
1422# "image":{
1423# "filename":"disks/test.qcow2",
1424# "format":"qcow2",
1425# "virtual-size":2048000,
1426# "backing_file":"base.qcow2",
1427# "full-backing-filename":"disks/base.qcow2",
1428# "backing-filename-format":"qcow2",
1429# "snapshots":[
1430# {
1431# "id": "1",
1432# "name": "snapshot1",
1433# "vm-state-size": 0,
1434# "date-sec": 10000200,
1435# "date-nsec": 12,
1436# "vm-clock-sec": 206,
1437# "vm-clock-nsec": 30
1438# }
1439# ],
1440# "backing-image":{
1441# "filename":"disks/base.qcow2",
1442# "format":"qcow2",
1443# "virtual-size":2048000
1444# }
1445# } } ] }
1446#
1ad166b6
BC
1447##
1448{ 'command': 'query-named-block-nodes', 'returns': [ 'BlockDeviceInfo' ] }
1449
1450##
5072f7b3 1451# @drive-mirror:
1ad166b6 1452#
12a21b73
MAL
1453# Start mirroring a block device's writes to a new destination. target
1454# specifies the target of the new image. If the file exists, or if it
1455# is a device, it will be used as the new destination for writes. If
1456# it does not exist, a new file will be created. format specifies the
1457# format of the mirror image, default is to probe if mode='existing',
1458# else the format of the source.
1ad166b6 1459#
faecd40a
EB
1460# See DriveMirror for parameter descriptions
1461#
1462# Returns: nothing on success
0524e93a 1463# If @device is not a valid block device, GenericError
faecd40a 1464#
5072f7b3 1465# Since: 1.3
12a21b73
MAL
1466#
1467# Example:
1468#
1469# -> { "execute": "drive-mirror",
1470# "arguments": { "device": "ide-hd0",
1471# "target": "/some/place/my-image",
1472# "sync": "full",
1473# "format": "qcow2" } }
1474# <- { "return": {} }
1475#
faecd40a
EB
1476##
1477{ 'command': 'drive-mirror', 'boxed': true,
1478 'data': 'DriveMirror' }
1479
1480##
5072f7b3 1481# @DriveMirror:
faecd40a
EB
1482#
1483# A set of parameters describing drive mirror setup.
1484#
71aa9867
AG
1485# @job-id: #optional identifier for the newly-created block job. If
1486# omitted, the device name will be used. (Since 2.7)
1487#
0524e93a
KW
1488# @device: the device name or node-name of a root node whose writes should be
1489# mirrored.
1ad166b6
BC
1490#
1491# @target: the target of the new image. If the file exists, or if it
1492# is a device, the existing file/device will be used as the new
1493# destination. If it does not exist, a new file will be created.
1494#
1495# @format: #optional the format of the new destination, default is to
1496# probe if @mode is 'existing', else the format of the source
1497#
4c828dc6
BC
1498# @node-name: #optional the new block driver state node name in the graph
1499# (Since 2.1)
1500#
09158f00
BC
1501# @replaces: #optional with sync=full graph node name to be replaced by the new
1502# image when a whole image copy is done. This can be used to repair
1503# broken Quorum files. (Since 2.1)
1504#
1ad166b6
BC
1505# @mode: #optional whether and how QEMU should create a new image, default is
1506# 'absolute-paths'.
1507#
1508# @speed: #optional the maximum speed, in bytes per second
1509#
1510# @sync: what parts of the disk image should be copied to the destination
1511# (all the disk, only the sectors allocated in the topmost image, or
1512# only new I/O).
1513#
1514# @granularity: #optional granularity of the dirty bitmap, default is 64K
1515# if the image format doesn't have clusters, 4K if the clusters
1516# are smaller than that, else the cluster size. Must be a
1517# power of 2 between 512 and 64M (since 1.4).
1518#
1519# @buf-size: #optional maximum amount of data in flight from source to
1520# target (since 1.4).
1521#
1522# @on-source-error: #optional the action to take on an error on the source,
1523# default 'report'. 'stop' and 'enospc' can only be used
1524# if the block device supports io-status (see BlockInfo).
1525#
1526# @on-target-error: #optional the action to take on an error on the target,
1527# default 'report' (no limitations, since this applies to
1528# a different block device than @device).
0fc9f8ea
FZ
1529# @unmap: #optional Whether to try to unmap target sectors where source has
1530# only zero. If true, and target unallocated sectors will read as zero,
1531# target image sectors will be unmapped; otherwise, zeroes will be
1532# written. Both will result in identical contents.
1533# Default is true. (Since 2.4)
1ad166b6 1534#
5072f7b3 1535# Since: 1.3
1ad166b6 1536##
faecd40a 1537{ 'struct': 'DriveMirror',
71aa9867
AG
1538 'data': { '*job-id': 'str', 'device': 'str', 'target': 'str',
1539 '*format': 'str', '*node-name': 'str', '*replaces': 'str',
1ad166b6
BC
1540 'sync': 'MirrorSyncMode', '*mode': 'NewImageMode',
1541 '*speed': 'int', '*granularity': 'uint32',
1542 '*buf-size': 'int', '*on-source-error': 'BlockdevOnError',
0fc9f8ea
FZ
1543 '*on-target-error': 'BlockdevOnError',
1544 '*unmap': 'bool' } }
1ad166b6 1545
341ebc2f 1546##
5072f7b3 1547# @BlockDirtyBitmap:
341ebc2f
JS
1548#
1549# @node: name of device/node which the bitmap is tracking
1550#
1551# @name: name of the dirty bitmap
1552#
5072f7b3 1553# Since: 2.4
341ebc2f 1554##
895a2a80 1555{ 'struct': 'BlockDirtyBitmap',
341ebc2f
JS
1556 'data': { 'node': 'str', 'name': 'str' } }
1557
1558##
5072f7b3 1559# @BlockDirtyBitmapAdd:
341ebc2f
JS
1560#
1561# @node: name of device/node which the bitmap is tracking
1562#
1563# @name: name of the dirty bitmap
1564#
1565# @granularity: #optional the bitmap granularity, default is 64k for
1566# block-dirty-bitmap-add
1567#
5072f7b3 1568# Since: 2.4
341ebc2f 1569##
895a2a80 1570{ 'struct': 'BlockDirtyBitmapAdd',
341ebc2f
JS
1571 'data': { 'node': 'str', 'name': 'str', '*granularity': 'uint32' } }
1572
1573##
5072f7b3 1574# @block-dirty-bitmap-add:
341ebc2f 1575#
2258a5db 1576# Create a dirty bitmap with a name on the node, and start tracking the writes.
341ebc2f
JS
1577#
1578# Returns: nothing on success
1579# If @node is not a valid block device or node, DeviceNotFound
1580# If @name is already taken, GenericError with an explanation
1581#
5072f7b3 1582# Since: 2.4
2258a5db
MAL
1583#
1584# Example:
1585#
1586# -> { "execute": "block-dirty-bitmap-add",
1587# "arguments": { "node": "drive0", "name": "bitmap0" } }
1588# <- { "return": {} }
1589#
341ebc2f
JS
1590##
1591{ 'command': 'block-dirty-bitmap-add',
1592 'data': 'BlockDirtyBitmapAdd' }
1593
1594##
5072f7b3 1595# @block-dirty-bitmap-remove:
341ebc2f 1596#
4bbca422
MAL
1597# Stop write tracking and remove the dirty bitmap that was created
1598# with block-dirty-bitmap-add.
341ebc2f
JS
1599#
1600# Returns: nothing on success
1601# If @node is not a valid block device or node, DeviceNotFound
1602# If @name is not found, GenericError with an explanation
9bd2b08f 1603# if @name is frozen by an operation, GenericError
341ebc2f 1604#
5072f7b3 1605# Since: 2.4
4bbca422
MAL
1606#
1607# Example:
1608#
1609# -> { "execute": "block-dirty-bitmap-remove",
1610# "arguments": { "node": "drive0", "name": "bitmap0" } }
1611# <- { "return": {} }
1612#
341ebc2f
JS
1613##
1614{ 'command': 'block-dirty-bitmap-remove',
1615 'data': 'BlockDirtyBitmap' }
1616
e74e6b78 1617##
5072f7b3 1618# @block-dirty-bitmap-clear:
e74e6b78 1619#
73dffdc8
MAL
1620# Clear (reset) a dirty bitmap on the device, so that an incremental
1621# backup from this point in time forward will only backup clusters
1622# modified after this clear operation.
e74e6b78
JS
1623#
1624# Returns: nothing on success
1625# If @node is not a valid block device, DeviceNotFound
1626# If @name is not found, GenericError with an explanation
1627#
5072f7b3 1628# Since: 2.4
73dffdc8
MAL
1629#
1630# Example:
1631#
1632# -> { "execute": "block-dirty-bitmap-clear",
1633# "arguments": { "node": "drive0", "name": "bitmap0" } }
1634# <- { "return": {} }
1635#
e74e6b78
JS
1636##
1637{ 'command': 'block-dirty-bitmap-clear',
1638 'data': 'BlockDirtyBitmap' }
1639
df92562e 1640##
5072f7b3 1641# @blockdev-mirror:
df92562e
FZ
1642#
1643# Start mirroring a block device's writes to a new destination.
1644#
71aa9867
AG
1645# @job-id: #optional identifier for the newly-created block job. If
1646# omitted, the device name will be used. (Since 2.7)
1647#
07eec652
KW
1648# @device: The device name or node-name of a root node whose writes should be
1649# mirrored.
df92562e
FZ
1650#
1651# @target: the id or node-name of the block device to mirror to. This mustn't be
1652# attached to guest.
1653#
1654# @replaces: #optional with sync=full graph node name to be replaced by the new
1655# image when a whole image copy is done. This can be used to repair
1656# broken Quorum files.
1657#
1658# @speed: #optional the maximum speed, in bytes per second
1659#
1660# @sync: what parts of the disk image should be copied to the destination
1661# (all the disk, only the sectors allocated in the topmost image, or
1662# only new I/O).
1663#
1664# @granularity: #optional granularity of the dirty bitmap, default is 64K
1665# if the image format doesn't have clusters, 4K if the clusters
1666# are smaller than that, else the cluster size. Must be a
1667# power of 2 between 512 and 64M
1668#
1669# @buf-size: #optional maximum amount of data in flight from source to
1670# target
1671#
1672# @on-source-error: #optional the action to take on an error on the source,
1673# default 'report'. 'stop' and 'enospc' can only be used
1674# if the block device supports io-status (see BlockInfo).
1675#
1676# @on-target-error: #optional the action to take on an error on the target,
1677# default 'report' (no limitations, since this applies to
1678# a different block device than @device).
1679#
6cdbceb1
KW
1680# @filter-node-name: #optional the node name that should be assigned to the
1681# filter driver that the mirror job inserts into the graph
1682# above @device. If this option is not given, a node name is
1683# autogenerated. (Since: 2.9)
1684#
df92562e
FZ
1685# Returns: nothing on success.
1686#
5072f7b3 1687# Since: 2.6
f6235a25
MAL
1688#
1689# Example:
1690#
1691# -> { "execute": "blockdev-mirror",
1692# "arguments": { "device": "ide-hd0",
1693# "target": "target0",
1694# "sync": "full" } }
1695# <- { "return": {} }
1696#
df92562e
FZ
1697##
1698{ 'command': 'blockdev-mirror',
71aa9867 1699 'data': { '*job-id': 'str', 'device': 'str', 'target': 'str',
df92562e
FZ
1700 '*replaces': 'str',
1701 'sync': 'MirrorSyncMode',
1702 '*speed': 'int', '*granularity': 'uint32',
1703 '*buf-size': 'int', '*on-source-error': 'BlockdevOnError',
6cdbceb1
KW
1704 '*on-target-error': 'BlockdevOnError',
1705 '*filter-node-name': 'str' } }
df92562e 1706
1ad166b6
BC
1707##
1708# @block_set_io_throttle:
1709#
1710# Change I/O throttle limits for a block drive.
1711#
76f4afb4
AG
1712# Since QEMU 2.4, each device with I/O limits is member of a throttle
1713# group.
1714#
1715# If two or more devices are members of the same group, the limits
1716# will apply to the combined I/O of the whole group in a round-robin
1717# fashion. Therefore, setting new I/O limits to a device will affect
1718# the whole group.
1719#
1720# The name of the group can be specified using the 'group' parameter.
1721# If the parameter is unset, it is assumed to be the current group of
1722# that device. If it's not in any group yet, the name of the device
1723# will be used as the name for its group.
1724#
1725# The 'group' parameter can also be used to move a device to a
1726# different group. In this case the limits specified in the parameters
1727# will be applied to the new group only.
1728#
1729# I/O limits can be disabled by setting all of them to 0. In this case
1730# the device will be removed from its group and the rest of its
6b932c0a 1731# members will not be affected. The 'group' parameter is ignored.
76f4afb4 1732#
4dc9397b
EB
1733# See BlockIOThrottle for parameter descriptions.
1734#
1735# Returns: Nothing on success
1736# If @device is not a valid block device, DeviceNotFound
1737#
1738# Since: 1.1
b4a0ac14
MAL
1739#
1740# Example:
1741#
1742# -> { "execute": "block_set_io_throttle",
1743# "arguments": { "id": "ide0-1-0",
1744# "bps": 1000000,
1745# "bps_rd": 0,
1746# "bps_wr": 0,
1747# "iops": 0,
1748# "iops_rd": 0,
1749# "iops_wr": 0,
1750# "bps_max": 8000000,
1751# "bps_rd_max": 0,
1752# "bps_wr_max": 0,
1753# "iops_max": 0,
1754# "iops_rd_max": 0,
1755# "iops_wr_max": 0,
1756# "bps_max_length": 60,
1757# "iops_size": 0 } }
1758# <- { "return": {} }
4dc9397b
EB
1759##
1760{ 'command': 'block_set_io_throttle', 'boxed': true,
1761 'data': 'BlockIOThrottle' }
1762
1763##
5072f7b3 1764# @BlockIOThrottle:
4dc9397b
EB
1765#
1766# A set of parameters describing block throttling.
1767#
7a9877a0
KW
1768# @device: #optional Block device name (deprecated, use @id instead)
1769#
1770# @id: #optional The name or QOM path of the guest device (since: 2.8)
1ad166b6
BC
1771#
1772# @bps: total throughput limit in bytes per second
1773#
1774# @bps_rd: read throughput limit in bytes per second
1775#
1776# @bps_wr: write throughput limit in bytes per second
1777#
1778# @iops: total I/O operations per second
1779#
f5a845fd 1780# @iops_rd: read I/O operations per second
1ad166b6
BC
1781#
1782# @iops_wr: write I/O operations per second
1783#
dce13204
AG
1784# @bps_max: #optional total throughput limit during bursts,
1785# in bytes (Since 1.7)
1ad166b6 1786#
dce13204
AG
1787# @bps_rd_max: #optional read throughput limit during bursts,
1788# in bytes (Since 1.7)
1ad166b6 1789#
dce13204
AG
1790# @bps_wr_max: #optional write throughput limit during bursts,
1791# in bytes (Since 1.7)
1ad166b6 1792#
dce13204
AG
1793# @iops_max: #optional total I/O operations per second during bursts,
1794# in bytes (Since 1.7)
1ad166b6 1795#
dce13204
AG
1796# @iops_rd_max: #optional read I/O operations per second during bursts,
1797# in bytes (Since 1.7)
1ad166b6 1798#
dce13204
AG
1799# @iops_wr_max: #optional write I/O operations per second during bursts,
1800# in bytes (Since 1.7)
1801#
1802# @bps_max_length: #optional maximum length of the @bps_max burst
1803# period, in seconds. It must only
1804# be set if @bps_max is set as well.
1805# Defaults to 1. (Since 2.6)
1806#
1807# @bps_rd_max_length: #optional maximum length of the @bps_rd_max
1808# burst period, in seconds. It must only
1809# be set if @bps_rd_max is set as well.
1810# Defaults to 1. (Since 2.6)
1811#
1812# @bps_wr_max_length: #optional maximum length of the @bps_wr_max
1813# burst period, in seconds. It must only
1814# be set if @bps_wr_max is set as well.
1815# Defaults to 1. (Since 2.6)
1816#
1817# @iops_max_length: #optional maximum length of the @iops burst
1818# period, in seconds. It must only
1819# be set if @iops_max is set as well.
1820# Defaults to 1. (Since 2.6)
1821#
1822# @iops_rd_max_length: #optional maximum length of the @iops_rd_max
1823# burst period, in seconds. It must only
1824# be set if @iops_rd_max is set as well.
1825# Defaults to 1. (Since 2.6)
1826#
1827# @iops_wr_max_length: #optional maximum length of the @iops_wr_max
1828# burst period, in seconds. It must only
1829# be set if @iops_wr_max is set as well.
1830# Defaults to 1. (Since 2.6)
1ad166b6
BC
1831#
1832# @iops_size: #optional an I/O size in bytes (Since 1.7)
1833#
76f4afb4
AG
1834# @group: #optional throttle group name (Since 2.4)
1835#
1ad166b6
BC
1836# Since: 1.1
1837##
4dc9397b 1838{ 'struct': 'BlockIOThrottle',
7a9877a0
KW
1839 'data': { '*device': 'str', '*id': 'str', 'bps': 'int', 'bps_rd': 'int',
1840 'bps_wr': 'int', 'iops': 'int', 'iops_rd': 'int', 'iops_wr': 'int',
1ad166b6
BC
1841 '*bps_max': 'int', '*bps_rd_max': 'int',
1842 '*bps_wr_max': 'int', '*iops_max': 'int',
1843 '*iops_rd_max': 'int', '*iops_wr_max': 'int',
dce13204
AG
1844 '*bps_max_length': 'int', '*bps_rd_max_length': 'int',
1845 '*bps_wr_max_length': 'int', '*iops_max_length': 'int',
1846 '*iops_rd_max_length': 'int', '*iops_wr_max_length': 'int',
76f4afb4 1847 '*iops_size': 'int', '*group': 'str' } }
1ad166b6
BC
1848
1849##
1850# @block-stream:
1851#
1852# Copy data from a backing file into a block device.
1853#
1854# The block streaming operation is performed in the background until the entire
1855# backing file has been copied. This command returns immediately once streaming
1856# has started. The status of ongoing block streaming operations can be checked
1857# with query-block-jobs. The operation can be stopped before it has completed
1858# using the block-job-cancel command.
1859#
554b6147
AG
1860# The node that receives the data is called the top image, can be located in
1861# any part of the chain (but always above the base image; see below) and can be
1862# specified using its device or node name. Earlier qemu versions only allowed
1863# 'device' to name the top level node; presence of the 'base-node' parameter
1864# during introspection can be used as a witness of the enhanced semantics
1865# of 'device'.
1866#
1ad166b6
BC
1867# If a base file is specified then sectors are not copied from that base file and
1868# its backing chain. When streaming completes the image file will have the base
1869# file as its backing file. This can be used to stream a subset of the backing
1870# file chain instead of flattening the entire image.
1871#
1872# On successful completion the image file is updated to drop the backing file
1873# and the BLOCK_JOB_COMPLETED event is emitted.
1874#
2323322e
AG
1875# @job-id: #optional identifier for the newly-created block job. If
1876# omitted, the device name will be used. (Since 2.7)
1877#
554b6147 1878# @device: the device or node name of the top image
1ad166b6 1879#
312fe09c
AG
1880# @base: #optional the common backing file name.
1881# It cannot be set if @base-node is also set.
1882#
1883# @base-node: #optional the node name of the backing file.
1884# It cannot be set if @base is also set. (Since 2.8)
1ad166b6 1885#
554b6147
AG
1886# @backing-file: #optional The backing file string to write into the top
1887# image. This filename is not validated.
13d8cc51
JC
1888#
1889# If a pathname string is such that it cannot be
1890# resolved by QEMU, that means that subsequent QMP or
1891# HMP commands must use node-names for the image in
1892# question, as filename lookup methods will fail.
1893#
1894# If not specified, QEMU will automatically determine
1895# the backing file string to use, or error out if there
1896# is no obvious choice. Care should be taken when
1897# specifying the string, to specify a valid filename or
1898# protocol.
1899# (Since 2.1)
1900#
1ad166b6
BC
1901# @speed: #optional the maximum speed, in bytes per second
1902#
1903# @on-error: #optional the action to take on an error (default report).
1904# 'stop' and 'enospc' can only be used if the block device
1905# supports io-status (see BlockInfo). Since 1.3.
1906#
49b37c23
MAL
1907# Returns: Nothing on success. If @device does not exist, DeviceNotFound.
1908#
1ad166b6 1909# Since: 1.1
49b37c23
MAL
1910#
1911# Example:
1912#
1913# -> { "execute": "block-stream",
1914# "arguments": { "device": "virtio0",
1915# "base": "/tmp/master.qcow2" } }
1916# <- { "return": {} }
1917#
1ad166b6
BC
1918##
1919{ 'command': 'block-stream',
2323322e 1920 'data': { '*job-id': 'str', 'device': 'str', '*base': 'str',
312fe09c 1921 '*base-node': 'str', '*backing-file': 'str', '*speed': 'int',
2323322e 1922 '*on-error': 'BlockdevOnError' } }
1ad166b6
BC
1923
1924##
1925# @block-job-set-speed:
1926#
1927# Set maximum speed for a background block operation.
1928#
1929# This command can only be issued when there is an active block job.
1930#
1931# Throttling can be disabled by setting the speed to 0.
1932#
6aae5be6
AG
1933# @device: The job identifier. This used to be a device name (hence
1934# the name of the parameter), but since QEMU 2.7 it can have
1935# other values.
1ad166b6
BC
1936#
1937# @speed: the maximum speed, in bytes per second, or 0 for unlimited.
1938# Defaults to 0.
1939#
1940# Returns: Nothing on success
1941# If no background operation is active on this device, DeviceNotActive
1942#
1943# Since: 1.1
1944##
1945{ 'command': 'block-job-set-speed',
1946 'data': { 'device': 'str', 'speed': 'int' } }
1947
1948##
1949# @block-job-cancel:
1950#
1951# Stop an active background block operation.
1952#
1953# This command returns immediately after marking the active background block
1954# operation for cancellation. It is an error to call this command if no
1955# operation is in progress.
1956#
1957# The operation will cancel as soon as possible and then emit the
1958# BLOCK_JOB_CANCELLED event. Before that happens the job is still visible when
1959# enumerated using query-block-jobs.
1960#
1961# For streaming, the image file retains its backing file unless the streaming
1962# operation happens to complete just as it is being cancelled. A new streaming
1963# operation can be started at a later time to finish copying all data from the
1964# backing file.
1965#
6aae5be6
AG
1966# @device: The job identifier. This used to be a device name (hence
1967# the name of the parameter), but since QEMU 2.7 it can have
1968# other values.
1ad166b6
BC
1969#
1970# @force: #optional whether to allow cancellation of a paused job (default
1971# false). Since 1.3.
1972#
1973# Returns: Nothing on success
1974# If no background operation is active on this device, DeviceNotActive
1975#
1976# Since: 1.1
1977##
1978{ 'command': 'block-job-cancel', 'data': { 'device': 'str', '*force': 'bool' } }
1979
1980##
1981# @block-job-pause:
1982#
1983# Pause an active background block operation.
1984#
1985# This command returns immediately after marking the active background block
1986# operation for pausing. It is an error to call this command if no
1987# operation is in progress. Pausing an already paused job has no cumulative
1988# effect; a single block-job-resume command will resume the job.
1989#
1990# The operation will pause as soon as possible. No event is emitted when
1991# the operation is actually paused. Cancelling a paused job automatically
1992# resumes it.
1993#
6aae5be6
AG
1994# @device: The job identifier. This used to be a device name (hence
1995# the name of the parameter), but since QEMU 2.7 it can have
1996# other values.
1ad166b6
BC
1997#
1998# Returns: Nothing on success
1999# If no background operation is active on this device, DeviceNotActive
2000#
2001# Since: 1.3
2002##
2003{ 'command': 'block-job-pause', 'data': { 'device': 'str' } }
2004
2005##
2006# @block-job-resume:
2007#
2008# Resume an active background block operation.
2009#
2010# This command returns immediately after resuming a paused background block
2011# operation. It is an error to call this command if no operation is in
2012# progress. Resuming an already running job is not an error.
2013#
2014# This command also clears the error status of the job.
2015#
6aae5be6
AG
2016# @device: The job identifier. This used to be a device name (hence
2017# the name of the parameter), but since QEMU 2.7 it can have
2018# other values.
1ad166b6
BC
2019#
2020# Returns: Nothing on success
2021# If no background operation is active on this device, DeviceNotActive
2022#
2023# Since: 1.3
2024##
2025{ 'command': 'block-job-resume', 'data': { 'device': 'str' } }
2026
2027##
2028# @block-job-complete:
2029#
2030# Manually trigger completion of an active background block operation. This
2031# is supported for drive mirroring, where it also switches the device to
2032# write to the target path only. The ability to complete is signaled with
2033# a BLOCK_JOB_READY event.
2034#
2035# This command completes an active background block operation synchronously.
2036# The ordering of this command's return with the BLOCK_JOB_COMPLETED event
2037# is not defined. Note that if an I/O error occurs during the processing of
2038# this command: 1) the command itself will fail; 2) the error will be processed
2039# according to the rerror/werror arguments that were specified when starting
2040# the operation.
2041#
2042# A cancelled or paused job cannot be completed.
2043#
6aae5be6
AG
2044# @device: The job identifier. This used to be a device name (hence
2045# the name of the parameter), but since QEMU 2.7 it can have
2046# other values.
1ad166b6
BC
2047#
2048# Returns: Nothing on success
2049# If no background operation is active on this device, DeviceNotActive
2050#
2051# Since: 1.3
2052##
2053{ 'command': 'block-job-complete', 'data': { 'device': 'str' } }
2054
2055##
5072f7b3 2056# @BlockdevDiscardOptions:
1ad166b6
BC
2057#
2058# Determines how to handle discard requests.
2059#
2060# @ignore: Ignore the request
2061# @unmap: Forward as an unmap request
2062#
2063# Since: 1.7
2064##
2065{ 'enum': 'BlockdevDiscardOptions',
2066 'data': [ 'ignore', 'unmap' ] }
2067
2068##
5072f7b3 2069# @BlockdevDetectZeroesOptions:
1ad166b6
BC
2070#
2071# Describes the operation mode for the automatic conversion of plain
2072# zero writes by the OS to driver specific optimized zero write commands.
2073#
2074# @off: Disabled (default)
2075# @on: Enabled
2076# @unmap: Enabled and even try to unmap blocks if possible. This requires
2077# also that @BlockdevDiscardOptions is set to unmap for this device.
2078#
2079# Since: 2.1
2080##
2081{ 'enum': 'BlockdevDetectZeroesOptions',
2082 'data': [ 'off', 'on', 'unmap' ] }
2083
2084##
5072f7b3 2085# @BlockdevAioOptions:
1ad166b6
BC
2086#
2087# Selects the AIO backend to handle I/O requests
2088#
2089# @threads: Use qemu's thread pool
2090# @native: Use native AIO backend (only Linux and Windows)
2091#
2092# Since: 1.7
2093##
2094{ 'enum': 'BlockdevAioOptions',
2095 'data': [ 'threads', 'native' ] }
2096
2097##
5072f7b3 2098# @BlockdevCacheOptions:
1ad166b6
BC
2099#
2100# Includes cache-related options for block devices
2101#
1ad166b6
BC
2102# @direct: #optional enables use of O_DIRECT (bypass the host page cache;
2103# default: false)
2104# @no-flush: #optional ignore any flush requests for the device (default:
2105# false)
2106#
2107# Since: 1.7
2108##
895a2a80 2109{ 'struct': 'BlockdevCacheOptions',
aaa436f9 2110 'data': { '*direct': 'bool',
1ad166b6
BC
2111 '*no-flush': 'bool' } }
2112
2113##
5072f7b3 2114# @BlockdevDriver:
1ad166b6
BC
2115#
2116# Drivers that are supported in block device operations.
2117#
9f2a70e4
MAL
2118# @host_device: Since 2.1
2119# @host_cdrom: Since 2.1
0a189ffb 2120# @gluster: Since 2.7
9f2a70e4
MAL
2121# @nbd: Since 2.8
2122# @nfs: Since 2.8
2123# @replication: Since 2.8
2124# @ssh: Since 2.8
31eb1202 2125# @iscsi: Since 2.9
1ad166b6
BC
2126#
2127# Since: 2.0
2128##
2129{ 'enum': 'BlockdevDriver',
550830f9 2130 'data': [ 'archipelago', 'blkdebug', 'blkverify', 'bochs', 'cloop',
7edac2dd 2131 'dmg', 'file', 'ftp', 'ftps', 'gluster', 'host_cdrom',
31eb1202
KW
2132 'host_device', 'http', 'https', 'iscsi', 'luks', 'nbd', 'nfs',
2133 'null-aio', 'null-co', 'parallels', 'qcow', 'qcow2', 'qed',
2134 'quorum', 'raw', 'replication', 'ssh', 'vdi', 'vhdx', 'vmdk',
2135 'vpc', 'vvfat' ] }
1ad166b6 2136
1ad166b6 2137##
5072f7b3 2138# @BlockdevOptionsFile:
1ad166b6 2139#
68555285 2140# Driver specific block device options for the file backend.
1ad166b6
BC
2141#
2142# @filename: path to the image file
0a4279d9 2143# @aio: #optional AIO backend (default: threads) (since: 2.8)
1ad166b6
BC
2144#
2145# Since: 1.7
2146##
895a2a80 2147{ 'struct': 'BlockdevOptionsFile',
0a4279d9
KW
2148 'data': { 'filename': 'str',
2149 '*aio': 'BlockdevAioOptions' } }
1ad166b6 2150
e819ab22 2151##
5072f7b3 2152# @BlockdevOptionsNull:
e819ab22
FZ
2153#
2154# Driver specific block device options for the null backend.
2155#
2156# @size: #optional size of the device in bytes.
e5e51dd3
FZ
2157# @latency-ns: #optional emulated latency (in nanoseconds) in processing
2158# requests. Default to zero which completes requests immediately.
2159# (Since 2.4)
e819ab22
FZ
2160#
2161# Since: 2.2
2162##
895a2a80 2163{ 'struct': 'BlockdevOptionsNull',
e5e51dd3 2164 'data': { '*size': 'int', '*latency-ns': 'uint64' } }
e819ab22 2165
1ad166b6 2166##
5072f7b3 2167# @BlockdevOptionsVVFAT:
1ad166b6
BC
2168#
2169# Driver specific block device options for the vvfat protocol.
2170#
2171# @dir: directory to be exported as FAT image
2172# @fat-type: #optional FAT type: 12, 16 or 32
2173# @floppy: #optional whether to export a floppy image (true) or
2174# partitioned hard disk (false; default)
d5941dda
WB
2175# @label: #optional set the volume label, limited to 11 bytes. FAT16 and
2176# FAT32 traditionally have some restrictions on labels, which are
2177# ignored by most operating systems. Defaults to "QEMU VVFAT".
2178# (since 2.4)
1ad166b6
BC
2179# @rw: #optional whether to allow write operations (default: false)
2180#
2181# Since: 1.7
2182##
895a2a80 2183{ 'struct': 'BlockdevOptionsVVFAT',
1ad166b6 2184 'data': { 'dir': 'str', '*fat-type': 'int', '*floppy': 'bool',
d5941dda 2185 '*label': 'str', '*rw': 'bool' } }
1ad166b6
BC
2186
2187##
5072f7b3 2188# @BlockdevOptionsGenericFormat:
1ad166b6
BC
2189#
2190# Driver specific block device options for image format that have no option
2191# besides their data source.
2192#
2193# @file: reference to or definition of the data source block device
2194#
2195# Since: 1.7
2196##
895a2a80 2197{ 'struct': 'BlockdevOptionsGenericFormat',
1ad166b6
BC
2198 'data': { 'file': 'BlockdevRef' } }
2199
78368575 2200##
5072f7b3 2201# @BlockdevOptionsLUKS:
78368575
DB
2202#
2203# Driver specific block device options for LUKS.
2204#
2205# @key-secret: #optional the ID of a QCryptoSecret object providing
2206# the decryption key (since 2.6). Mandatory except when
2207# doing a metadata-only probe of the image.
2208#
2209# Since: 2.6
2210##
2211{ 'struct': 'BlockdevOptionsLUKS',
2212 'base': 'BlockdevOptionsGenericFormat',
2213 'data': { '*key-secret': 'str' } }
2214
2215
1ad166b6 2216##
5072f7b3 2217# @BlockdevOptionsGenericCOWFormat:
1ad166b6
BC
2218#
2219# Driver specific block device options for image format that have no option
2220# besides their data source and an optional backing file.
2221#
2222# @backing: #optional reference to or definition of the backing file block
2223# device (if missing, taken from the image file content). It is
2224# allowed to pass an empty string here in order to disable the
2225# default backing file.
2226#
2227# Since: 1.7
2228##
895a2a80 2229{ 'struct': 'BlockdevOptionsGenericCOWFormat',
1ad166b6
BC
2230 'base': 'BlockdevOptionsGenericFormat',
2231 'data': { '*backing': 'BlockdevRef' } }
2232
f6585811 2233##
5072f7b3 2234# @Qcow2OverlapCheckMode:
f6585811
HR
2235#
2236# General overlap check modes.
2237#
2238# @none: Do not perform any checks
2239#
2240# @constant: Perform only checks which can be done in constant time and
2241# without reading anything from disk
2242#
2243# @cached: Perform only checks which can be done without reading anything
2244# from disk
2245#
2246# @all: Perform all available overlap checks
2247#
2248# Since: 2.2
2249##
2250{ 'enum': 'Qcow2OverlapCheckMode',
2251 'data': [ 'none', 'constant', 'cached', 'all' ] }
2252
2253##
5072f7b3 2254# @Qcow2OverlapCheckFlags:
f6585811
HR
2255#
2256# Structure of flags for each metadata structure. Setting a field to 'true'
2257# makes qemu guard that structure against unintended overwriting. The default
2258# value is chosen according to the template given.
2259#
2260# @template: Specifies a template mode which can be adjusted using the other
2261# flags, defaults to 'cached'
2262#
2263# Since: 2.2
2264##
895a2a80 2265{ 'struct': 'Qcow2OverlapCheckFlags',
f6585811
HR
2266 'data': { '*template': 'Qcow2OverlapCheckMode',
2267 '*main-header': 'bool',
2268 '*active-l1': 'bool',
2269 '*active-l2': 'bool',
2270 '*refcount-table': 'bool',
2271 '*refcount-block': 'bool',
2272 '*snapshot-table': 'bool',
2273 '*inactive-l1': 'bool',
2274 '*inactive-l2': 'bool' } }
2275
2276##
5072f7b3 2277# @Qcow2OverlapChecks:
f6585811
HR
2278#
2279# Specifies which metadata structures should be guarded against unintended
2280# overwriting.
2281#
2282# @flags: set of flags for separate specification of each metadata structure
2283# type
2284#
2285# @mode: named mode which chooses a specific set of flags
2286#
2287# Since: 2.2
2288##
ab916fad 2289{ 'alternate': 'Qcow2OverlapChecks',
f6585811
HR
2290 'data': { 'flags': 'Qcow2OverlapCheckFlags',
2291 'mode': 'Qcow2OverlapCheckMode' } }
2292
1ad166b6 2293##
5072f7b3 2294# @BlockdevOptionsQcow2:
1ad166b6
BC
2295#
2296# Driver specific block device options for qcow2.
2297#
2298# @lazy-refcounts: #optional whether to enable the lazy refcounts
2299# feature (default is taken from the image file)
2300#
2301# @pass-discard-request: #optional whether discard requests to the qcow2
2302# device should be forwarded to the data source
2303#
2304# @pass-discard-snapshot: #optional whether discard requests for the data source
2305# should be issued when a snapshot operation (e.g.
2306# deleting a snapshot) frees clusters in the qcow2 file
2307#
2308# @pass-discard-other: #optional whether discard requests for the data source
2309# should be issued on other occasions where a cluster
2310# gets freed
2311#
f6585811
HR
2312# @overlap-check: #optional which overlap checks to perform for writes
2313# to the image, defaults to 'cached' (since 2.2)
2314#
2315# @cache-size: #optional the maximum total size of the L2 table and
2316# refcount block caches in bytes (since 2.2)
2317#
2318# @l2-cache-size: #optional the maximum size of the L2 table cache in
2319# bytes (since 2.2)
2320#
2321# @refcount-cache-size: #optional the maximum size of the refcount block cache
2322# in bytes (since 2.2)
2323#
279621c0
AG
2324# @cache-clean-interval: #optional clean unused entries in the L2 and refcount
2325# caches. The interval is in seconds. The default value
2326# is 0 and it disables this feature (since 2.5)
2327#
1ad166b6
BC
2328# Since: 1.7
2329##
895a2a80 2330{ 'struct': 'BlockdevOptionsQcow2',
1ad166b6
BC
2331 'base': 'BlockdevOptionsGenericCOWFormat',
2332 'data': { '*lazy-refcounts': 'bool',
2333 '*pass-discard-request': 'bool',
2334 '*pass-discard-snapshot': 'bool',
f6585811
HR
2335 '*pass-discard-other': 'bool',
2336 '*overlap-check': 'Qcow2OverlapChecks',
2337 '*cache-size': 'int',
2338 '*l2-cache-size': 'int',
279621c0
AG
2339 '*refcount-cache-size': 'int',
2340 '*cache-clean-interval': 'int' } }
1ad166b6 2341
b1de5f43
CN
2342
2343##
5072f7b3 2344# @BlockdevOptionsArchipelago:
b1de5f43
CN
2345#
2346# Driver specific block device options for Archipelago.
2347#
2348# @volume: Name of the Archipelago volume image
2349#
2350# @mport: #optional The port number on which mapperd is
2351# listening. This is optional
2352# and if not specified, QEMU will make Archipelago
2353# use the default port (1001).
2354#
2355# @vport: #optional The port number on which vlmcd is
2356# listening. This is optional
2357# and if not specified, QEMU will make Archipelago
2358# use the default port (501).
2359#
2360# @segment: #optional The name of the shared memory segment
2361# Archipelago stack is using. This is optional
2362# and if not specified, QEMU will make Archipelago
2363# use the default value, 'archipelago'.
2364# Since: 2.2
2365##
895a2a80 2366{ 'struct': 'BlockdevOptionsArchipelago',
b1de5f43
CN
2367 'data': { 'volume': 'str',
2368 '*mport': 'int',
2369 '*vport': 'int',
2370 '*segment': 'str' } }
2371
ad0e90a6 2372##
5072f7b3 2373# @BlockdevOptionsSsh:
ad0e90a6
AA
2374#
2375# @server: host address
2376#
2377# @path: path to the image on the host
2378#
2379# @user: #optional user as which to connect, defaults to current
2380# local user name
2381#
2382# TODO: Expose the host_key_check option in QMP
2383#
5072f7b3 2384# Since: 2.8
ad0e90a6
AA
2385##
2386{ 'struct': 'BlockdevOptionsSsh',
2387 'data': { 'server': 'InetSocketAddress',
2388 'path': 'str',
2389 '*user': 'str' } }
2390
b1de5f43 2391
1ad166b6 2392##
5072f7b3 2393# @BlkdebugEvent:
1ad166b6
BC
2394#
2395# Trigger events supported by blkdebug.
a31939e6
EB
2396#
2397# Since: 2.0
1ad166b6 2398##
a31939e6 2399{ 'enum': 'BlkdebugEvent', 'prefix': 'BLKDBG',
5be5b776
EB
2400 'data': [ 'l1_update', 'l1_grow_alloc_table', 'l1_grow_write_table',
2401 'l1_grow_activate_table', 'l2_load', 'l2_update',
2402 'l2_update_compressed', 'l2_alloc_cow_read', 'l2_alloc_write',
1ad166b6
BC
2403 'read_aio', 'read_backing_aio', 'read_compressed', 'write_aio',
2404 'write_compressed', 'vmstate_load', 'vmstate_save', 'cow_read',
2405 'cow_write', 'reftable_load', 'reftable_grow', 'reftable_update',
2406 'refblock_load', 'refblock_update', 'refblock_update_part',
5be5b776
EB
2407 'refblock_alloc', 'refblock_alloc_hookup', 'refblock_alloc_write',
2408 'refblock_alloc_write_blocks', 'refblock_alloc_write_table',
2409 'refblock_alloc_switch_table', 'cluster_alloc',
1ad166b6 2410 'cluster_alloc_bytes', 'cluster_free', 'flush_to_os',
5be5b776
EB
2411 'flush_to_disk', 'pwritev_rmw_head', 'pwritev_rmw_after_head',
2412 'pwritev_rmw_tail', 'pwritev_rmw_after_tail', 'pwritev',
d21de4d9 2413 'pwritev_zero', 'pwritev_done', 'empty_image_prepare' ] }
1ad166b6
BC
2414
2415##
5072f7b3 2416# @BlkdebugInjectErrorOptions:
1ad166b6
BC
2417#
2418# Describes a single error injection for blkdebug.
2419#
2420# @event: trigger event
2421#
2422# @state: #optional the state identifier blkdebug needs to be in to
2423# actually trigger the event; defaults to "any"
2424#
2425# @errno: #optional error identifier (errno) to be returned; defaults to
2426# EIO
2427#
2428# @sector: #optional specifies the sector index which has to be affected
2429# in order to actually trigger the event; defaults to "any
2430# sector"
2431#
2432# @once: #optional disables further events after this one has been
2433# triggered; defaults to false
2434#
2435# @immediately: #optional fail immediately; defaults to false
2436#
2437# Since: 2.0
2438##
895a2a80 2439{ 'struct': 'BlkdebugInjectErrorOptions',
1ad166b6
BC
2440 'data': { 'event': 'BlkdebugEvent',
2441 '*state': 'int',
2442 '*errno': 'int',
2443 '*sector': 'int',
2444 '*once': 'bool',
2445 '*immediately': 'bool' } }
2446
2447##
5072f7b3 2448# @BlkdebugSetStateOptions:
1ad166b6
BC
2449#
2450# Describes a single state-change event for blkdebug.
2451#
2452# @event: trigger event
2453#
2454# @state: #optional the current state identifier blkdebug needs to be in;
2455# defaults to "any"
2456#
2457# @new_state: the state identifier blkdebug is supposed to assume if
2458# this event is triggered
2459#
2460# Since: 2.0
2461##
895a2a80 2462{ 'struct': 'BlkdebugSetStateOptions',
1ad166b6
BC
2463 'data': { 'event': 'BlkdebugEvent',
2464 '*state': 'int',
2465 'new_state': 'int' } }
2466
2467##
5072f7b3 2468# @BlockdevOptionsBlkdebug:
1ad166b6
BC
2469#
2470# Driver specific block device options for blkdebug.
2471#
2472# @image: underlying raw block device (or image file)
2473#
2474# @config: #optional filename of the configuration file
2475#
835db3ee
EB
2476# @align: #optional required alignment for requests in bytes,
2477# must be power of 2, or 0 for default
1ad166b6
BC
2478#
2479# @inject-error: #optional array of error injection descriptions
2480#
2481# @set-state: #optional array of state-change descriptions
2482#
2483# Since: 2.0
2484##
895a2a80 2485{ 'struct': 'BlockdevOptionsBlkdebug',
1ad166b6
BC
2486 'data': { 'image': 'BlockdevRef',
2487 '*config': 'str',
2488 '*align': 'int',
2489 '*inject-error': ['BlkdebugInjectErrorOptions'],
2490 '*set-state': ['BlkdebugSetStateOptions'] } }
2491
2492##
5072f7b3 2493# @BlockdevOptionsBlkverify:
1ad166b6
BC
2494#
2495# Driver specific block device options for blkverify.
2496#
2497# @test: block device to be tested
2498#
2499# @raw: raw image used for verification
2500#
2501# Since: 2.0
2502##
895a2a80 2503{ 'struct': 'BlockdevOptionsBlkverify',
1ad166b6
BC
2504 'data': { 'test': 'BlockdevRef',
2505 'raw': 'BlockdevRef' } }
2506
62c6031f 2507##
5072f7b3 2508# @QuorumReadPattern:
62c6031f
LY
2509#
2510# An enumeration of quorum read patterns.
2511#
2512# @quorum: read all the children and do a quorum vote on reads
2513#
2514# @fifo: read only from the first child that has not failed
2515#
2516# Since: 2.2
2517##
2518{ 'enum': 'QuorumReadPattern', 'data': [ 'quorum', 'fifo' ] }
2519
1ad166b6 2520##
5072f7b3 2521# @BlockdevOptionsQuorum:
1ad166b6
BC
2522#
2523# Driver specific block device options for Quorum
2524#
2525# @blkverify: #optional true if the driver must print content mismatch
2526# set to false by default
2527#
2528# @children: the children block devices to use
2529#
2530# @vote-threshold: the vote limit under which a read will fail
2531#
cf29a570
BC
2532# @rewrite-corrupted: #optional rewrite corrupted data when quorum is reached
2533# (Since 2.1)
2534#
62c6031f
LY
2535# @read-pattern: #optional choose read pattern and set to quorum by default
2536# (Since 2.2)
2537#
1ad166b6
BC
2538# Since: 2.0
2539##
895a2a80 2540{ 'struct': 'BlockdevOptionsQuorum',
1ad166b6
BC
2541 'data': { '*blkverify': 'bool',
2542 'children': [ 'BlockdevRef' ],
62c6031f
LY
2543 'vote-threshold': 'int',
2544 '*rewrite-corrupted': 'bool',
2545 '*read-pattern': 'QuorumReadPattern' } }
1ad166b6 2546
7edac2dd 2547##
5072f7b3 2548# @GlusterTransport:
7edac2dd
PKK
2549#
2550# An enumeration of Gluster transport types
2551#
2552# @tcp: TCP - Transmission Control Protocol
2553#
2554# @unix: UNIX - Unix domain socket
2555#
2556# Since: 2.7
2557##
2558{ 'enum': 'GlusterTransport',
2559 'data': [ 'unix', 'tcp' ] }
2560
2561
2562##
5072f7b3 2563# @GlusterServer:
7edac2dd
PKK
2564#
2565# Captures the address of a socket
2566#
2567# Details for connecting to a gluster server
2568#
2569# @type: Transport type used for gluster connection
2570#
c76d7aab
PKK
2571# This is similar to SocketAddress, only distinction:
2572#
2573# 1. GlusterServer is a flat union, SocketAddress is a simple union.
2574# A flat union is nicer than simple because it avoids nesting
2575# (i.e. more {}) on the wire.
2576#
2577# 2. GlusterServer lacks case 'fd', since gluster doesn't let you
2578# pass in a file descriptor.
2579#
2580# GlusterServer is actually not Gluster-specific, its a
2581# compatibility evolved into an alternate for SocketAddress.
2582#
7edac2dd
PKK
2583# Since: 2.7
2584##
2585{ 'union': 'GlusterServer',
2586 'base': { 'type': 'GlusterTransport' },
2587 'discriminator': 'type',
2588 'data': { 'unix': 'UnixSocketAddress',
2589 'tcp': 'InetSocketAddress' } }
2590
2591##
5072f7b3 2592# @BlockdevOptionsGluster:
7edac2dd
PKK
2593#
2594# Driver specific block device options for Gluster
2595#
2596# @volume: name of gluster volume where VM image resides
2597#
2598# @path: absolute path to image file in gluster volume
2599#
0a189ffb 2600# @server: gluster servers description
7edac2dd 2601#
1a417e46 2602# @debug: #optional libgfapi log level (default '4' which is Error)
4230e5d1 2603# (Since 2.8)
7edac2dd 2604#
05fce20d 2605# @logfile: #optional libgfapi log file (default /dev/stderr) (Since 2.8)
e9db8ff3 2606#
7edac2dd
PKK
2607# Since: 2.7
2608##
2609{ 'struct': 'BlockdevOptionsGluster',
2610 'data': { 'volume': 'str',
2611 'path': 'str',
6c7189bb 2612 'server': ['GlusterServer'],
1a417e46 2613 '*debug': 'int',
e9db8ff3 2614 '*logfile': 'str' } }
7edac2dd 2615
31eb1202
KW
2616##
2617# @IscsiTransport:
2618#
2619# An enumeration of libiscsi transport types
2620#
2621# Since: 2.9
2622##
2623{ 'enum': 'IscsiTransport',
2624 'data': [ 'tcp', 'iser' ] }
2625
2626##
2627# @IscsiHeaderDigest:
2628#
2629# An enumeration of header digests supported by libiscsi
2630#
2631# Since: 2.9
2632##
2633{ 'enum': 'IscsiHeaderDigest',
2634 'prefix': 'QAPI_ISCSI_HEADER_DIGEST',
2635 'data': [ 'crc32c', 'none', 'crc32c-none', 'none-crc32c' ] }
2636
2637##
2638# @BlockdevOptionsIscsi:
2639#
51654aa5 2640# @transport: The iscsi transport type
31eb1202 2641#
51654aa5 2642# @portal: The address of the iscsi portal
31eb1202 2643#
51654aa5 2644# @target: The target iqn name
31eb1202 2645#
51654aa5 2646# @lun: #optional LUN to connect to. Defaults to 0.
31eb1202 2647#
51654aa5 2648# @user: #optional User name to log in with. If omitted, no CHAP
31eb1202
KW
2649# authentication is performed.
2650#
51654aa5 2651# @password-secret: #optional The ID of a QCryptoSecret object providing
31eb1202
KW
2652# the password for the login. This option is required if
2653# @user is specified.
2654#
51654aa5 2655# @initiator-name: #optional The iqn name we want to identify to the target
31eb1202
KW
2656# as. If this option is not specified, an initiator name is
2657# generated automatically.
2658#
51654aa5 2659# @header-digest: #optional The desired header digest. Defaults to
31eb1202
KW
2660# none-crc32c.
2661#
51654aa5 2662# @timeout: #optional Timeout in seconds after which a request will
31eb1202
KW
2663# timeout. 0 means no timeout and is the default.
2664#
2665# Driver specific block device options for iscsi
2666#
2667# Since: 2.9
2668##
2669{ 'struct': 'BlockdevOptionsIscsi',
2670 'data': { 'transport': 'IscsiTransport',
2671 'portal': 'str',
2672 'target': 'str',
2673 '*lun': 'int',
2674 '*user': 'str',
2675 '*password-secret': 'str',
2676 '*initiator-name': 'str',
2677 '*header-digest': 'IscsiHeaderDigest',
2678 '*timeout': 'int' } }
2679
190b9a8b 2680##
5072f7b3 2681# @ReplicationMode:
190b9a8b
CX
2682#
2683# An enumeration of replication modes.
2684#
2685# @primary: Primary mode, the vm's state will be sent to secondary QEMU.
2686#
2687# @secondary: Secondary mode, receive the vm's state from primary QEMU.
2688#
2689# Since: 2.8
2690##
2691{ 'enum' : 'ReplicationMode', 'data' : [ 'primary', 'secondary' ] }
2692
82ac5543 2693##
5072f7b3 2694# @BlockdevOptionsReplication:
82ac5543
WC
2695#
2696# Driver specific block device options for replication
2697#
2698# @mode: the replication mode
2699#
2700# @top-id: #optional In secondary mode, node name or device ID of the root
f4f2539b
CX
2701# node who owns the replication node chain. Must not be given in
2702# primary mode.
82ac5543
WC
2703#
2704# Since: 2.8
2705##
2706{ 'struct': 'BlockdevOptionsReplication',
2707 'base': 'BlockdevOptionsGenericFormat',
2708 'data': { 'mode': 'ReplicationMode',
2709 '*top-id': 'str' } }
2710
aa2623d8 2711##
5072f7b3 2712# @NFSTransport:
aa2623d8
AA
2713#
2714# An enumeration of NFS transport types
2715#
2716# @inet: TCP transport
2717#
5072f7b3 2718# Since: 2.8
aa2623d8
AA
2719##
2720{ 'enum': 'NFSTransport',
2721 'data': [ 'inet' ] }
2722
2723##
5072f7b3 2724# @NFSServer:
aa2623d8
AA
2725#
2726# Captures the address of the socket
2727#
2728# @type: transport type used for NFS (only TCP supported)
2729#
2730# @host: host address for NFS server
2731#
5072f7b3 2732# Since: 2.8
aa2623d8
AA
2733##
2734{ 'struct': 'NFSServer',
2735 'data': { 'type': 'NFSTransport',
2736 'host': 'str' } }
2737
2738##
5072f7b3 2739# @BlockdevOptionsNfs:
aa2623d8
AA
2740#
2741# Driver specific block device option for NFS
2742#
2743# @server: host address
2744#
2745# @path: path of the image on the host
2746#
2747# @user: #optional UID value to use when talking to the
2748# server (defaults to 65534 on Windows and getuid()
2749# on unix)
2750#
2751# @group: #optional GID value to use when talking to the
2752# server (defaults to 65534 on Windows and getgid()
2753# in unix)
2754#
2755# @tcp-syn-count: #optional number of SYNs during the session
2756# establishment (defaults to libnfs default)
2757#
2758# @readahead-size: #optional set the readahead size in bytes (defaults
2759# to libnfs default)
2760#
2761# @page-cache-size: #optional set the pagecache size in bytes (defaults
2762# to libnfs default)
2763#
7103d916 2764# @debug: #optional set the NFS debug level (max 2) (defaults
aa2623d8
AA
2765# to libnfs default)
2766#
5072f7b3 2767# Since: 2.8
aa2623d8
AA
2768##
2769{ 'struct': 'BlockdevOptionsNfs',
2770 'data': { 'server': 'NFSServer',
2771 'path': 'str',
2772 '*user': 'int',
2773 '*group': 'int',
2774 '*tcp-syn-count': 'int',
2775 '*readahead-size': 'int',
2776 '*page-cache-size': 'int',
7103d916 2777 '*debug': 'int' } }
aa2623d8 2778
68555285 2779##
5072f7b3 2780# @BlockdevOptionsCurl:
68555285
KW
2781#
2782# Driver specific block device options for the curl backend.
2783#
2784# @filename: path to the image file
2785#
2786# Since: 1.7
2787##
2788{ 'struct': 'BlockdevOptionsCurl',
2789 'data': { 'filename': 'str' } }
2790
6b02b1f0 2791##
5072f7b3 2792# @BlockdevOptionsNbd:
6b02b1f0
HR
2793#
2794# Driver specific block device options for NBD.
2795#
2796# @server: NBD server address
2797#
2798# @export: #optional export name
2799#
2800# @tls-creds: #optional TLS credentials ID
2801#
2802# Since: 2.8
2803##
2804{ 'struct': 'BlockdevOptionsNbd',
2805 'data': { 'server': 'SocketAddress',
2806 '*export': 'str',
2807 '*tls-creds': 'str' } }
2808
2fdc7045 2809##
5072f7b3 2810# @BlockdevOptionsRaw:
2fdc7045
TG
2811#
2812# Driver specific block device options for the raw driver.
2813#
2814# @offset: #optional position where the block device starts
2815# @size: #optional the assumed size of the device
2816#
2817# Since: 2.8
2818##
2819{ 'struct': 'BlockdevOptionsRaw',
2820 'base': 'BlockdevOptionsGenericFormat',
2821 'data': { '*offset': 'int', '*size': 'int' } }
2822
1ad166b6 2823##
5072f7b3 2824# @BlockdevOptions:
1ad166b6 2825#
3666a97f
EB
2826# Options for creating a block device. Many options are available for all
2827# block devices, independent of the block driver:
2828#
2829# @driver: block driver name
9ec8873e
KW
2830# @node-name: #optional the node name of the new node (Since 2.0).
2831# This option is required on the top level of blockdev-add.
3666a97f
EB
2832# @discard: #optional discard-related options (default: ignore)
2833# @cache: #optional cache-related options
3666a97f
EB
2834# @read-only: #optional whether the block device should be read-only
2835# (default: false)
3666a97f
EB
2836# @detect-zeroes: #optional detect and optimize zero writes (Since 2.1)
2837# (default: off)
2838#
2839# Remaining options are determined by the block driver.
1ad166b6
BC
2840#
2841# Since: 1.7
2842##
2843{ 'union': 'BlockdevOptions',
3666a97f 2844 'base': { 'driver': 'BlockdevDriver',
3666a97f
EB
2845 '*node-name': 'str',
2846 '*discard': 'BlockdevDiscardOptions',
2847 '*cache': 'BlockdevCacheOptions',
3666a97f 2848 '*read-only': 'bool',
3666a97f 2849 '*detect-zeroes': 'BlockdevDetectZeroesOptions' },
1ad166b6
BC
2850 'discriminator': 'driver',
2851 'data': {
b1de5f43 2852 'archipelago':'BlockdevOptionsArchipelago',
db866be9
FZ
2853 'blkdebug': 'BlockdevOptionsBlkdebug',
2854 'blkverify': 'BlockdevOptionsBlkverify',
2855 'bochs': 'BlockdevOptionsGenericFormat',
2856 'cloop': 'BlockdevOptionsGenericFormat',
db866be9 2857 'dmg': 'BlockdevOptionsGenericFormat',
1ad166b6 2858 'file': 'BlockdevOptionsFile',
68555285
KW
2859 'ftp': 'BlockdevOptionsCurl',
2860 'ftps': 'BlockdevOptionsCurl',
7edac2dd 2861 'gluster': 'BlockdevOptionsGluster',
1ad166b6 2862 'host_cdrom': 'BlockdevOptionsFile',
db866be9 2863 'host_device':'BlockdevOptionsFile',
68555285
KW
2864 'http': 'BlockdevOptionsCurl',
2865 'https': 'BlockdevOptionsCurl',
31eb1202 2866 'iscsi': 'BlockdevOptionsIscsi',
78368575 2867 'luks': 'BlockdevOptionsLUKS',
6b02b1f0 2868 'nbd': 'BlockdevOptionsNbd',
aa2623d8 2869 'nfs': 'BlockdevOptionsNfs',
db866be9
FZ
2870 'null-aio': 'BlockdevOptionsNull',
2871 'null-co': 'BlockdevOptionsNull',
1ad166b6 2872 'parallels': 'BlockdevOptionsGenericFormat',
1ad166b6 2873 'qcow2': 'BlockdevOptionsQcow2',
db866be9 2874 'qcow': 'BlockdevOptionsGenericCOWFormat',
1ad166b6 2875 'qed': 'BlockdevOptionsGenericCOWFormat',
db866be9 2876 'quorum': 'BlockdevOptionsQuorum',
2fdc7045 2877 'raw': 'BlockdevOptionsRaw',
db866be9 2878# TODO rbd: Wait for structured options
82ac5543 2879 'replication':'BlockdevOptionsReplication',
db866be9 2880# TODO sheepdog: Wait for structured options
ad0e90a6 2881 'ssh': 'BlockdevOptionsSsh',
1ad166b6
BC
2882 'vdi': 'BlockdevOptionsGenericFormat',
2883 'vhdx': 'BlockdevOptionsGenericFormat',
2884 'vmdk': 'BlockdevOptionsGenericCOWFormat',
2885 'vpc': 'BlockdevOptionsGenericFormat',
db866be9 2886 'vvfat': 'BlockdevOptionsVVFAT'
1ad166b6
BC
2887 } }
2888
2889##
5072f7b3 2890# @BlockdevRef:
1ad166b6
BC
2891#
2892# Reference to a block device.
2893#
2894# @definition: defines a new block device inline
2895# @reference: references the ID of an existing block device. An
2896# empty string means that no block device should be
2897# referenced.
2898#
2899# Since: 1.7
2900##
ab916fad 2901{ 'alternate': 'BlockdevRef',
1ad166b6
BC
2902 'data': { 'definition': 'BlockdevOptions',
2903 'reference': 'str' } }
2904
2905##
2906# @blockdev-add:
2907#
be4b67bc
HR
2908# Creates a new block device. If the @id option is given at the top level, a
2909# BlockBackend will be created; otherwise, @node-name is mandatory at the top
2910# level and no BlockBackend will be created.
1ad166b6 2911#
7a305384
MAL
2912# For the arguments, see the documentation of BlockdevOptions.
2913#
2914# Note: This command is still a work in progress. It doesn't support all
81b936ae
AG
2915# block drivers among other things. Stay away from it unless you want
2916# to help with its development.
da2cf4e8 2917#
1ad166b6 2918# Since: 1.7
b4749948
MAL
2919#
2920# Example:
2921#
2922# 1.
2923# -> { "execute": "blockdev-add",
2924# "arguments": {
b1660997
JC
2925# "driver": "qcow2",
2926# "node-name": "test1",
2927# "file": {
2928# "driver": "file",
2929# "filename": "test.qcow2"
2930# }
2931# }
2932# }
b4749948
MAL
2933# <- { "return": {} }
2934#
2935# 2.
2936# -> { "execute": "blockdev-add",
2937# "arguments": {
b1660997
JC
2938# "driver": "qcow2",
2939# "node-name": "node0",
2940# "discard": "unmap",
2941# "cache": {
2942# "direct": true
b4749948
MAL
2943# },
2944# "file": {
b1660997
JC
2945# "driver": "file",
2946# "filename": "/tmp/test.qcow2"
b4749948
MAL
2947# },
2948# "backing": {
b1660997
JC
2949# "driver": "raw",
2950# "file": {
2951# "driver": "file",
2952# "filename": "/dev/fdset/4"
b4749948
MAL
2953# }
2954# }
b4749948
MAL
2955# }
2956# }
2957#
2958# <- { "return": {} }
2959#
1ad166b6 2960##
0153d2f5 2961{ 'command': 'blockdev-add', 'data': 'BlockdevOptions', 'boxed': true }
1ad166b6 2962
81b936ae
AG
2963##
2964# @x-blockdev-del:
2965#
2966# Deletes a block device that has been added using blockdev-add.
9ec8873e
KW
2967# The command will fail if the node is attached to a device or is
2968# otherwise being used.
81b936ae 2969#
7a305384
MAL
2970# @node-name: Name of the graph node to delete.
2971#
2972# Note: This command is still a work in progress and is considered
81b936ae
AG
2973# experimental. Stay away from it unless you want to help with its
2974# development.
2975#
81b936ae 2976# Since: 2.5
915a213f
MAL
2977#
2978# Example:
2979#
2980# -> { "execute": "blockdev-add",
2981# "arguments": {
b1660997
JC
2982# "driver": "qcow2",
2983# "node-name": "node0",
2984# "file": {
2985# "driver": "file",
2986# "filename": "test.qcow2"
2987# }
915a213f
MAL
2988# }
2989# }
2990# <- { "return": {} }
2991#
2992# -> { "execute": "x-blockdev-del",
2993# "arguments": { "node-name": "node0" }
2994# }
2995# <- { "return": {} }
2996#
81b936ae 2997##
9ec8873e 2998{ 'command': 'x-blockdev-del', 'data': { 'node-name': 'str' } }
81b936ae 2999
7d8a9f71
HR
3000##
3001# @blockdev-open-tray:
3002#
3003# Opens a block device's tray. If there is a block driver state tree inserted as
3004# a medium, it will become inaccessible to the guest (but it will remain
3005# associated to the block device, so closing the tray will make it accessible
3006# again).
3007#
3008# If the tray was already open before, this will be a no-op.
3009#
3010# Once the tray opens, a DEVICE_TRAY_MOVED event is emitted. There are cases in
3011# which no such event will be generated, these include:
3012# - if the guest has locked the tray, @force is false and the guest does not
3013# respond to the eject request
3014# - if the BlockBackend denoted by @device does not have a guest device attached
3015# to it
12c7ec87 3016# - if the guest device does not have an actual tray
7d8a9f71 3017#
b33945cf
KW
3018# @device: #optional Block device name (deprecated, use @id instead)
3019#
3020# @id: #optional The name or QOM path of the guest device (since: 2.8)
7d8a9f71
HR
3021#
3022# @force: #optional if false (the default), an eject request will be sent to
3023# the guest if it has locked the tray (and the tray will not be opened
3024# immediately); if true, the tray will be opened regardless of whether
3025# it is locked
3026#
3027# Since: 2.5
1133b1d6
MAL
3028#
3029# Example:
3030#
3031# -> { "execute": "blockdev-open-tray",
3032# "arguments": { "id": "ide0-1-0" } }
3033#
3034# <- { "timestamp": { "seconds": 1418751016,
3035# "microseconds": 716996 },
3036# "event": "DEVICE_TRAY_MOVED",
3037# "data": { "device": "ide1-cd0",
3038# "id": "ide0-1-0",
3039# "tray-open": true } }
3040#
3041# <- { "return": {} }
3042#
7d8a9f71
HR
3043##
3044{ 'command': 'blockdev-open-tray',
b33945cf
KW
3045 'data': { '*device': 'str',
3046 '*id': 'str',
7d8a9f71
HR
3047 '*force': 'bool' } }
3048
abaaf59d
HR
3049##
3050# @blockdev-close-tray:
3051#
3052# Closes a block device's tray. If there is a block driver state tree associated
3053# with the block device (which is currently ejected), that tree will be loaded
3054# as the medium.
3055#
3056# If the tray was already closed before, this will be a no-op.
3057#
b33945cf
KW
3058# @device: #optional Block device name (deprecated, use @id instead)
3059#
3060# @id: #optional The name or QOM path of the guest device (since: 2.8)
abaaf59d
HR
3061#
3062# Since: 2.5
7f3c6f22
MAL
3063#
3064# Example:
3065#
3066# -> { "execute": "blockdev-close-tray",
3067# "arguments": { "id": "ide0-1-0" } }
3068#
3069# <- { "timestamp": { "seconds": 1418751345,
3070# "microseconds": 272147 },
3071# "event": "DEVICE_TRAY_MOVED",
3072# "data": { "device": "ide1-cd0",
3073# "id": "ide0-1-0",
3074# "tray-open": false } }
3075#
3076# <- { "return": {} }
3077#
abaaf59d
HR
3078##
3079{ 'command': 'blockdev-close-tray',
b33945cf
KW
3080 'data': { '*device': 'str',
3081 '*id': 'str' } }
abaaf59d 3082
2814f672 3083##
6e0abc25 3084# @x-blockdev-remove-medium:
2814f672
HR
3085#
3086# Removes a medium (a block driver state tree) from a block device. That block
3087# device's tray must currently be open (unless there is no attached guest
3088# device).
3089#
3090# If the tray is open and there is no medium inserted, this will be a no-op.
3091#
00949bab
KW
3092# @device: #optional Block device name (deprecated, use @id instead)
3093#
3094# @id: #optional The name or QOM path of the guest device (since: 2.8)
2814f672 3095#
7a305384
MAL
3096# Note: This command is still a work in progress and is considered experimental.
3097# Stay away from it unless you want to help with its development.
3098#
2814f672 3099# Since: 2.5
8e1c1429
MAL
3100#
3101# Example:
3102#
3103# -> { "execute": "x-blockdev-remove-medium",
3104# "arguments": { "id": "ide0-1-0" } }
3105#
3106# <- { "error": { "class": "GenericError",
3107# "desc": "Tray of device 'ide0-1-0' is not open" } }
3108#
3109# -> { "execute": "blockdev-open-tray",
3110# "arguments": { "id": "ide0-1-0" } }
3111#
3112# <- { "timestamp": { "seconds": 1418751627,
3113# "microseconds": 549958 },
3114# "event": "DEVICE_TRAY_MOVED",
3115# "data": { "device": "ide1-cd0",
3116# "id": "ide0-1-0",
3117# "tray-open": true } }
3118#
3119# <- { "return": {} }
3120#
3121# -> { "execute": "x-blockdev-remove-medium",
3122# "arguments": { "device": "ide0-1-0" } }
3123#
3124# <- { "return": {} }
3125#
2814f672 3126##
6e0abc25 3127{ 'command': 'x-blockdev-remove-medium',
00949bab
KW
3128 'data': { '*device': 'str',
3129 '*id': 'str' } }
2814f672 3130
d1299882 3131##
6e0abc25 3132# @x-blockdev-insert-medium:
d1299882
HR
3133#
3134# Inserts a medium (a block driver state tree) into a block device. That block
3135# device's tray must currently be open (unless there is no attached guest
3136# device) and there must be no medium inserted already.
3137#
716df217
KW
3138# @device: #optional Block device name (deprecated, use @id instead)
3139#
3140# @id: #optional The name or QOM path of the guest device (since: 2.8)
d1299882
HR
3141#
3142# @node-name: name of a node in the block driver state graph
3143#
7a305384
MAL
3144# Note: This command is still a work in progress and is considered experimental.
3145# Stay away from it unless you want to help with its development.
3146#
d1299882 3147# Since: 2.5
b480abf3
MAL
3148#
3149# Example:
3150#
3151# -> { "execute": "blockdev-add",
3152# "arguments": {
3153# "options": { "node-name": "node0",
3154# "driver": "raw",
3155# "file": { "driver": "file",
3156# "filename": "fedora.iso" } } } }
3157# <- { "return": {} }
3158#
3159# -> { "execute": "x-blockdev-insert-medium",
3160# "arguments": { "id": "ide0-1-0",
3161# "node-name": "node0" } }
3162#
3163# <- { "return": {} }
3164#
d1299882 3165##
6e0abc25 3166{ 'command': 'x-blockdev-insert-medium',
716df217
KW
3167 'data': { '*device': 'str',
3168 '*id': 'str',
d1299882
HR
3169 'node-name': 'str'} }
3170
a589569f 3171
39ff43d9
HR
3172##
3173# @BlockdevChangeReadOnlyMode:
3174#
3175# Specifies the new read-only mode of a block device subject to the
3176# @blockdev-change-medium command.
3177#
3178# @retain: Retains the current read-only mode
3179#
3180# @read-only: Makes the device read-only
3181#
3182# @read-write: Makes the device writable
3183#
3184# Since: 2.3
be3e83cb 3185#
39ff43d9
HR
3186##
3187{ 'enum': 'BlockdevChangeReadOnlyMode',
3188 'data': ['retain', 'read-only', 'read-write'] }
3189
3190
24fb4133
HR
3191##
3192# @blockdev-change-medium:
3193#
3194# Changes the medium inserted into a block device by ejecting the current medium
3195# and loading a new image file which is inserted as the new medium (this command
6e0abc25
HR
3196# combines blockdev-open-tray, x-blockdev-remove-medium,
3197# x-blockdev-insert-medium and blockdev-close-tray).
24fb4133 3198#
70e2cb3b
KW
3199# @device: #optional Block device name (deprecated, use @id instead)
3200#
3201# @id: #optional The name or QOM path of the guest device
3202# (since: 2.8)
24fb4133
HR
3203#
3204# @filename: filename of the new image to be loaded
3205#
5d0c7f4f 3206# @format: #optional format to open the new image with (defaults to
24fb4133
HR
3207# the probed format)
3208#
5d0c7f4f 3209# @read-only-mode: #optional change the read-only mode of the device; defaults
39ff43d9
HR
3210# to 'retain'
3211#
24fb4133 3212# Since: 2.5
be3e83cb
MAL
3213#
3214# Examples:
3215#
3216# 1. Change a removable medium
3217#
3218# -> { "execute": "blockdev-change-medium",
3219# "arguments": { "id": "ide0-1-0",
3220# "filename": "/srv/images/Fedora-12-x86_64-DVD.iso",
3221# "format": "raw" } }
3222# <- { "return": {} }
3223#
3224# 2. Load a read-only medium into a writable drive
3225#
3226# -> { "execute": "blockdev-change-medium",
3227# "arguments": { "id": "floppyA",
3228# "filename": "/srv/images/ro.img",
3229# "format": "raw",
3230# "read-only-mode": "retain" } }
3231#
3232# <- { "error":
3233# { "class": "GenericError",
3234# "desc": "Could not open '/srv/images/ro.img': Permission denied" } }
3235#
3236# -> { "execute": "blockdev-change-medium",
3237# "arguments": { "id": "floppyA",
3238# "filename": "/srv/images/ro.img",
3239# "format": "raw",
3240# "read-only-mode": "read-only" } }
3241#
3242# <- { "return": {} }
3243#
24fb4133
HR
3244##
3245{ 'command': 'blockdev-change-medium',
70e2cb3b
KW
3246 'data': { '*device': 'str',
3247 '*id': 'str',
24fb4133 3248 'filename': 'str',
39ff43d9
HR
3249 '*format': 'str',
3250 '*read-only-mode': 'BlockdevChangeReadOnlyMode' } }
24fb4133
HR
3251
3252
a589569f 3253##
5072f7b3 3254# @BlockErrorAction:
a589569f
WX
3255#
3256# An enumeration of action that has been taken when a DISK I/O occurs
3257#
3258# @ignore: error has been ignored
3259#
3260# @report: error has been reported to the device
3261#
3262# @stop: error caused VM to be stopped
3263#
3264# Since: 2.1
3265##
3266{ 'enum': 'BlockErrorAction',
3267 'data': [ 'ignore', 'report', 'stop' ] }
5a2d2cbd
WX
3268
3269
c120f0fa 3270##
5072f7b3 3271# @BLOCK_IMAGE_CORRUPTED:
c120f0fa 3272#
370d4eba
MAL
3273# Emitted when a disk image is being marked corrupt. The image can be
3274# identified by its device or node name. The 'device' field is always
3275# present for compatibility reasons, but it can be empty ("") if the
3276# image does not have a device name associated.
c120f0fa 3277#
dc881b44
AG
3278# @device: device name. This is always present for compatibility
3279# reasons, but it can be empty ("") if the image does not
3280# have a device name associated.
3281#
3282# @node-name: #optional node name (Since: 2.4)
c120f0fa
WX
3283#
3284# @msg: informative message for human consumption, such as the kind of
2f44a08b
WX
3285# corruption being detected. It should not be parsed by machine as it is
3286# not guaranteed to be stable
c120f0fa 3287#
5d0c7f4f 3288# @offset: #optional if the corruption resulted from an image access, this is
0caef8f6 3289# the host's access offset into the image
c120f0fa 3290#
5d0c7f4f 3291# @size: #optional if the corruption resulted from an image access, this is
c120f0fa
WX
3292# the access size
3293#
370d4eba 3294# @fatal: if set, the image is marked corrupt and therefore unusable after this
9bf040b9
HR
3295# event and must be repaired (Since 2.2; before, every
3296# BLOCK_IMAGE_CORRUPTED event was fatal)
3297#
07c9f583
MAL
3298# Note: If action is "stop", a STOP event will eventually follow the
3299# BLOCK_IO_ERROR event.
3300#
370d4eba
MAL
3301# Example:
3302#
3303# <- { "event": "BLOCK_IMAGE_CORRUPTED",
3304# "data": { "device": "ide0-hd0", "node-name": "node0",
3305# "msg": "Prevented active L1 table overwrite", "offset": 196608,
3306# "size": 65536 },
3307# "timestamp": { "seconds": 1378126126, "microseconds": 966463 } }
3308#
c120f0fa
WX
3309# Since: 1.7
3310##
3311{ 'event': 'BLOCK_IMAGE_CORRUPTED',
dc881b44
AG
3312 'data': { 'device' : 'str',
3313 '*node-name' : 'str',
3314 'msg' : 'str',
3315 '*offset' : 'int',
3316 '*size' : 'int',
3317 'fatal' : 'bool' } }
c120f0fa 3318
5a2d2cbd 3319##
5072f7b3 3320# @BLOCK_IO_ERROR:
5a2d2cbd
WX
3321#
3322# Emitted when a disk I/O error occurs
3323#
2bf7e10f
KW
3324# @device: device name. This is always present for compatibility
3325# reasons, but it can be empty ("") if the image does not
3326# have a device name associated.
3327#
3328# @node-name: node name. Note that errors may be reported for the root node
3329# that is directly attached to a guest device rather than for the
3330# node where the error occurred. (Since: 2.8)
5a2d2cbd
WX
3331#
3332# @operation: I/O operation
3333#
3334# @action: action that has been taken
3335#
c7c2ff0c
LC
3336# @nospace: #optional true if I/O error was caused due to a no-space
3337# condition. This key is only present if query-block's
3338# io-status is present, please see query-block documentation
3339# for more information (since: 2.2)
3340#
624ff573
LC
3341# @reason: human readable string describing the error cause.
3342# (This field is a debugging aid for humans, it should not
3343# be parsed by applications) (since: 2.2)
3344#
5a2d2cbd
WX
3345# Note: If action is "stop", a STOP event will eventually follow the
3346# BLOCK_IO_ERROR event
3347#
3348# Since: 0.13.0
07c9f583
MAL
3349#
3350# Example:
3351#
3352# <- { "event": "BLOCK_IO_ERROR",
3353# "data": { "device": "ide0-hd1",
3354# "node-name": "#block212",
3355# "operation": "write",
3356# "action": "stop" },
3357# "timestamp": { "seconds": 1265044230, "microseconds": 450486 } }
3358#
5a2d2cbd
WX
3359##
3360{ 'event': 'BLOCK_IO_ERROR',
2bf7e10f 3361 'data': { 'device': 'str', 'node-name': 'str', 'operation': 'IoOperationType',
624ff573
LC
3362 'action': 'BlockErrorAction', '*nospace': 'bool',
3363 'reason': 'str' } }
5a2d2cbd 3364
bcada37b 3365##
5072f7b3 3366# @BLOCK_JOB_COMPLETED:
bcada37b
WX
3367#
3368# Emitted when a block job has completed
3369#
3370# @type: job type
3371#
6aae5be6
AG
3372# @device: The job identifier. Originally the device name but other
3373# values are allowed since QEMU 2.7
bcada37b
WX
3374#
3375# @len: maximum progress value
3376#
3377# @offset: current progress value. On success this is equal to len.
3378# On failure this is less than len
3379#
3380# @speed: rate limit, bytes per second
3381#
5d0c7f4f 3382# @error: #optional error message. Only present on failure. This field
bcada37b
WX
3383# contains a human-readable error message. There are no semantics
3384# other than that streaming has failed and clients should not try to
3385# interpret the error string
3386#
3387# Since: 1.1
e21e65b2
MAL
3388#
3389# Example:
3390#
3391# <- { "event": "BLOCK_JOB_COMPLETED",
3392# "data": { "type": "stream", "device": "virtio-disk0",
3393# "len": 10737418240, "offset": 10737418240,
3394# "speed": 0 },
3395# "timestamp": { "seconds": 1267061043, "microseconds": 959568 } }
3396#
bcada37b
WX
3397##
3398{ 'event': 'BLOCK_JOB_COMPLETED',
3399 'data': { 'type' : 'BlockJobType',
3400 'device': 'str',
3401 'len' : 'int',
3402 'offset': 'int',
3403 'speed' : 'int',
3404 '*error': 'str' } }
3405
3406##
5072f7b3 3407# @BLOCK_JOB_CANCELLED:
bcada37b
WX
3408#
3409# Emitted when a block job has been cancelled
3410#
3411# @type: job type
3412#
6aae5be6
AG
3413# @device: The job identifier. Originally the device name but other
3414# values are allowed since QEMU 2.7
bcada37b
WX
3415#
3416# @len: maximum progress value
3417#
3418# @offset: current progress value. On success this is equal to len.
3419# On failure this is less than len
3420#
3421# @speed: rate limit, bytes per second
3422#
3423# Since: 1.1
e161df39
MAL
3424#
3425# Example:
3426#
3427# <- { "event": "BLOCK_JOB_CANCELLED",
3428# "data": { "type": "stream", "device": "virtio-disk0",
3429# "len": 10737418240, "offset": 134217728,
3430# "speed": 0 },
3431# "timestamp": { "seconds": 1267061043, "microseconds": 959568 } }
3432#
bcada37b
WX
3433##
3434{ 'event': 'BLOCK_JOB_CANCELLED',
3435 'data': { 'type' : 'BlockJobType',
3436 'device': 'str',
3437 'len' : 'int',
3438 'offset': 'int',
3439 'speed' : 'int' } }
3440
5a2d2cbd 3441##
5072f7b3 3442# @BLOCK_JOB_ERROR:
5a2d2cbd
WX
3443#
3444# Emitted when a block job encounters an error
3445#
6aae5be6
AG
3446# @device: The job identifier. Originally the device name but other
3447# values are allowed since QEMU 2.7
5a2d2cbd
WX
3448#
3449# @operation: I/O operation
3450#
3451# @action: action that has been taken
3452#
3453# Since: 1.3
af0e0910
MAL
3454#
3455# Example:
3456#
3457# <- { "event": "BLOCK_JOB_ERROR",
3458# "data": { "device": "ide0-hd1",
3459# "operation": "write",
3460# "action": "stop" },
3461# "timestamp": { "seconds": 1265044230, "microseconds": 450486 } }
3462#
5a2d2cbd
WX
3463##
3464{ 'event': 'BLOCK_JOB_ERROR',
3465 'data': { 'device' : 'str',
3466 'operation': 'IoOperationType',
823c6863 3467 'action' : 'BlockErrorAction' } }
bcada37b
WX
3468
3469##
5072f7b3 3470# @BLOCK_JOB_READY:
bcada37b
WX
3471#
3472# Emitted when a block job is ready to complete
3473#
518848a2
MA
3474# @type: job type
3475#
6aae5be6
AG
3476# @device: The job identifier. Originally the device name but other
3477# values are allowed since QEMU 2.7
bcada37b 3478#
518848a2
MA
3479# @len: maximum progress value
3480#
3481# @offset: current progress value. On success this is equal to len.
3482# On failure this is less than len
3483#
3484# @speed: rate limit, bytes per second
3485#
bcada37b
WX
3486# Note: The "ready to complete" status is always reset by a @BLOCK_JOB_ERROR
3487# event
3488#
3489# Since: 1.3
11a3dee1
MAL
3490#
3491# Example:
3492#
3493# <- { "event": "BLOCK_JOB_READY",
3494# "data": { "device": "drive0", "type": "mirror", "speed": 0,
3495# "len": 2097152, "offset": 2097152 }
3496# "timestamp": { "seconds": 1265044230, "microseconds": 450486 } }
3497#
bcada37b
WX
3498##
3499{ 'event': 'BLOCK_JOB_READY',
518848a2
MA
3500 'data': { 'type' : 'BlockJobType',
3501 'device': 'str',
3502 'len' : 'int',
3503 'offset': 'int',
3504 'speed' : 'int' } }
ffeaac9b 3505
49687ace 3506##
5072f7b3 3507# @PreallocMode:
ffeaac9b
HT
3508#
3509# Preallocation mode of QEMU image file
3510#
3511# @off: no preallocation
3512# @metadata: preallocate only for metadata
3513# @falloc: like @full preallocation but allocate disk space by
3514# posix_fallocate() rather than writing zeros.
3515# @full: preallocate all data by writing zeros to device to ensure disk
3516# space is really available. @full preallocation also sets up
3517# metadata correctly.
3518#
5072f7b3 3519# Since: 2.2
ffeaac9b
HT
3520##
3521{ 'enum': 'PreallocMode',
3522 'data': [ 'off', 'metadata', 'falloc', 'full' ] }
e2462113
FR
3523
3524##
5072f7b3 3525# @BLOCK_WRITE_THRESHOLD:
e2462113
FR
3526#
3527# Emitted when writes on block device reaches or exceeds the
3528# configured write threshold. For thin-provisioned devices, this
3529# means the device should be extended to avoid pausing for
3530# disk exhaustion.
3531# The event is one shot. Once triggered, it needs to be
3532# re-registered with another block-set-threshold command.
3533#
3534# @node-name: graph node name on which the threshold was exceeded.
3535#
3536# @amount-exceeded: amount of data which exceeded the threshold, in bytes.
3537#
3538# @write-threshold: last configured threshold, in bytes.
3539#
3540# Since: 2.3
3541##
3542{ 'event': 'BLOCK_WRITE_THRESHOLD',
3543 'data': { 'node-name': 'str',
3544 'amount-exceeded': 'uint64',
3545 'write-threshold': 'uint64' } }
3546
3547##
5072f7b3 3548# @block-set-write-threshold:
e2462113 3549#
e817862b
MAL
3550# Change the write threshold for a block drive. An event will be
3551# delivered if a write to this block drive crosses the configured
3552# threshold. The threshold is an offset, thus must be
3553# non-negative. Default is no write threshold. Setting the threshold
3554# to zero disables it.
3555#
e2462113
FR
3556# This is useful to transparently resize thin-provisioned drives without
3557# the guest OS noticing.
3558#
3559# @node-name: graph node name on which the threshold must be set.
3560#
3561# @write-threshold: configured threshold for the block device, bytes.
3562# Use 0 to disable the threshold.
3563#
e2462113 3564# Since: 2.3
e817862b
MAL
3565#
3566# Example:
3567#
3568# -> { "execute": "block-set-write-threshold",
3569# "arguments": { "node-name": "mydev",
3570# "write-threshold": 17179869184 } }
3571# <- { "return": {} }
3572#
e2462113
FR
3573##
3574{ 'command': 'block-set-write-threshold',
3575 'data': { 'node-name': 'str', 'write-threshold': 'uint64' } }
7f821597
WC
3576
3577##
5072f7b3 3578# @x-blockdev-change:
7f821597
WC
3579#
3580# Dynamically reconfigure the block driver state graph. It can be used
3581# to add, remove, insert or replace a graph node. Currently only the
3582# Quorum driver implements this feature to add or remove its child. This
3583# is useful to fix a broken quorum child.
3584#
3585# If @node is specified, it will be inserted under @parent. @child
3586# may not be specified in this case. If both @parent and @child are
3587# specified but @node is not, @child will be detached from @parent.
3588#
3589# @parent: the id or name of the parent node.
3590#
3591# @child: #optional the name of a child under the given parent node.
3592#
3593# @node: #optional the name of the node that will be added.
3594#
3595# Note: this command is experimental, and its API is not stable. It
3596# does not support all kinds of operations, all kinds of children, nor
3597# all block drivers.
3598#
3599# Warning: The data in a new quorum child MUST be consistent with that of
3600# the rest of the array.
3601#
3602# Since: 2.7
bd77ea2e
MAL
3603#
3604# Example:
3605#
3606# 1. Add a new node to a quorum
3607# -> { "execute": "blockdev-add",
3608# "arguments": {
3609# "options": { "driver": "raw",
3610# "node-name": "new_node",
3611# "file": { "driver": "file",
3612# "filename": "test.raw" } } } }
3613# <- { "return": {} }
3614# -> { "execute": "x-blockdev-change",
3615# "arguments": { "parent": "disk1",
3616# "node": "new_node" } }
3617# <- { "return": {} }
3618#
3619# 2. Delete a quorum's node
3620# -> { "execute": "x-blockdev-change",
3621# "arguments": { "parent": "disk1",
3622# "child": "children.1" } }
3623# <- { "return": {} }
3624#
7f821597
WC
3625##
3626{ 'command': 'x-blockdev-change',
3627 'data' : { 'parent': 'str',
3628 '*child': 'str',
3629 '*node': 'str' } }