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