xref: /openbmc/qemu/qapi/block-export.json (revision fefee85da055e100ea86d15274106f78502c2819)
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#
685daa6bfdSKevin Wolf# An NBD block export.
695daa6bfdSKevin Wolf#
705daa6bfdSKevin Wolf# @device: The device name or node name of the node to be exported
715daa6bfdSKevin Wolf#
725daa6bfdSKevin Wolf# @name: Export name. If unspecified, the @device parameter is used as the
735daa6bfdSKevin Wolf#        export name. (Since 2.12)
745daa6bfdSKevin Wolf#
755daa6bfdSKevin Wolf# @description: Free-form description of the export, up to 4096 bytes.
765daa6bfdSKevin Wolf#               (Since 5.0)
775daa6bfdSKevin Wolf#
785daa6bfdSKevin Wolf# @writable: Whether clients should be able to write to the device via the
795daa6bfdSKevin Wolf#            NBD connection (default false).
805daa6bfdSKevin Wolf#
815daa6bfdSKevin Wolf# @bitmap: Also export the dirty bitmap reachable from @device, so the
825daa6bfdSKevin Wolf#          NBD client can use NBD_OPT_SET_META_CONTEXT with
835daa6bfdSKevin Wolf#          "qemu:dirty-bitmap:NAME" to inspect the bitmap. (since 4.0)
845daa6bfdSKevin Wolf#
855daa6bfdSKevin Wolf# Since: 5.0
865daa6bfdSKevin Wolf##
87143ea767SKevin Wolf{ 'struct': 'BlockExportOptionsNbd',
885daa6bfdSKevin Wolf  'data': {'device': 'str', '*name': 'str', '*description': 'str',
895daa6bfdSKevin Wolf           '*writable': 'bool', '*bitmap': 'str' } }
905daa6bfdSKevin Wolf
915daa6bfdSKevin Wolf##
925daa6bfdSKevin Wolf# @nbd-server-add:
935daa6bfdSKevin Wolf#
945daa6bfdSKevin Wolf# Export a block node to QEMU's embedded NBD server.
955daa6bfdSKevin Wolf#
965daa6bfdSKevin Wolf# Returns: error if the server is not running, or export with the same name
975daa6bfdSKevin Wolf#          already exists.
985daa6bfdSKevin Wolf#
995daa6bfdSKevin Wolf# Since: 1.3.0
1005daa6bfdSKevin Wolf##
1015daa6bfdSKevin Wolf{ 'command': 'nbd-server-add',
102143ea767SKevin Wolf  'data': 'BlockExportOptionsNbd', 'boxed': true }
1035daa6bfdSKevin Wolf
1045daa6bfdSKevin Wolf##
1055daa6bfdSKevin Wolf# @NbdServerRemoveMode:
1065daa6bfdSKevin Wolf#
1075daa6bfdSKevin Wolf# Mode for removing an NBD export.
1085daa6bfdSKevin Wolf#
1095daa6bfdSKevin Wolf# @safe: Remove export if there are no existing connections, fail otherwise.
1105daa6bfdSKevin Wolf#
1115daa6bfdSKevin Wolf# @hard: Drop all connections immediately and remove export.
1125daa6bfdSKevin Wolf#
1135daa6bfdSKevin Wolf# Potential additional modes to be added in the future:
1145daa6bfdSKevin Wolf#
1155daa6bfdSKevin Wolf# hide: Just hide export from new clients, leave existing connections as is.
1165daa6bfdSKevin Wolf# Remove export after all clients are disconnected.
1175daa6bfdSKevin Wolf#
1185daa6bfdSKevin Wolf# soft: Hide export from new clients, answer with ESHUTDOWN for all further
1195daa6bfdSKevin Wolf# requests from existing clients.
1205daa6bfdSKevin Wolf#
1215daa6bfdSKevin Wolf# Since: 2.12
1225daa6bfdSKevin Wolf##
1235daa6bfdSKevin Wolf{'enum': 'NbdServerRemoveMode', 'data': ['safe', 'hard']}
1245daa6bfdSKevin Wolf
1255daa6bfdSKevin Wolf##
1265daa6bfdSKevin Wolf# @nbd-server-remove:
1275daa6bfdSKevin Wolf#
1285daa6bfdSKevin Wolf# Remove NBD export by name.
1295daa6bfdSKevin Wolf#
1305daa6bfdSKevin Wolf# @name: Export name.
1315daa6bfdSKevin Wolf#
1325daa6bfdSKevin Wolf# @mode: Mode of command operation. See @NbdServerRemoveMode description.
1335daa6bfdSKevin Wolf#        Default is 'safe'.
1345daa6bfdSKevin Wolf#
1355daa6bfdSKevin Wolf# Returns: error if
1365daa6bfdSKevin Wolf#            - the server is not running
1375daa6bfdSKevin Wolf#            - export is not found
1385daa6bfdSKevin Wolf#            - mode is 'safe' and there are existing connections
1395daa6bfdSKevin Wolf#
1405daa6bfdSKevin Wolf# Since: 2.12
1415daa6bfdSKevin Wolf##
1425daa6bfdSKevin Wolf{ 'command': 'nbd-server-remove',
1435daa6bfdSKevin Wolf  'data': {'name': 'str', '*mode': 'NbdServerRemoveMode'} }
1445daa6bfdSKevin Wolf
1455daa6bfdSKevin Wolf##
1465daa6bfdSKevin Wolf# @nbd-server-stop:
1475daa6bfdSKevin Wolf#
1485daa6bfdSKevin Wolf# Stop QEMU's embedded NBD server, and unregister all devices previously
1495daa6bfdSKevin Wolf# added via @nbd-server-add.
1505daa6bfdSKevin Wolf#
1515daa6bfdSKevin Wolf# Since: 1.3.0
1525daa6bfdSKevin Wolf##
1535daa6bfdSKevin Wolf{ 'command': 'nbd-server-stop' }
1545daa6bfdSKevin Wolf
1555daa6bfdSKevin Wolf##
1565daa6bfdSKevin Wolf# @BlockExportType:
1575daa6bfdSKevin Wolf#
1585daa6bfdSKevin Wolf# An enumeration of block export types
1595daa6bfdSKevin Wolf#
1605daa6bfdSKevin Wolf# @nbd: NBD export
1615daa6bfdSKevin Wolf#
1625daa6bfdSKevin Wolf# Since: 4.2
1635daa6bfdSKevin Wolf##
1645daa6bfdSKevin Wolf{ 'enum': 'BlockExportType',
1655daa6bfdSKevin Wolf  'data': [ 'nbd' ] }
1665daa6bfdSKevin Wolf
1675daa6bfdSKevin Wolf##
168143ea767SKevin Wolf# @BlockExportOptions:
1695daa6bfdSKevin Wolf#
1705daa6bfdSKevin Wolf# Describes a block export, i.e. how single node should be exported on an
1715daa6bfdSKevin Wolf# external interface.
1725daa6bfdSKevin Wolf#
173*fefee85dSKevin Wolf# @writethrough: If true, caches are flushed after every write request to the
174*fefee85dSKevin Wolf#                export before completion is signalled. (since: 5.2;
175*fefee85dSKevin Wolf#                default: false)
176*fefee85dSKevin Wolf#
1775daa6bfdSKevin Wolf# Since: 4.2
1785daa6bfdSKevin Wolf##
179143ea767SKevin Wolf{ 'union': 'BlockExportOptions',
180*fefee85dSKevin Wolf  'base': { 'type': 'BlockExportType',
181*fefee85dSKevin Wolf            '*writethrough': 'bool' },
1825daa6bfdSKevin Wolf  'discriminator': 'type',
1835daa6bfdSKevin Wolf  'data': {
184143ea767SKevin Wolf      'nbd': 'BlockExportOptionsNbd'
1855daa6bfdSKevin Wolf   } }
18656ee8626SKevin Wolf
18756ee8626SKevin Wolf##
18856ee8626SKevin Wolf# @block-export-add:
18956ee8626SKevin Wolf#
19056ee8626SKevin Wolf# Creates a new block export.
19156ee8626SKevin Wolf#
19256ee8626SKevin Wolf# Since: 5.2
19356ee8626SKevin Wolf##
19456ee8626SKevin Wolf{ 'command': 'block-export-add',
19556ee8626SKevin Wolf  'data': 'BlockExportOptions', 'boxed': true }
196