xref: /openbmc/qemu/qapi/block.json (revision ddda3748)
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# @BlockdevSnapshotInternal:
65#
66# @device: the device name or node-name of a root node to generate the snapshot
67#          from
68#
69# @name: the name of the internal snapshot to be created
70#
71# Notes: In transaction, if @name is empty, or any snapshot matching @name
72#        exists, the operation will fail. Only some image formats support it,
73#        for example, qcow2, rbd, and sheepdog.
74#
75# Since: 1.7
76##
77{ 'struct': 'BlockdevSnapshotInternal',
78  'data': { 'device': 'str', 'name': 'str' } }
79
80##
81# @PRManagerInfo:
82#
83# Information about a persistent reservation manager
84#
85# @id: the identifier of the persistent reservation manager
86#
87# @connected: true if the persistent reservation manager is connected to
88#             the underlying storage or helper
89#
90# Since: 3.0
91##
92{ 'struct': 'PRManagerInfo',
93  'data': {'id': 'str', 'connected': 'bool'} }
94
95##
96# @query-pr-managers:
97#
98# Returns a list of information about each persistent reservation manager.
99#
100# Returns: a list of @PRManagerInfo for each persistent reservation manager
101#
102# Since: 3.0
103##
104{ 'command': 'query-pr-managers', 'returns': ['PRManagerInfo'],
105  'allow-preconfig': true }
106
107
108##
109# @blockdev-snapshot-internal-sync:
110#
111# Synchronously take an internal snapshot of a block device, when the
112# format of the image used supports it. If the name is an empty
113# string, or a snapshot with name already exists, the operation will
114# fail.
115#
116# For the arguments, see the documentation of BlockdevSnapshotInternal.
117#
118# Returns: - nothing on success
119#          - If @device is not a valid block device, GenericError
120#          - If any snapshot matching @name exists, or @name is empty,
121#            GenericError
122#          - If the format of the image used does not support it,
123#            BlockFormatFeatureNotSupported
124#
125# Since: 1.7
126#
127# Example:
128#
129# -> { "execute": "blockdev-snapshot-internal-sync",
130#      "arguments": { "device": "ide-hd0",
131#                     "name": "snapshot0" }
132#    }
133# <- { "return": {} }
134#
135##
136{ 'command': 'blockdev-snapshot-internal-sync',
137  'data': 'BlockdevSnapshotInternal' }
138
139##
140# @blockdev-snapshot-delete-internal-sync:
141#
142# Synchronously delete an internal snapshot of a block device, when the format
143# of the image used support it. The snapshot is identified by name or id or
144# both. One of the name or id is required. Return SnapshotInfo for the
145# successfully deleted snapshot.
146#
147# @device: the device name or node-name of a root node to delete the snapshot
148#          from
149#
150# @id: optional the snapshot's ID to be deleted
151#
152# @name: optional the snapshot's name to be deleted
153#
154# Returns: - SnapshotInfo on success
155#          - If @device is not a valid block device, GenericError
156#          - If snapshot not found, GenericError
157#          - If the format of the image used does not support it,
158#            BlockFormatFeatureNotSupported
159#          - If @id and @name are both not specified, GenericError
160#
161# Since: 1.7
162#
163# Example:
164#
165# -> { "execute": "blockdev-snapshot-delete-internal-sync",
166#      "arguments": { "device": "ide-hd0",
167#                     "name": "snapshot0" }
168#    }
169# <- { "return": {
170#                    "id": "1",
171#                    "name": "snapshot0",
172#                    "vm-state-size": 0,
173#                    "date-sec": 1000012,
174#                    "date-nsec": 10,
175#                    "vm-clock-sec": 100,
176#                    "vm-clock-nsec": 20
177#      }
178#    }
179#
180##
181{ 'command': 'blockdev-snapshot-delete-internal-sync',
182  'data': { 'device': 'str', '*id': 'str', '*name': 'str'},
183  'returns': 'SnapshotInfo' }
184
185##
186# @eject:
187#
188# Ejects a device from a removable drive.
189#
190# @device: Block device name (deprecated, use @id instead)
191#
192# @id: The name or QOM path of the guest device (since: 2.8)
193#
194# @force: If true, eject regardless of whether the drive is locked.
195#         If not specified, the default value is false.
196#
197# Returns: - Nothing on success
198#          - If @device is not a valid block device, DeviceNotFound
199# Notes:    Ejecting a device with no media results in success
200#
201# Since: 0.14.0
202#
203# Example:
204#
205# -> { "execute": "eject", "arguments": { "id": "ide1-0-1" } }
206# <- { "return": {} }
207##
208{ 'command': 'eject',
209  'data': { '*device': 'str',
210            '*id': 'str',
211            '*force': 'bool' } }
212
213##
214# @nbd-server-start:
215#
216# Start an NBD server listening on the given host and port.  Block
217# devices can then be exported using @nbd-server-add.  The NBD
218# server will present them as named exports; for example, another
219# QEMU instance could refer to them as "nbd:HOST:PORT:exportname=NAME".
220#
221# @addr: Address on which to listen.
222# @tls-creds: ID of the TLS credentials object (since 2.6).
223# @tls-authz: ID of the QAuthZ authorization object used to validate
224#             the client's x509 distinguished name. This object is
225#             is only resolved at time of use, so can be deleted and
226#             recreated on the fly while the NBD server is active.
227#             If missing, it will default to denying access (since 4.0).
228#
229# Returns: error if the server is already running.
230#
231# Since: 1.3.0
232##
233{ 'command': 'nbd-server-start',
234  'data': { 'addr': 'SocketAddressLegacy',
235            '*tls-creds': 'str',
236            '*tls-authz': 'str'} }
237
238##
239# @nbd-server-add:
240#
241# Export a block node to QEMU's embedded NBD server.
242#
243# @device: The device name or node name of the node to be exported
244#
245# @name: Export name. If unspecified, the @device parameter is used as the
246#        export name. (Since 2.12)
247#
248# @description: Free-form description of the export, up to 4096 bytes.
249#               (Since 5.0)
250#
251# @writable: Whether clients should be able to write to the device via the
252#            NBD connection (default false).
253#
254# @bitmap: Also export the dirty bitmap reachable from @device, so the
255#          NBD client can use NBD_OPT_SET_META_CONTEXT with
256#          "qemu:dirty-bitmap:NAME" to inspect the bitmap. (since 4.0)
257#
258# Returns: error if the server is not running, or export with the same name
259#          already exists.
260#
261# Since: 1.3.0
262##
263{ 'command': 'nbd-server-add',
264  'data': {'device': 'str', '*name': 'str', '*description': 'str',
265           '*writable': 'bool', '*bitmap': 'str' } }
266
267##
268# @NbdServerRemoveMode:
269#
270# Mode for removing an NBD export.
271#
272# @safe: Remove export if there are no existing connections, fail otherwise.
273#
274# @hard: Drop all connections immediately and remove export.
275#
276# Potential additional modes to be added in the future:
277#
278# hide: Just hide export from new clients, leave existing connections as is.
279# Remove export after all clients are disconnected.
280#
281# soft: Hide export from new clients, answer with ESHUTDOWN for all further
282# requests from existing clients.
283#
284# Since: 2.12
285##
286{'enum': 'NbdServerRemoveMode', 'data': ['safe', 'hard']}
287
288##
289# @nbd-server-remove:
290#
291# Remove NBD export by name.
292#
293# @name: Export name.
294#
295# @mode: Mode of command operation. See @NbdServerRemoveMode description.
296#        Default is 'safe'.
297#
298# Returns: error if
299#            - the server is not running
300#            - export is not found
301#            - mode is 'safe' and there are existing connections
302#
303# Since: 2.12
304##
305{ 'command': 'nbd-server-remove',
306  'data': {'name': 'str', '*mode': 'NbdServerRemoveMode'} }
307
308##
309# @nbd-server-stop:
310#
311# Stop QEMU's embedded NBD server, and unregister all devices previously
312# added via @nbd-server-add.
313#
314# Since: 1.3.0
315##
316{ 'command': 'nbd-server-stop' }
317
318##
319# @DEVICE_TRAY_MOVED:
320#
321# Emitted whenever the tray of a removable device is moved by the guest or by
322# HMP/QMP commands
323#
324# @device: Block device name. This is always present for compatibility
325#          reasons, but it can be empty ("") if the image does not
326#          have a device name associated.
327#
328# @id: The name or QOM path of the guest device (since 2.8)
329#
330# @tray-open: true if the tray has been opened or false if it has been closed
331#
332# Since: 1.1
333#
334# Example:
335#
336# <- { "event": "DEVICE_TRAY_MOVED",
337#      "data": { "device": "ide1-cd0",
338#                "id": "/machine/unattached/device[22]",
339#                "tray-open": true
340#      },
341#      "timestamp": { "seconds": 1265044230, "microseconds": 450486 } }
342#
343##
344{ 'event': 'DEVICE_TRAY_MOVED',
345  'data': { 'device': 'str', 'id': 'str', 'tray-open': 'bool' } }
346
347##
348# @PR_MANAGER_STATUS_CHANGED:
349#
350# Emitted whenever the connected status of a persistent reservation
351# manager changes.
352#
353# @id: The id of the PR manager object
354#
355# @connected: true if the PR manager is connected to a backend
356#
357# Since: 3.0
358#
359# Example:
360#
361# <- { "event": "PR_MANAGER_STATUS_CHANGED",
362#      "data": { "id": "pr-helper0",
363#                "connected": true
364#      },
365#      "timestamp": { "seconds": 1519840375, "microseconds": 450486 } }
366#
367##
368{ 'event': 'PR_MANAGER_STATUS_CHANGED',
369  'data': { 'id': 'str', 'connected': 'bool' } }
370
371##
372# @QuorumOpType:
373#
374# An enumeration of the quorum operation types
375#
376# @read: read operation
377#
378# @write: write operation
379#
380# @flush: flush operation
381#
382# Since: 2.6
383##
384{ 'enum': 'QuorumOpType',
385  'data': [ 'read', 'write', 'flush' ] }
386
387##
388# @QUORUM_FAILURE:
389#
390# Emitted by the Quorum block driver if it fails to establish a quorum
391#
392# @reference: device name if defined else node name
393#
394# @sector-num: number of the first sector of the failed read operation
395#
396# @sectors-count: failed read operation sector count
397#
398# Note: This event is rate-limited.
399#
400# Since: 2.0
401#
402# Example:
403#
404# <- { "event": "QUORUM_FAILURE",
405#      "data": { "reference": "usr1", "sector-num": 345435, "sectors-count": 5 },
406#      "timestamp": { "seconds": 1344522075, "microseconds": 745528 } }
407#
408##
409{ 'event': 'QUORUM_FAILURE',
410  'data': { 'reference': 'str', 'sector-num': 'int', 'sectors-count': 'int' } }
411
412##
413# @QUORUM_REPORT_BAD:
414#
415# Emitted to report a corruption of a Quorum file
416#
417# @type: quorum operation type (Since 2.6)
418#
419# @error: error message. Only present on failure. This field
420#         contains a human-readable error message. There are no semantics other
421#         than that the block layer reported an error and clients should not
422#         try to interpret the error string.
423#
424# @node-name: the graph node name of the block driver state
425#
426# @sector-num: number of the first sector of the failed read operation
427#
428# @sectors-count: failed read operation sector count
429#
430# Note: This event is rate-limited.
431#
432# Since: 2.0
433#
434# Example:
435#
436# 1. Read operation
437#
438# { "event": "QUORUM_REPORT_BAD",
439#      "data": { "node-name": "node0", "sector-num": 345435, "sectors-count": 5,
440#                "type": "read" },
441#      "timestamp": { "seconds": 1344522075, "microseconds": 745528 } }
442#
443# 2. Flush operation
444#
445# { "event": "QUORUM_REPORT_BAD",
446#      "data": { "node-name": "node0", "sector-num": 0, "sectors-count": 2097120,
447#                "type": "flush", "error": "Broken pipe" },
448#      "timestamp": { "seconds": 1456406829, "microseconds": 291763 } }
449#
450##
451{ 'event': 'QUORUM_REPORT_BAD',
452  'data': { 'type': 'QuorumOpType', '*error': 'str', 'node-name': 'str',
453            'sector-num': 'int', 'sectors-count': 'int' } }
454