5 # == Block device exports
8 { 'include': 'sockets.json' }
9 { 'include': 'block-core.json' }
14 # Keep this type consistent with the nbd-server-start arguments. The
15 # only intended difference is using SocketAddress instead of
16 # SocketAddressLegacy.
18 # @addr: Address on which to listen.
20 # @tls-creds: ID of the TLS credentials object (since 2.6).
22 # @tls-authz: ID of the QAuthZ authorization object used to validate
23 # the client's x509 distinguished name. This object is is only
24 # resolved at time of use, so can be deleted and recreated on the
25 # fly while the NBD server is active. If missing, it will default
26 # to denying access (since 4.0).
28 # @max-connections: The maximum number of connections to allow at the
29 # same time, 0 for unlimited. Setting this to 1 also stops the
30 # server from advertising multiple client support (since 5.2;
35 { 'struct': 'NbdServerOptions',
36 'data': { 'addr': 'SocketAddress',
39 '*max-connections': 'uint32' } }
44 # Start an NBD server listening on the given host and port. Block
45 # devices can then be exported using @nbd-server-add. The NBD server
46 # will present them as named exports; for example, another QEMU
47 # instance could refer to them as "nbd:HOST:PORT:exportname=NAME".
49 # Keep this type consistent with the NbdServerOptions type. The only
50 # intended difference is using SocketAddressLegacy instead of
53 # @addr: Address on which to listen.
55 # @tls-creds: ID of the TLS credentials object (since 2.6).
57 # @tls-authz: ID of the QAuthZ authorization object used to validate
58 # the client's x509 distinguished name. This object is is only
59 # resolved at time of use, so can be deleted and recreated on the
60 # fly while the NBD server is active. If missing, it will default
61 # to denying access (since 4.0).
63 # @max-connections: The maximum number of connections to allow at the
64 # same time, 0 for unlimited. Setting this to 1 also stops the
65 # server from advertising multiple client support (since 5.2;
69 # - if the server is already running
73 { 'command': 'nbd-server-start',
74 'data': { 'addr': 'SocketAddressLegacy',
77 '*max-connections': 'uint32' },
78 'allow-preconfig': true }
81 # @BlockExportOptionsNbdBase:
83 # An NBD block export (common options shared between nbd-server-add
84 # and the NBD branch of block-export-add).
86 # @name: Export name. If unspecified, the @device parameter is used
87 # as the export name. (Since 2.12)
89 # @description: Free-form description of the export, up to 4096 bytes.
94 { 'struct': 'BlockExportOptionsNbdBase',
95 'data': { '*name': 'str', '*description': 'str' } }
98 # @BlockExportOptionsNbd:
100 # An NBD block export (distinct options used in the NBD branch of
103 # @bitmaps: Also export each of the named dirty bitmaps reachable from
104 # @device, so the NBD client can use NBD_OPT_SET_META_CONTEXT with
105 # the metadata context name "qemu:dirty-bitmap:BITMAP" to inspect
106 # each bitmap. Since 7.1 bitmap may be specified by node/name
109 # @allocation-depth: Also export the allocation depth map for @device,
110 # so the NBD client can use NBD_OPT_SET_META_CONTEXT with the
111 # metadata context name "qemu:allocation-depth" to inspect
112 # allocation details. (since 5.2)
116 { 'struct': 'BlockExportOptionsNbd',
117 'base': 'BlockExportOptionsNbdBase',
118 'data': { '*bitmaps': ['BlockDirtyBitmapOrStr'],
119 '*allocation-depth': 'bool' } }
122 # @BlockExportOptionsVhostUserBlk:
124 # A vhost-user-blk block export.
126 # @addr: The vhost-user socket on which to listen. Both 'unix' and
127 # 'fd' SocketAddress types are supported. Passed fds must be UNIX
130 # @logical-block-size: Logical block size in bytes. Defaults to 512
133 # @num-queues: Number of request virtqueues. Must be greater than 0.
138 { 'struct': 'BlockExportOptionsVhostUserBlk',
139 'data': { 'addr': 'SocketAddress',
140 '*logical-block-size': 'size',
141 '*num-queues': 'uint16'} }
144 # @FuseExportAllowOther:
146 # Possible allow_other modes for FUSE exports.
148 # @off: Do not pass allow_other as a mount option.
150 # @on: Pass allow_other as a mount option.
152 # @auto: Try mounting with allow_other first, and if that fails, retry
153 # without allow_other.
157 { 'enum': 'FuseExportAllowOther',
158 'data': ['off', 'on', 'auto'] }
161 # @BlockExportOptionsFuse:
163 # Options for exporting a block graph node on some (file) mountpoint
166 # @mountpoint: Path on which to export the block device via FUSE. This
167 # must point to an existing regular file.
169 # @growable: Whether writes beyond the EOF should grow the block node
170 # accordingly. (default: false)
172 # @allow-other: If this is off, only qemu's user is allowed access to
173 # this export. That cannot be changed even with chmod or chown.
174 # Enabling this option will allow other users access to the export
175 # with the FUSE mount option "allow_other". Note that using
176 # allow_other as a non-root user requires user_allow_other to be
177 # enabled in the global fuse.conf configuration file. In auto
178 # mode (the default), the FUSE export driver will first attempt to
179 # mount the export with allow_other, and if that fails, try again
180 # without. (since 6.1; default: auto)
184 { 'struct': 'BlockExportOptionsFuse',
185 'data': { 'mountpoint': 'str',
187 '*allow-other': 'FuseExportAllowOther' },
188 'if': 'CONFIG_FUSE' }
191 # @BlockExportOptionsVduseBlk:
193 # A vduse-blk block export.
195 # @name: the name of VDUSE device (must be unique across the host).
197 # @num-queues: the number of virtqueues. Defaults to 1.
199 # @queue-size: the size of virtqueue. Defaults to 256.
201 # @logical-block-size: Logical block size in bytes. Range [512,
202 # PAGE_SIZE] and must be power of 2. Defaults to 512 bytes.
204 # @serial: the serial number of virtio block device. Defaults to
209 { 'struct': 'BlockExportOptionsVduseBlk',
210 'data': { 'name': 'str',
211 '*num-queues': 'uint16',
212 '*queue-size': 'uint16',
213 '*logical-block-size': 'size',
217 # @NbdServerAddOptions:
219 # An NBD block export, per legacy nbd-server-add command.
221 # @device: The device name or node name of the node to be exported
223 # @writable: Whether clients should be able to write to the device via
224 # the NBD connection (default false).
226 # @bitmap: Also export a single dirty bitmap reachable from @device,
227 # so the NBD client can use NBD_OPT_SET_META_CONTEXT with the
228 # metadata context name "qemu:dirty-bitmap:BITMAP" to inspect the
229 # bitmap (since 4.0).
233 { 'struct': 'NbdServerAddOptions',
234 'base': 'BlockExportOptionsNbdBase',
235 'data': { 'device': 'str',
236 '*writable': 'bool', '*bitmap': 'str' } }
241 # Export a block node to QEMU's embedded NBD server.
243 # The export name will be used as the id for the resulting block
248 # @deprecated: This command is deprecated. Use @block-export-add
252 # - if the server is not running
253 # - if an export with the same name already exists
257 { 'command': 'nbd-server-add',
258 'data': 'NbdServerAddOptions', 'boxed': true, 'features': ['deprecated'],
259 'allow-preconfig': true }
262 # @BlockExportRemoveMode:
264 # Mode for removing a block export.
266 # @safe: Remove export if there are no existing connections, fail
269 # @hard: Drop all connections immediately and remove export.
271 # TODO: Potential additional modes to be added in the future:
273 # - hide: Just hide export from new clients, leave existing
274 # connections as is. Remove export after all clients are
277 # - soft: Hide export from new clients, answer with ESHUTDOWN for
278 # all further requests from existing clients.
282 {'enum': 'BlockExportRemoveMode', 'data': ['safe', 'hard']}
285 # @nbd-server-remove:
287 # Remove NBD export by name.
289 # @name: Block export id.
291 # @mode: Mode of command operation. See @BlockExportRemoveMode
292 # description. Default is 'safe'.
296 # @deprecated: This command is deprecated. Use @block-export-del
300 # - if the server is not running
301 # - if export is not found
302 # - if mode is 'safe' and there are existing connections
306 { 'command': 'nbd-server-remove',
307 'data': {'name': 'str', '*mode': 'BlockExportRemoveMode'},
308 'features': ['deprecated'],
309 'allow-preconfig': true }
314 # Stop QEMU's embedded NBD server, and unregister all devices
315 # previously added via @nbd-server-add.
319 { 'command': 'nbd-server-stop',
320 'allow-preconfig': true }
325 # An enumeration of block export types
329 # @vhost-user-blk: vhost-user-blk export (since 5.2)
331 # @fuse: FUSE export (since: 6.0)
333 # @vduse-blk: vduse-blk export (since 7.1)
337 { 'enum': 'BlockExportType',
339 { 'name': 'vhost-user-blk',
340 'if': 'CONFIG_VHOST_USER_BLK_SERVER' },
341 { 'name': 'fuse', 'if': 'CONFIG_FUSE' },
342 { 'name': 'vduse-blk', 'if': 'CONFIG_VDUSE_BLK_EXPORT' } ] }
345 # @BlockExportOptions:
347 # Describes a block export, i.e. how single node should be exported on
348 # an external interface.
350 # @type: Block export type
352 # @id: A unique identifier for the block export (across all export
355 # @node-name: The node name of the block node to be exported
358 # @writable: True if clients should be able to write to the export
361 # @writethrough: If true, caches are flushed after every write request
362 # to the export before completion is signalled. (since: 5.2;
365 # @iothread: The name of the iothread object where the export will
366 # run. The default is to use the thread currently associated with
367 # the block node. (since: 5.2)
369 # @fixed-iothread: True prevents the block node from being moved to
370 # another thread while the export is active. If true and
371 # @iothread is given, export creation fails if the block node
372 # cannot be moved to the iothread. The default is false.
377 { 'union': 'BlockExportOptions',
378 'base': { 'type': 'BlockExportType',
380 '*fixed-iothread': 'bool',
384 '*writethrough': 'bool' },
385 'discriminator': 'type',
387 'nbd': 'BlockExportOptionsNbd',
388 'vhost-user-blk': { 'type': 'BlockExportOptionsVhostUserBlk',
389 'if': 'CONFIG_VHOST_USER_BLK_SERVER' },
390 'fuse': { 'type': 'BlockExportOptionsFuse',
391 'if': 'CONFIG_FUSE' },
392 'vduse-blk': { 'type': 'BlockExportOptionsVduseBlk',
393 'if': 'CONFIG_VDUSE_BLK_EXPORT' }
399 # Creates a new block export.
403 { 'command': 'block-export-add',
404 'data': 'BlockExportOptions', 'boxed': true,
405 'allow-preconfig': true }
410 # Request to remove a block export. This drops the user's reference
411 # to the export, but the export may still stay around after this
412 # command returns until the shutdown of the export has completed.
414 # @id: Block export id.
416 # @mode: Mode of command operation. See @BlockExportRemoveMode
417 # description. Default is 'safe'.
420 # - if the export is not found
421 # - if @mode is 'safe' and the export is still in use (e.g. by
422 # existing client connections)
426 { 'command': 'block-export-del',
427 'data': { 'id': 'str', '*mode': 'BlockExportRemoveMode' },
428 'allow-preconfig': true }
431 # @BLOCK_EXPORT_DELETED:
433 # Emitted when a block export is removed and its id can be reused.
435 # @id: Block export id.
439 { 'event': 'BLOCK_EXPORT_DELETED',
440 'data': { 'id': 'str' } }
445 # Information about a single block export.
447 # @id: The unique identifier for the block export
449 # @type: The block export type
451 # @node-name: The node name of the block node that is exported
453 # @shutting-down: True if the export is shutting down (e.g. after a
454 # block-export-del command, but before the shutdown has completed)
458 { 'struct': 'BlockExportInfo',
459 'data': { 'id': 'str',
460 'type': 'BlockExportType',
462 'shutting-down': 'bool' } }
465 # @query-block-exports:
467 # Returns: A list of BlockExportInfo describing all block exports
471 { 'command': 'query-block-exports', 'returns': ['BlockExportInfo'],
472 'allow-preconfig': true }