xref: /openbmc/qemu/qapi/block-core.json (revision 47451466)
1# -*- Mode: Python -*-
2
3##
4# == Block core (VM unrelated)
5##
6
7{ 'include': 'common.json' }
8{ 'include': 'crypto.json' }
9{ 'include': 'job.json' }
10{ 'include': 'sockets.json' }
11
12##
13# @SnapshotInfo:
14#
15# @id: unique snapshot id
16#
17# @name: user chosen name
18#
19# @vm-state-size: size of the VM state
20#
21# @date-sec: UTC date of the snapshot in seconds
22#
23# @date-nsec: fractional part in nano seconds to be used with date-sec
24#
25# @vm-clock-sec: VM clock relative to boot in seconds
26#
27# @vm-clock-nsec: fractional part in nano seconds to be used with vm-clock-sec
28#
29# Since: 1.3
30#
31##
32{ 'struct': 'SnapshotInfo',
33  'data': { 'id': 'str', 'name': 'str', 'vm-state-size': 'int',
34            'date-sec': 'int', 'date-nsec': 'int',
35            'vm-clock-sec': 'int', 'vm-clock-nsec': 'int' } }
36
37##
38# @ImageInfoSpecificQCow2EncryptionBase:
39#
40# @format: The encryption format
41#
42# Since: 2.10
43##
44{ 'struct': 'ImageInfoSpecificQCow2EncryptionBase',
45  'data': { 'format': 'BlockdevQcow2EncryptionFormat'}}
46
47##
48# @ImageInfoSpecificQCow2Encryption:
49#
50# Since: 2.10
51##
52{ 'union': 'ImageInfoSpecificQCow2Encryption',
53  'base': 'ImageInfoSpecificQCow2EncryptionBase',
54  'discriminator': 'format',
55  'data': { 'aes': 'QCryptoBlockInfoQCow',
56            'luks': 'QCryptoBlockInfoLUKS' } }
57
58##
59# @ImageInfoSpecificQCow2:
60#
61# @compat: compatibility level
62#
63# @lazy-refcounts: on or off; only valid for compat >= 1.1
64#
65# @corrupt: true if the image has been marked corrupt; only valid for
66#           compat >= 1.1 (since 2.2)
67#
68# @refcount-bits: width of a refcount entry in bits (since 2.3)
69#
70# @encrypt: details about encryption parameters; only set if image
71#           is encrypted (since 2.10)
72#
73# Since: 1.7
74##
75{ 'struct': 'ImageInfoSpecificQCow2',
76  'data': {
77      'compat': 'str',
78      '*lazy-refcounts': 'bool',
79      '*corrupt': 'bool',
80      'refcount-bits': 'int',
81      '*encrypt': 'ImageInfoSpecificQCow2Encryption'
82  } }
83
84##
85# @ImageInfoSpecificVmdk:
86#
87# @create-type: The create type of VMDK image
88#
89# @cid: Content id of image
90#
91# @parent-cid: Parent VMDK image's cid
92#
93# @extents: List of extent files
94#
95# Since: 1.7
96##
97{ 'struct': 'ImageInfoSpecificVmdk',
98  'data': {
99      'create-type': 'str',
100      'cid': 'int',
101      'parent-cid': 'int',
102      'extents': ['ImageInfo']
103  } }
104
105##
106# @ImageInfoSpecific:
107#
108# A discriminated record of image format specific information structures.
109#
110# Since: 1.7
111##
112{ 'union': 'ImageInfoSpecific',
113  'data': {
114      'qcow2': 'ImageInfoSpecificQCow2',
115      'vmdk': 'ImageInfoSpecificVmdk',
116      # If we need to add block driver specific parameters for
117      # LUKS in future, then we'll subclass QCryptoBlockInfoLUKS
118      # to define a ImageInfoSpecificLUKS
119      'luks': 'QCryptoBlockInfoLUKS'
120  } }
121
122##
123# @ImageInfo:
124#
125# Information about a QEMU image file
126#
127# @filename: name of the image file
128#
129# @format: format of the image file
130#
131# @virtual-size: maximum capacity in bytes of the image
132#
133# @actual-size: actual size on disk in bytes of the image
134#
135# @dirty-flag: true if image is not cleanly closed
136#
137# @cluster-size: size of a cluster in bytes
138#
139# @encrypted: true if the image is encrypted
140#
141# @compressed: true if the image is compressed (Since 1.7)
142#
143# @backing-filename: name of the backing file
144#
145# @full-backing-filename: full path of the backing file
146#
147# @backing-filename-format: the format of the backing file
148#
149# @snapshots: list of VM snapshots
150#
151# @backing-image: info of the backing image (since 1.6)
152#
153# @format-specific: structure supplying additional format-specific
154# information (since 1.7)
155#
156# Since: 1.3
157#
158##
159{ 'struct': 'ImageInfo',
160  'data': {'filename': 'str', 'format': 'str', '*dirty-flag': 'bool',
161           '*actual-size': 'int', 'virtual-size': 'int',
162           '*cluster-size': 'int', '*encrypted': 'bool', '*compressed': 'bool',
163           '*backing-filename': 'str', '*full-backing-filename': 'str',
164           '*backing-filename-format': 'str', '*snapshots': ['SnapshotInfo'],
165           '*backing-image': 'ImageInfo',
166           '*format-specific': 'ImageInfoSpecific' } }
167
168##
169# @ImageCheck:
170#
171# Information about a QEMU image file check
172#
173# @filename: name of the image file checked
174#
175# @format: format of the image file checked
176#
177# @check-errors: number of unexpected errors occurred during check
178#
179# @image-end-offset: offset (in bytes) where the image ends, this
180#                    field is present if the driver for the image format
181#                    supports it
182#
183# @corruptions: number of corruptions found during the check if any
184#
185# @leaks: number of leaks found during the check if any
186#
187# @corruptions-fixed: number of corruptions fixed during the check
188#                     if any
189#
190# @leaks-fixed: number of leaks fixed during the check if any
191#
192# @total-clusters: total number of clusters, this field is present
193#                  if the driver for the image format supports it
194#
195# @allocated-clusters: total number of allocated clusters, this
196#                      field is present if the driver for the image format
197#                      supports it
198#
199# @fragmented-clusters: total number of fragmented clusters, this
200#                       field is present if the driver for the image format
201#                       supports it
202#
203# @compressed-clusters: total number of compressed clusters, this
204#                       field is present if the driver for the image format
205#                       supports it
206#
207# Since: 1.4
208#
209##
210{ 'struct': 'ImageCheck',
211  'data': {'filename': 'str', 'format': 'str', 'check-errors': 'int',
212           '*image-end-offset': 'int', '*corruptions': 'int', '*leaks': 'int',
213           '*corruptions-fixed': 'int', '*leaks-fixed': 'int',
214           '*total-clusters': 'int', '*allocated-clusters': 'int',
215           '*fragmented-clusters': 'int', '*compressed-clusters': 'int' } }
216
217##
218# @MapEntry:
219#
220# Mapping information from a virtual block range to a host file range
221#
222# @start: the start byte of the mapped virtual range
223#
224# @length: the number of bytes of the mapped virtual range
225#
226# @data: whether the mapped range has data
227#
228# @zero: whether the virtual blocks are zeroed
229#
230# @depth: the depth of the mapping
231#
232# @offset: the offset in file that the virtual sectors are mapped to
233#
234# @filename: filename that is referred to by @offset
235#
236# Since: 2.6
237#
238##
239{ 'struct': 'MapEntry',
240  'data': {'start': 'int', 'length': 'int', 'data': 'bool',
241           'zero': 'bool', 'depth': 'int', '*offset': 'int',
242           '*filename': 'str' } }
243
244##
245# @BlockdevCacheInfo:
246#
247# Cache mode information for a block device
248#
249# @writeback:   true if writeback mode is enabled
250# @direct:      true if the host page cache is bypassed (O_DIRECT)
251# @no-flush:    true if flush requests are ignored for the device
252#
253# Since: 2.3
254##
255{ 'struct': 'BlockdevCacheInfo',
256  'data': { 'writeback': 'bool',
257            'direct': 'bool',
258            'no-flush': 'bool' } }
259
260##
261# @BlockDeviceInfo:
262#
263# Information about the backing device for a block device.
264#
265# @file: the filename of the backing device
266#
267# @node-name: the name of the block driver node (Since 2.0)
268#
269# @ro: true if the backing device was open read-only
270#
271# @drv: the name of the block format used to open the backing device. As of
272#       0.14.0 this can be: 'blkdebug', 'bochs', 'cloop', 'cow', 'dmg',
273#       'file', 'file', 'ftp', 'ftps', 'host_cdrom', 'host_device',
274#       'http', 'https', 'luks', 'nbd', 'parallels', 'qcow',
275#       'qcow2', 'raw', 'vdi', 'vmdk', 'vpc', 'vvfat'
276#       2.2: 'archipelago' added, 'cow' dropped
277#       2.3: 'host_floppy' deprecated
278#       2.5: 'host_floppy' dropped
279#       2.6: 'luks' added
280#       2.8: 'replication' added, 'tftp' dropped
281#       2.9: 'archipelago' dropped
282#
283# @backing_file: the name of the backing file (for copy-on-write)
284#
285# @backing_file_depth: number of files in the backing file chain (since: 1.2)
286#
287# @encrypted: true if the backing device is encrypted
288#
289# @encryption_key_missing: Deprecated; always false
290#
291# @detect_zeroes: detect and optimize zero writes (Since 2.1)
292#
293# @bps: total throughput limit in bytes per second is specified
294#
295# @bps_rd: read throughput limit in bytes per second is specified
296#
297# @bps_wr: write throughput limit in bytes per second is specified
298#
299# @iops: total I/O operations per second is specified
300#
301# @iops_rd: read I/O operations per second is specified
302#
303# @iops_wr: write I/O operations per second is specified
304#
305# @image: the info of image used (since: 1.6)
306#
307# @bps_max: total throughput limit during bursts,
308#                     in bytes (Since 1.7)
309#
310# @bps_rd_max: read throughput limit during bursts,
311#                        in bytes (Since 1.7)
312#
313# @bps_wr_max: write throughput limit during bursts,
314#                        in bytes (Since 1.7)
315#
316# @iops_max: total I/O operations per second during bursts,
317#                      in bytes (Since 1.7)
318#
319# @iops_rd_max: read I/O operations per second during bursts,
320#                         in bytes (Since 1.7)
321#
322# @iops_wr_max: write I/O operations per second during bursts,
323#                         in bytes (Since 1.7)
324#
325# @bps_max_length: maximum length of the @bps_max burst
326#                            period, in seconds. (Since 2.6)
327#
328# @bps_rd_max_length: maximum length of the @bps_rd_max
329#                               burst period, in seconds. (Since 2.6)
330#
331# @bps_wr_max_length: maximum length of the @bps_wr_max
332#                               burst period, in seconds. (Since 2.6)
333#
334# @iops_max_length: maximum length of the @iops burst
335#                             period, in seconds. (Since 2.6)
336#
337# @iops_rd_max_length: maximum length of the @iops_rd_max
338#                                burst period, in seconds. (Since 2.6)
339#
340# @iops_wr_max_length: maximum length of the @iops_wr_max
341#                                burst period, in seconds. (Since 2.6)
342#
343# @iops_size: an I/O size in bytes (Since 1.7)
344#
345# @group: throttle group name (Since 2.4)
346#
347# @cache: the cache mode used for the block device (since: 2.3)
348#
349# @write_threshold: configured write threshold for the device.
350#                   0 if disabled. (Since 2.3)
351#
352# Since: 0.14.0
353#
354##
355{ 'struct': 'BlockDeviceInfo',
356  'data': { 'file': 'str', '*node-name': 'str', 'ro': 'bool', 'drv': 'str',
357            '*backing_file': 'str', 'backing_file_depth': 'int',
358            'encrypted': 'bool', 'encryption_key_missing': 'bool',
359            'detect_zeroes': 'BlockdevDetectZeroesOptions',
360            'bps': 'int', 'bps_rd': 'int', 'bps_wr': 'int',
361            'iops': 'int', 'iops_rd': 'int', 'iops_wr': 'int',
362            'image': 'ImageInfo',
363            '*bps_max': 'int', '*bps_rd_max': 'int',
364            '*bps_wr_max': 'int', '*iops_max': 'int',
365            '*iops_rd_max': 'int', '*iops_wr_max': 'int',
366            '*bps_max_length': 'int', '*bps_rd_max_length': 'int',
367            '*bps_wr_max_length': 'int', '*iops_max_length': 'int',
368            '*iops_rd_max_length': 'int', '*iops_wr_max_length': 'int',
369            '*iops_size': 'int', '*group': 'str', 'cache': 'BlockdevCacheInfo',
370            'write_threshold': 'int' } }
371
372##
373# @BlockDeviceIoStatus:
374#
375# An enumeration of block device I/O status.
376#
377# @ok: The last I/O operation has succeeded
378#
379# @failed: The last I/O operation has failed
380#
381# @nospace: The last I/O operation has failed due to a no-space condition
382#
383# Since: 1.0
384##
385{ 'enum': 'BlockDeviceIoStatus', 'data': [ 'ok', 'failed', 'nospace' ] }
386
387##
388# @BlockDeviceMapEntry:
389#
390# Entry in the metadata map of the device (returned by "qemu-img map")
391#
392# @start: Offset in the image of the first byte described by this entry
393#         (in bytes)
394#
395# @length: Length of the range described by this entry (in bytes)
396#
397# @depth: Number of layers (0 = top image, 1 = top image's backing file, etc.)
398#         before reaching one for which the range is allocated.  The value is
399#         in the range 0 to the depth of the image chain - 1.
400#
401# @zero: the sectors in this range read as zeros
402#
403# @data: reading the image will actually read data from a file (in particular,
404#        if @offset is present this means that the sectors are not simply
405#        preallocated, but contain actual data in raw format)
406#
407# @offset: if present, the image file stores the data for this range in
408#          raw format at the given offset.
409#
410# Since: 1.7
411##
412{ 'struct': 'BlockDeviceMapEntry',
413  'data': { 'start': 'int', 'length': 'int', 'depth': 'int', 'zero': 'bool',
414            'data': 'bool', '*offset': 'int' } }
415
416##
417# @DirtyBitmapStatus:
418#
419# An enumeration of possible states that a dirty bitmap can report to the user.
420#
421# @frozen: The bitmap is currently in-use by a backup operation or block job,
422#          and is immutable.
423#
424# @disabled: The bitmap is currently in-use by an internal operation and is
425#            read-only. It can still be deleted.
426#
427# @active: The bitmap is actively monitoring for new writes, and can be cleared,
428#          deleted, or used for backup operations.
429#
430# @locked: The bitmap is currently in-use by some operation and can not be
431#          cleared, deleted, or used for backup operations. (Since 2.12)
432#
433# Since: 2.4
434##
435{ 'enum': 'DirtyBitmapStatus',
436  'data': ['active', 'disabled', 'frozen', 'locked'] }
437
438##
439# @BlockDirtyInfo:
440#
441# Block dirty bitmap information.
442#
443# @name: the name of the dirty bitmap (Since 2.4)
444#
445# @count: number of dirty bytes according to the dirty bitmap
446#
447# @granularity: granularity of the dirty bitmap in bytes (since 1.4)
448#
449# @status: current status of the dirty bitmap (since 2.4)
450#
451# Since: 1.3
452##
453{ 'struct': 'BlockDirtyInfo',
454  'data': {'*name': 'str', 'count': 'int', 'granularity': 'uint32',
455           'status': 'DirtyBitmapStatus'} }
456
457##
458# @BlockLatencyHistogramInfo:
459#
460# Block latency histogram.
461#
462# @boundaries: list of interval boundary values in nanoseconds, all greater
463#              than zero and in ascending order.
464#              For example, the list [10, 50, 100] produces the following
465#              histogram intervals: [0, 10), [10, 50), [50, 100), [100, +inf).
466#
467# @bins: list of io request counts corresponding to histogram intervals.
468#        len(@bins) = len(@boundaries) + 1
469#        For the example above, @bins may be something like [3, 1, 5, 2],
470#        and corresponding histogram looks like:
471#
472#        5|           *
473#        4|           *
474#        3| *         *
475#        2| *         *    *
476#        1| *    *    *    *
477#         +------------------
478#             10   50   100
479#
480# Since: 2.12
481##
482{ 'struct': 'BlockLatencyHistogramInfo',
483  'data': {'boundaries': ['uint64'], 'bins': ['uint64'] } }
484
485##
486# @x-block-latency-histogram-set:
487#
488# Manage read, write and flush latency histograms for the device.
489#
490# If only @device parameter is specified, remove all present latency histograms
491# for the device. Otherwise, add/reset some of (or all) latency histograms.
492#
493# @device: device name to set latency histogram for.
494#
495# @boundaries: list of interval boundary values (see description in
496#              BlockLatencyHistogramInfo definition). If specified, all
497#              latency histograms are removed, and empty ones created for all
498#              io types with intervals corresponding to @boundaries (except for
499#              io types, for which specific boundaries are set through the
500#              following parameters).
501#
502# @boundaries-read: list of interval boundary values for read latency
503#                   histogram. If specified, old read latency histogram is
504#                   removed, and empty one created with intervals
505#                   corresponding to @boundaries-read. The parameter has higher
506#                   priority then @boundaries.
507#
508# @boundaries-write: list of interval boundary values for write latency
509#                    histogram.
510#
511# @boundaries-flush: list of interval boundary values for flush latency
512#                    histogram.
513#
514# Returns: error if device is not found or any boundary arrays are invalid.
515#
516# Since: 2.12
517#
518# Example: set new histograms for all io types with intervals
519# [0, 10), [10, 50), [50, 100), [100, +inf):
520#
521# -> { "execute": "block-latency-histogram-set",
522#      "arguments": { "device": "drive0",
523#                     "boundaries": [10, 50, 100] } }
524# <- { "return": {} }
525#
526# Example: set new histogram only for write, other histograms will remain
527# not changed (or not created):
528#
529# -> { "execute": "block-latency-histogram-set",
530#      "arguments": { "device": "drive0",
531#                     "boundaries-write": [10, 50, 100] } }
532# <- { "return": {} }
533#
534# Example: set new histograms with the following intervals:
535#   read, flush: [0, 10), [10, 50), [50, 100), [100, +inf)
536#   write: [0, 1000), [1000, 5000), [5000, +inf)
537#
538# -> { "execute": "block-latency-histogram-set",
539#      "arguments": { "device": "drive0",
540#                     "boundaries": [10, 50, 100],
541#                     "boundaries-write": [1000, 5000] } }
542# <- { "return": {} }
543#
544# Example: remove all latency histograms:
545#
546# -> { "execute": "block-latency-histogram-set",
547#      "arguments": { "device": "drive0" } }
548# <- { "return": {} }
549##
550{ 'command': 'x-block-latency-histogram-set',
551  'data': {'device': 'str',
552           '*boundaries': ['uint64'],
553           '*boundaries-read': ['uint64'],
554           '*boundaries-write': ['uint64'],
555           '*boundaries-flush': ['uint64'] } }
556
557##
558# @BlockInfo:
559#
560# Block device information.  This structure describes a virtual device and
561# the backing device associated with it.
562#
563# @device: The device name associated with the virtual device.
564#
565# @qdev: The qdev ID, or if no ID is assigned, the QOM path of the block
566#        device. (since 2.10)
567#
568# @type: This field is returned only for compatibility reasons, it should
569#        not be used (always returns 'unknown')
570#
571# @removable: True if the device supports removable media.
572#
573# @locked: True if the guest has locked this device from having its media
574#          removed
575#
576# @tray_open: True if the device's tray is open
577#             (only present if it has a tray)
578#
579# @dirty-bitmaps: dirty bitmaps information (only present if the
580#                 driver has one or more dirty bitmaps) (Since 2.0)
581#
582# @io-status: @BlockDeviceIoStatus. Only present if the device
583#             supports it and the VM is configured to stop on errors
584#             (supported device models: virtio-blk, IDE, SCSI except
585#             scsi-generic)
586#
587# @inserted: @BlockDeviceInfo describing the device if media is
588#            present
589#
590# Since:  0.14.0
591##
592{ 'struct': 'BlockInfo',
593  'data': {'device': 'str', '*qdev': 'str', 'type': 'str', 'removable': 'bool',
594           'locked': 'bool', '*inserted': 'BlockDeviceInfo',
595           '*tray_open': 'bool', '*io-status': 'BlockDeviceIoStatus',
596           '*dirty-bitmaps': ['BlockDirtyInfo'] } }
597
598##
599# @BlockMeasureInfo:
600#
601# Image file size calculation information.  This structure describes the size
602# requirements for creating a new image file.
603#
604# The size requirements depend on the new image file format.  File size always
605# equals virtual disk size for the 'raw' format, even for sparse POSIX files.
606# Compact formats such as 'qcow2' represent unallocated and zero regions
607# efficiently so file size may be smaller than virtual disk size.
608#
609# The values are upper bounds that are guaranteed to fit the new image file.
610# Subsequent modification, such as internal snapshot or bitmap creation, may
611# require additional space and is not covered here.
612#
613# @required: Size required for a new image file, in bytes.
614#
615# @fully-allocated: Image file size, in bytes, once data has been written
616#                   to all sectors.
617#
618# Since: 2.10
619##
620{ 'struct': 'BlockMeasureInfo',
621  'data': {'required': 'int', 'fully-allocated': 'int'} }
622
623##
624# @query-block:
625#
626# Get a list of BlockInfo for all virtual block devices.
627#
628# Returns: a list of @BlockInfo describing each virtual block device. Filter
629# nodes that were created implicitly are skipped over.
630#
631# Since: 0.14.0
632#
633# Example:
634#
635# -> { "execute": "query-block" }
636# <- {
637#       "return":[
638#          {
639#             "io-status": "ok",
640#             "device":"ide0-hd0",
641#             "locked":false,
642#             "removable":false,
643#             "inserted":{
644#                "ro":false,
645#                "drv":"qcow2",
646#                "encrypted":false,
647#                "file":"disks/test.qcow2",
648#                "backing_file_depth":1,
649#                "bps":1000000,
650#                "bps_rd":0,
651#                "bps_wr":0,
652#                "iops":1000000,
653#                "iops_rd":0,
654#                "iops_wr":0,
655#                "bps_max": 8000000,
656#                "bps_rd_max": 0,
657#                "bps_wr_max": 0,
658#                "iops_max": 0,
659#                "iops_rd_max": 0,
660#                "iops_wr_max": 0,
661#                "iops_size": 0,
662#                "detect_zeroes": "on",
663#                "write_threshold": 0,
664#                "image":{
665#                   "filename":"disks/test.qcow2",
666#                   "format":"qcow2",
667#                   "virtual-size":2048000,
668#                   "backing_file":"base.qcow2",
669#                   "full-backing-filename":"disks/base.qcow2",
670#                   "backing-filename-format":"qcow2",
671#                   "snapshots":[
672#                      {
673#                         "id": "1",
674#                         "name": "snapshot1",
675#                         "vm-state-size": 0,
676#                         "date-sec": 10000200,
677#                         "date-nsec": 12,
678#                         "vm-clock-sec": 206,
679#                         "vm-clock-nsec": 30
680#                      }
681#                   ],
682#                   "backing-image":{
683#                       "filename":"disks/base.qcow2",
684#                       "format":"qcow2",
685#                       "virtual-size":2048000
686#                   }
687#                }
688#             },
689#             "qdev": "ide_disk",
690#             "type":"unknown"
691#          },
692#          {
693#             "io-status": "ok",
694#             "device":"ide1-cd0",
695#             "locked":false,
696#             "removable":true,
697#             "qdev": "/machine/unattached/device[23]",
698#             "tray_open": false,
699#             "type":"unknown"
700#          },
701#          {
702#             "device":"floppy0",
703#             "locked":false,
704#             "removable":true,
705#             "qdev": "/machine/unattached/device[20]",
706#             "type":"unknown"
707#          },
708#          {
709#             "device":"sd0",
710#             "locked":false,
711#             "removable":true,
712#             "type":"unknown"
713#          }
714#       ]
715#    }
716#
717##
718{ 'command': 'query-block', 'returns': ['BlockInfo'] }
719
720
721##
722# @BlockDeviceTimedStats:
723#
724# Statistics of a block device during a given interval of time.
725#
726# @interval_length: Interval used for calculating the statistics,
727#                   in seconds.
728#
729# @min_rd_latency_ns: Minimum latency of read operations in the
730#                     defined interval, in nanoseconds.
731#
732# @min_wr_latency_ns: Minimum latency of write operations in the
733#                     defined interval, in nanoseconds.
734#
735# @min_flush_latency_ns: Minimum latency of flush operations in the
736#                        defined interval, in nanoseconds.
737#
738# @max_rd_latency_ns: Maximum latency of read operations in the
739#                     defined interval, in nanoseconds.
740#
741# @max_wr_latency_ns: Maximum latency of write operations in the
742#                     defined interval, in nanoseconds.
743#
744# @max_flush_latency_ns: Maximum latency of flush operations in the
745#                        defined interval, in nanoseconds.
746#
747# @avg_rd_latency_ns: Average latency of read operations in the
748#                     defined interval, in nanoseconds.
749#
750# @avg_wr_latency_ns: Average latency of write operations in the
751#                     defined interval, in nanoseconds.
752#
753# @avg_flush_latency_ns: Average latency of flush operations in the
754#                        defined interval, in nanoseconds.
755#
756# @avg_rd_queue_depth: Average number of pending read operations
757#                      in the defined interval.
758#
759# @avg_wr_queue_depth: Average number of pending write operations
760#                      in the defined interval.
761#
762# Since: 2.5
763##
764{ 'struct': 'BlockDeviceTimedStats',
765  'data': { 'interval_length': 'int', 'min_rd_latency_ns': 'int',
766            'max_rd_latency_ns': 'int', 'avg_rd_latency_ns': 'int',
767            'min_wr_latency_ns': 'int', 'max_wr_latency_ns': 'int',
768            'avg_wr_latency_ns': 'int', 'min_flush_latency_ns': 'int',
769            'max_flush_latency_ns': 'int', 'avg_flush_latency_ns': 'int',
770            'avg_rd_queue_depth': 'number', 'avg_wr_queue_depth': 'number' } }
771
772##
773# @BlockDeviceStats:
774#
775# Statistics of a virtual block device or a block backing device.
776#
777# @rd_bytes:      The number of bytes read by the device.
778#
779# @wr_bytes:      The number of bytes written by the device.
780#
781# @rd_operations: The number of read operations performed by the device.
782#
783# @wr_operations: The number of write operations performed by the device.
784#
785# @flush_operations: The number of cache flush operations performed by the
786#                    device (since 0.15.0)
787#
788# @flush_total_time_ns: Total time spend on cache flushes in nano-seconds
789#                       (since 0.15.0).
790#
791# @wr_total_time_ns: Total time spend on writes in nano-seconds (since 0.15.0).
792#
793# @rd_total_time_ns: Total_time_spend on reads in nano-seconds (since 0.15.0).
794#
795# @wr_highest_offset: The offset after the greatest byte written to the
796#                     device.  The intended use of this information is for
797#                     growable sparse files (like qcow2) that are used on top
798#                     of a physical device.
799#
800# @rd_merged: Number of read requests that have been merged into another
801#             request (Since 2.3).
802#
803# @wr_merged: Number of write requests that have been merged into another
804#             request (Since 2.3).
805#
806# @idle_time_ns: Time since the last I/O operation, in
807#                nanoseconds. If the field is absent it means that
808#                there haven't been any operations yet (Since 2.5).
809#
810# @failed_rd_operations: The number of failed read operations
811#                        performed by the device (Since 2.5)
812#
813# @failed_wr_operations: The number of failed write operations
814#                        performed by the device (Since 2.5)
815#
816# @failed_flush_operations: The number of failed flush operations
817#                           performed by the device (Since 2.5)
818#
819# @invalid_rd_operations: The number of invalid read operations
820#                          performed by the device (Since 2.5)
821#
822# @invalid_wr_operations: The number of invalid write operations
823#                         performed by the device (Since 2.5)
824#
825# @invalid_flush_operations: The number of invalid flush operations
826#                            performed by the device (Since 2.5)
827#
828# @account_invalid: Whether invalid operations are included in the
829#                   last access statistics (Since 2.5)
830#
831# @account_failed: Whether failed operations are included in the
832#                  latency and last access statistics (Since 2.5)
833#
834# @timed_stats: Statistics specific to the set of previously defined
835#               intervals of time (Since 2.5)
836#
837# @x_rd_latency_histogram: @BlockLatencyHistogramInfo. (Since 2.12)
838#
839# @x_wr_latency_histogram: @BlockLatencyHistogramInfo. (Since 2.12)
840#
841# @x_flush_latency_histogram: @BlockLatencyHistogramInfo. (Since 2.12)
842#
843# Since: 0.14.0
844##
845{ 'struct': 'BlockDeviceStats',
846  'data': {'rd_bytes': 'int', 'wr_bytes': 'int', 'rd_operations': 'int',
847           'wr_operations': 'int', 'flush_operations': 'int',
848           'flush_total_time_ns': 'int', 'wr_total_time_ns': 'int',
849           'rd_total_time_ns': 'int', 'wr_highest_offset': 'int',
850           'rd_merged': 'int', 'wr_merged': 'int', '*idle_time_ns': 'int',
851           'failed_rd_operations': 'int', 'failed_wr_operations': 'int',
852           'failed_flush_operations': 'int', 'invalid_rd_operations': 'int',
853           'invalid_wr_operations': 'int', 'invalid_flush_operations': 'int',
854           'account_invalid': 'bool', 'account_failed': 'bool',
855           'timed_stats': ['BlockDeviceTimedStats'],
856           '*x_rd_latency_histogram': 'BlockLatencyHistogramInfo',
857           '*x_wr_latency_histogram': 'BlockLatencyHistogramInfo',
858           '*x_flush_latency_histogram': 'BlockLatencyHistogramInfo' } }
859
860##
861# @BlockStats:
862#
863# Statistics of a virtual block device or a block backing device.
864#
865# @device: If the stats are for a virtual block device, the name
866#          corresponding to the virtual block device.
867#
868# @node-name: The node name of the device. (Since 2.3)
869#
870# @stats:  A @BlockDeviceStats for the device.
871#
872# @parent: This describes the file block device if it has one.
873#          Contains recursively the statistics of the underlying
874#          protocol (e.g. the host file for a qcow2 image). If there is
875#          no underlying protocol, this field is omitted
876#
877# @backing: This describes the backing block device if it has one.
878#           (Since 2.0)
879#
880# Since: 0.14.0
881##
882{ 'struct': 'BlockStats',
883  'data': {'*device': 'str', '*node-name': 'str',
884           'stats': 'BlockDeviceStats',
885           '*parent': 'BlockStats',
886           '*backing': 'BlockStats'} }
887
888##
889# @query-blockstats:
890#
891# Query the @BlockStats for all virtual block devices.
892#
893# @query-nodes: If true, the command will query all the block nodes
894#               that have a node name, in a list which will include "parent"
895#               information, but not "backing".
896#               If false or omitted, the behavior is as before - query all the
897#               device backends, recursively including their "parent" and
898#               "backing". Filter nodes that were created implicitly are
899#               skipped over in this mode. (Since 2.3)
900#
901# Returns: A list of @BlockStats for each virtual block devices.
902#
903# Since: 0.14.0
904#
905# Example:
906#
907# -> { "execute": "query-blockstats" }
908# <- {
909#       "return":[
910#          {
911#             "device":"ide0-hd0",
912#             "parent":{
913#                "stats":{
914#                   "wr_highest_offset":3686448128,
915#                   "wr_bytes":9786368,
916#                   "wr_operations":751,
917#                   "rd_bytes":122567168,
918#                   "rd_operations":36772
919#                   "wr_total_times_ns":313253456
920#                   "rd_total_times_ns":3465673657
921#                   "flush_total_times_ns":49653
922#                   "flush_operations":61,
923#                   "rd_merged":0,
924#                   "wr_merged":0,
925#                   "idle_time_ns":2953431879,
926#                   "account_invalid":true,
927#                   "account_failed":false
928#                }
929#             },
930#             "stats":{
931#                "wr_highest_offset":2821110784,
932#                "wr_bytes":9786368,
933#                "wr_operations":692,
934#                "rd_bytes":122739200,
935#                "rd_operations":36604
936#                "flush_operations":51,
937#                "wr_total_times_ns":313253456
938#                "rd_total_times_ns":3465673657
939#                "flush_total_times_ns":49653,
940#                "rd_merged":0,
941#                "wr_merged":0,
942#                "idle_time_ns":2953431879,
943#                "account_invalid":true,
944#                "account_failed":false
945#             }
946#          },
947#          {
948#             "device":"ide1-cd0",
949#             "stats":{
950#                "wr_highest_offset":0,
951#                "wr_bytes":0,
952#                "wr_operations":0,
953#                "rd_bytes":0,
954#                "rd_operations":0
955#                "flush_operations":0,
956#                "wr_total_times_ns":0
957#                "rd_total_times_ns":0
958#                "flush_total_times_ns":0,
959#                "rd_merged":0,
960#                "wr_merged":0,
961#                "account_invalid":false,
962#                "account_failed":false
963#             }
964#          },
965#          {
966#             "device":"floppy0",
967#             "stats":{
968#                "wr_highest_offset":0,
969#                "wr_bytes":0,
970#                "wr_operations":0,
971#                "rd_bytes":0,
972#                "rd_operations":0
973#                "flush_operations":0,
974#                "wr_total_times_ns":0
975#                "rd_total_times_ns":0
976#                "flush_total_times_ns":0,
977#                "rd_merged":0,
978#                "wr_merged":0,
979#                "account_invalid":false,
980#                "account_failed":false
981#             }
982#          },
983#          {
984#             "device":"sd0",
985#             "stats":{
986#                "wr_highest_offset":0,
987#                "wr_bytes":0,
988#                "wr_operations":0,
989#                "rd_bytes":0,
990#                "rd_operations":0
991#                "flush_operations":0,
992#                "wr_total_times_ns":0
993#                "rd_total_times_ns":0
994#                "flush_total_times_ns":0,
995#                "rd_merged":0,
996#                "wr_merged":0,
997#                "account_invalid":false,
998#                "account_failed":false
999#             }
1000#          }
1001#       ]
1002#    }
1003#
1004##
1005{ 'command': 'query-blockstats',
1006  'data': { '*query-nodes': 'bool' },
1007  'returns': ['BlockStats'] }
1008
1009##
1010# @BlockdevOnError:
1011#
1012# An enumeration of possible behaviors for errors on I/O operations.
1013# The exact meaning depends on whether the I/O was initiated by a guest
1014# or by a block job
1015#
1016# @report: for guest operations, report the error to the guest;
1017#          for jobs, cancel the job
1018#
1019# @ignore: ignore the error, only report a QMP event (BLOCK_IO_ERROR
1020#          or BLOCK_JOB_ERROR)
1021#
1022# @enospc: same as @stop on ENOSPC, same as @report otherwise.
1023#
1024# @stop: for guest operations, stop the virtual machine;
1025#        for jobs, pause the job
1026#
1027# @auto: inherit the error handling policy of the backend (since: 2.7)
1028#
1029# Since: 1.3
1030##
1031{ 'enum': 'BlockdevOnError',
1032  'data': ['report', 'ignore', 'enospc', 'stop', 'auto'] }
1033
1034##
1035# @MirrorSyncMode:
1036#
1037# An enumeration of possible behaviors for the initial synchronization
1038# phase of storage mirroring.
1039#
1040# @top: copies data in the topmost image to the destination
1041#
1042# @full: copies data from all images to the destination
1043#
1044# @none: only copy data written from now on
1045#
1046# @incremental: only copy data described by the dirty bitmap. Since: 2.4
1047#
1048# Since: 1.3
1049##
1050{ 'enum': 'MirrorSyncMode',
1051  'data': ['top', 'full', 'none', 'incremental'] }
1052
1053##
1054# @BlockJobInfo:
1055#
1056# Information about a long-running block device operation.
1057#
1058# @type: the job type ('stream' for image streaming)
1059#
1060# @device: The job identifier. Originally the device name but other
1061#          values are allowed since QEMU 2.7
1062#
1063# @len: Estimated @offset value at the completion of the job. This value can
1064#       arbitrarily change while the job is running, in both directions.
1065#
1066# @offset: Progress made until now. The unit is arbitrary and the value can
1067#          only meaningfully be used for the ratio of @offset to @len. The
1068#          value is monotonically increasing.
1069#
1070# @busy: false if the job is known to be in a quiescent state, with
1071#        no pending I/O.  Since 1.3.
1072#
1073# @paused: whether the job is paused or, if @busy is true, will
1074#          pause itself as soon as possible.  Since 1.3.
1075#
1076# @speed: the rate limit, bytes per second
1077#
1078# @io-status: the status of the job (since 1.3)
1079#
1080# @ready: true if the job may be completed (since 2.2)
1081#
1082# @status: Current job state/status (since 2.12)
1083#
1084# @auto-finalize: Job will finalize itself when PENDING, moving to
1085#                 the CONCLUDED state. (since 2.12)
1086#
1087# @auto-dismiss: Job will dismiss itself when CONCLUDED, moving to the NULL
1088#                state and disappearing from the query list. (since 2.12)
1089#
1090# @error: Error information if the job did not complete successfully.
1091#         Not set if the job completed successfully. (since 2.12.1)
1092#
1093# Since: 1.1
1094##
1095{ 'struct': 'BlockJobInfo',
1096  'data': {'type': 'str', 'device': 'str', 'len': 'int',
1097           'offset': 'int', 'busy': 'bool', 'paused': 'bool', 'speed': 'int',
1098           'io-status': 'BlockDeviceIoStatus', 'ready': 'bool',
1099           'status': 'JobStatus',
1100           'auto-finalize': 'bool', 'auto-dismiss': 'bool',
1101           '*error': 'str' } }
1102
1103##
1104# @query-block-jobs:
1105#
1106# Return information about long-running block device operations.
1107#
1108# Returns: a list of @BlockJobInfo for each active block job
1109#
1110# Since: 1.1
1111##
1112{ 'command': 'query-block-jobs', 'returns': ['BlockJobInfo'] }
1113
1114##
1115# @block_passwd:
1116#
1117# This command sets the password of a block device that has not been open
1118# with a password and requires one.
1119#
1120# This command is now obsolete and will always return an error since 2.10
1121#
1122##
1123{ 'command': 'block_passwd', 'data': {'*device': 'str',
1124                                      '*node-name': 'str', 'password': 'str'} }
1125
1126##
1127# @block_resize:
1128#
1129# Resize a block image while a guest is running.
1130#
1131# Either @device or @node-name must be set but not both.
1132#
1133# @device: the name of the device to get the image resized
1134#
1135# @node-name: graph node name to get the image resized (Since 2.0)
1136#
1137# @size:  new image size in bytes
1138#
1139# Returns: nothing on success
1140#          If @device is not a valid block device, DeviceNotFound
1141#
1142# Since: 0.14.0
1143#
1144# Example:
1145#
1146# -> { "execute": "block_resize",
1147#      "arguments": { "device": "scratch", "size": 1073741824 } }
1148# <- { "return": {} }
1149#
1150##
1151{ 'command': 'block_resize', 'data': { '*device': 'str',
1152                                       '*node-name': 'str',
1153                                       'size': 'int' }}
1154
1155##
1156# @NewImageMode:
1157#
1158# An enumeration that tells QEMU how to set the backing file path in
1159# a new image file.
1160#
1161# @existing: QEMU should look for an existing image file.
1162#
1163# @absolute-paths: QEMU should create a new image with absolute paths
1164# for the backing file. If there is no backing file available, the new
1165# image will not be backed either.
1166#
1167# Since: 1.1
1168##
1169{ 'enum': 'NewImageMode',
1170  'data': [ 'existing', 'absolute-paths' ] }
1171
1172##
1173# @BlockdevSnapshotSync:
1174#
1175# Either @device or @node-name must be set but not both.
1176#
1177# @device: the name of the device to generate the snapshot from.
1178#
1179# @node-name: graph node name to generate the snapshot from (Since 2.0)
1180#
1181# @snapshot-file: the target of the new image. If the file exists, or
1182# if it is a device, the snapshot will be created in the existing
1183# file/device. Otherwise, a new file will be created.
1184#
1185# @snapshot-node-name: the graph node name of the new image (Since 2.0)
1186#
1187# @format: the format of the snapshot image, default is 'qcow2'.
1188#
1189# @mode: whether and how QEMU should create a new image, default is
1190#        'absolute-paths'.
1191##
1192{ 'struct': 'BlockdevSnapshotSync',
1193  'data': { '*device': 'str', '*node-name': 'str',
1194            'snapshot-file': 'str', '*snapshot-node-name': 'str',
1195            '*format': 'str', '*mode': 'NewImageMode' } }
1196
1197##
1198# @BlockdevSnapshot:
1199#
1200# @node: device or node name that will have a snapshot created.
1201#
1202# @overlay: reference to the existing block device that will become
1203#           the overlay of @node, as part of creating the snapshot.
1204#           It must not have a current backing file (this can be
1205#           achieved by passing "backing": null to blockdev-add).
1206#
1207# Since: 2.5
1208##
1209{ 'struct': 'BlockdevSnapshot',
1210  'data': { 'node': 'str', 'overlay': 'str' } }
1211
1212##
1213# @DriveBackup:
1214#
1215# @job-id: identifier for the newly-created block job. If
1216#          omitted, the device name will be used. (Since 2.7)
1217#
1218# @device: the device name or node-name of a root node which should be copied.
1219#
1220# @target: the target of the new image. If the file exists, or if it
1221#          is a device, the existing file/device will be used as the new
1222#          destination.  If it does not exist, a new file will be created.
1223#
1224# @format: the format of the new destination, default is to
1225#          probe if @mode is 'existing', else the format of the source
1226#
1227# @sync: what parts of the disk image should be copied to the destination
1228#        (all the disk, only the sectors allocated in the topmost image, from a
1229#        dirty bitmap, or only new I/O).
1230#
1231# @mode: whether and how QEMU should create a new image, default is
1232#        'absolute-paths'.
1233#
1234# @speed: the maximum speed, in bytes per second
1235#
1236# @bitmap: the name of dirty bitmap if sync is "incremental".
1237#          Must be present if sync is "incremental", must NOT be present
1238#          otherwise. (Since 2.4)
1239#
1240# @compress: true to compress data, if the target format supports it.
1241#            (default: false) (since 2.8)
1242#
1243# @on-source-error: the action to take on an error on the source,
1244#                   default 'report'.  'stop' and 'enospc' can only be used
1245#                   if the block device supports io-status (see BlockInfo).
1246#
1247# @on-target-error: the action to take on an error on the target,
1248#                   default 'report' (no limitations, since this applies to
1249#                   a different block device than @device).
1250#
1251# @auto-finalize: When false, this job will wait in a PENDING state after it has
1252#                 finished its work, waiting for @block-job-finalize.
1253#                 When true, this job will automatically perform its abort or
1254#                 commit actions.
1255#                 Defaults to true. (Since 2.12)
1256#
1257# @auto-dismiss: When false, this job will wait in a CONCLUDED state after it
1258#                has completed ceased all work, and wait for @block-job-dismiss.
1259#                When true, this job will automatically disappear from the query
1260#                list without user intervention.
1261#                Defaults to true. (Since 2.12)
1262#
1263# Note: @on-source-error and @on-target-error only affect background
1264# I/O.  If an error occurs during a guest write request, the device's
1265# rerror/werror actions will be used.
1266#
1267# Since: 1.6
1268##
1269{ 'struct': 'DriveBackup',
1270  'data': { '*job-id': 'str', 'device': 'str', 'target': 'str',
1271            '*format': 'str', 'sync': 'MirrorSyncMode',
1272            '*mode': 'NewImageMode', '*speed': 'int',
1273            '*bitmap': 'str', '*compress': 'bool',
1274            '*on-source-error': 'BlockdevOnError',
1275            '*on-target-error': 'BlockdevOnError',
1276            '*auto-finalize': 'bool', '*auto-dismiss': 'bool' } }
1277
1278##
1279# @BlockdevBackup:
1280#
1281# @job-id: identifier for the newly-created block job. If
1282#          omitted, the device name will be used. (Since 2.7)
1283#
1284# @device: the device name or node-name of a root node which should be copied.
1285#
1286# @target: the device name or node-name of the backup target node.
1287#
1288# @sync: what parts of the disk image should be copied to the destination
1289#        (all the disk, only the sectors allocated in the topmost image, or
1290#        only new I/O).
1291#
1292# @speed: the maximum speed, in bytes per second. The default is 0,
1293#         for unlimited.
1294#
1295# @compress: true to compress data, if the target format supports it.
1296#            (default: false) (since 2.8)
1297#
1298# @on-source-error: the action to take on an error on the source,
1299#                   default 'report'.  'stop' and 'enospc' can only be used
1300#                   if the block device supports io-status (see BlockInfo).
1301#
1302# @on-target-error: the action to take on an error on the target,
1303#                   default 'report' (no limitations, since this applies to
1304#                   a different block device than @device).
1305#
1306# @auto-finalize: When false, this job will wait in a PENDING state after it has
1307#                 finished its work, waiting for @block-job-finalize.
1308#                 When true, this job will automatically perform its abort or
1309#                 commit actions.
1310#                 Defaults to true. (Since 2.12)
1311#
1312# @auto-dismiss: When false, this job will wait in a CONCLUDED state after it
1313#                has completed ceased all work, and wait for @block-job-dismiss.
1314#                When true, this job will automatically disappear from the query
1315#                list without user intervention.
1316#                Defaults to true. (Since 2.12)
1317#
1318# Note: @on-source-error and @on-target-error only affect background
1319# I/O.  If an error occurs during a guest write request, the device's
1320# rerror/werror actions will be used.
1321#
1322# Since: 2.3
1323##
1324{ 'struct': 'BlockdevBackup',
1325  'data': { '*job-id': 'str', 'device': 'str', 'target': 'str',
1326            'sync': 'MirrorSyncMode', '*speed': 'int', '*compress': 'bool',
1327            '*on-source-error': 'BlockdevOnError',
1328            '*on-target-error': 'BlockdevOnError',
1329            '*auto-finalize': 'bool', '*auto-dismiss': 'bool' } }
1330
1331##
1332# @blockdev-snapshot-sync:
1333#
1334# Generates a synchronous snapshot of a block device.
1335#
1336# For the arguments, see the documentation of BlockdevSnapshotSync.
1337#
1338# Returns: nothing on success
1339#          If @device is not a valid block device, DeviceNotFound
1340#
1341# Since: 0.14.0
1342#
1343# Example:
1344#
1345# -> { "execute": "blockdev-snapshot-sync",
1346#      "arguments": { "device": "ide-hd0",
1347#                     "snapshot-file":
1348#                     "/some/place/my-image",
1349#                     "format": "qcow2" } }
1350# <- { "return": {} }
1351#
1352##
1353{ 'command': 'blockdev-snapshot-sync',
1354  'data': 'BlockdevSnapshotSync' }
1355
1356
1357##
1358# @blockdev-snapshot:
1359#
1360# Generates a snapshot of a block device.
1361#
1362# Create a snapshot, by installing 'node' as the backing image of
1363# 'overlay'. Additionally, if 'node' is associated with a block
1364# device, the block device changes to using 'overlay' as its new active
1365# image.
1366#
1367# For the arguments, see the documentation of BlockdevSnapshot.
1368#
1369# Since: 2.5
1370#
1371# Example:
1372#
1373# -> { "execute": "blockdev-add",
1374#      "arguments": { "driver": "qcow2",
1375#                     "node-name": "node1534",
1376#                     "file": { "driver": "file",
1377#                               "filename": "hd1.qcow2" },
1378#                     "backing": null } }
1379#
1380# <- { "return": {} }
1381#
1382# -> { "execute": "blockdev-snapshot",
1383#      "arguments": { "node": "ide-hd0",
1384#                     "overlay": "node1534" } }
1385# <- { "return": {} }
1386#
1387##
1388{ 'command': 'blockdev-snapshot',
1389  'data': 'BlockdevSnapshot' }
1390
1391##
1392# @change-backing-file:
1393#
1394# Change the backing file in the image file metadata.  This does not
1395# cause QEMU to reopen the image file to reparse the backing filename
1396# (it may, however, perform a reopen to change permissions from
1397# r/o -> r/w -> r/o, if needed). The new backing file string is written
1398# into the image file metadata, and the QEMU internal strings are
1399# updated.
1400#
1401# @image-node-name: The name of the block driver state node of the
1402#                   image to modify. The "device" argument is used
1403#                   to verify "image-node-name" is in the chain
1404#                   described by "device".
1405#
1406# @device:          The device name or node-name of the root node that owns
1407#                   image-node-name.
1408#
1409# @backing-file:    The string to write as the backing file.  This
1410#                   string is not validated, so care should be taken
1411#                   when specifying the string or the image chain may
1412#                   not be able to be reopened again.
1413#
1414# Returns: Nothing on success
1415#
1416#          If "device" does not exist or cannot be determined, DeviceNotFound
1417#
1418# Since: 2.1
1419##
1420{ 'command': 'change-backing-file',
1421  'data': { 'device': 'str', 'image-node-name': 'str',
1422            'backing-file': 'str' } }
1423
1424##
1425# @block-commit:
1426#
1427# Live commit of data from overlay image nodes into backing nodes - i.e.,
1428# writes data between 'top' and 'base' into 'base'.
1429#
1430# @job-id: identifier for the newly-created block job. If
1431#          omitted, the device name will be used. (Since 2.7)
1432#
1433# @device:  the device name or node-name of a root node
1434#
1435# @base:   The file name of the backing image to write data into.
1436#                    If not specified, this is the deepest backing image.
1437#
1438# @top:    The file name of the backing image within the image chain,
1439#                    which contains the topmost data to be committed down. If
1440#                    not specified, this is the active layer.
1441#
1442# @backing-file:  The backing file string to write into the overlay
1443#                           image of 'top'.  If 'top' is the active layer,
1444#                           specifying a backing file string is an error. This
1445#                           filename is not validated.
1446#
1447#                           If a pathname string is such that it cannot be
1448#                           resolved by QEMU, that means that subsequent QMP or
1449#                           HMP commands must use node-names for the image in
1450#                           question, as filename lookup methods will fail.
1451#
1452#                           If not specified, QEMU will automatically determine
1453#                           the backing file string to use, or error out if
1454#                           there is no obvious choice. Care should be taken
1455#                           when specifying the string, to specify a valid
1456#                           filename or protocol.
1457#                           (Since 2.1)
1458#
1459#                    If top == base, that is an error.
1460#                    If top == active, the job will not be completed by itself,
1461#                    user needs to complete the job with the block-job-complete
1462#                    command after getting the ready event. (Since 2.0)
1463#
1464#                    If the base image is smaller than top, then the base image
1465#                    will be resized to be the same size as top.  If top is
1466#                    smaller than the base image, the base will not be
1467#                    truncated.  If you want the base image size to match the
1468#                    size of the smaller top, you can safely truncate it
1469#                    yourself once the commit operation successfully completes.
1470#
1471# @speed:  the maximum speed, in bytes per second
1472#
1473# @filter-node-name: the node name that should be assigned to the
1474#                    filter driver that the commit job inserts into the graph
1475#                    above @top. If this option is not given, a node name is
1476#                    autogenerated. (Since: 2.9)
1477#
1478# Returns: Nothing on success
1479#          If commit or stream is already active on this device, DeviceInUse
1480#          If @device does not exist, DeviceNotFound
1481#          If image commit is not supported by this device, NotSupported
1482#          If @base or @top is invalid, a generic error is returned
1483#          If @speed is invalid, InvalidParameter
1484#
1485# Since: 1.3
1486#
1487# Example:
1488#
1489# -> { "execute": "block-commit",
1490#      "arguments": { "device": "virtio0",
1491#                     "top": "/tmp/snap1.qcow2" } }
1492# <- { "return": {} }
1493#
1494##
1495{ 'command': 'block-commit',
1496  'data': { '*job-id': 'str', 'device': 'str', '*base': 'str', '*top': 'str',
1497            '*backing-file': 'str', '*speed': 'int',
1498            '*filter-node-name': 'str' } }
1499
1500##
1501# @drive-backup:
1502#
1503# Start a point-in-time copy of a block device to a new destination.  The
1504# status of ongoing drive-backup operations can be checked with
1505# query-block-jobs where the BlockJobInfo.type field has the value 'backup'.
1506# The operation can be stopped before it has completed using the
1507# block-job-cancel command.
1508#
1509# Returns: nothing on success
1510#          If @device is not a valid block device, GenericError
1511#
1512# Since: 1.6
1513#
1514# Example:
1515#
1516# -> { "execute": "drive-backup",
1517#      "arguments": { "device": "drive0",
1518#                     "sync": "full",
1519#                     "target": "backup.img" } }
1520# <- { "return": {} }
1521#
1522##
1523{ 'command': 'drive-backup', 'boxed': true,
1524  'data': 'DriveBackup' }
1525
1526##
1527# @blockdev-backup:
1528#
1529# Start a point-in-time copy of a block device to a new destination.  The
1530# status of ongoing blockdev-backup operations can be checked with
1531# query-block-jobs where the BlockJobInfo.type field has the value 'backup'.
1532# The operation can be stopped before it has completed using the
1533# block-job-cancel command.
1534#
1535# Returns: nothing on success
1536#          If @device is not a valid block device, DeviceNotFound
1537#
1538# Since: 2.3
1539#
1540# Example:
1541# -> { "execute": "blockdev-backup",
1542#      "arguments": { "device": "src-id",
1543#                     "sync": "full",
1544#                     "target": "tgt-id" } }
1545# <- { "return": {} }
1546#
1547##
1548{ 'command': 'blockdev-backup', 'boxed': true,
1549  'data': 'BlockdevBackup' }
1550
1551
1552##
1553# @query-named-block-nodes:
1554#
1555# Get the named block driver list
1556#
1557# Returns: the list of BlockDeviceInfo
1558#
1559# Since: 2.0
1560#
1561# Example:
1562#
1563# -> { "execute": "query-named-block-nodes" }
1564# <- { "return": [ { "ro":false,
1565#                    "drv":"qcow2",
1566#                    "encrypted":false,
1567#                    "file":"disks/test.qcow2",
1568#                    "node-name": "my-node",
1569#                    "backing_file_depth":1,
1570#                    "bps":1000000,
1571#                    "bps_rd":0,
1572#                    "bps_wr":0,
1573#                    "iops":1000000,
1574#                    "iops_rd":0,
1575#                    "iops_wr":0,
1576#                    "bps_max": 8000000,
1577#                    "bps_rd_max": 0,
1578#                    "bps_wr_max": 0,
1579#                    "iops_max": 0,
1580#                    "iops_rd_max": 0,
1581#                    "iops_wr_max": 0,
1582#                    "iops_size": 0,
1583#                    "write_threshold": 0,
1584#                    "image":{
1585#                       "filename":"disks/test.qcow2",
1586#                       "format":"qcow2",
1587#                       "virtual-size":2048000,
1588#                       "backing_file":"base.qcow2",
1589#                       "full-backing-filename":"disks/base.qcow2",
1590#                       "backing-filename-format":"qcow2",
1591#                       "snapshots":[
1592#                          {
1593#                             "id": "1",
1594#                             "name": "snapshot1",
1595#                             "vm-state-size": 0,
1596#                             "date-sec": 10000200,
1597#                             "date-nsec": 12,
1598#                             "vm-clock-sec": 206,
1599#                             "vm-clock-nsec": 30
1600#                          }
1601#                       ],
1602#                       "backing-image":{
1603#                           "filename":"disks/base.qcow2",
1604#                           "format":"qcow2",
1605#                           "virtual-size":2048000
1606#                       }
1607#                    } } ] }
1608#
1609##
1610{ 'command': 'query-named-block-nodes', 'returns': [ 'BlockDeviceInfo' ] }
1611
1612##
1613# @drive-mirror:
1614#
1615# Start mirroring a block device's writes to a new destination. target
1616# specifies the target of the new image. If the file exists, or if it
1617# is a device, it will be used as the new destination for writes. If
1618# it does not exist, a new file will be created. format specifies the
1619# format of the mirror image, default is to probe if mode='existing',
1620# else the format of the source.
1621#
1622# Returns: nothing on success
1623#          If @device is not a valid block device, GenericError
1624#
1625# Since: 1.3
1626#
1627# Example:
1628#
1629# -> { "execute": "drive-mirror",
1630#      "arguments": { "device": "ide-hd0",
1631#                     "target": "/some/place/my-image",
1632#                     "sync": "full",
1633#                     "format": "qcow2" } }
1634# <- { "return": {} }
1635#
1636##
1637{ 'command': 'drive-mirror', 'boxed': true,
1638  'data': 'DriveMirror' }
1639
1640##
1641# @DriveMirror:
1642#
1643# A set of parameters describing drive mirror setup.
1644#
1645# @job-id: identifier for the newly-created block job. If
1646#          omitted, the device name will be used. (Since 2.7)
1647#
1648# @device:  the device name or node-name of a root node whose writes should be
1649#           mirrored.
1650#
1651# @target: the target of the new image. If the file exists, or if it
1652#          is a device, the existing file/device will be used as the new
1653#          destination.  If it does not exist, a new file will be created.
1654#
1655# @format: the format of the new destination, default is to
1656#          probe if @mode is 'existing', else the format of the source
1657#
1658# @node-name: the new block driver state node name in the graph
1659#             (Since 2.1)
1660#
1661# @replaces: with sync=full graph node name to be replaced by the new
1662#            image when a whole image copy is done. This can be used to repair
1663#            broken Quorum files. (Since 2.1)
1664#
1665# @mode: whether and how QEMU should create a new image, default is
1666#        'absolute-paths'.
1667#
1668# @speed:  the maximum speed, in bytes per second
1669#
1670# @sync: what parts of the disk image should be copied to the destination
1671#        (all the disk, only the sectors allocated in the topmost image, or
1672#        only new I/O).
1673#
1674# @granularity: granularity of the dirty bitmap, default is 64K
1675#               if the image format doesn't have clusters, 4K if the clusters
1676#               are smaller than that, else the cluster size.  Must be a
1677#               power of 2 between 512 and 64M (since 1.4).
1678#
1679# @buf-size: maximum amount of data in flight from source to
1680#            target (since 1.4).
1681#
1682# @on-source-error: the action to take on an error on the source,
1683#                   default 'report'.  'stop' and 'enospc' can only be used
1684#                   if the block device supports io-status (see BlockInfo).
1685#
1686# @on-target-error: the action to take on an error on the target,
1687#                   default 'report' (no limitations, since this applies to
1688#                   a different block device than @device).
1689# @unmap: Whether to try to unmap target sectors where source has
1690#         only zero. If true, and target unallocated sectors will read as zero,
1691#         target image sectors will be unmapped; otherwise, zeroes will be
1692#         written. Both will result in identical contents.
1693#         Default is true. (Since 2.4)
1694#
1695# Since: 1.3
1696##
1697{ 'struct': 'DriveMirror',
1698  'data': { '*job-id': 'str', 'device': 'str', 'target': 'str',
1699            '*format': 'str', '*node-name': 'str', '*replaces': 'str',
1700            'sync': 'MirrorSyncMode', '*mode': 'NewImageMode',
1701            '*speed': 'int', '*granularity': 'uint32',
1702            '*buf-size': 'int', '*on-source-error': 'BlockdevOnError',
1703            '*on-target-error': 'BlockdevOnError',
1704            '*unmap': 'bool' } }
1705
1706##
1707# @BlockDirtyBitmap:
1708#
1709# @node: name of device/node which the bitmap is tracking
1710#
1711# @name: name of the dirty bitmap
1712#
1713# Since: 2.4
1714##
1715{ 'struct': 'BlockDirtyBitmap',
1716  'data': { 'node': 'str', 'name': 'str' } }
1717
1718##
1719# @BlockDirtyBitmapAdd:
1720#
1721# @node: name of device/node which the bitmap is tracking
1722#
1723# @name: name of the dirty bitmap
1724#
1725# @granularity: the bitmap granularity, default is 64k for
1726#               block-dirty-bitmap-add
1727#
1728# @persistent: the bitmap is persistent, i.e. it will be saved to the
1729#              corresponding block device image file on its close. For now only
1730#              Qcow2 disks support persistent bitmaps. Default is false for
1731#              block-dirty-bitmap-add. (Since: 2.10)
1732#
1733# @autoload: ignored and deprecated since 2.12.
1734#            Currently, all dirty tracking bitmaps are loaded from Qcow2 on
1735#            open.
1736#
1737# @x-disabled: the bitmap is created in the disabled state, which means that
1738#              it will not track drive changes. The bitmap may be enabled with
1739#              x-block-dirty-bitmap-enable. Default is false. (Since: 3.0)
1740#
1741# Since: 2.4
1742##
1743{ 'struct': 'BlockDirtyBitmapAdd',
1744  'data': { 'node': 'str', 'name': 'str', '*granularity': 'uint32',
1745            '*persistent': 'bool', '*autoload': 'bool', '*x-disabled': 'bool' } }
1746
1747##
1748# @BlockDirtyBitmapMerge:
1749#
1750# @node: name of device/node which the bitmap is tracking
1751#
1752# @dst_name: name of the destination dirty bitmap
1753#
1754# @src_name: name of the source dirty bitmap
1755#
1756# Since: 3.0
1757##
1758{ 'struct': 'BlockDirtyBitmapMerge',
1759  'data': { 'node': 'str', 'dst_name': 'str', 'src_name': 'str' } }
1760
1761##
1762# @block-dirty-bitmap-add:
1763#
1764# Create a dirty bitmap with a name on the node, and start tracking the writes.
1765#
1766# Returns: nothing on success
1767#          If @node is not a valid block device or node, DeviceNotFound
1768#          If @name is already taken, GenericError with an explanation
1769#
1770# Since: 2.4
1771#
1772# Example:
1773#
1774# -> { "execute": "block-dirty-bitmap-add",
1775#      "arguments": { "node": "drive0", "name": "bitmap0" } }
1776# <- { "return": {} }
1777#
1778##
1779{ 'command': 'block-dirty-bitmap-add',
1780  'data': 'BlockDirtyBitmapAdd' }
1781
1782##
1783# @block-dirty-bitmap-remove:
1784#
1785# Stop write tracking and remove the dirty bitmap that was created
1786# with block-dirty-bitmap-add. If the bitmap is persistent, remove it from its
1787# storage too.
1788#
1789# Returns: nothing on success
1790#          If @node is not a valid block device or node, DeviceNotFound
1791#          If @name is not found, GenericError with an explanation
1792#          if @name is frozen by an operation, GenericError
1793#
1794# Since: 2.4
1795#
1796# Example:
1797#
1798# -> { "execute": "block-dirty-bitmap-remove",
1799#      "arguments": { "node": "drive0", "name": "bitmap0" } }
1800# <- { "return": {} }
1801#
1802##
1803{ 'command': 'block-dirty-bitmap-remove',
1804  'data': 'BlockDirtyBitmap' }
1805
1806##
1807# @block-dirty-bitmap-clear:
1808#
1809# Clear (reset) a dirty bitmap on the device, so that an incremental
1810# backup from this point in time forward will only backup clusters
1811# modified after this clear operation.
1812#
1813# Returns: nothing on success
1814#          If @node is not a valid block device, DeviceNotFound
1815#          If @name is not found, GenericError with an explanation
1816#
1817# Since: 2.4
1818#
1819# Example:
1820#
1821# -> { "execute": "block-dirty-bitmap-clear",
1822#      "arguments": { "node": "drive0", "name": "bitmap0" } }
1823# <- { "return": {} }
1824#
1825##
1826{ 'command': 'block-dirty-bitmap-clear',
1827  'data': 'BlockDirtyBitmap' }
1828
1829##
1830# @x-block-dirty-bitmap-enable:
1831#
1832# Enables a dirty bitmap so that it will begin tracking disk changes.
1833#
1834# Returns: nothing on success
1835#          If @node is not a valid block device, DeviceNotFound
1836#          If @name is not found, GenericError with an explanation
1837#
1838# Since: 3.0
1839#
1840# Example:
1841#
1842# -> { "execute": "x-block-dirty-bitmap-enable",
1843#      "arguments": { "node": "drive0", "name": "bitmap0" } }
1844# <- { "return": {} }
1845#
1846##
1847  { 'command': 'x-block-dirty-bitmap-enable',
1848    'data': 'BlockDirtyBitmap' }
1849
1850##
1851# @x-block-dirty-bitmap-disable:
1852#
1853# Disables a dirty bitmap so that it will stop tracking disk changes.
1854#
1855# Returns: nothing on success
1856#          If @node is not a valid block device, DeviceNotFound
1857#          If @name is not found, GenericError with an explanation
1858#
1859# Since: 3.0
1860#
1861# Example:
1862#
1863# -> { "execute": "x-block-dirty-bitmap-disable",
1864#      "arguments": { "node": "drive0", "name": "bitmap0" } }
1865# <- { "return": {} }
1866#
1867##
1868    { 'command': 'x-block-dirty-bitmap-disable',
1869      'data': 'BlockDirtyBitmap' }
1870
1871##
1872# @x-block-dirty-bitmap-merge:
1873#
1874# Merge @src_name dirty bitmap to @dst_name dirty bitmap. @src_name dirty
1875# bitmap is unchanged. On error, @dst_name is unchanged.
1876#
1877# Returns: nothing on success
1878#          If @node is not a valid block device, DeviceNotFound
1879#          If @dst_name or @src_name is not found, GenericError
1880#          If bitmaps has different sizes or granularities, GenericError
1881#
1882# Since: 3.0
1883#
1884# Example:
1885#
1886# -> { "execute": "x-block-dirty-bitmap-merge",
1887#      "arguments": { "node": "drive0", "dst_name": "bitmap0",
1888#                     "src_name": "bitmap1" } }
1889# <- { "return": {} }
1890#
1891##
1892      { 'command': 'x-block-dirty-bitmap-merge',
1893        'data': 'BlockDirtyBitmapMerge' }
1894
1895##
1896# @BlockDirtyBitmapSha256:
1897#
1898# SHA256 hash of dirty bitmap data
1899#
1900# @sha256: ASCII representation of SHA256 bitmap hash
1901#
1902# Since: 2.10
1903##
1904  { 'struct': 'BlockDirtyBitmapSha256',
1905    'data': {'sha256': 'str'} }
1906
1907##
1908# @x-debug-block-dirty-bitmap-sha256:
1909#
1910# Get bitmap SHA256
1911#
1912# Returns: BlockDirtyBitmapSha256 on success
1913#          If @node is not a valid block device, DeviceNotFound
1914#          If @name is not found or if hashing has failed, GenericError with an
1915#          explanation
1916#
1917# Since: 2.10
1918##
1919  { 'command': 'x-debug-block-dirty-bitmap-sha256',
1920    'data': 'BlockDirtyBitmap', 'returns': 'BlockDirtyBitmapSha256' }
1921
1922##
1923# @blockdev-mirror:
1924#
1925# Start mirroring a block device's writes to a new destination.
1926#
1927# @job-id: identifier for the newly-created block job. If
1928#          omitted, the device name will be used. (Since 2.7)
1929#
1930# @device: The device name or node-name of a root node whose writes should be
1931#          mirrored.
1932#
1933# @target: the id or node-name of the block device to mirror to. This mustn't be
1934#          attached to guest.
1935#
1936# @replaces: with sync=full graph node name to be replaced by the new
1937#            image when a whole image copy is done. This can be used to repair
1938#            broken Quorum files.
1939#
1940# @speed:  the maximum speed, in bytes per second
1941#
1942# @sync: what parts of the disk image should be copied to the destination
1943#        (all the disk, only the sectors allocated in the topmost image, or
1944#        only new I/O).
1945#
1946# @granularity: granularity of the dirty bitmap, default is 64K
1947#               if the image format doesn't have clusters, 4K if the clusters
1948#               are smaller than that, else the cluster size.  Must be a
1949#               power of 2 between 512 and 64M
1950#
1951# @buf-size: maximum amount of data in flight from source to
1952#            target
1953#
1954# @on-source-error: the action to take on an error on the source,
1955#                   default 'report'.  'stop' and 'enospc' can only be used
1956#                   if the block device supports io-status (see BlockInfo).
1957#
1958# @on-target-error: the action to take on an error on the target,
1959#                   default 'report' (no limitations, since this applies to
1960#                   a different block device than @device).
1961#
1962# @filter-node-name: the node name that should be assigned to the
1963#                    filter driver that the mirror job inserts into the graph
1964#                    above @device. If this option is not given, a node name is
1965#                    autogenerated. (Since: 2.9)
1966#
1967# Returns: nothing on success.
1968#
1969# Since: 2.6
1970#
1971# Example:
1972#
1973# -> { "execute": "blockdev-mirror",
1974#      "arguments": { "device": "ide-hd0",
1975#                     "target": "target0",
1976#                     "sync": "full" } }
1977# <- { "return": {} }
1978#
1979##
1980{ 'command': 'blockdev-mirror',
1981  'data': { '*job-id': 'str', 'device': 'str', 'target': 'str',
1982            '*replaces': 'str',
1983            'sync': 'MirrorSyncMode',
1984            '*speed': 'int', '*granularity': 'uint32',
1985            '*buf-size': 'int', '*on-source-error': 'BlockdevOnError',
1986            '*on-target-error': 'BlockdevOnError',
1987            '*filter-node-name': 'str' } }
1988
1989##
1990# @block_set_io_throttle:
1991#
1992# Change I/O throttle limits for a block drive.
1993#
1994# Since QEMU 2.4, each device with I/O limits is member of a throttle
1995# group.
1996#
1997# If two or more devices are members of the same group, the limits
1998# will apply to the combined I/O of the whole group in a round-robin
1999# fashion. Therefore, setting new I/O limits to a device will affect
2000# the whole group.
2001#
2002# The name of the group can be specified using the 'group' parameter.
2003# If the parameter is unset, it is assumed to be the current group of
2004# that device. If it's not in any group yet, the name of the device
2005# will be used as the name for its group.
2006#
2007# The 'group' parameter can also be used to move a device to a
2008# different group. In this case the limits specified in the parameters
2009# will be applied to the new group only.
2010#
2011# I/O limits can be disabled by setting all of them to 0. In this case
2012# the device will be removed from its group and the rest of its
2013# members will not be affected. The 'group' parameter is ignored.
2014#
2015# Returns: Nothing on success
2016#          If @device is not a valid block device, DeviceNotFound
2017#
2018# Since: 1.1
2019#
2020# Example:
2021#
2022# -> { "execute": "block_set_io_throttle",
2023#      "arguments": { "id": "virtio-blk-pci0/virtio-backend",
2024#                     "bps": 0,
2025#                     "bps_rd": 0,
2026#                     "bps_wr": 0,
2027#                     "iops": 512,
2028#                     "iops_rd": 0,
2029#                     "iops_wr": 0,
2030#                     "bps_max": 0,
2031#                     "bps_rd_max": 0,
2032#                     "bps_wr_max": 0,
2033#                     "iops_max": 0,
2034#                     "iops_rd_max": 0,
2035#                     "iops_wr_max": 0,
2036#                     "bps_max_length": 0,
2037#                     "iops_size": 0 } }
2038# <- { "return": {} }
2039#
2040# -> { "execute": "block_set_io_throttle",
2041#      "arguments": { "id": "ide0-1-0",
2042#                     "bps": 1000000,
2043#                     "bps_rd": 0,
2044#                     "bps_wr": 0,
2045#                     "iops": 0,
2046#                     "iops_rd": 0,
2047#                     "iops_wr": 0,
2048#                     "bps_max": 8000000,
2049#                     "bps_rd_max": 0,
2050#                     "bps_wr_max": 0,
2051#                     "iops_max": 0,
2052#                     "iops_rd_max": 0,
2053#                     "iops_wr_max": 0,
2054#                     "bps_max_length": 60,
2055#                     "iops_size": 0 } }
2056# <- { "return": {} }
2057##
2058{ 'command': 'block_set_io_throttle', 'boxed': true,
2059  'data': 'BlockIOThrottle' }
2060
2061##
2062# @BlockIOThrottle:
2063#
2064# A set of parameters describing block throttling.
2065#
2066# @device: Block device name (deprecated, use @id instead)
2067#
2068# @id: The name or QOM path of the guest device (since: 2.8)
2069#
2070# @bps: total throughput limit in bytes per second
2071#
2072# @bps_rd: read throughput limit in bytes per second
2073#
2074# @bps_wr: write throughput limit in bytes per second
2075#
2076# @iops: total I/O operations per second
2077#
2078# @iops_rd: read I/O operations per second
2079#
2080# @iops_wr: write I/O operations per second
2081#
2082# @bps_max: total throughput limit during bursts,
2083#                     in bytes (Since 1.7)
2084#
2085# @bps_rd_max: read throughput limit during bursts,
2086#                        in bytes (Since 1.7)
2087#
2088# @bps_wr_max: write throughput limit during bursts,
2089#                        in bytes (Since 1.7)
2090#
2091# @iops_max: total I/O operations per second during bursts,
2092#                      in bytes (Since 1.7)
2093#
2094# @iops_rd_max: read I/O operations per second during bursts,
2095#                         in bytes (Since 1.7)
2096#
2097# @iops_wr_max: write I/O operations per second during bursts,
2098#                         in bytes (Since 1.7)
2099#
2100# @bps_max_length: maximum length of the @bps_max burst
2101#                            period, in seconds. It must only
2102#                            be set if @bps_max is set as well.
2103#                            Defaults to 1. (Since 2.6)
2104#
2105# @bps_rd_max_length: maximum length of the @bps_rd_max
2106#                               burst period, in seconds. It must only
2107#                               be set if @bps_rd_max is set as well.
2108#                               Defaults to 1. (Since 2.6)
2109#
2110# @bps_wr_max_length: maximum length of the @bps_wr_max
2111#                               burst period, in seconds. It must only
2112#                               be set if @bps_wr_max is set as well.
2113#                               Defaults to 1. (Since 2.6)
2114#
2115# @iops_max_length: maximum length of the @iops burst
2116#                             period, in seconds. It must only
2117#                             be set if @iops_max is set as well.
2118#                             Defaults to 1. (Since 2.6)
2119#
2120# @iops_rd_max_length: maximum length of the @iops_rd_max
2121#                                burst period, in seconds. It must only
2122#                                be set if @iops_rd_max is set as well.
2123#                                Defaults to 1. (Since 2.6)
2124#
2125# @iops_wr_max_length: maximum length of the @iops_wr_max
2126#                                burst period, in seconds. It must only
2127#                                be set if @iops_wr_max is set as well.
2128#                                Defaults to 1. (Since 2.6)
2129#
2130# @iops_size: an I/O size in bytes (Since 1.7)
2131#
2132# @group: throttle group name (Since 2.4)
2133#
2134# Since: 1.1
2135##
2136{ 'struct': 'BlockIOThrottle',
2137  'data': { '*device': 'str', '*id': 'str', 'bps': 'int', 'bps_rd': 'int',
2138            'bps_wr': 'int', 'iops': 'int', 'iops_rd': 'int', 'iops_wr': 'int',
2139            '*bps_max': 'int', '*bps_rd_max': 'int',
2140            '*bps_wr_max': 'int', '*iops_max': 'int',
2141            '*iops_rd_max': 'int', '*iops_wr_max': 'int',
2142            '*bps_max_length': 'int', '*bps_rd_max_length': 'int',
2143            '*bps_wr_max_length': 'int', '*iops_max_length': 'int',
2144            '*iops_rd_max_length': 'int', '*iops_wr_max_length': 'int',
2145            '*iops_size': 'int', '*group': 'str' } }
2146
2147##
2148# @ThrottleLimits:
2149#
2150# Limit parameters for throttling.
2151# Since some limit combinations are illegal, limits should always be set in one
2152# transaction. All fields are optional. When setting limits, if a field is
2153# missing the current value is not changed.
2154#
2155# @iops-total:             limit total I/O operations per second
2156# @iops-total-max:         I/O operations burst
2157# @iops-total-max-length:  length of the iops-total-max burst period, in seconds
2158#                          It must only be set if @iops-total-max is set as well.
2159# @iops-read:              limit read operations per second
2160# @iops-read-max:          I/O operations read burst
2161# @iops-read-max-length:   length of the iops-read-max burst period, in seconds
2162#                          It must only be set if @iops-read-max is set as well.
2163# @iops-write:             limit write operations per second
2164# @iops-write-max:         I/O operations write burst
2165# @iops-write-max-length:  length of the iops-write-max burst period, in seconds
2166#                          It must only be set if @iops-write-max is set as well.
2167# @bps-total:              limit total bytes per second
2168# @bps-total-max:          total bytes burst
2169# @bps-total-max-length:   length of the bps-total-max burst period, in seconds.
2170#                          It must only be set if @bps-total-max is set as well.
2171# @bps-read:               limit read bytes per second
2172# @bps-read-max:           total bytes read burst
2173# @bps-read-max-length:    length of the bps-read-max burst period, in seconds
2174#                          It must only be set if @bps-read-max is set as well.
2175# @bps-write:              limit write bytes per second
2176# @bps-write-max:          total bytes write burst
2177# @bps-write-max-length:   length of the bps-write-max burst period, in seconds
2178#                          It must only be set if @bps-write-max is set as well.
2179# @iops-size:              when limiting by iops max size of an I/O in bytes
2180#
2181# Since: 2.11
2182##
2183{ 'struct': 'ThrottleLimits',
2184  'data': { '*iops-total' : 'int', '*iops-total-max' : 'int',
2185            '*iops-total-max-length' : 'int', '*iops-read' : 'int',
2186            '*iops-read-max' : 'int', '*iops-read-max-length' : 'int',
2187            '*iops-write' : 'int', '*iops-write-max' : 'int',
2188            '*iops-write-max-length' : 'int', '*bps-total' : 'int',
2189            '*bps-total-max' : 'int', '*bps-total-max-length' : 'int',
2190            '*bps-read' : 'int', '*bps-read-max' : 'int',
2191            '*bps-read-max-length' : 'int', '*bps-write' : 'int',
2192            '*bps-write-max' : 'int', '*bps-write-max-length' : 'int',
2193            '*iops-size' : 'int' } }
2194
2195##
2196# @block-stream:
2197#
2198# Copy data from a backing file into a block device.
2199#
2200# The block streaming operation is performed in the background until the entire
2201# backing file has been copied.  This command returns immediately once streaming
2202# has started.  The status of ongoing block streaming operations can be checked
2203# with query-block-jobs.  The operation can be stopped before it has completed
2204# using the block-job-cancel command.
2205#
2206# The node that receives the data is called the top image, can be located in
2207# any part of the chain (but always above the base image; see below) and can be
2208# specified using its device or node name. Earlier qemu versions only allowed
2209# 'device' to name the top level node; presence of the 'base-node' parameter
2210# during introspection can be used as a witness of the enhanced semantics
2211# of 'device'.
2212#
2213# If a base file is specified then sectors are not copied from that base file and
2214# its backing chain.  When streaming completes the image file will have the base
2215# file as its backing file.  This can be used to stream a subset of the backing
2216# file chain instead of flattening the entire image.
2217#
2218# On successful completion the image file is updated to drop the backing file
2219# and the BLOCK_JOB_COMPLETED event is emitted.
2220#
2221# @job-id: identifier for the newly-created block job. If
2222#          omitted, the device name will be used. (Since 2.7)
2223#
2224# @device: the device or node name of the top image
2225#
2226# @base:   the common backing file name.
2227#                    It cannot be set if @base-node is also set.
2228#
2229# @base-node: the node name of the backing file.
2230#                       It cannot be set if @base is also set. (Since 2.8)
2231#
2232# @backing-file: The backing file string to write into the top
2233#                          image. This filename is not validated.
2234#
2235#                          If a pathname string is such that it cannot be
2236#                          resolved by QEMU, that means that subsequent QMP or
2237#                          HMP commands must use node-names for the image in
2238#                          question, as filename lookup methods will fail.
2239#
2240#                          If not specified, QEMU will automatically determine
2241#                          the backing file string to use, or error out if there
2242#                          is no obvious choice.  Care should be taken when
2243#                          specifying the string, to specify a valid filename or
2244#                          protocol.
2245#                          (Since 2.1)
2246#
2247# @speed:  the maximum speed, in bytes per second
2248#
2249# @on-error: the action to take on an error (default report).
2250#            'stop' and 'enospc' can only be used if the block device
2251#            supports io-status (see BlockInfo).  Since 1.3.
2252#
2253# Returns: Nothing on success. If @device does not exist, DeviceNotFound.
2254#
2255# Since: 1.1
2256#
2257# Example:
2258#
2259# -> { "execute": "block-stream",
2260#      "arguments": { "device": "virtio0",
2261#                     "base": "/tmp/master.qcow2" } }
2262# <- { "return": {} }
2263#
2264##
2265{ 'command': 'block-stream',
2266  'data': { '*job-id': 'str', 'device': 'str', '*base': 'str',
2267            '*base-node': 'str', '*backing-file': 'str', '*speed': 'int',
2268            '*on-error': 'BlockdevOnError' } }
2269
2270##
2271# @block-job-set-speed:
2272#
2273# Set maximum speed for a background block operation.
2274#
2275# This command can only be issued when there is an active block job.
2276#
2277# Throttling can be disabled by setting the speed to 0.
2278#
2279# @device: The job identifier. This used to be a device name (hence
2280#          the name of the parameter), but since QEMU 2.7 it can have
2281#          other values.
2282#
2283# @speed:  the maximum speed, in bytes per second, or 0 for unlimited.
2284#          Defaults to 0.
2285#
2286# Returns: Nothing on success
2287#          If no background operation is active on this device, DeviceNotActive
2288#
2289# Since: 1.1
2290##
2291{ 'command': 'block-job-set-speed',
2292  'data': { 'device': 'str', 'speed': 'int' } }
2293
2294##
2295# @block-job-cancel:
2296#
2297# Stop an active background block operation.
2298#
2299# This command returns immediately after marking the active background block
2300# operation for cancellation.  It is an error to call this command if no
2301# operation is in progress.
2302#
2303# The operation will cancel as soon as possible and then emit the
2304# BLOCK_JOB_CANCELLED event.  Before that happens the job is still visible when
2305# enumerated using query-block-jobs.
2306#
2307# Note that if you issue 'block-job-cancel' after 'drive-mirror' has indicated
2308# (via the event BLOCK_JOB_READY) that the source and destination are
2309# synchronized, then the event triggered by this command changes to
2310# BLOCK_JOB_COMPLETED, to indicate that the mirroring has ended and the
2311# destination now has a point-in-time copy tied to the time of the cancellation.
2312#
2313# For streaming, the image file retains its backing file unless the streaming
2314# operation happens to complete just as it is being cancelled.  A new streaming
2315# operation can be started at a later time to finish copying all data from the
2316# backing file.
2317#
2318# @device: The job identifier. This used to be a device name (hence
2319#          the name of the parameter), but since QEMU 2.7 it can have
2320#          other values.
2321#
2322# @force: If true, and the job has already emitted the event BLOCK_JOB_READY,
2323#         abandon the job immediately (even if it is paused) instead of waiting
2324#         for the destination to complete its final synchronization (since 1.3)
2325#
2326# Returns: Nothing on success
2327#          If no background operation is active on this device, DeviceNotActive
2328#
2329# Since: 1.1
2330##
2331{ 'command': 'block-job-cancel', 'data': { 'device': 'str', '*force': 'bool' } }
2332
2333##
2334# @block-job-pause:
2335#
2336# Pause an active background block operation.
2337#
2338# This command returns immediately after marking the active background block
2339# operation for pausing.  It is an error to call this command if no
2340# operation is in progress or if the job is already paused.
2341#
2342# The operation will pause as soon as possible.  No event is emitted when
2343# the operation is actually paused.  Cancelling a paused job automatically
2344# resumes it.
2345#
2346# @device: The job identifier. This used to be a device name (hence
2347#          the name of the parameter), but since QEMU 2.7 it can have
2348#          other values.
2349#
2350# Returns: Nothing on success
2351#          If no background operation is active on this device, DeviceNotActive
2352#
2353# Since: 1.3
2354##
2355{ 'command': 'block-job-pause', 'data': { 'device': 'str' } }
2356
2357##
2358# @block-job-resume:
2359#
2360# Resume an active background block operation.
2361#
2362# This command returns immediately after resuming a paused background block
2363# operation.  It is an error to call this command if no operation is in
2364# progress or if the job is not paused.
2365#
2366# This command also clears the error status of the job.
2367#
2368# @device: The job identifier. This used to be a device name (hence
2369#          the name of the parameter), but since QEMU 2.7 it can have
2370#          other values.
2371#
2372# Returns: Nothing on success
2373#          If no background operation is active on this device, DeviceNotActive
2374#
2375# Since: 1.3
2376##
2377{ 'command': 'block-job-resume', 'data': { 'device': 'str' } }
2378
2379##
2380# @block-job-complete:
2381#
2382# Manually trigger completion of an active background block operation.  This
2383# is supported for drive mirroring, where it also switches the device to
2384# write to the target path only.  The ability to complete is signaled with
2385# a BLOCK_JOB_READY event.
2386#
2387# This command completes an active background block operation synchronously.
2388# The ordering of this command's return with the BLOCK_JOB_COMPLETED event
2389# is not defined.  Note that if an I/O error occurs during the processing of
2390# this command: 1) the command itself will fail; 2) the error will be processed
2391# according to the rerror/werror arguments that were specified when starting
2392# the operation.
2393#
2394# A cancelled or paused job cannot be completed.
2395#
2396# @device: The job identifier. This used to be a device name (hence
2397#          the name of the parameter), but since QEMU 2.7 it can have
2398#          other values.
2399#
2400# Returns: Nothing on success
2401#          If no background operation is active on this device, DeviceNotActive
2402#
2403# Since: 1.3
2404##
2405{ 'command': 'block-job-complete', 'data': { 'device': 'str' } }
2406
2407##
2408# @block-job-dismiss:
2409#
2410# For jobs that have already concluded, remove them from the block-job-query
2411# list. This command only needs to be run for jobs which were started with
2412# QEMU 2.12+ job lifetime management semantics.
2413#
2414# This command will refuse to operate on any job that has not yet reached
2415# its terminal state, JOB_STATUS_CONCLUDED. For jobs that make use of the
2416# BLOCK_JOB_READY event, block-job-cancel or block-job-complete will still need
2417# to be used as appropriate.
2418#
2419# @id: The job identifier.
2420#
2421# Returns: Nothing on success
2422#
2423# Since: 2.12
2424##
2425{ 'command': 'block-job-dismiss', 'data': { 'id': 'str' } }
2426
2427##
2428# @block-job-finalize:
2429#
2430# Once a job that has manual=true reaches the pending state, it can be
2431# instructed to finalize any graph changes and do any necessary cleanup
2432# via this command.
2433# For jobs in a transaction, instructing one job to finalize will force
2434# ALL jobs in the transaction to finalize, so it is only necessary to instruct
2435# a single member job to finalize.
2436#
2437# @id: The job identifier.
2438#
2439# Returns: Nothing on success
2440#
2441# Since: 2.12
2442##
2443{ 'command': 'block-job-finalize', 'data': { 'id': 'str' } }
2444
2445##
2446# @BlockdevDiscardOptions:
2447#
2448# Determines how to handle discard requests.
2449#
2450# @ignore:      Ignore the request
2451# @unmap:       Forward as an unmap request
2452#
2453# Since: 2.9
2454##
2455{ 'enum': 'BlockdevDiscardOptions',
2456  'data': [ 'ignore', 'unmap' ] }
2457
2458##
2459# @BlockdevDetectZeroesOptions:
2460#
2461# Describes the operation mode for the automatic conversion of plain
2462# zero writes by the OS to driver specific optimized zero write commands.
2463#
2464# @off:      Disabled (default)
2465# @on:       Enabled
2466# @unmap:    Enabled and even try to unmap blocks if possible. This requires
2467#            also that @BlockdevDiscardOptions is set to unmap for this device.
2468#
2469# Since: 2.1
2470##
2471{ 'enum': 'BlockdevDetectZeroesOptions',
2472  'data': [ 'off', 'on', 'unmap' ] }
2473
2474##
2475# @BlockdevAioOptions:
2476#
2477# Selects the AIO backend to handle I/O requests
2478#
2479# @threads:     Use qemu's thread pool
2480# @native:      Use native AIO backend (only Linux and Windows)
2481#
2482# Since: 2.9
2483##
2484{ 'enum': 'BlockdevAioOptions',
2485  'data': [ 'threads', 'native' ] }
2486
2487##
2488# @BlockdevCacheOptions:
2489#
2490# Includes cache-related options for block devices
2491#
2492# @direct:      enables use of O_DIRECT (bypass the host page cache;
2493#               default: false)
2494# @no-flush:    ignore any flush requests for the device (default:
2495#               false)
2496#
2497# Since: 2.9
2498##
2499{ 'struct': 'BlockdevCacheOptions',
2500  'data': { '*direct': 'bool',
2501            '*no-flush': 'bool' } }
2502
2503##
2504# @BlockdevDriver:
2505#
2506# Drivers that are supported in block device operations.
2507#
2508# @vxhs: Since 2.10
2509# @throttle: Since 2.11
2510# @nvme: Since 2.12
2511# @copy-on-read: Since 3.0
2512#
2513# Since: 2.9
2514##
2515{ 'enum': 'BlockdevDriver',
2516  'data': [ 'blkdebug', 'blkverify', 'bochs', 'cloop', 'copy-on-read',
2517            'dmg', 'file', 'ftp', 'ftps', 'gluster', 'host_cdrom',
2518            'host_device', 'http', 'https', 'iscsi', 'luks', 'nbd', 'nfs',
2519            'null-aio', 'null-co', 'nvme', 'parallels', 'qcow', 'qcow2', 'qed',
2520            'quorum', 'raw', 'rbd', 'replication', 'sheepdog', 'ssh',
2521            'throttle', 'vdi', 'vhdx', 'vmdk', 'vpc', 'vvfat', 'vxhs' ] }
2522
2523##
2524# @BlockdevOptionsFile:
2525#
2526# Driver specific block device options for the file backend.
2527#
2528# @filename:    path to the image file
2529# @pr-manager:  the id for the object that will handle persistent reservations
2530#               for this device (default: none, forward the commands via SG_IO;
2531#               since 2.11)
2532# @aio:         AIO backend (default: threads) (since: 2.8)
2533# @locking:     whether to enable file locking. If set to 'auto', only enable
2534#               when Open File Descriptor (OFD) locking API is available
2535#               (default: auto, since 2.10)
2536# @x-check-cache-dropped: whether to check that page cache was dropped on live
2537#                         migration.  May cause noticeable delays if the image
2538#                         file is large, do not use in production.
2539#                         (default: off) (since: 3.0)
2540#
2541# Since: 2.9
2542##
2543{ 'struct': 'BlockdevOptionsFile',
2544  'data': { 'filename': 'str',
2545            '*pr-manager': 'str',
2546            '*locking': 'OnOffAuto',
2547            '*aio': 'BlockdevAioOptions',
2548            '*x-check-cache-dropped': 'bool' } }
2549
2550##
2551# @BlockdevOptionsNull:
2552#
2553# Driver specific block device options for the null backend.
2554#
2555# @size:    size of the device in bytes.
2556# @latency-ns: emulated latency (in nanoseconds) in processing
2557#              requests. Default to zero which completes requests immediately.
2558#              (Since 2.4)
2559#
2560# Since: 2.9
2561##
2562{ 'struct': 'BlockdevOptionsNull',
2563  'data': { '*size': 'int', '*latency-ns': 'uint64' } }
2564
2565##
2566# @BlockdevOptionsNVMe:
2567#
2568# Driver specific block device options for the NVMe backend.
2569#
2570# @device:    controller address of the NVMe device.
2571# @namespace: namespace number of the device, starting from 1.
2572#
2573# Since: 2.12
2574##
2575{ 'struct': 'BlockdevOptionsNVMe',
2576  'data': { 'device': 'str', 'namespace': 'int' } }
2577
2578##
2579# @BlockdevOptionsVVFAT:
2580#
2581# Driver specific block device options for the vvfat protocol.
2582#
2583# @dir:         directory to be exported as FAT image
2584# @fat-type:    FAT type: 12, 16 or 32
2585# @floppy:      whether to export a floppy image (true) or
2586#               partitioned hard disk (false; default)
2587# @label:       set the volume label, limited to 11 bytes. FAT16 and
2588#               FAT32 traditionally have some restrictions on labels, which are
2589#               ignored by most operating systems. Defaults to "QEMU VVFAT".
2590#               (since 2.4)
2591# @rw:          whether to allow write operations (default: false)
2592#
2593# Since: 2.9
2594##
2595{ 'struct': 'BlockdevOptionsVVFAT',
2596  'data': { 'dir': 'str', '*fat-type': 'int', '*floppy': 'bool',
2597            '*label': 'str', '*rw': 'bool' } }
2598
2599##
2600# @BlockdevOptionsGenericFormat:
2601#
2602# Driver specific block device options for image format that have no option
2603# besides their data source.
2604#
2605# @file:        reference to or definition of the data source block device
2606#
2607# Since: 2.9
2608##
2609{ 'struct': 'BlockdevOptionsGenericFormat',
2610  'data': { 'file': 'BlockdevRef' } }
2611
2612##
2613# @BlockdevOptionsLUKS:
2614#
2615# Driver specific block device options for LUKS.
2616#
2617# @key-secret: the ID of a QCryptoSecret object providing
2618#              the decryption key (since 2.6). Mandatory except when
2619#              doing a metadata-only probe of the image.
2620#
2621# Since: 2.9
2622##
2623{ 'struct': 'BlockdevOptionsLUKS',
2624  'base': 'BlockdevOptionsGenericFormat',
2625  'data': { '*key-secret': 'str' } }
2626
2627
2628##
2629# @BlockdevOptionsGenericCOWFormat:
2630#
2631# Driver specific block device options for image format that have no option
2632# besides their data source and an optional backing file.
2633#
2634# @backing:     reference to or definition of the backing file block
2635#               device, null disables the backing file entirely.
2636#               Defaults to the backing file stored the image file.
2637#
2638# Since: 2.9
2639##
2640{ 'struct': 'BlockdevOptionsGenericCOWFormat',
2641  'base': 'BlockdevOptionsGenericFormat',
2642  'data': { '*backing': 'BlockdevRefOrNull' } }
2643
2644##
2645# @Qcow2OverlapCheckMode:
2646#
2647# General overlap check modes.
2648#
2649# @none:        Do not perform any checks
2650#
2651# @constant:    Perform only checks which can be done in constant time and
2652#               without reading anything from disk
2653#
2654# @cached:      Perform only checks which can be done without reading anything
2655#               from disk
2656#
2657# @all:         Perform all available overlap checks
2658#
2659# Since: 2.9
2660##
2661{ 'enum': 'Qcow2OverlapCheckMode',
2662  'data': [ 'none', 'constant', 'cached', 'all' ] }
2663
2664##
2665# @Qcow2OverlapCheckFlags:
2666#
2667# Structure of flags for each metadata structure. Setting a field to 'true'
2668# makes qemu guard that structure against unintended overwriting. The default
2669# value is chosen according to the template given.
2670#
2671# @template: Specifies a template mode which can be adjusted using the other
2672#            flags, defaults to 'cached'
2673#
2674# Since: 2.9
2675##
2676{ 'struct': 'Qcow2OverlapCheckFlags',
2677  'data': { '*template':       'Qcow2OverlapCheckMode',
2678            '*main-header':    'bool',
2679            '*active-l1':      'bool',
2680            '*active-l2':      'bool',
2681            '*refcount-table': 'bool',
2682            '*refcount-block': 'bool',
2683            '*snapshot-table': 'bool',
2684            '*inactive-l1':    'bool',
2685            '*inactive-l2':    'bool' } }
2686
2687##
2688# @Qcow2OverlapChecks:
2689#
2690# Specifies which metadata structures should be guarded against unintended
2691# overwriting.
2692#
2693# @flags:   set of flags for separate specification of each metadata structure
2694#           type
2695#
2696# @mode:    named mode which chooses a specific set of flags
2697#
2698# Since: 2.9
2699##
2700{ 'alternate': 'Qcow2OverlapChecks',
2701  'data': { 'flags': 'Qcow2OverlapCheckFlags',
2702            'mode':  'Qcow2OverlapCheckMode' } }
2703
2704##
2705# @BlockdevQcowEncryptionFormat:
2706#
2707# @aes: AES-CBC with plain64 initialization vectors
2708#
2709# Since: 2.10
2710##
2711{ 'enum': 'BlockdevQcowEncryptionFormat',
2712  'data': [ 'aes' ] }
2713
2714##
2715# @BlockdevQcowEncryption:
2716#
2717# Since: 2.10
2718##
2719{ 'union': 'BlockdevQcowEncryption',
2720  'base': { 'format': 'BlockdevQcowEncryptionFormat' },
2721  'discriminator': 'format',
2722  'data': { 'aes': 'QCryptoBlockOptionsQCow' } }
2723
2724##
2725# @BlockdevOptionsQcow:
2726#
2727# Driver specific block device options for qcow.
2728#
2729# @encrypt:               Image decryption options. Mandatory for
2730#                         encrypted images, except when doing a metadata-only
2731#                         probe of the image.
2732#
2733# Since: 2.10
2734##
2735{ 'struct': 'BlockdevOptionsQcow',
2736  'base': 'BlockdevOptionsGenericCOWFormat',
2737  'data': { '*encrypt': 'BlockdevQcowEncryption' } }
2738
2739
2740
2741##
2742# @BlockdevQcow2EncryptionFormat:
2743# @aes: AES-CBC with plain64 initialization venctors
2744#
2745# Since: 2.10
2746##
2747{ 'enum': 'BlockdevQcow2EncryptionFormat',
2748  'data': [ 'aes', 'luks' ] }
2749
2750##
2751# @BlockdevQcow2Encryption:
2752#
2753# Since: 2.10
2754##
2755{ 'union': 'BlockdevQcow2Encryption',
2756  'base': { 'format': 'BlockdevQcow2EncryptionFormat' },
2757  'discriminator': 'format',
2758  'data': { 'aes': 'QCryptoBlockOptionsQCow',
2759            'luks': 'QCryptoBlockOptionsLUKS'} }
2760
2761##
2762# @BlockdevOptionsQcow2:
2763#
2764# Driver specific block device options for qcow2.
2765#
2766# @lazy-refcounts:        whether to enable the lazy refcounts
2767#                         feature (default is taken from the image file)
2768#
2769# @pass-discard-request:  whether discard requests to the qcow2
2770#                         device should be forwarded to the data source
2771#
2772# @pass-discard-snapshot: whether discard requests for the data source
2773#                         should be issued when a snapshot operation (e.g.
2774#                         deleting a snapshot) frees clusters in the qcow2 file
2775#
2776# @pass-discard-other:    whether discard requests for the data source
2777#                         should be issued on other occasions where a cluster
2778#                         gets freed
2779#
2780# @overlap-check:         which overlap checks to perform for writes
2781#                         to the image, defaults to 'cached' (since 2.2)
2782#
2783# @cache-size:            the maximum total size of the L2 table and
2784#                         refcount block caches in bytes (since 2.2)
2785#
2786# @l2-cache-size:         the maximum size of the L2 table cache in
2787#                         bytes (since 2.2)
2788#
2789# @l2-cache-entry-size:   the size of each entry in the L2 cache in
2790#                         bytes. It must be a power of two between 512
2791#                         and the cluster size. The default value is
2792#                         the cluster size (since 2.12)
2793#
2794# @refcount-cache-size:   the maximum size of the refcount block cache
2795#                         in bytes (since 2.2)
2796#
2797# @cache-clean-interval:  clean unused entries in the L2 and refcount
2798#                         caches. The interval is in seconds. The default value
2799#                         is 0 and it disables this feature (since 2.5)
2800# @encrypt:               Image decryption options. Mandatory for
2801#                         encrypted images, except when doing a metadata-only
2802#                         probe of the image. (since 2.10)
2803#
2804# Since: 2.9
2805##
2806{ 'struct': 'BlockdevOptionsQcow2',
2807  'base': 'BlockdevOptionsGenericCOWFormat',
2808  'data': { '*lazy-refcounts': 'bool',
2809            '*pass-discard-request': 'bool',
2810            '*pass-discard-snapshot': 'bool',
2811            '*pass-discard-other': 'bool',
2812            '*overlap-check': 'Qcow2OverlapChecks',
2813            '*cache-size': 'int',
2814            '*l2-cache-size': 'int',
2815            '*l2-cache-entry-size': 'int',
2816            '*refcount-cache-size': 'int',
2817            '*cache-clean-interval': 'int',
2818            '*encrypt': 'BlockdevQcow2Encryption' } }
2819
2820##
2821# @SshHostKeyCheckMode:
2822#
2823# @none             Don't check the host key at all
2824# @hash             Compare the host key with a given hash
2825# @known_hosts      Check the host key against the known_hosts file
2826#
2827# Since: 2.12
2828##
2829{ 'enum': 'SshHostKeyCheckMode',
2830  'data': [ 'none', 'hash', 'known_hosts' ] }
2831
2832##
2833# @SshHostKeyCheckHashType:
2834#
2835# @md5              The given hash is an md5 hash
2836# @sha1             The given hash is an sha1 hash
2837#
2838# Since: 2.12
2839##
2840{ 'enum': 'SshHostKeyCheckHashType',
2841  'data': [ 'md5', 'sha1' ] }
2842
2843##
2844# @SshHostKeyHash:
2845#
2846# @type             The hash algorithm used for the hash
2847# @hash             The expected hash value
2848#
2849# Since: 2.12
2850##
2851{ 'struct': 'SshHostKeyHash',
2852  'data': { 'type': 'SshHostKeyCheckHashType',
2853            'hash': 'str' }}
2854
2855##
2856# @SshHostKeyDummy:
2857#
2858# For those union branches that don't need additional fields.
2859#
2860# Since: 2.12
2861##
2862{ 'struct': 'SshHostKeyDummy',
2863  'data': {} }
2864
2865##
2866# @SshHostKeyCheck:
2867#
2868# Since: 2.12
2869##
2870{ 'union': 'SshHostKeyCheck',
2871  'base': { 'mode': 'SshHostKeyCheckMode' },
2872  'discriminator': 'mode',
2873  'data': { 'none': 'SshHostKeyDummy',
2874            'hash': 'SshHostKeyHash',
2875            'known_hosts': 'SshHostKeyDummy' } }
2876
2877##
2878# @BlockdevOptionsSsh:
2879#
2880# @server:              host address
2881#
2882# @path:                path to the image on the host
2883#
2884# @user:                user as which to connect, defaults to current
2885#                       local user name
2886#
2887# @host-key-check:      Defines how and what to check the host key against
2888#                       (default: known_hosts)
2889#
2890# Since: 2.9
2891##
2892{ 'struct': 'BlockdevOptionsSsh',
2893  'data': { 'server': 'InetSocketAddress',
2894            'path': 'str',
2895            '*user': 'str',
2896            '*host-key-check': 'SshHostKeyCheck' } }
2897
2898
2899##
2900# @BlkdebugEvent:
2901#
2902# Trigger events supported by blkdebug.
2903#
2904# @l1_shrink_write_table:      write zeros to the l1 table to shrink image.
2905#                              (since 2.11)
2906#
2907# @l1_shrink_free_l2_clusters: discard the l2 tables. (since 2.11)
2908#
2909# @cor_write: a write due to copy-on-read (since 2.11)
2910#
2911# Since: 2.9
2912##
2913{ 'enum': 'BlkdebugEvent', 'prefix': 'BLKDBG',
2914  'data': [ 'l1_update', 'l1_grow_alloc_table', 'l1_grow_write_table',
2915            'l1_grow_activate_table', 'l2_load', 'l2_update',
2916            'l2_update_compressed', 'l2_alloc_cow_read', 'l2_alloc_write',
2917            'read_aio', 'read_backing_aio', 'read_compressed', 'write_aio',
2918            'write_compressed', 'vmstate_load', 'vmstate_save', 'cow_read',
2919            'cow_write', 'reftable_load', 'reftable_grow', 'reftable_update',
2920            'refblock_load', 'refblock_update', 'refblock_update_part',
2921            'refblock_alloc', 'refblock_alloc_hookup', 'refblock_alloc_write',
2922            'refblock_alloc_write_blocks', 'refblock_alloc_write_table',
2923            'refblock_alloc_switch_table', 'cluster_alloc',
2924            'cluster_alloc_bytes', 'cluster_free', 'flush_to_os',
2925            'flush_to_disk', 'pwritev_rmw_head', 'pwritev_rmw_after_head',
2926            'pwritev_rmw_tail', 'pwritev_rmw_after_tail', 'pwritev',
2927            'pwritev_zero', 'pwritev_done', 'empty_image_prepare',
2928            'l1_shrink_write_table', 'l1_shrink_free_l2_clusters',
2929            'cor_write'] }
2930
2931##
2932# @BlkdebugInjectErrorOptions:
2933#
2934# Describes a single error injection for blkdebug.
2935#
2936# @event:       trigger event
2937#
2938# @state:       the state identifier blkdebug needs to be in to
2939#               actually trigger the event; defaults to "any"
2940#
2941# @errno:       error identifier (errno) to be returned; defaults to
2942#               EIO
2943#
2944# @sector:      specifies the sector index which has to be affected
2945#               in order to actually trigger the event; defaults to "any
2946#               sector"
2947#
2948# @once:        disables further events after this one has been
2949#               triggered; defaults to false
2950#
2951# @immediately: fail immediately; defaults to false
2952#
2953# Since: 2.9
2954##
2955{ 'struct': 'BlkdebugInjectErrorOptions',
2956  'data': { 'event': 'BlkdebugEvent',
2957            '*state': 'int',
2958            '*errno': 'int',
2959            '*sector': 'int',
2960            '*once': 'bool',
2961            '*immediately': 'bool' } }
2962
2963##
2964# @BlkdebugSetStateOptions:
2965#
2966# Describes a single state-change event for blkdebug.
2967#
2968# @event:       trigger event
2969#
2970# @state:       the current state identifier blkdebug needs to be in;
2971#               defaults to "any"
2972#
2973# @new_state:   the state identifier blkdebug is supposed to assume if
2974#               this event is triggered
2975#
2976# Since: 2.9
2977##
2978{ 'struct': 'BlkdebugSetStateOptions',
2979  'data': { 'event': 'BlkdebugEvent',
2980            '*state': 'int',
2981            'new_state': 'int' } }
2982
2983##
2984# @BlockdevOptionsBlkdebug:
2985#
2986# Driver specific block device options for blkdebug.
2987#
2988# @image:           underlying raw block device (or image file)
2989#
2990# @config:          filename of the configuration file
2991#
2992# @align:           required alignment for requests in bytes, must be
2993#                   positive power of 2, or 0 for default
2994#
2995# @max-transfer:    maximum size for I/O transfers in bytes, must be
2996#                   positive multiple of @align and of the underlying
2997#                   file's request alignment (but need not be a power of
2998#                   2), or 0 for default (since 2.10)
2999#
3000# @opt-write-zero:  preferred alignment for write zero requests in bytes,
3001#                   must be positive multiple of @align and of the
3002#                   underlying file's request alignment (but need not be a
3003#                   power of 2), or 0 for default (since 2.10)
3004#
3005# @max-write-zero:  maximum size for write zero requests in bytes, must be
3006#                   positive multiple of @align, of @opt-write-zero, and of
3007#                   the underlying file's request alignment (but need not
3008#                   be a power of 2), or 0 for default (since 2.10)
3009#
3010# @opt-discard:     preferred alignment for discard requests in bytes, must
3011#                   be positive multiple of @align and of the underlying
3012#                   file's request alignment (but need not be a power of
3013#                   2), or 0 for default (since 2.10)
3014#
3015# @max-discard:     maximum size for discard requests in bytes, must be
3016#                   positive multiple of @align, of @opt-discard, and of
3017#                   the underlying file's request alignment (but need not
3018#                   be a power of 2), or 0 for default (since 2.10)
3019#
3020# @inject-error:    array of error injection descriptions
3021#
3022# @set-state:       array of state-change descriptions
3023#
3024# Since: 2.9
3025##
3026{ 'struct': 'BlockdevOptionsBlkdebug',
3027  'data': { 'image': 'BlockdevRef',
3028            '*config': 'str',
3029            '*align': 'int', '*max-transfer': 'int32',
3030            '*opt-write-zero': 'int32', '*max-write-zero': 'int32',
3031            '*opt-discard': 'int32', '*max-discard': 'int32',
3032            '*inject-error': ['BlkdebugInjectErrorOptions'],
3033            '*set-state': ['BlkdebugSetStateOptions'] } }
3034
3035##
3036# @BlockdevOptionsBlkverify:
3037#
3038# Driver specific block device options for blkverify.
3039#
3040# @test:    block device to be tested
3041#
3042# @raw:     raw image used for verification
3043#
3044# Since: 2.9
3045##
3046{ 'struct': 'BlockdevOptionsBlkverify',
3047  'data': { 'test': 'BlockdevRef',
3048            'raw': 'BlockdevRef' } }
3049
3050##
3051# @QuorumReadPattern:
3052#
3053# An enumeration of quorum read patterns.
3054#
3055# @quorum: read all the children and do a quorum vote on reads
3056#
3057# @fifo: read only from the first child that has not failed
3058#
3059# Since: 2.9
3060##
3061{ 'enum': 'QuorumReadPattern', 'data': [ 'quorum', 'fifo' ] }
3062
3063##
3064# @BlockdevOptionsQuorum:
3065#
3066# Driver specific block device options for Quorum
3067#
3068# @blkverify:      true if the driver must print content mismatch
3069#                  set to false by default
3070#
3071# @children:       the children block devices to use
3072#
3073# @vote-threshold: the vote limit under which a read will fail
3074#
3075# @rewrite-corrupted: rewrite corrupted data when quorum is reached
3076#                     (Since 2.1)
3077#
3078# @read-pattern: choose read pattern and set to quorum by default
3079#                (Since 2.2)
3080#
3081# Since: 2.9
3082##
3083{ 'struct': 'BlockdevOptionsQuorum',
3084  'data': { '*blkverify': 'bool',
3085            'children': [ 'BlockdevRef' ],
3086            'vote-threshold': 'int',
3087            '*rewrite-corrupted': 'bool',
3088            '*read-pattern': 'QuorumReadPattern' } }
3089
3090##
3091# @BlockdevOptionsGluster:
3092#
3093# Driver specific block device options for Gluster
3094#
3095# @volume:      name of gluster volume where VM image resides
3096#
3097# @path:        absolute path to image file in gluster volume
3098#
3099# @server:      gluster servers description
3100#
3101# @debug:       libgfapi log level (default '4' which is Error)
3102#               (Since 2.8)
3103#
3104# @logfile:     libgfapi log file (default /dev/stderr) (Since 2.8)
3105#
3106# Since: 2.9
3107##
3108{ 'struct': 'BlockdevOptionsGluster',
3109  'data': { 'volume': 'str',
3110            'path': 'str',
3111            'server': ['SocketAddress'],
3112            '*debug': 'int',
3113            '*logfile': 'str' } }
3114
3115##
3116# @IscsiTransport:
3117#
3118# An enumeration of libiscsi transport types
3119#
3120# Since: 2.9
3121##
3122{ 'enum': 'IscsiTransport',
3123  'data': [ 'tcp', 'iser' ] }
3124
3125##
3126# @IscsiHeaderDigest:
3127#
3128# An enumeration of header digests supported by libiscsi
3129#
3130# Since: 2.9
3131##
3132{ 'enum': 'IscsiHeaderDigest',
3133  'prefix': 'QAPI_ISCSI_HEADER_DIGEST',
3134  'data': [ 'crc32c', 'none', 'crc32c-none', 'none-crc32c' ] }
3135
3136##
3137# @BlockdevOptionsIscsi:
3138#
3139# @transport:       The iscsi transport type
3140#
3141# @portal:          The address of the iscsi portal
3142#
3143# @target:          The target iqn name
3144#
3145# @lun:             LUN to connect to. Defaults to 0.
3146#
3147# @user:            User name to log in with. If omitted, no CHAP
3148#                   authentication is performed.
3149#
3150# @password-secret: The ID of a QCryptoSecret object providing
3151#                   the password for the login. This option is required if
3152#                   @user is specified.
3153#
3154# @initiator-name:  The iqn name we want to identify to the target
3155#                   as. If this option is not specified, an initiator name is
3156#                   generated automatically.
3157#
3158# @header-digest:   The desired header digest. Defaults to
3159#                   none-crc32c.
3160#
3161# @timeout:         Timeout in seconds after which a request will
3162#                   timeout. 0 means no timeout and is the default.
3163#
3164# Driver specific block device options for iscsi
3165#
3166# Since: 2.9
3167##
3168{ 'struct': 'BlockdevOptionsIscsi',
3169  'data': { 'transport': 'IscsiTransport',
3170            'portal': 'str',
3171            'target': 'str',
3172            '*lun': 'int',
3173            '*user': 'str',
3174            '*password-secret': 'str',
3175            '*initiator-name': 'str',
3176            '*header-digest': 'IscsiHeaderDigest',
3177            '*timeout': 'int' } }
3178
3179
3180##
3181# @RbdAuthMode:
3182#
3183# Since: 3.0
3184##
3185{ 'enum': 'RbdAuthMode',
3186  'data': [ 'cephx', 'none' ] }
3187
3188##
3189# @BlockdevOptionsRbd:
3190#
3191# @pool:               Ceph pool name.
3192#
3193# @image:              Image name in the Ceph pool.
3194#
3195# @conf:               path to Ceph configuration file.  Values
3196#                      in the configuration file will be overridden by
3197#                      options specified via QAPI.
3198#
3199# @snapshot:           Ceph snapshot name.
3200#
3201# @user:               Ceph id name.
3202#
3203# @auth-client-required: Acceptable authentication modes.
3204#                      This maps to Ceph configuration option
3205#                      "auth_client_required".  (Since 3.0)
3206#
3207# @key-secret:         ID of a QCryptoSecret object providing a key
3208#                      for cephx authentication.
3209#                      This maps to Ceph configuration option
3210#                      "key".  (Since 3.0)
3211#
3212# @server:             Monitor host address and port.  This maps
3213#                      to the "mon_host" Ceph option.
3214#
3215# Since: 2.9
3216##
3217{ 'struct': 'BlockdevOptionsRbd',
3218  'data': { 'pool': 'str',
3219            'image': 'str',
3220            '*conf': 'str',
3221            '*snapshot': 'str',
3222            '*user': 'str',
3223            '*auth-client-required': ['RbdAuthMode'],
3224            '*key-secret': 'str',
3225            '*server': ['InetSocketAddressBase'] } }
3226
3227##
3228# @BlockdevOptionsSheepdog:
3229#
3230# Driver specific block device options for sheepdog
3231#
3232# @vdi:         Virtual disk image name
3233# @server:      The Sheepdog server to connect to
3234# @snap-id:     Snapshot ID
3235# @tag:         Snapshot tag name
3236#
3237# Only one of @snap-id and @tag may be present.
3238#
3239# Since: 2.9
3240##
3241{ 'struct': 'BlockdevOptionsSheepdog',
3242  'data': { 'server': 'SocketAddress',
3243            'vdi': 'str',
3244            '*snap-id': 'uint32',
3245            '*tag': 'str' } }
3246
3247##
3248# @ReplicationMode:
3249#
3250# An enumeration of replication modes.
3251#
3252# @primary: Primary mode, the vm's state will be sent to secondary QEMU.
3253#
3254# @secondary: Secondary mode, receive the vm's state from primary QEMU.
3255#
3256# Since: 2.9
3257##
3258{ 'enum' : 'ReplicationMode', 'data' : [ 'primary', 'secondary' ] }
3259
3260##
3261# @BlockdevOptionsReplication:
3262#
3263# Driver specific block device options for replication
3264#
3265# @mode: the replication mode
3266#
3267# @top-id: In secondary mode, node name or device ID of the root
3268#          node who owns the replication node chain. Must not be given in
3269#          primary mode.
3270#
3271# Since: 2.9
3272##
3273{ 'struct': 'BlockdevOptionsReplication',
3274  'base': 'BlockdevOptionsGenericFormat',
3275  'data': { 'mode': 'ReplicationMode',
3276            '*top-id': 'str' } }
3277
3278##
3279# @NFSTransport:
3280#
3281# An enumeration of NFS transport types
3282#
3283# @inet:        TCP transport
3284#
3285# Since: 2.9
3286##
3287{ 'enum': 'NFSTransport',
3288  'data': [ 'inet' ] }
3289
3290##
3291# @NFSServer:
3292#
3293# Captures the address of the socket
3294#
3295# @type:        transport type used for NFS (only TCP supported)
3296#
3297# @host:        host address for NFS server
3298#
3299# Since: 2.9
3300##
3301{ 'struct': 'NFSServer',
3302  'data': { 'type': 'NFSTransport',
3303            'host': 'str' } }
3304
3305##
3306# @BlockdevOptionsNfs:
3307#
3308# Driver specific block device option for NFS
3309#
3310# @server:                  host address
3311#
3312# @path:                    path of the image on the host
3313#
3314# @user:                    UID value to use when talking to the
3315#                           server (defaults to 65534 on Windows and getuid()
3316#                           on unix)
3317#
3318# @group:                   GID value to use when talking to the
3319#                           server (defaults to 65534 on Windows and getgid()
3320#                           in unix)
3321#
3322# @tcp-syn-count:           number of SYNs during the session
3323#                           establishment (defaults to libnfs default)
3324#
3325# @readahead-size:          set the readahead size in bytes (defaults
3326#                           to libnfs default)
3327#
3328# @page-cache-size:         set the pagecache size in bytes (defaults
3329#                           to libnfs default)
3330#
3331# @debug:                   set the NFS debug level (max 2) (defaults
3332#                           to libnfs default)
3333#
3334# Since: 2.9
3335##
3336{ 'struct': 'BlockdevOptionsNfs',
3337  'data': { 'server': 'NFSServer',
3338            'path': 'str',
3339            '*user': 'int',
3340            '*group': 'int',
3341            '*tcp-syn-count': 'int',
3342            '*readahead-size': 'int',
3343            '*page-cache-size': 'int',
3344            '*debug': 'int' } }
3345
3346##
3347# @BlockdevOptionsCurlBase:
3348#
3349# Driver specific block device options shared by all protocols supported by the
3350# curl backend.
3351#
3352# @url:                     URL of the image file
3353#
3354# @readahead:               Size of the read-ahead cache; must be a multiple of
3355#                           512 (defaults to 256 kB)
3356#
3357# @timeout:                 Timeout for connections, in seconds (defaults to 5)
3358#
3359# @username:                Username for authentication (defaults to none)
3360#
3361# @password-secret:         ID of a QCryptoSecret object providing a password
3362#                           for authentication (defaults to no password)
3363#
3364# @proxy-username:          Username for proxy authentication (defaults to none)
3365#
3366# @proxy-password-secret:   ID of a QCryptoSecret object providing a password
3367#                           for proxy authentication (defaults to no password)
3368#
3369# Since: 2.9
3370##
3371{ 'struct': 'BlockdevOptionsCurlBase',
3372  'data': { 'url': 'str',
3373            '*readahead': 'int',
3374            '*timeout': 'int',
3375            '*username': 'str',
3376            '*password-secret': 'str',
3377            '*proxy-username': 'str',
3378            '*proxy-password-secret': 'str' } }
3379
3380##
3381# @BlockdevOptionsCurlHttp:
3382#
3383# Driver specific block device options for HTTP connections over the curl
3384# backend.  URLs must start with "http://".
3385#
3386# @cookie:      List of cookies to set; format is
3387#               "name1=content1; name2=content2;" as explained by
3388#               CURLOPT_COOKIE(3). Defaults to no cookies.
3389#
3390# @cookie-secret: ID of a QCryptoSecret object providing the cookie data in a
3391#                 secure way. See @cookie for the format. (since 2.10)
3392#
3393# Since: 2.9
3394##
3395{ 'struct': 'BlockdevOptionsCurlHttp',
3396  'base': 'BlockdevOptionsCurlBase',
3397  'data': { '*cookie': 'str',
3398            '*cookie-secret': 'str'} }
3399
3400##
3401# @BlockdevOptionsCurlHttps:
3402#
3403# Driver specific block device options for HTTPS connections over the curl
3404# backend.  URLs must start with "https://".
3405#
3406# @cookie:      List of cookies to set; format is
3407#               "name1=content1; name2=content2;" as explained by
3408#               CURLOPT_COOKIE(3). Defaults to no cookies.
3409#
3410# @sslverify:   Whether to verify the SSL certificate's validity (defaults to
3411#               true)
3412#
3413# @cookie-secret: ID of a QCryptoSecret object providing the cookie data in a
3414#                 secure way. See @cookie for the format. (since 2.10)
3415#
3416# Since: 2.9
3417##
3418{ 'struct': 'BlockdevOptionsCurlHttps',
3419  'base': 'BlockdevOptionsCurlBase',
3420  'data': { '*cookie': 'str',
3421            '*sslverify': 'bool',
3422            '*cookie-secret': 'str'} }
3423
3424##
3425# @BlockdevOptionsCurlFtp:
3426#
3427# Driver specific block device options for FTP connections over the curl
3428# backend.  URLs must start with "ftp://".
3429#
3430# Since: 2.9
3431##
3432{ 'struct': 'BlockdevOptionsCurlFtp',
3433  'base': 'BlockdevOptionsCurlBase',
3434  'data': { } }
3435
3436##
3437# @BlockdevOptionsCurlFtps:
3438#
3439# Driver specific block device options for FTPS connections over the curl
3440# backend.  URLs must start with "ftps://".
3441#
3442# @sslverify:   Whether to verify the SSL certificate's validity (defaults to
3443#               true)
3444#
3445# Since: 2.9
3446##
3447{ 'struct': 'BlockdevOptionsCurlFtps',
3448  'base': 'BlockdevOptionsCurlBase',
3449  'data': { '*sslverify': 'bool' } }
3450
3451##
3452# @BlockdevOptionsNbd:
3453#
3454# Driver specific block device options for NBD.
3455#
3456# @server:      NBD server address
3457#
3458# @export:      export name
3459#
3460# @tls-creds:   TLS credentials ID
3461#
3462# Since: 2.9
3463##
3464{ 'struct': 'BlockdevOptionsNbd',
3465  'data': { 'server': 'SocketAddress',
3466            '*export': 'str',
3467            '*tls-creds': 'str' } }
3468
3469##
3470# @BlockdevOptionsRaw:
3471#
3472# Driver specific block device options for the raw driver.
3473#
3474# @offset:      position where the block device starts
3475# @size:        the assumed size of the device
3476#
3477# Since: 2.9
3478##
3479{ 'struct': 'BlockdevOptionsRaw',
3480  'base': 'BlockdevOptionsGenericFormat',
3481  'data': { '*offset': 'int', '*size': 'int' } }
3482
3483##
3484# @BlockdevOptionsVxHS:
3485#
3486# Driver specific block device options for VxHS
3487#
3488# @vdisk-id:    UUID of VxHS volume
3489# @server:      vxhs server IP, port
3490# @tls-creds:   TLS credentials ID
3491#
3492# Since: 2.10
3493##
3494{ 'struct': 'BlockdevOptionsVxHS',
3495  'data': { 'vdisk-id': 'str',
3496            'server': 'InetSocketAddressBase',
3497            '*tls-creds': 'str' } }
3498
3499##
3500# @BlockdevOptionsThrottle:
3501#
3502# Driver specific block device options for the throttle driver
3503#
3504# @throttle-group:   the name of the throttle-group object to use. It
3505#                    must already exist.
3506# @file:             reference to or definition of the data source block device
3507# Since: 2.11
3508##
3509{ 'struct': 'BlockdevOptionsThrottle',
3510  'data': { 'throttle-group': 'str',
3511            'file' : 'BlockdevRef'
3512             } }
3513##
3514# @BlockdevOptions:
3515#
3516# Options for creating a block device.  Many options are available for all
3517# block devices, independent of the block driver:
3518#
3519# @driver:        block driver name
3520# @node-name:     the node name of the new node (Since 2.0).
3521#                 This option is required on the top level of blockdev-add.
3522# @discard:       discard-related options (default: ignore)
3523# @cache:         cache-related options
3524# @read-only:     whether the block device should be read-only (default: false).
3525#                 Note that some block drivers support only read-only access,
3526#                 either generally or in certain configurations. In this case,
3527#                 the default value does not work and the option must be
3528#                 specified explicitly.
3529# @detect-zeroes: detect and optimize zero writes (Since 2.1)
3530#                 (default: off)
3531# @force-share:   force share all permission on added nodes.
3532#                 Requires read-only=true. (Since 2.10)
3533#
3534# Remaining options are determined by the block driver.
3535#
3536# Since: 2.9
3537##
3538{ 'union': 'BlockdevOptions',
3539  'base': { 'driver': 'BlockdevDriver',
3540            '*node-name': 'str',
3541            '*discard': 'BlockdevDiscardOptions',
3542            '*cache': 'BlockdevCacheOptions',
3543            '*read-only': 'bool',
3544            '*force-share': 'bool',
3545            '*detect-zeroes': 'BlockdevDetectZeroesOptions' },
3546  'discriminator': 'driver',
3547  'data': {
3548      'blkdebug':   'BlockdevOptionsBlkdebug',
3549      'blkverify':  'BlockdevOptionsBlkverify',
3550      'bochs':      'BlockdevOptionsGenericFormat',
3551      'cloop':      'BlockdevOptionsGenericFormat',
3552      'copy-on-read':'BlockdevOptionsGenericFormat',
3553      'dmg':        'BlockdevOptionsGenericFormat',
3554      'file':       'BlockdevOptionsFile',
3555      'ftp':        'BlockdevOptionsCurlFtp',
3556      'ftps':       'BlockdevOptionsCurlFtps',
3557      'gluster':    'BlockdevOptionsGluster',
3558      'host_cdrom': 'BlockdevOptionsFile',
3559      'host_device':'BlockdevOptionsFile',
3560      'http':       'BlockdevOptionsCurlHttp',
3561      'https':      'BlockdevOptionsCurlHttps',
3562      'iscsi':      'BlockdevOptionsIscsi',
3563      'luks':       'BlockdevOptionsLUKS',
3564      'nbd':        'BlockdevOptionsNbd',
3565      'nfs':        'BlockdevOptionsNfs',
3566      'null-aio':   'BlockdevOptionsNull',
3567      'null-co':    'BlockdevOptionsNull',
3568      'nvme':       'BlockdevOptionsNVMe',
3569      'parallels':  'BlockdevOptionsGenericFormat',
3570      'qcow2':      'BlockdevOptionsQcow2',
3571      'qcow':       'BlockdevOptionsQcow',
3572      'qed':        'BlockdevOptionsGenericCOWFormat',
3573      'quorum':     'BlockdevOptionsQuorum',
3574      'raw':        'BlockdevOptionsRaw',
3575      'rbd':        'BlockdevOptionsRbd',
3576      'replication':'BlockdevOptionsReplication',
3577      'sheepdog':   'BlockdevOptionsSheepdog',
3578      'ssh':        'BlockdevOptionsSsh',
3579      'throttle':   'BlockdevOptionsThrottle',
3580      'vdi':        'BlockdevOptionsGenericFormat',
3581      'vhdx':       'BlockdevOptionsGenericFormat',
3582      'vmdk':       'BlockdevOptionsGenericCOWFormat',
3583      'vpc':        'BlockdevOptionsGenericFormat',
3584      'vvfat':      'BlockdevOptionsVVFAT',
3585      'vxhs':       'BlockdevOptionsVxHS'
3586  } }
3587
3588##
3589# @BlockdevRef:
3590#
3591# Reference to a block device.
3592#
3593# @definition:      defines a new block device inline
3594# @reference:       references the ID of an existing block device
3595#
3596# Since: 2.9
3597##
3598{ 'alternate': 'BlockdevRef',
3599  'data': { 'definition': 'BlockdevOptions',
3600            'reference': 'str' } }
3601
3602##
3603# @BlockdevRefOrNull:
3604#
3605# Reference to a block device.
3606#
3607# @definition:      defines a new block device inline
3608# @reference:       references the ID of an existing block device.
3609#                   An empty string means that no block device should
3610#                   be referenced.  Deprecated; use null instead.
3611# @null:            No block device should be referenced (since 2.10)
3612#
3613# Since: 2.9
3614##
3615{ 'alternate': 'BlockdevRefOrNull',
3616  'data': { 'definition': 'BlockdevOptions',
3617            'reference': 'str',
3618            'null': 'null' } }
3619
3620##
3621# @blockdev-add:
3622#
3623# Creates a new block device. If the @id option is given at the top level, a
3624# BlockBackend will be created; otherwise, @node-name is mandatory at the top
3625# level and no BlockBackend will be created.
3626#
3627# Since: 2.9
3628#
3629# Example:
3630#
3631# 1.
3632# -> { "execute": "blockdev-add",
3633#      "arguments": {
3634#           "driver": "qcow2",
3635#           "node-name": "test1",
3636#           "file": {
3637#               "driver": "file",
3638#               "filename": "test.qcow2"
3639#            }
3640#       }
3641#     }
3642# <- { "return": {} }
3643#
3644# 2.
3645# -> { "execute": "blockdev-add",
3646#      "arguments": {
3647#           "driver": "qcow2",
3648#           "node-name": "node0",
3649#           "discard": "unmap",
3650#           "cache": {
3651#              "direct": true
3652#            },
3653#            "file": {
3654#              "driver": "file",
3655#              "filename": "/tmp/test.qcow2"
3656#            },
3657#            "backing": {
3658#               "driver": "raw",
3659#               "file": {
3660#                  "driver": "file",
3661#                  "filename": "/dev/fdset/4"
3662#                }
3663#            }
3664#        }
3665#      }
3666#
3667# <- { "return": {} }
3668#
3669##
3670{ 'command': 'blockdev-add', 'data': 'BlockdevOptions', 'boxed': true }
3671
3672##
3673# @blockdev-del:
3674#
3675# Deletes a block device that has been added using blockdev-add.
3676# The command will fail if the node is attached to a device or is
3677# otherwise being used.
3678#
3679# @node-name: Name of the graph node to delete.
3680#
3681# Since: 2.9
3682#
3683# Example:
3684#
3685# -> { "execute": "blockdev-add",
3686#      "arguments": {
3687#           "driver": "qcow2",
3688#           "node-name": "node0",
3689#           "file": {
3690#               "driver": "file",
3691#               "filename": "test.qcow2"
3692#           }
3693#      }
3694#    }
3695# <- { "return": {} }
3696#
3697# -> { "execute": "blockdev-del",
3698#      "arguments": { "node-name": "node0" }
3699#    }
3700# <- { "return": {} }
3701#
3702##
3703{ 'command': 'blockdev-del', 'data': { 'node-name': 'str' } }
3704
3705##
3706# @BlockdevCreateOptionsFile:
3707#
3708# Driver specific image creation options for file.
3709#
3710# @filename         Filename for the new image file
3711# @size             Size of the virtual disk in bytes
3712# @preallocation    Preallocation mode for the new image (default: off)
3713# @nocow            Turn off copy-on-write (valid only on btrfs; default: off)
3714#
3715# Since: 2.12
3716##
3717{ 'struct': 'BlockdevCreateOptionsFile',
3718  'data': { 'filename':         'str',
3719            'size':             'size',
3720            '*preallocation':   'PreallocMode',
3721            '*nocow':           'bool' } }
3722
3723##
3724# @BlockdevCreateOptionsGluster:
3725#
3726# Driver specific image creation options for gluster.
3727#
3728# @location         Where to store the new image file
3729# @size             Size of the virtual disk in bytes
3730# @preallocation    Preallocation mode for the new image (default: off)
3731#
3732# Since: 2.12
3733##
3734{ 'struct': 'BlockdevCreateOptionsGluster',
3735  'data': { 'location':         'BlockdevOptionsGluster',
3736            'size':             'size',
3737            '*preallocation':   'PreallocMode' } }
3738
3739##
3740# @BlockdevCreateOptionsLUKS:
3741#
3742# Driver specific image creation options for LUKS.
3743#
3744# @file             Node to create the image format on
3745# @size             Size of the virtual disk in bytes
3746#
3747# Since: 2.12
3748##
3749{ 'struct': 'BlockdevCreateOptionsLUKS',
3750  'base': 'QCryptoBlockCreateOptionsLUKS',
3751  'data': { 'file':             'BlockdevRef',
3752            'size':             'size' } }
3753
3754##
3755# @BlockdevCreateOptionsNfs:
3756#
3757# Driver specific image creation options for NFS.
3758#
3759# @location         Where to store the new image file
3760# @size             Size of the virtual disk in bytes
3761#
3762# Since: 2.12
3763##
3764{ 'struct': 'BlockdevCreateOptionsNfs',
3765  'data': { 'location':         'BlockdevOptionsNfs',
3766            'size':             'size' } }
3767
3768##
3769# @BlockdevCreateOptionsParallels:
3770#
3771# Driver specific image creation options for parallels.
3772#
3773# @file             Node to create the image format on
3774# @size             Size of the virtual disk in bytes
3775# @cluster-size     Cluster size in bytes (default: 1 MB)
3776#
3777# Since: 2.12
3778##
3779{ 'struct': 'BlockdevCreateOptionsParallels',
3780  'data': { 'file':             'BlockdevRef',
3781            'size':             'size',
3782            '*cluster-size':    'size' } }
3783
3784##
3785# @BlockdevCreateOptionsQcow:
3786#
3787# Driver specific image creation options for qcow.
3788#
3789# @file             Node to create the image format on
3790# @size             Size of the virtual disk in bytes
3791# @backing-file     File name of the backing file if a backing file
3792#                   should be used
3793# @encrypt          Encryption options if the image should be encrypted
3794#
3795# Since: 2.12
3796##
3797{ 'struct': 'BlockdevCreateOptionsQcow',
3798  'data': { 'file':             'BlockdevRef',
3799            'size':             'size',
3800            '*backing-file':    'str',
3801            '*encrypt':         'QCryptoBlockCreateOptions' } }
3802
3803##
3804# @BlockdevQcow2Version:
3805#
3806# @v2:  The original QCOW2 format as introduced in qemu 0.10 (version 2)
3807# @v3:  The extended QCOW2 format as introduced in qemu 1.1 (version 3)
3808#
3809# Since: 2.12
3810##
3811{ 'enum': 'BlockdevQcow2Version',
3812  'data': [ 'v2', 'v3' ] }
3813
3814
3815##
3816# @BlockdevCreateOptionsQcow2:
3817#
3818# Driver specific image creation options for qcow2.
3819#
3820# @file             Node to create the image format on
3821# @size             Size of the virtual disk in bytes
3822# @version          Compatibility level (default: v3)
3823# @backing-file     File name of the backing file if a backing file
3824#                   should be used
3825# @backing-fmt      Name of the block driver to use for the backing file
3826# @encrypt          Encryption options if the image should be encrypted
3827# @cluster-size     qcow2 cluster size in bytes (default: 65536)
3828# @preallocation    Preallocation mode for the new image (default: off)
3829# @lazy-refcounts   True if refcounts may be updated lazily (default: off)
3830# @refcount-bits    Width of reference counts in bits (default: 16)
3831#
3832# Since: 2.12
3833##
3834{ 'struct': 'BlockdevCreateOptionsQcow2',
3835  'data': { 'file':             'BlockdevRef',
3836            'size':             'size',
3837            '*version':         'BlockdevQcow2Version',
3838            '*backing-file':    'str',
3839            '*backing-fmt':     'BlockdevDriver',
3840            '*encrypt':         'QCryptoBlockCreateOptions',
3841            '*cluster-size':    'size',
3842            '*preallocation':   'PreallocMode',
3843            '*lazy-refcounts':  'bool',
3844            '*refcount-bits':   'int' } }
3845
3846##
3847# @BlockdevCreateOptionsQed:
3848#
3849# Driver specific image creation options for qed.
3850#
3851# @file             Node to create the image format on
3852# @size             Size of the virtual disk in bytes
3853# @backing-file     File name of the backing file if a backing file
3854#                   should be used
3855# @backing-fmt      Name of the block driver to use for the backing file
3856# @cluster-size     Cluster size in bytes (default: 65536)
3857# @table-size       L1/L2 table size (in clusters)
3858#
3859# Since: 2.12
3860##
3861{ 'struct': 'BlockdevCreateOptionsQed',
3862  'data': { 'file':             'BlockdevRef',
3863            'size':             'size',
3864            '*backing-file':    'str',
3865            '*backing-fmt':     'BlockdevDriver',
3866            '*cluster-size':    'size',
3867            '*table-size':      'int' } }
3868
3869##
3870# @BlockdevCreateOptionsRbd:
3871#
3872# Driver specific image creation options for rbd/Ceph.
3873#
3874# @location         Where to store the new image file. This location cannot
3875#                   point to a snapshot.
3876# @size             Size of the virtual disk in bytes
3877# @cluster-size     RBD object size
3878#
3879# Since: 2.12
3880##
3881{ 'struct': 'BlockdevCreateOptionsRbd',
3882  'data': { 'location':         'BlockdevOptionsRbd',
3883            'size':             'size',
3884            '*cluster-size' :   'size' } }
3885
3886##
3887# @SheepdogRedundancyType:
3888#
3889# @full             Create a fully replicated vdi with x copies
3890# @erasure-coded    Create an erasure coded vdi with x data strips and
3891#                   y parity strips
3892#
3893# Since: 2.12
3894##
3895{ 'enum': 'SheepdogRedundancyType',
3896  'data': [ 'full', 'erasure-coded' ] }
3897
3898##
3899# @SheepdogRedundancyFull:
3900#
3901# @copies           Number of copies to use (between 1 and 31)
3902#
3903# Since: 2.12
3904##
3905{ 'struct': 'SheepdogRedundancyFull',
3906  'data': { 'copies': 'int' }}
3907
3908##
3909# @SheepdogRedundancyErasureCoded:
3910#
3911# @data-strips      Number of data strips to use (one of {2,4,8,16})
3912# @parity-strips    Number of parity strips to use (between 1 and 15)
3913#
3914# Since: 2.12
3915##
3916{ 'struct': 'SheepdogRedundancyErasureCoded',
3917  'data': { 'data-strips': 'int',
3918            'parity-strips': 'int' }}
3919
3920##
3921# @SheepdogRedundancy:
3922#
3923# Since: 2.12
3924##
3925{ 'union': 'SheepdogRedundancy',
3926  'base': { 'type': 'SheepdogRedundancyType' },
3927  'discriminator': 'type',
3928  'data': { 'full': 'SheepdogRedundancyFull',
3929            'erasure-coded': 'SheepdogRedundancyErasureCoded' } }
3930
3931##
3932# @BlockdevCreateOptionsSheepdog:
3933#
3934# Driver specific image creation options for Sheepdog.
3935#
3936# @location         Where to store the new image file
3937# @size             Size of the virtual disk in bytes
3938# @backing-file     File name of a base image
3939# @preallocation    Preallocation mode (allowed values: off, full)
3940# @redundancy       Redundancy of the image
3941# @object-size      Object size of the image
3942#
3943# Since: 2.12
3944##
3945{ 'struct': 'BlockdevCreateOptionsSheepdog',
3946  'data': { 'location':         'BlockdevOptionsSheepdog',
3947            'size':             'size',
3948            '*backing-file':    'str',
3949            '*preallocation':   'PreallocMode',
3950            '*redundancy':      'SheepdogRedundancy',
3951            '*object-size':     'size' } }
3952
3953##
3954# @BlockdevCreateOptionsSsh:
3955#
3956# Driver specific image creation options for SSH.
3957#
3958# @location         Where to store the new image file
3959# @size             Size of the virtual disk in bytes
3960#
3961# Since: 2.12
3962##
3963{ 'struct': 'BlockdevCreateOptionsSsh',
3964  'data': { 'location':         'BlockdevOptionsSsh',
3965            'size':             'size' } }
3966
3967##
3968# @BlockdevCreateOptionsVdi:
3969#
3970# Driver specific image creation options for VDI.
3971#
3972# @file             Node to create the image format on
3973# @size             Size of the virtual disk in bytes
3974# @preallocation    Preallocation mode for the new image (allowed values: off,
3975#                   metadata; default: off)
3976#
3977# Since: 2.12
3978##
3979{ 'struct': 'BlockdevCreateOptionsVdi',
3980  'data': { 'file':             'BlockdevRef',
3981            'size':             'size',
3982            '*preallocation':   'PreallocMode' } }
3983
3984##
3985# @BlockdevVhdxSubformat:
3986#
3987# @dynamic: Growing image file
3988# @fixed:   Preallocated fixed-size image file
3989#
3990# Since: 2.12
3991##
3992{ 'enum': 'BlockdevVhdxSubformat',
3993  'data': [ 'dynamic', 'fixed' ] }
3994
3995##
3996# @BlockdevCreateOptionsVhdx:
3997#
3998# Driver specific image creation options for vhdx.
3999#
4000# @file             Node to create the image format on
4001# @size             Size of the virtual disk in bytes
4002# @log-size         Log size in bytes, must be a multiple of 1 MB
4003#                   (default: 1 MB)
4004# @block-size       Block size in bytes, must be a multiple of 1 MB and not
4005#                   larger than 256 MB (default: automatically choose a block
4006#                   size depending on the image size)
4007# @subformat        vhdx subformat (default: dynamic)
4008# @block-state-zero Force use of payload blocks of type 'ZERO'. Non-standard,
4009#                   but default.  Do not set to 'off' when using 'qemu-img
4010#                   convert' with subformat=dynamic.
4011#
4012# Since: 2.12
4013##
4014{ 'struct': 'BlockdevCreateOptionsVhdx',
4015  'data': { 'file':                 'BlockdevRef',
4016            'size':                 'size',
4017            '*log-size':            'size',
4018            '*block-size':          'size',
4019            '*subformat':           'BlockdevVhdxSubformat',
4020            '*block-state-zero':    'bool' } }
4021
4022##
4023# @BlockdevVpcSubformat:
4024#
4025# @dynamic: Growing image file
4026# @fixed:   Preallocated fixed-size image file
4027#
4028# Since: 2.12
4029##
4030{ 'enum': 'BlockdevVpcSubformat',
4031  'data': [ 'dynamic', 'fixed' ] }
4032
4033##
4034# @BlockdevCreateOptionsVpc:
4035#
4036# Driver specific image creation options for vpc (VHD).
4037#
4038# @file             Node to create the image format on
4039# @size             Size of the virtual disk in bytes
4040# @subformat        vhdx subformat (default: dynamic)
4041# @force-size       Force use of the exact byte size instead of rounding to the
4042#                   next size that can be represented in CHS geometry
4043#                   (default: false)
4044#
4045# Since: 2.12
4046##
4047{ 'struct': 'BlockdevCreateOptionsVpc',
4048  'data': { 'file':                 'BlockdevRef',
4049            'size':                 'size',
4050            '*subformat':           'BlockdevVpcSubformat',
4051            '*force-size':          'bool' } }
4052
4053##
4054# @BlockdevCreateNotSupported:
4055#
4056# This is used for all drivers that don't support creating images.
4057#
4058# Since: 2.12
4059##
4060{ 'struct': 'BlockdevCreateNotSupported', 'data': {}}
4061
4062##
4063# @BlockdevCreateOptions:
4064#
4065# Options for creating an image format on a given node.
4066#
4067# @driver           block driver to create the image format
4068#
4069# Since: 2.12
4070##
4071{ 'union': 'BlockdevCreateOptions',
4072  'base': {
4073      'driver':         'BlockdevDriver' },
4074  'discriminator': 'driver',
4075  'data': {
4076      'blkdebug':       'BlockdevCreateNotSupported',
4077      'blkverify':      'BlockdevCreateNotSupported',
4078      'bochs':          'BlockdevCreateNotSupported',
4079      'cloop':          'BlockdevCreateNotSupported',
4080      'copy-on-read':   'BlockdevCreateNotSupported',
4081      'dmg':            'BlockdevCreateNotSupported',
4082      'file':           'BlockdevCreateOptionsFile',
4083      'ftp':            'BlockdevCreateNotSupported',
4084      'ftps':           'BlockdevCreateNotSupported',
4085      'gluster':        'BlockdevCreateOptionsGluster',
4086      'host_cdrom':     'BlockdevCreateNotSupported',
4087      'host_device':    'BlockdevCreateNotSupported',
4088      'http':           'BlockdevCreateNotSupported',
4089      'https':          'BlockdevCreateNotSupported',
4090      'iscsi':          'BlockdevCreateNotSupported',
4091      'luks':           'BlockdevCreateOptionsLUKS',
4092      'nbd':            'BlockdevCreateNotSupported',
4093      'nfs':            'BlockdevCreateOptionsNfs',
4094      'null-aio':       'BlockdevCreateNotSupported',
4095      'null-co':        'BlockdevCreateNotSupported',
4096      'nvme':           'BlockdevCreateNotSupported',
4097      'parallels':      'BlockdevCreateOptionsParallels',
4098      'qcow':           'BlockdevCreateOptionsQcow',
4099      'qcow2':          'BlockdevCreateOptionsQcow2',
4100      'qed':            'BlockdevCreateOptionsQed',
4101      'quorum':         'BlockdevCreateNotSupported',
4102      'raw':            'BlockdevCreateNotSupported',
4103      'rbd':            'BlockdevCreateOptionsRbd',
4104      'replication':    'BlockdevCreateNotSupported',
4105      'sheepdog':       'BlockdevCreateOptionsSheepdog',
4106      'ssh':            'BlockdevCreateOptionsSsh',
4107      'throttle':       'BlockdevCreateNotSupported',
4108      'vdi':            'BlockdevCreateOptionsVdi',
4109      'vhdx':           'BlockdevCreateOptionsVhdx',
4110      'vmdk':           'BlockdevCreateNotSupported',
4111      'vpc':            'BlockdevCreateOptionsVpc',
4112      'vvfat':          'BlockdevCreateNotSupported',
4113      'vxhs':           'BlockdevCreateNotSupported'
4114  } }
4115
4116##
4117# @blockdev-create:
4118#
4119# Starts a job to create an image format on a given node. The job is
4120# automatically finalized, but a manual job-dismiss is required.
4121#
4122# @job-id:          Identifier for the newly created job.
4123#
4124# @options:         Options for the image creation.
4125#
4126# Since: 3.0
4127##
4128{ 'command': 'blockdev-create',
4129  'data': { 'job-id': 'str',
4130            'options': 'BlockdevCreateOptions' } }
4131
4132##
4133# @blockdev-open-tray:
4134#
4135# Opens a block device's tray. If there is a block driver state tree inserted as
4136# a medium, it will become inaccessible to the guest (but it will remain
4137# associated to the block device, so closing the tray will make it accessible
4138# again).
4139#
4140# If the tray was already open before, this will be a no-op.
4141#
4142# Once the tray opens, a DEVICE_TRAY_MOVED event is emitted. There are cases in
4143# which no such event will be generated, these include:
4144# - if the guest has locked the tray, @force is false and the guest does not
4145#   respond to the eject request
4146# - if the BlockBackend denoted by @device does not have a guest device attached
4147#   to it
4148# - if the guest device does not have an actual tray
4149#
4150# @device: Block device name (deprecated, use @id instead)
4151#
4152# @id:     The name or QOM path of the guest device (since: 2.8)
4153#
4154# @force:  if false (the default), an eject request will be sent to
4155#          the guest if it has locked the tray (and the tray will not be opened
4156#          immediately); if true, the tray will be opened regardless of whether
4157#          it is locked
4158#
4159# Since: 2.5
4160#
4161# Example:
4162#
4163# -> { "execute": "blockdev-open-tray",
4164#      "arguments": { "id": "ide0-1-0" } }
4165#
4166# <- { "timestamp": { "seconds": 1418751016,
4167#                     "microseconds": 716996 },
4168#      "event": "DEVICE_TRAY_MOVED",
4169#      "data": { "device": "ide1-cd0",
4170#                "id": "ide0-1-0",
4171#                "tray-open": true } }
4172#
4173# <- { "return": {} }
4174#
4175##
4176{ 'command': 'blockdev-open-tray',
4177  'data': { '*device': 'str',
4178            '*id': 'str',
4179            '*force': 'bool' } }
4180
4181##
4182# @blockdev-close-tray:
4183#
4184# Closes a block device's tray. If there is a block driver state tree associated
4185# with the block device (which is currently ejected), that tree will be loaded
4186# as the medium.
4187#
4188# If the tray was already closed before, this will be a no-op.
4189#
4190# @device:  Block device name (deprecated, use @id instead)
4191#
4192# @id:      The name or QOM path of the guest device (since: 2.8)
4193#
4194# Since: 2.5
4195#
4196# Example:
4197#
4198# -> { "execute": "blockdev-close-tray",
4199#      "arguments": { "id": "ide0-1-0" } }
4200#
4201# <- { "timestamp": { "seconds": 1418751345,
4202#                     "microseconds": 272147 },
4203#      "event": "DEVICE_TRAY_MOVED",
4204#      "data": { "device": "ide1-cd0",
4205#                "id": "ide0-1-0",
4206#                "tray-open": false } }
4207#
4208# <- { "return": {} }
4209#
4210##
4211{ 'command': 'blockdev-close-tray',
4212  'data': { '*device': 'str',
4213            '*id': 'str' } }
4214
4215##
4216# @blockdev-remove-medium:
4217#
4218# Removes a medium (a block driver state tree) from a block device. That block
4219# device's tray must currently be open (unless there is no attached guest
4220# device).
4221#
4222# If the tray is open and there is no medium inserted, this will be a no-op.
4223#
4224# @id:     The name or QOM path of the guest device
4225#
4226# Since: 2.12
4227#
4228# Example:
4229#
4230# -> { "execute": "blockdev-remove-medium",
4231#      "arguments": { "id": "ide0-1-0" } }
4232#
4233# <- { "error": { "class": "GenericError",
4234#                 "desc": "Tray of device 'ide0-1-0' is not open" } }
4235#
4236# -> { "execute": "blockdev-open-tray",
4237#      "arguments": { "id": "ide0-1-0" } }
4238#
4239# <- { "timestamp": { "seconds": 1418751627,
4240#                     "microseconds": 549958 },
4241#      "event": "DEVICE_TRAY_MOVED",
4242#      "data": { "device": "ide1-cd0",
4243#                "id": "ide0-1-0",
4244#                "tray-open": true } }
4245#
4246# <- { "return": {} }
4247#
4248# -> { "execute": "blockdev-remove-medium",
4249#      "arguments": { "id": "ide0-1-0" } }
4250#
4251# <- { "return": {} }
4252#
4253##
4254{ 'command': 'blockdev-remove-medium',
4255  'data': { 'id': 'str' } }
4256
4257##
4258# @blockdev-insert-medium:
4259#
4260# Inserts a medium (a block driver state tree) into a block device. That block
4261# device's tray must currently be open (unless there is no attached guest
4262# device) and there must be no medium inserted already.
4263#
4264# @id:        The name or QOM path of the guest device
4265#
4266# @node-name: name of a node in the block driver state graph
4267#
4268# Since: 2.12
4269#
4270# Example:
4271#
4272# -> { "execute": "blockdev-add",
4273#      "arguments": {
4274#          "node-name": "node0",
4275#          "driver": "raw",
4276#          "file": { "driver": "file",
4277#                    "filename": "fedora.iso" } } }
4278# <- { "return": {} }
4279#
4280# -> { "execute": "blockdev-insert-medium",
4281#      "arguments": { "id": "ide0-1-0",
4282#                     "node-name": "node0" } }
4283#
4284# <- { "return": {} }
4285#
4286##
4287{ 'command': 'blockdev-insert-medium',
4288  'data': { 'id': 'str',
4289            'node-name': 'str'} }
4290
4291
4292##
4293# @BlockdevChangeReadOnlyMode:
4294#
4295# Specifies the new read-only mode of a block device subject to the
4296# @blockdev-change-medium command.
4297#
4298# @retain:      Retains the current read-only mode
4299#
4300# @read-only:   Makes the device read-only
4301#
4302# @read-write:  Makes the device writable
4303#
4304# Since: 2.3
4305#
4306##
4307{ 'enum': 'BlockdevChangeReadOnlyMode',
4308  'data': ['retain', 'read-only', 'read-write'] }
4309
4310
4311##
4312# @blockdev-change-medium:
4313#
4314# Changes the medium inserted into a block device by ejecting the current medium
4315# and loading a new image file which is inserted as the new medium (this command
4316# combines blockdev-open-tray, blockdev-remove-medium, blockdev-insert-medium
4317# and blockdev-close-tray).
4318#
4319# @device:          Block device name (deprecated, use @id instead)
4320#
4321# @id:              The name or QOM path of the guest device
4322#                   (since: 2.8)
4323#
4324# @filename:        filename of the new image to be loaded
4325#
4326# @format:          format to open the new image with (defaults to
4327#                   the probed format)
4328#
4329# @read-only-mode:  change the read-only mode of the device; defaults
4330#                   to 'retain'
4331#
4332# Since: 2.5
4333#
4334# Examples:
4335#
4336# 1. Change a removable medium
4337#
4338# -> { "execute": "blockdev-change-medium",
4339#      "arguments": { "id": "ide0-1-0",
4340#                     "filename": "/srv/images/Fedora-12-x86_64-DVD.iso",
4341#                     "format": "raw" } }
4342# <- { "return": {} }
4343#
4344# 2. Load a read-only medium into a writable drive
4345#
4346# -> { "execute": "blockdev-change-medium",
4347#      "arguments": { "id": "floppyA",
4348#                     "filename": "/srv/images/ro.img",
4349#                     "format": "raw",
4350#                     "read-only-mode": "retain" } }
4351#
4352# <- { "error":
4353#      { "class": "GenericError",
4354#        "desc": "Could not open '/srv/images/ro.img': Permission denied" } }
4355#
4356# -> { "execute": "blockdev-change-medium",
4357#      "arguments": { "id": "floppyA",
4358#                     "filename": "/srv/images/ro.img",
4359#                     "format": "raw",
4360#                     "read-only-mode": "read-only" } }
4361#
4362# <- { "return": {} }
4363#
4364##
4365{ 'command': 'blockdev-change-medium',
4366  'data': { '*device': 'str',
4367            '*id': 'str',
4368            'filename': 'str',
4369            '*format': 'str',
4370            '*read-only-mode': 'BlockdevChangeReadOnlyMode' } }
4371
4372
4373##
4374# @BlockErrorAction:
4375#
4376# An enumeration of action that has been taken when a DISK I/O occurs
4377#
4378# @ignore: error has been ignored
4379#
4380# @report: error has been reported to the device
4381#
4382# @stop: error caused VM to be stopped
4383#
4384# Since: 2.1
4385##
4386{ 'enum': 'BlockErrorAction',
4387  'data': [ 'ignore', 'report', 'stop' ] }
4388
4389
4390##
4391# @BLOCK_IMAGE_CORRUPTED:
4392#
4393# Emitted when a disk image is being marked corrupt. The image can be
4394# identified by its device or node name. The 'device' field is always
4395# present for compatibility reasons, but it can be empty ("") if the
4396# image does not have a device name associated.
4397#
4398# @device: device name. This is always present for compatibility
4399#          reasons, but it can be empty ("") if the image does not
4400#          have a device name associated.
4401#
4402# @node-name: node name (Since: 2.4)
4403#
4404# @msg: informative message for human consumption, such as the kind of
4405#       corruption being detected. It should not be parsed by machine as it is
4406#       not guaranteed to be stable
4407#
4408# @offset: if the corruption resulted from an image access, this is
4409#          the host's access offset into the image
4410#
4411# @size: if the corruption resulted from an image access, this is
4412#        the access size
4413#
4414# @fatal: if set, the image is marked corrupt and therefore unusable after this
4415#        event and must be repaired (Since 2.2; before, every
4416#        BLOCK_IMAGE_CORRUPTED event was fatal)
4417#
4418# Note: If action is "stop", a STOP event will eventually follow the
4419#       BLOCK_IO_ERROR event.
4420#
4421# Example:
4422#
4423# <- { "event": "BLOCK_IMAGE_CORRUPTED",
4424#      "data": { "device": "ide0-hd0", "node-name": "node0",
4425#                "msg": "Prevented active L1 table overwrite", "offset": 196608,
4426#                "size": 65536 },
4427#      "timestamp": { "seconds": 1378126126, "microseconds": 966463 } }
4428#
4429# Since: 1.7
4430##
4431{ 'event': 'BLOCK_IMAGE_CORRUPTED',
4432  'data': { 'device'     : 'str',
4433            '*node-name' : 'str',
4434            'msg'        : 'str',
4435            '*offset'    : 'int',
4436            '*size'      : 'int',
4437            'fatal'      : 'bool' } }
4438
4439##
4440# @BLOCK_IO_ERROR:
4441#
4442# Emitted when a disk I/O error occurs
4443#
4444# @device: device name. This is always present for compatibility
4445#          reasons, but it can be empty ("") if the image does not
4446#          have a device name associated.
4447#
4448# @node-name: node name. Note that errors may be reported for the root node
4449#             that is directly attached to a guest device rather than for the
4450#             node where the error occurred. The node name is not present if
4451#             the drive is empty. (Since: 2.8)
4452#
4453# @operation: I/O operation
4454#
4455# @action: action that has been taken
4456#
4457# @nospace: true if I/O error was caused due to a no-space
4458#           condition. This key is only present if query-block's
4459#           io-status is present, please see query-block documentation
4460#           for more information (since: 2.2)
4461#
4462# @reason: human readable string describing the error cause.
4463#          (This field is a debugging aid for humans, it should not
4464#           be parsed by applications) (since: 2.2)
4465#
4466# Note: If action is "stop", a STOP event will eventually follow the
4467# BLOCK_IO_ERROR event
4468#
4469# Since: 0.13.0
4470#
4471# Example:
4472#
4473# <- { "event": "BLOCK_IO_ERROR",
4474#      "data": { "device": "ide0-hd1",
4475#                "node-name": "#block212",
4476#                "operation": "write",
4477#                "action": "stop" },
4478#      "timestamp": { "seconds": 1265044230, "microseconds": 450486 } }
4479#
4480##
4481{ 'event': 'BLOCK_IO_ERROR',
4482  'data': { 'device': 'str', '*node-name': 'str',
4483            'operation': 'IoOperationType',
4484            'action': 'BlockErrorAction', '*nospace': 'bool',
4485            'reason': 'str' } }
4486
4487##
4488# @BLOCK_JOB_COMPLETED:
4489#
4490# Emitted when a block job has completed
4491#
4492# @type: job type
4493#
4494# @device: The job identifier. Originally the device name but other
4495#          values are allowed since QEMU 2.7
4496#
4497# @len: maximum progress value
4498#
4499# @offset: current progress value. On success this is equal to len.
4500#          On failure this is less than len
4501#
4502# @speed: rate limit, bytes per second
4503#
4504# @error: error message. Only present on failure. This field
4505#         contains a human-readable error message. There are no semantics
4506#         other than that streaming has failed and clients should not try to
4507#         interpret the error string
4508#
4509# Since: 1.1
4510#
4511# Example:
4512#
4513# <- { "event": "BLOCK_JOB_COMPLETED",
4514#      "data": { "type": "stream", "device": "virtio-disk0",
4515#                "len": 10737418240, "offset": 10737418240,
4516#                "speed": 0 },
4517#      "timestamp": { "seconds": 1267061043, "microseconds": 959568 } }
4518#
4519##
4520{ 'event': 'BLOCK_JOB_COMPLETED',
4521  'data': { 'type'  : 'JobType',
4522            'device': 'str',
4523            'len'   : 'int',
4524            'offset': 'int',
4525            'speed' : 'int',
4526            '*error': 'str' } }
4527
4528##
4529# @BLOCK_JOB_CANCELLED:
4530#
4531# Emitted when a block job has been cancelled
4532#
4533# @type: job type
4534#
4535# @device: The job identifier. Originally the device name but other
4536#          values are allowed since QEMU 2.7
4537#
4538# @len: maximum progress value
4539#
4540# @offset: current progress value. On success this is equal to len.
4541#          On failure this is less than len
4542#
4543# @speed: rate limit, bytes per second
4544#
4545# Since: 1.1
4546#
4547# Example:
4548#
4549# <- { "event": "BLOCK_JOB_CANCELLED",
4550#      "data": { "type": "stream", "device": "virtio-disk0",
4551#                "len": 10737418240, "offset": 134217728,
4552#                "speed": 0 },
4553#      "timestamp": { "seconds": 1267061043, "microseconds": 959568 } }
4554#
4555##
4556{ 'event': 'BLOCK_JOB_CANCELLED',
4557  'data': { 'type'  : 'JobType',
4558            'device': 'str',
4559            'len'   : 'int',
4560            'offset': 'int',
4561            'speed' : 'int' } }
4562
4563##
4564# @BLOCK_JOB_ERROR:
4565#
4566# Emitted when a block job encounters an error
4567#
4568# @device: The job identifier. Originally the device name but other
4569#          values are allowed since QEMU 2.7
4570#
4571# @operation: I/O operation
4572#
4573# @action: action that has been taken
4574#
4575# Since: 1.3
4576#
4577# Example:
4578#
4579# <- { "event": "BLOCK_JOB_ERROR",
4580#      "data": { "device": "ide0-hd1",
4581#                "operation": "write",
4582#                "action": "stop" },
4583#      "timestamp": { "seconds": 1265044230, "microseconds": 450486 } }
4584#
4585##
4586{ 'event': 'BLOCK_JOB_ERROR',
4587  'data': { 'device'   : 'str',
4588            'operation': 'IoOperationType',
4589            'action'   : 'BlockErrorAction' } }
4590
4591##
4592# @BLOCK_JOB_READY:
4593#
4594# Emitted when a block job is ready to complete
4595#
4596# @type: job type
4597#
4598# @device: The job identifier. Originally the device name but other
4599#          values are allowed since QEMU 2.7
4600#
4601# @len: maximum progress value
4602#
4603# @offset: current progress value. On success this is equal to len.
4604#          On failure this is less than len
4605#
4606# @speed: rate limit, bytes per second
4607#
4608# Note: The "ready to complete" status is always reset by a @BLOCK_JOB_ERROR
4609# event
4610#
4611# Since: 1.3
4612#
4613# Example:
4614#
4615# <- { "event": "BLOCK_JOB_READY",
4616#      "data": { "device": "drive0", "type": "mirror", "speed": 0,
4617#                "len": 2097152, "offset": 2097152 }
4618#      "timestamp": { "seconds": 1265044230, "microseconds": 450486 } }
4619#
4620##
4621{ 'event': 'BLOCK_JOB_READY',
4622  'data': { 'type'  : 'JobType',
4623            'device': 'str',
4624            'len'   : 'int',
4625            'offset': 'int',
4626            'speed' : 'int' } }
4627
4628##
4629# @BLOCK_JOB_PENDING:
4630#
4631# Emitted when a block job is awaiting explicit authorization to finalize graph
4632# changes via @block-job-finalize. If this job is part of a transaction, it will
4633# not emit this event until the transaction has converged first.
4634#
4635# @type: job type
4636#
4637# @id: The job identifier.
4638#
4639# Since: 2.12
4640#
4641# Example:
4642#
4643# <- { "event": "BLOCK_JOB_WAITING",
4644#      "data": { "device": "drive0", "type": "mirror" },
4645#      "timestamp": { "seconds": 1265044230, "microseconds": 450486 } }
4646#
4647##
4648{ 'event': 'BLOCK_JOB_PENDING',
4649  'data': { 'type'  : 'JobType',
4650            'id'    : 'str' } }
4651
4652##
4653# @PreallocMode:
4654#
4655# Preallocation mode of QEMU image file
4656#
4657# @off: no preallocation
4658# @metadata: preallocate only for metadata
4659# @falloc: like @full preallocation but allocate disk space by
4660#          posix_fallocate() rather than writing zeros.
4661# @full: preallocate all data by writing zeros to device to ensure disk
4662#        space is really available. @full preallocation also sets up
4663#        metadata correctly.
4664#
4665# Since: 2.2
4666##
4667{ 'enum': 'PreallocMode',
4668  'data': [ 'off', 'metadata', 'falloc', 'full' ] }
4669
4670##
4671# @BLOCK_WRITE_THRESHOLD:
4672#
4673# Emitted when writes on block device reaches or exceeds the
4674# configured write threshold. For thin-provisioned devices, this
4675# means the device should be extended to avoid pausing for
4676# disk exhaustion.
4677# The event is one shot. Once triggered, it needs to be
4678# re-registered with another block-set-write-threshold command.
4679#
4680# @node-name: graph node name on which the threshold was exceeded.
4681#
4682# @amount-exceeded: amount of data which exceeded the threshold, in bytes.
4683#
4684# @write-threshold: last configured threshold, in bytes.
4685#
4686# Since: 2.3
4687##
4688{ 'event': 'BLOCK_WRITE_THRESHOLD',
4689  'data': { 'node-name': 'str',
4690            'amount-exceeded': 'uint64',
4691            'write-threshold': 'uint64' } }
4692
4693##
4694# @block-set-write-threshold:
4695#
4696# Change the write threshold for a block drive. An event will be
4697# delivered if a write to this block drive crosses the configured
4698# threshold.  The threshold is an offset, thus must be
4699# non-negative. Default is no write threshold. Setting the threshold
4700# to zero disables it.
4701#
4702# This is useful to transparently resize thin-provisioned drives without
4703# the guest OS noticing.
4704#
4705# @node-name: graph node name on which the threshold must be set.
4706#
4707# @write-threshold: configured threshold for the block device, bytes.
4708#                   Use 0 to disable the threshold.
4709#
4710# Since: 2.3
4711#
4712# Example:
4713#
4714# -> { "execute": "block-set-write-threshold",
4715#      "arguments": { "node-name": "mydev",
4716#                     "write-threshold": 17179869184 } }
4717# <- { "return": {} }
4718#
4719##
4720{ 'command': 'block-set-write-threshold',
4721  'data': { 'node-name': 'str', 'write-threshold': 'uint64' } }
4722
4723##
4724# @x-blockdev-change:
4725#
4726# Dynamically reconfigure the block driver state graph. It can be used
4727# to add, remove, insert or replace a graph node. Currently only the
4728# Quorum driver implements this feature to add or remove its child. This
4729# is useful to fix a broken quorum child.
4730#
4731# If @node is specified, it will be inserted under @parent. @child
4732# may not be specified in this case. If both @parent and @child are
4733# specified but @node is not, @child will be detached from @parent.
4734#
4735# @parent: the id or name of the parent node.
4736#
4737# @child: the name of a child under the given parent node.
4738#
4739# @node: the name of the node that will be added.
4740#
4741# Note: this command is experimental, and its API is not stable. It
4742# does not support all kinds of operations, all kinds of children, nor
4743# all block drivers.
4744#
4745# FIXME Removing children from a quorum node means introducing gaps in the
4746# child indices. This cannot be represented in the 'children' list of
4747# BlockdevOptionsQuorum, as returned by .bdrv_refresh_filename().
4748#
4749# Warning: The data in a new quorum child MUST be consistent with that of
4750# the rest of the array.
4751#
4752# Since: 2.7
4753#
4754# Example:
4755#
4756# 1. Add a new node to a quorum
4757# -> { "execute": "blockdev-add",
4758#      "arguments": {
4759#          "driver": "raw",
4760#          "node-name": "new_node",
4761#          "file": { "driver": "file",
4762#                    "filename": "test.raw" } } }
4763# <- { "return": {} }
4764# -> { "execute": "x-blockdev-change",
4765#      "arguments": { "parent": "disk1",
4766#                     "node": "new_node" } }
4767# <- { "return": {} }
4768#
4769# 2. Delete a quorum's node
4770# -> { "execute": "x-blockdev-change",
4771#      "arguments": { "parent": "disk1",
4772#                     "child": "children.1" } }
4773# <- { "return": {} }
4774#
4775##
4776{ 'command': 'x-blockdev-change',
4777  'data' : { 'parent': 'str',
4778             '*child': 'str',
4779             '*node': 'str' } }
4780
4781##
4782# @x-blockdev-set-iothread:
4783#
4784# Move @node and its children into the @iothread.  If @iothread is null then
4785# move @node and its children into the main loop.
4786#
4787# The node must not be attached to a BlockBackend.
4788#
4789# @node-name: the name of the block driver node
4790#
4791# @iothread: the name of the IOThread object or null for the main loop
4792#
4793# @force: true if the node and its children should be moved when a BlockBackend
4794#         is already attached
4795#
4796# Note: this command is experimental and intended for test cases that need
4797# control over IOThreads only.
4798#
4799# Since: 2.12
4800#
4801# Example:
4802#
4803# 1. Move a node into an IOThread
4804# -> { "execute": "x-blockdev-set-iothread",
4805#      "arguments": { "node-name": "disk1",
4806#                     "iothread": "iothread0" } }
4807# <- { "return": {} }
4808#
4809# 2. Move a node into the main loop
4810# -> { "execute": "x-blockdev-set-iothread",
4811#      "arguments": { "node-name": "disk1",
4812#                     "iothread": null } }
4813# <- { "return": {} }
4814#
4815##
4816{ 'command': 'x-blockdev-set-iothread',
4817  'data' : { 'node-name': 'str',
4818             'iothread': 'StrOrNull',
4819             '*force': 'bool' } }
4820