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