xref: /openbmc/qemu/qapi/block-export.json (revision 30dbc81d310cc5c78589ab689083371c4bfced1f)
15daa6bfdSKevin Wolf# -*- Mode: Python -*-
25daa6bfdSKevin Wolf# vim: filetype=python
35daa6bfdSKevin Wolf
45daa6bfdSKevin Wolf##
55daa6bfdSKevin Wolf# == Block device exports
65daa6bfdSKevin Wolf##
75daa6bfdSKevin Wolf
85daa6bfdSKevin Wolf{ 'include': 'sockets.json' }
95daa6bfdSKevin Wolf
105daa6bfdSKevin Wolf##
115daa6bfdSKevin Wolf# @NbdServerOptions:
125daa6bfdSKevin Wolf#
135daa6bfdSKevin Wolf# Keep this type consistent with the nbd-server-start arguments. The only
145daa6bfdSKevin Wolf# intended difference is using SocketAddress instead of SocketAddressLegacy.
155daa6bfdSKevin Wolf#
165daa6bfdSKevin Wolf# @addr: Address on which to listen.
175daa6bfdSKevin Wolf# @tls-creds: ID of the TLS credentials object (since 2.6).
185daa6bfdSKevin Wolf# @tls-authz: ID of the QAuthZ authorization object used to validate
195daa6bfdSKevin Wolf#             the client's x509 distinguished name. This object is
205daa6bfdSKevin Wolf#             is only resolved at time of use, so can be deleted and
215daa6bfdSKevin Wolf#             recreated on the fly while the NBD server is active.
225daa6bfdSKevin Wolf#             If missing, it will default to denying access (since 4.0).
231c8222b0SKevin Wolf# @max-connections: The maximum number of connections to allow at the same
241c8222b0SKevin Wolf#                   time, 0 for unlimited. (since 5.2; default: 0)
255daa6bfdSKevin Wolf#
265daa6bfdSKevin Wolf# Since: 4.2
275daa6bfdSKevin Wolf##
285daa6bfdSKevin Wolf{ 'struct': 'NbdServerOptions',
295daa6bfdSKevin Wolf  'data': { 'addr': 'SocketAddress',
305daa6bfdSKevin Wolf            '*tls-creds': 'str',
311c8222b0SKevin Wolf            '*tls-authz': 'str',
321c8222b0SKevin Wolf            '*max-connections': 'uint32' } }
335daa6bfdSKevin Wolf
345daa6bfdSKevin Wolf##
355daa6bfdSKevin Wolf# @nbd-server-start:
365daa6bfdSKevin Wolf#
375daa6bfdSKevin Wolf# Start an NBD server listening on the given host and port.  Block
385daa6bfdSKevin Wolf# devices can then be exported using @nbd-server-add.  The NBD
395daa6bfdSKevin Wolf# server will present them as named exports; for example, another
405daa6bfdSKevin Wolf# QEMU instance could refer to them as "nbd:HOST:PORT:exportname=NAME".
415daa6bfdSKevin Wolf#
425daa6bfdSKevin Wolf# Keep this type consistent with the NbdServerOptions type. The only intended
435daa6bfdSKevin Wolf# difference is using SocketAddressLegacy instead of SocketAddress.
445daa6bfdSKevin Wolf#
455daa6bfdSKevin Wolf# @addr: Address on which to listen.
465daa6bfdSKevin Wolf# @tls-creds: ID of the TLS credentials object (since 2.6).
475daa6bfdSKevin Wolf# @tls-authz: ID of the QAuthZ authorization object used to validate
485daa6bfdSKevin Wolf#             the client's x509 distinguished name. This object is
495daa6bfdSKevin Wolf#             is only resolved at time of use, so can be deleted and
505daa6bfdSKevin Wolf#             recreated on the fly while the NBD server is active.
515daa6bfdSKevin Wolf#             If missing, it will default to denying access (since 4.0).
521c8222b0SKevin Wolf# @max-connections: The maximum number of connections to allow at the same
531c8222b0SKevin Wolf#                   time, 0 for unlimited. (since 5.2; default: 0)
545daa6bfdSKevin Wolf#
555daa6bfdSKevin Wolf# Returns: error if the server is already running.
565daa6bfdSKevin Wolf#
575daa6bfdSKevin Wolf# Since: 1.3.0
585daa6bfdSKevin Wolf##
595daa6bfdSKevin Wolf{ 'command': 'nbd-server-start',
605daa6bfdSKevin Wolf  'data': { 'addr': 'SocketAddressLegacy',
615daa6bfdSKevin Wolf            '*tls-creds': 'str',
621c8222b0SKevin Wolf            '*tls-authz': 'str',
631c8222b0SKevin Wolf            '*max-connections': 'uint32' } }
645daa6bfdSKevin Wolf
655daa6bfdSKevin Wolf##
66143ea767SKevin Wolf# @BlockExportOptionsNbd:
675daa6bfdSKevin Wolf#
68b6076afcSKevin Wolf# An NBD block export (options shared between nbd-server-add and the NBD branch
69b6076afcSKevin Wolf# of block-export-add).
705daa6bfdSKevin Wolf#
715daa6bfdSKevin Wolf# @name: Export name. If unspecified, the @device parameter is used as the
725daa6bfdSKevin Wolf#        export name. (Since 2.12)
735daa6bfdSKevin Wolf#
745daa6bfdSKevin Wolf# @description: Free-form description of the export, up to 4096 bytes.
755daa6bfdSKevin Wolf#               (Since 5.0)
765daa6bfdSKevin Wolf#
775daa6bfdSKevin Wolf# @bitmap: Also export the dirty bitmap reachable from @device, so the
785daa6bfdSKevin Wolf#          NBD client can use NBD_OPT_SET_META_CONTEXT with
795daa6bfdSKevin Wolf#          "qemu:dirty-bitmap:NAME" to inspect the bitmap. (since 4.0)
805daa6bfdSKevin Wolf#
815daa6bfdSKevin Wolf# Since: 5.0
825daa6bfdSKevin Wolf##
83143ea767SKevin Wolf{ 'struct': 'BlockExportOptionsNbd',
84b6076afcSKevin Wolf  'data': { '*name': 'str', '*description': 'str',
85*30dbc81dSKevin Wolf            '*bitmap': 'str' } }
865daa6bfdSKevin Wolf
875daa6bfdSKevin Wolf##
88b6076afcSKevin Wolf# @NbdServerAddOptions:
89b6076afcSKevin Wolf#
90b6076afcSKevin Wolf# An NBD block export.
91b6076afcSKevin Wolf#
92b6076afcSKevin Wolf# @device: The device name or node name of the node to be exported
93b6076afcSKevin Wolf#
94*30dbc81dSKevin Wolf# @writable: Whether clients should be able to write to the device via the
95*30dbc81dSKevin Wolf#            NBD connection (default false).
96*30dbc81dSKevin Wolf#
97b6076afcSKevin Wolf# Since: 5.0
98b6076afcSKevin Wolf##
99b6076afcSKevin Wolf{ 'struct': 'NbdServerAddOptions',
100b6076afcSKevin Wolf  'base': 'BlockExportOptionsNbd',
101*30dbc81dSKevin Wolf  'data': { 'device': 'str',
102*30dbc81dSKevin Wolf            '*writable': 'bool' } }
103b6076afcSKevin Wolf
104b6076afcSKevin Wolf##
1055daa6bfdSKevin Wolf# @nbd-server-add:
1065daa6bfdSKevin Wolf#
1075daa6bfdSKevin Wolf# Export a block node to QEMU's embedded NBD server.
1085daa6bfdSKevin Wolf#
109d53be9ceSKevin Wolf# The export name will be used as the id for the resulting block export.
110d53be9ceSKevin Wolf#
1115daa6bfdSKevin Wolf# Returns: error if the server is not running, or export with the same name
1125daa6bfdSKevin Wolf#          already exists.
1135daa6bfdSKevin Wolf#
1145daa6bfdSKevin Wolf# Since: 1.3.0
1155daa6bfdSKevin Wolf##
1165daa6bfdSKevin Wolf{ 'command': 'nbd-server-add',
117b6076afcSKevin Wolf  'data': 'NbdServerAddOptions', 'boxed': true }
1185daa6bfdSKevin Wolf
1195daa6bfdSKevin Wolf##
1203c3bc462SKevin Wolf# @BlockExportRemoveMode:
1215daa6bfdSKevin Wolf#
1223c3bc462SKevin Wolf# Mode for removing a block export.
1235daa6bfdSKevin Wolf#
1245daa6bfdSKevin Wolf# @safe: Remove export if there are no existing connections, fail otherwise.
1255daa6bfdSKevin Wolf#
1265daa6bfdSKevin Wolf# @hard: Drop all connections immediately and remove export.
1275daa6bfdSKevin Wolf#
1285daa6bfdSKevin Wolf# Potential additional modes to be added in the future:
1295daa6bfdSKevin Wolf#
1305daa6bfdSKevin Wolf# hide: Just hide export from new clients, leave existing connections as is.
1315daa6bfdSKevin Wolf# Remove export after all clients are disconnected.
1325daa6bfdSKevin Wolf#
1335daa6bfdSKevin Wolf# soft: Hide export from new clients, answer with ESHUTDOWN for all further
1345daa6bfdSKevin Wolf# requests from existing clients.
1355daa6bfdSKevin Wolf#
1365daa6bfdSKevin Wolf# Since: 2.12
1375daa6bfdSKevin Wolf##
1383c3bc462SKevin Wolf{'enum': 'BlockExportRemoveMode', 'data': ['safe', 'hard']}
1395daa6bfdSKevin Wolf
1405daa6bfdSKevin Wolf##
1415daa6bfdSKevin Wolf# @nbd-server-remove:
1425daa6bfdSKevin Wolf#
1435daa6bfdSKevin Wolf# Remove NBD export by name.
1445daa6bfdSKevin Wolf#
1453c3bc462SKevin Wolf# @name: Block export id.
1465daa6bfdSKevin Wolf#
1473c3bc462SKevin Wolf# @mode: Mode of command operation. See @BlockExportRemoveMode description.
1485daa6bfdSKevin Wolf#        Default is 'safe'.
1495daa6bfdSKevin Wolf#
1505daa6bfdSKevin Wolf# Returns: error if
1515daa6bfdSKevin Wolf#            - the server is not running
1525daa6bfdSKevin Wolf#            - export is not found
1535daa6bfdSKevin Wolf#            - mode is 'safe' and there are existing connections
1545daa6bfdSKevin Wolf#
1555daa6bfdSKevin Wolf# Since: 2.12
1565daa6bfdSKevin Wolf##
1575daa6bfdSKevin Wolf{ 'command': 'nbd-server-remove',
1583c3bc462SKevin Wolf  'data': {'name': 'str', '*mode': 'BlockExportRemoveMode'} }
1595daa6bfdSKevin Wolf
1605daa6bfdSKevin Wolf##
1615daa6bfdSKevin Wolf# @nbd-server-stop:
1625daa6bfdSKevin Wolf#
1635daa6bfdSKevin Wolf# Stop QEMU's embedded NBD server, and unregister all devices previously
1645daa6bfdSKevin Wolf# added via @nbd-server-add.
1655daa6bfdSKevin Wolf#
1665daa6bfdSKevin Wolf# Since: 1.3.0
1675daa6bfdSKevin Wolf##
1685daa6bfdSKevin Wolf{ 'command': 'nbd-server-stop' }
1695daa6bfdSKevin Wolf
1705daa6bfdSKevin Wolf##
1715daa6bfdSKevin Wolf# @BlockExportType:
1725daa6bfdSKevin Wolf#
1735daa6bfdSKevin Wolf# An enumeration of block export types
1745daa6bfdSKevin Wolf#
1755daa6bfdSKevin Wolf# @nbd: NBD export
1765daa6bfdSKevin Wolf#
1775daa6bfdSKevin Wolf# Since: 4.2
1785daa6bfdSKevin Wolf##
1795daa6bfdSKevin Wolf{ 'enum': 'BlockExportType',
1805daa6bfdSKevin Wolf  'data': [ 'nbd' ] }
1815daa6bfdSKevin Wolf
1825daa6bfdSKevin Wolf##
183143ea767SKevin Wolf# @BlockExportOptions:
1845daa6bfdSKevin Wolf#
1855daa6bfdSKevin Wolf# Describes a block export, i.e. how single node should be exported on an
1865daa6bfdSKevin Wolf# external interface.
1875daa6bfdSKevin Wolf#
188d53be9ceSKevin Wolf# @id: A unique identifier for the block export (across all export types)
189d53be9ceSKevin Wolf#
190b6076afcSKevin Wolf# @node-name: The node name of the block node to be exported (since: 5.2)
191b6076afcSKevin Wolf#
192*30dbc81dSKevin Wolf# @writable: True if clients should be able to write to the export
193*30dbc81dSKevin Wolf#            (default false)
194*30dbc81dSKevin Wolf#
195fefee85dSKevin Wolf# @writethrough: If true, caches are flushed after every write request to the
196fefee85dSKevin Wolf#                export before completion is signalled. (since: 5.2;
197fefee85dSKevin Wolf#                default: false)
198fefee85dSKevin Wolf#
1995daa6bfdSKevin Wolf# Since: 4.2
2005daa6bfdSKevin Wolf##
201143ea767SKevin Wolf{ 'union': 'BlockExportOptions',
202fefee85dSKevin Wolf  'base': { 'type': 'BlockExportType',
203d53be9ceSKevin Wolf            'id': 'str',
204b6076afcSKevin Wolf            'node-name': 'str',
205*30dbc81dSKevin Wolf            '*writable': 'bool',
206fefee85dSKevin Wolf            '*writethrough': 'bool' },
2075daa6bfdSKevin Wolf  'discriminator': 'type',
2085daa6bfdSKevin Wolf  'data': {
209143ea767SKevin Wolf      'nbd': 'BlockExportOptionsNbd'
2105daa6bfdSKevin Wolf   } }
21156ee8626SKevin Wolf
21256ee8626SKevin Wolf##
21356ee8626SKevin Wolf# @block-export-add:
21456ee8626SKevin Wolf#
21556ee8626SKevin Wolf# Creates a new block export.
21656ee8626SKevin Wolf#
21756ee8626SKevin Wolf# Since: 5.2
21856ee8626SKevin Wolf##
21956ee8626SKevin Wolf{ 'command': 'block-export-add',
22056ee8626SKevin Wolf  'data': 'BlockExportOptions', 'boxed': true }
2213c3bc462SKevin Wolf
2223c3bc462SKevin Wolf##
2233c3bc462SKevin Wolf# @block-export-del:
2243c3bc462SKevin Wolf#
2253c3bc462SKevin Wolf# Request to remove a block export. This drops the user's reference to the
2263c3bc462SKevin Wolf# export, but the export may still stay around after this command returns until
2273c3bc462SKevin Wolf# the shutdown of the export has completed.
2283c3bc462SKevin Wolf#
2293c3bc462SKevin Wolf# @id: Block export id.
2303c3bc462SKevin Wolf#
2313c3bc462SKevin Wolf# @mode: Mode of command operation. See @BlockExportRemoveMode description.
2323c3bc462SKevin Wolf#        Default is 'safe'.
2333c3bc462SKevin Wolf#
2343c3bc462SKevin Wolf# Returns: Error if the export is not found or @mode is 'safe' and the export
2353c3bc462SKevin Wolf#          is still in use (e.g. by existing client connections)
2363c3bc462SKevin Wolf#
2373c3bc462SKevin Wolf# Since: 5.2
2383c3bc462SKevin Wolf##
2393c3bc462SKevin Wolf{ 'command': 'block-export-del',
2403c3bc462SKevin Wolf  'data': { 'id': 'str', '*mode': 'BlockExportRemoveMode' } }
2411a9f7a80SKevin Wolf
2421a9f7a80SKevin Wolf##
2431a9f7a80SKevin Wolf# @BLOCK_EXPORT_DELETED:
2441a9f7a80SKevin Wolf#
2451a9f7a80SKevin Wolf# Emitted when a block export is removed and its id can be reused.
2461a9f7a80SKevin Wolf#
2471a9f7a80SKevin Wolf# @id: Block export id.
2481a9f7a80SKevin Wolf#
2491a9f7a80SKevin Wolf# Since: 5.2
2501a9f7a80SKevin Wolf##
2511a9f7a80SKevin Wolf{ 'event': 'BLOCK_EXPORT_DELETED',
2521a9f7a80SKevin Wolf  'data': { 'id': 'str' } }
2538cade320SKevin Wolf
2548cade320SKevin Wolf##
2558cade320SKevin Wolf# @BlockExportInfo:
2568cade320SKevin Wolf#
2578cade320SKevin Wolf# Information about a single block export.
2588cade320SKevin Wolf#
2598cade320SKevin Wolf# @id: The unique identifier for the block export
2608cade320SKevin Wolf#
2618cade320SKevin Wolf# @type: The block export type
2628cade320SKevin Wolf#
2638cade320SKevin Wolf# @node-name: The node name of the block node that is exported
2648cade320SKevin Wolf#
2658cade320SKevin Wolf# @shutting-down: True if the export is shutting down (e.g. after a
2668cade320SKevin Wolf#                 block-export-del command, but before the shutdown has
2678cade320SKevin Wolf#                 completed)
2688cade320SKevin Wolf#
2698cade320SKevin Wolf# Since:  5.2
2708cade320SKevin Wolf##
2718cade320SKevin Wolf{ 'struct': 'BlockExportInfo',
2728cade320SKevin Wolf  'data': { 'id': 'str',
2738cade320SKevin Wolf            'type': 'BlockExportType',
2748cade320SKevin Wolf            'node-name': 'str',
2758cade320SKevin Wolf            'shutting-down': 'bool' } }
2768cade320SKevin Wolf
2778cade320SKevin Wolf##
2788cade320SKevin Wolf# @query-block-exports:
2798cade320SKevin Wolf#
2808cade320SKevin Wolf# Returns: A list of BlockExportInfo describing all block exports
2818cade320SKevin Wolf#
2828cade320SKevin Wolf# Since: 5.2
2838cade320SKevin Wolf##
2848cade320SKevin Wolf{ 'command': 'query-block-exports', 'returns': ['BlockExportInfo'] }
285