5 # == Block device exports
8 { 'include': 'sockets.json' }
13 # Keep this type consistent with the nbd-server-start arguments. The only
14 # intended difference is using SocketAddress instead of SocketAddressLegacy.
16 # @addr: Address on which to listen.
17 # @tls-creds: ID of the TLS credentials object (since 2.6).
18 # @tls-authz: ID of the QAuthZ authorization object used to validate
19 # the client's x509 distinguished name. This object is
20 # is only resolved at time of use, so can be deleted and
21 # recreated on the fly while the NBD server is active.
22 # If missing, it will default to denying access (since 4.0).
23 # @max-connections: The maximum number of connections to allow at the same
24 # time, 0 for unlimited. (since 5.2; default: 0)
28 { 'struct': 'NbdServerOptions',
29 'data': { 'addr': 'SocketAddress',
32 '*max-connections': 'uint32' } }
37 # Start an NBD server listening on the given host and port. Block
38 # devices can then be exported using @nbd-server-add. The NBD
39 # server will present them as named exports; for example, another
40 # QEMU instance could refer to them as "nbd:HOST:PORT:exportname=NAME".
42 # Keep this type consistent with the NbdServerOptions type. The only intended
43 # difference is using SocketAddressLegacy instead of SocketAddress.
45 # @addr: Address on which to listen.
46 # @tls-creds: ID of the TLS credentials object (since 2.6).
47 # @tls-authz: ID of the QAuthZ authorization object used to validate
48 # the client's x509 distinguished name. This object is
49 # is only resolved at time of use, so can be deleted and
50 # recreated on the fly while the NBD server is active.
51 # If missing, it will default to denying access (since 4.0).
52 # @max-connections: The maximum number of connections to allow at the same
53 # time, 0 for unlimited. (since 5.2; default: 0)
55 # Returns: error if the server is already running.
59 { 'command': 'nbd-server-start',
60 'data': { 'addr': 'SocketAddressLegacy',
63 '*max-connections': 'uint32' } }
66 # @BlockExportOptionsNbd:
68 # An NBD block export (options shared between nbd-server-add and the NBD branch
69 # of block-export-add).
71 # @name: Export name. If unspecified, the @device parameter is used as the
72 # export name. (Since 2.12)
74 # @description: Free-form description of the export, up to 4096 bytes.
77 # @writable: Whether clients should be able to write to the device via the
78 # NBD connection (default false).
80 # @bitmap: Also export the dirty bitmap reachable from @device, so the
81 # NBD client can use NBD_OPT_SET_META_CONTEXT with
82 # "qemu:dirty-bitmap:NAME" to inspect the bitmap. (since 4.0)
86 { 'struct': 'BlockExportOptionsNbd',
87 'data': { '*name': 'str', '*description': 'str',
88 '*writable': 'bool', '*bitmap': 'str' } }
91 # @NbdServerAddOptions:
93 # An NBD block export.
95 # @device: The device name or node name of the node to be exported
99 { 'struct': 'NbdServerAddOptions',
100 'base': 'BlockExportOptionsNbd',
101 'data': { 'device': 'str' } }
106 # Export a block node to QEMU's embedded NBD server.
108 # The export name will be used as the id for the resulting block export.
110 # Returns: error if the server is not running, or export with the same name
115 { 'command': 'nbd-server-add',
116 'data': 'NbdServerAddOptions', 'boxed': true }
119 # @BlockExportRemoveMode:
121 # Mode for removing a block export.
123 # @safe: Remove export if there are no existing connections, fail otherwise.
125 # @hard: Drop all connections immediately and remove export.
127 # Potential additional modes to be added in the future:
129 # hide: Just hide export from new clients, leave existing connections as is.
130 # Remove export after all clients are disconnected.
132 # soft: Hide export from new clients, answer with ESHUTDOWN for all further
133 # requests from existing clients.
137 {'enum': 'BlockExportRemoveMode', 'data': ['safe', 'hard']}
140 # @nbd-server-remove:
142 # Remove NBD export by name.
144 # @name: Block export id.
146 # @mode: Mode of command operation. See @BlockExportRemoveMode description.
150 # - the server is not running
151 # - export is not found
152 # - mode is 'safe' and there are existing connections
156 { 'command': 'nbd-server-remove',
157 'data': {'name': 'str', '*mode': 'BlockExportRemoveMode'} }
162 # Stop QEMU's embedded NBD server, and unregister all devices previously
163 # added via @nbd-server-add.
167 { 'command': 'nbd-server-stop' }
172 # An enumeration of block export types
178 { 'enum': 'BlockExportType',
182 # @BlockExportOptions:
184 # Describes a block export, i.e. how single node should be exported on an
185 # external interface.
187 # @id: A unique identifier for the block export (across all export types)
189 # @node-name: The node name of the block node to be exported (since: 5.2)
191 # @writethrough: If true, caches are flushed after every write request to the
192 # export before completion is signalled. (since: 5.2;
197 { 'union': 'BlockExportOptions',
198 'base': { 'type': 'BlockExportType',
201 '*writethrough': 'bool' },
202 'discriminator': 'type',
204 'nbd': 'BlockExportOptionsNbd'
210 # Creates a new block export.
214 { 'command': 'block-export-add',
215 'data': 'BlockExportOptions', 'boxed': true }
220 # Request to remove a block export. This drops the user's reference to the
221 # export, but the export may still stay around after this command returns until
222 # the shutdown of the export has completed.
224 # @id: Block export id.
226 # @mode: Mode of command operation. See @BlockExportRemoveMode description.
229 # Returns: Error if the export is not found or @mode is 'safe' and the export
230 # is still in use (e.g. by existing client connections)
234 { 'command': 'block-export-del',
235 'data': { 'id': 'str', '*mode': 'BlockExportRemoveMode' } }
238 # @BLOCK_EXPORT_DELETED:
240 # Emitted when a block export is removed and its id can be reused.
242 # @id: Block export id.
246 { 'event': 'BLOCK_EXPORT_DELETED',
247 'data': { 'id': 'str' } }
252 # Information about a single block export.
254 # @id: The unique identifier for the block export
256 # @type: The block export type
258 # @node-name: The node name of the block node that is exported
260 # @shutting-down: True if the export is shutting down (e.g. after a
261 # block-export-del command, but before the shutdown has
266 { 'struct': 'BlockExportInfo',
267 'data': { 'id': 'str',
268 'type': 'BlockExportType',
270 'shutting-down': 'bool' } }
273 # @query-block-exports:
275 # Returns: A list of BlockExportInfo describing all block exports
279 { 'command': 'query-block-exports', 'returns': ['BlockExportInfo'] }