xref: /qemu/qapi/block.json (revision 308e7549)
1# -*- Mode: Python -*-
2
3##
4# = Block devices
5##
6
7{ 'include': 'block-core.json' }
8
9##
10# == Additional block stuff (VM related)
11##
12
13##
14# @BiosAtaTranslation:
15#
16# Policy that BIOS should use to interpret cylinder/head/sector
17# addresses.  Note that Bochs BIOS and SeaBIOS will not actually
18# translate logical CHS to physical; instead, they will use logical
19# block addressing.
20#
21# @auto: If cylinder/heads/sizes are passed, choose between none and LBA
22#        depending on the size of the disk.  If they are not passed,
23#        choose none if QEMU can guess that the disk had 16 or fewer
24#        heads, large if QEMU can guess that the disk had 131072 or
25#        fewer tracks across all heads (i.e. cylinders*heads<131072),
26#        otherwise LBA.
27#
28# @none: The physical disk geometry is equal to the logical geometry.
29#
30# @lba: Assume 63 sectors per track and one of 16, 32, 64, 128 or 255
31#       heads (if fewer than 255 are enough to cover the whole disk
32#       with 1024 cylinders/head).  The number of cylinders/head is
33#       then computed based on the number of sectors and heads.
34#
35# @large: The number of cylinders per head is scaled down to 1024
36#         by correspondingly scaling up the number of heads.
37#
38# @rechs: Same as @large, but first convert a 16-head geometry to
39#         15-head, by proportionally scaling up the number of
40#         cylinders/head.
41#
42# Since: 2.0
43##
44{ 'enum': 'BiosAtaTranslation',
45  'data': ['auto', 'none', 'lba', 'large', 'rechs']}
46
47##
48# @FloppyDriveType:
49#
50# Type of Floppy drive to be emulated by the Floppy Disk Controller.
51#
52# @144:  1.44MB 3.5" drive
53# @288:  2.88MB 3.5" drive
54# @120:  1.2MB 5.25" drive
55# @none: No drive connected
56# @auto: Automatically determined by inserted media at boot
57#
58# Since: 2.6
59##
60{ 'enum': 'FloppyDriveType',
61  'data': ['144', '288', '120', 'none', 'auto']}
62
63##
64# @PRManagerInfo:
65#
66# Information about a persistent reservation manager
67#
68# @id: the identifier of the persistent reservation manager
69#
70# @connected: true if the persistent reservation manager is connected to
71#             the underlying storage or helper
72#
73# Since: 3.0
74##
75{ 'struct': 'PRManagerInfo',
76  'data': {'id': 'str', 'connected': 'bool'} }
77
78##
79# @query-pr-managers:
80#
81# Returns a list of information about each persistent reservation manager.
82#
83# Returns: a list of @PRManagerInfo for each persistent reservation manager
84#
85# Since: 3.0
86##
87{ 'command': 'query-pr-managers', 'returns': ['PRManagerInfo'],
88  'allow-preconfig': true }
89
90##
91# @eject:
92#
93# Ejects the medium from a removable drive.
94#
95# @device: Block device name
96#
97# @id: The name or QOM path of the guest device (since: 2.8)
98#
99# @force: If true, eject regardless of whether the drive is locked.
100#         If not specified, the default value is false.
101#
102# Features:
103# @deprecated: Member @device is deprecated.  Use @id instead.
104#
105# Returns: - Nothing on success
106#          - If @device is not a valid block device, DeviceNotFound
107# Notes:    Ejecting a device with no media results in success
108#
109# Since: 0.14.0
110#
111# Example:
112#
113# -> { "execute": "eject", "arguments": { "id": "ide1-0-1" } }
114# <- { "return": {} }
115##
116{ 'command': 'eject',
117  'data': { '*device': { 'type': 'str', 'features': [ 'deprecated' ] },
118            '*id': 'str',
119            '*force': 'bool' } }
120
121##
122# @blockdev-open-tray:
123#
124# Opens a block device's tray. If there is a block driver state tree inserted as
125# a medium, it will become inaccessible to the guest (but it will remain
126# associated to the block device, so closing the tray will make it accessible
127# again).
128#
129# If the tray was already open before, this will be a no-op.
130#
131# Once the tray opens, a DEVICE_TRAY_MOVED event is emitted. There are cases in
132# which no such event will be generated, these include:
133#
134# - if the guest has locked the tray, @force is false and the guest does not
135#   respond to the eject request
136# - if the BlockBackend denoted by @device does not have a guest device attached
137#   to it
138# - if the guest device does not have an actual tray
139#
140# @device: Block device name
141#
142# @id: The name or QOM path of the guest device (since: 2.8)
143#
144# @force: if false (the default), an eject request will be sent to
145#         the guest if it has locked the tray (and the tray will not be opened
146#         immediately); if true, the tray will be opened regardless of whether
147#         it is locked
148#
149# Features:
150# @deprecated: Member @device is deprecated.  Use @id instead.
151#
152# Since: 2.5
153#
154# Example:
155#
156# -> { "execute": "blockdev-open-tray",
157#      "arguments": { "id": "ide0-1-0" } }
158#
159# <- { "timestamp": { "seconds": 1418751016,
160#                     "microseconds": 716996 },
161#      "event": "DEVICE_TRAY_MOVED",
162#      "data": { "device": "ide1-cd0",
163#                "id": "ide0-1-0",
164#                "tray-open": true } }
165#
166# <- { "return": {} }
167#
168##
169{ 'command': 'blockdev-open-tray',
170  'data': { '*device': { 'type': 'str', 'features': [ 'deprecated' ] },
171            '*id': 'str',
172            '*force': 'bool' } }
173
174##
175# @blockdev-close-tray:
176#
177# Closes a block device's tray. If there is a block driver state tree associated
178# with the block device (which is currently ejected), that tree will be loaded
179# as the medium.
180#
181# If the tray was already closed before, this will be a no-op.
182#
183# @device: Block device name
184#
185# @id: The name or QOM path of the guest device (since: 2.8)
186#
187# Features:
188# @deprecated: Member @device is deprecated.  Use @id instead.
189#
190# Since: 2.5
191#
192# Example:
193#
194# -> { "execute": "blockdev-close-tray",
195#      "arguments": { "id": "ide0-1-0" } }
196#
197# <- { "timestamp": { "seconds": 1418751345,
198#                     "microseconds": 272147 },
199#      "event": "DEVICE_TRAY_MOVED",
200#      "data": { "device": "ide1-cd0",
201#                "id": "ide0-1-0",
202#                "tray-open": false } }
203#
204# <- { "return": {} }
205#
206##
207{ 'command': 'blockdev-close-tray',
208  'data': { '*device': { 'type': 'str', 'features': [ 'deprecated' ] },
209            '*id': 'str' } }
210
211##
212# @blockdev-remove-medium:
213#
214# Removes a medium (a block driver state tree) from a block device. That block
215# device's tray must currently be open (unless there is no attached guest
216# device).
217#
218# If the tray is open and there is no medium inserted, this will be a no-op.
219#
220# @id: The name or QOM path of the guest device
221#
222# Since: 2.12
223#
224# Example:
225#
226# -> { "execute": "blockdev-remove-medium",
227#      "arguments": { "id": "ide0-1-0" } }
228#
229# <- { "error": { "class": "GenericError",
230#                 "desc": "Tray of device 'ide0-1-0' is not open" } }
231#
232# -> { "execute": "blockdev-open-tray",
233#      "arguments": { "id": "ide0-1-0" } }
234#
235# <- { "timestamp": { "seconds": 1418751627,
236#                     "microseconds": 549958 },
237#      "event": "DEVICE_TRAY_MOVED",
238#      "data": { "device": "ide1-cd0",
239#                "id": "ide0-1-0",
240#                "tray-open": true } }
241#
242# <- { "return": {} }
243#
244# -> { "execute": "blockdev-remove-medium",
245#      "arguments": { "id": "ide0-1-0" } }
246#
247# <- { "return": {} }
248#
249##
250{ 'command': 'blockdev-remove-medium',
251  'data': { 'id': 'str' } }
252
253##
254# @blockdev-insert-medium:
255#
256# Inserts a medium (a block driver state tree) into a block device. That block
257# device's tray must currently be open (unless there is no attached guest
258# device) and there must be no medium inserted already.
259#
260# @id: The name or QOM path of the guest device
261#
262# @node-name: name of a node in the block driver state graph
263#
264# Since: 2.12
265#
266# Example:
267#
268# -> { "execute": "blockdev-add",
269#      "arguments": {
270#          "node-name": "node0",
271#          "driver": "raw",
272#          "file": { "driver": "file",
273#                    "filename": "fedora.iso" } } }
274# <- { "return": {} }
275#
276# -> { "execute": "blockdev-insert-medium",
277#      "arguments": { "id": "ide0-1-0",
278#                     "node-name": "node0" } }
279#
280# <- { "return": {} }
281#
282##
283{ 'command': 'blockdev-insert-medium',
284  'data': { 'id': 'str',
285            'node-name': 'str'} }
286
287
288##
289# @BlockdevChangeReadOnlyMode:
290#
291# Specifies the new read-only mode of a block device subject to the
292# @blockdev-change-medium command.
293#
294# @retain: Retains the current read-only mode
295#
296# @read-only: Makes the device read-only
297#
298# @read-write: Makes the device writable
299#
300# Since: 2.3
301#
302##
303{ 'enum': 'BlockdevChangeReadOnlyMode',
304  'data': ['retain', 'read-only', 'read-write'] }
305
306
307##
308# @blockdev-change-medium:
309#
310# Changes the medium inserted into a block device by ejecting the current medium
311# and loading a new image file which is inserted as the new medium (this command
312# combines blockdev-open-tray, blockdev-remove-medium, blockdev-insert-medium
313# and blockdev-close-tray).
314#
315# @device: Block device name
316#
317# @id: The name or QOM path of the guest device
318#      (since: 2.8)
319#
320# @filename: filename of the new image to be loaded
321#
322# @format: format to open the new image with (defaults to
323#          the probed format)
324#
325# @read-only-mode: change the read-only mode of the device; defaults
326#                  to 'retain'
327#
328# Features:
329# @deprecated: Member @device is deprecated.  Use @id instead.
330#
331# Since: 2.5
332#
333# Examples:
334#
335# 1. Change a removable medium
336#
337# -> { "execute": "blockdev-change-medium",
338#      "arguments": { "id": "ide0-1-0",
339#                     "filename": "/srv/images/Fedora-12-x86_64-DVD.iso",
340#                     "format": "raw" } }
341# <- { "return": {} }
342#
343# 2. Load a read-only medium into a writable drive
344#
345# -> { "execute": "blockdev-change-medium",
346#      "arguments": { "id": "floppyA",
347#                     "filename": "/srv/images/ro.img",
348#                     "format": "raw",
349#                     "read-only-mode": "retain" } }
350#
351# <- { "error":
352#      { "class": "GenericError",
353#        "desc": "Could not open '/srv/images/ro.img': Permission denied" } }
354#
355# -> { "execute": "blockdev-change-medium",
356#      "arguments": { "id": "floppyA",
357#                     "filename": "/srv/images/ro.img",
358#                     "format": "raw",
359#                     "read-only-mode": "read-only" } }
360#
361# <- { "return": {} }
362#
363##
364{ 'command': 'blockdev-change-medium',
365  'data': { '*device': { 'type': 'str', 'features': [ 'deprecated' ] },
366            '*id': 'str',
367            'filename': 'str',
368            '*format': 'str',
369            '*read-only-mode': 'BlockdevChangeReadOnlyMode' } }
370
371
372##
373# @DEVICE_TRAY_MOVED:
374#
375# Emitted whenever the tray of a removable device is moved by the guest or by
376# HMP/QMP commands
377#
378# @device: Block device name. This is always present for compatibility
379#          reasons, but it can be empty ("") if the image does not
380#          have a device name associated.
381#
382# @id: The name or QOM path of the guest device (since 2.8)
383#
384# @tray-open: true if the tray has been opened or false if it has been closed
385#
386# Since: 1.1
387#
388# Example:
389#
390# <- { "event": "DEVICE_TRAY_MOVED",
391#      "data": { "device": "ide1-cd0",
392#                "id": "/machine/unattached/device[22]",
393#                "tray-open": true
394#      },
395#      "timestamp": { "seconds": 1265044230, "microseconds": 450486 } }
396#
397##
398{ 'event': 'DEVICE_TRAY_MOVED',
399  'data': { 'device': 'str', 'id': 'str', 'tray-open': 'bool' } }
400
401##
402# @PR_MANAGER_STATUS_CHANGED:
403#
404# Emitted whenever the connected status of a persistent reservation
405# manager changes.
406#
407# @id: The id of the PR manager object
408#
409# @connected: true if the PR manager is connected to a backend
410#
411# Since: 3.0
412#
413# Example:
414#
415# <- { "event": "PR_MANAGER_STATUS_CHANGED",
416#      "data": { "id": "pr-helper0",
417#                "connected": true
418#      },
419#      "timestamp": { "seconds": 1519840375, "microseconds": 450486 } }
420#
421##
422{ 'event': 'PR_MANAGER_STATUS_CHANGED',
423  'data': { 'id': 'str', 'connected': 'bool' } }
424
425##
426# @block_set_io_throttle:
427#
428# Change I/O throttle limits for a block drive.
429#
430# Since QEMU 2.4, each device with I/O limits is member of a throttle
431# group.
432#
433# If two or more devices are members of the same group, the limits
434# will apply to the combined I/O of the whole group in a round-robin
435# fashion. Therefore, setting new I/O limits to a device will affect
436# the whole group.
437#
438# The name of the group can be specified using the 'group' parameter.
439# If the parameter is unset, it is assumed to be the current group of
440# that device. If it's not in any group yet, the name of the device
441# will be used as the name for its group.
442#
443# The 'group' parameter can also be used to move a device to a
444# different group. In this case the limits specified in the parameters
445# will be applied to the new group only.
446#
447# I/O limits can be disabled by setting all of them to 0. In this case
448# the device will be removed from its group and the rest of its
449# members will not be affected. The 'group' parameter is ignored.
450#
451# Returns: - Nothing on success
452#          - If @device is not a valid block device, DeviceNotFound
453#
454# Since: 1.1
455#
456# Example:
457#
458# -> { "execute": "block_set_io_throttle",
459#      "arguments": { "id": "virtio-blk-pci0/virtio-backend",
460#                     "bps": 0,
461#                     "bps_rd": 0,
462#                     "bps_wr": 0,
463#                     "iops": 512,
464#                     "iops_rd": 0,
465#                     "iops_wr": 0,
466#                     "bps_max": 0,
467#                     "bps_rd_max": 0,
468#                     "bps_wr_max": 0,
469#                     "iops_max": 0,
470#                     "iops_rd_max": 0,
471#                     "iops_wr_max": 0,
472#                     "bps_max_length": 0,
473#                     "iops_size": 0 } }
474# <- { "return": {} }
475#
476# -> { "execute": "block_set_io_throttle",
477#      "arguments": { "id": "ide0-1-0",
478#                     "bps": 1000000,
479#                     "bps_rd": 0,
480#                     "bps_wr": 0,
481#                     "iops": 0,
482#                     "iops_rd": 0,
483#                     "iops_wr": 0,
484#                     "bps_max": 8000000,
485#                     "bps_rd_max": 0,
486#                     "bps_wr_max": 0,
487#                     "iops_max": 0,
488#                     "iops_rd_max": 0,
489#                     "iops_wr_max": 0,
490#                     "bps_max_length": 60,
491#                     "iops_size": 0 } }
492# <- { "return": {} }
493##
494{ 'command': 'block_set_io_throttle', 'boxed': true,
495  'data': 'BlockIOThrottle' }
496
497##
498# @block-latency-histogram-set:
499#
500# Manage read, write and flush latency histograms for the device.
501#
502# If only @id parameter is specified, remove all present latency histograms
503# for the device. Otherwise, add/reset some of (or all) latency histograms.
504#
505# @id: The name or QOM path of the guest device.
506#
507# @boundaries: list of interval boundary values (see description in
508#              BlockLatencyHistogramInfo definition). If specified, all
509#              latency histograms are removed, and empty ones created for all
510#              io types with intervals corresponding to @boundaries (except for
511#              io types, for which specific boundaries are set through the
512#              following parameters).
513#
514# @boundaries-read: list of interval boundary values for read latency
515#                   histogram. If specified, old read latency histogram is
516#                   removed, and empty one created with intervals
517#                   corresponding to @boundaries-read. The parameter has higher
518#                   priority then @boundaries.
519#
520# @boundaries-write: list of interval boundary values for write latency
521#                    histogram.
522#
523# @boundaries-flush: list of interval boundary values for flush latency
524#                    histogram.
525#
526# Returns: error if device is not found or any boundary arrays are invalid.
527#
528# Since: 4.0
529#
530# Example: set new histograms for all io types with intervals
531# [0, 10), [10, 50), [50, 100), [100, +inf):
532#
533# -> { "execute": "block-latency-histogram-set",
534#      "arguments": { "id": "drive0",
535#                     "boundaries": [10, 50, 100] } }
536# <- { "return": {} }
537#
538# Example: set new histogram only for write, other histograms will remain
539# not changed (or not created):
540#
541# -> { "execute": "block-latency-histogram-set",
542#      "arguments": { "id": "drive0",
543#                     "boundaries-write": [10, 50, 100] } }
544# <- { "return": {} }
545#
546# Example: set new histograms with the following intervals:
547#   read, flush: [0, 10), [10, 50), [50, 100), [100, +inf)
548#   write: [0, 1000), [1000, 5000), [5000, +inf)
549#
550# -> { "execute": "block-latency-histogram-set",
551#      "arguments": { "id": "drive0",
552#                     "boundaries": [10, 50, 100],
553#                     "boundaries-write": [1000, 5000] } }
554# <- { "return": {} }
555#
556# Example: remove all latency histograms:
557#
558# -> { "execute": "block-latency-histogram-set",
559#      "arguments": { "id": "drive0" } }
560# <- { "return": {} }
561##
562{ 'command': 'block-latency-histogram-set',
563  'data': {'id': 'str',
564           '*boundaries': ['uint64'],
565           '*boundaries-read': ['uint64'],
566           '*boundaries-write': ['uint64'],
567           '*boundaries-flush': ['uint64'] } }
568