1# -*- Mode: Python -*- 2# vim: filetype=python 3 4## 5# == Block device exports 6## 7 8{ 'include': 'sockets.json' } 9{ 'include': 'block-core.json' } 10 11## 12# @NbdServerOptions: 13# 14# Keep this type consistent with the nbd-server-start arguments. The only 15# intended difference is using SocketAddress instead of SocketAddressLegacy. 16# 17# @addr: Address on which to listen. 18# @tls-creds: ID of the TLS credentials object (since 2.6). 19# @tls-authz: ID of the QAuthZ authorization object used to validate 20# the client's x509 distinguished name. This object is 21# is only resolved at time of use, so can be deleted and 22# recreated on the fly while the NBD server is active. 23# If missing, it will default to denying access (since 4.0). 24# @max-connections: The maximum number of connections to allow at the same 25# time, 0 for unlimited. Setting this to 1 also stops 26# the server from advertising multiple client support 27# (since 5.2; default: 0) 28# 29# Since: 4.2 30## 31{ 'struct': 'NbdServerOptions', 32 'data': { 'addr': 'SocketAddress', 33 '*tls-creds': 'str', 34 '*tls-authz': 'str', 35 '*max-connections': 'uint32' } } 36 37## 38# @nbd-server-start: 39# 40# Start an NBD server listening on the given host and port. Block 41# devices can then be exported using @nbd-server-add. The NBD 42# server will present them as named exports; for example, another 43# QEMU instance could refer to them as "nbd:HOST:PORT:exportname=NAME". 44# 45# Keep this type consistent with the NbdServerOptions type. The only intended 46# difference is using SocketAddressLegacy instead of SocketAddress. 47# 48# @addr: Address on which to listen. 49# @tls-creds: ID of the TLS credentials object (since 2.6). 50# @tls-authz: ID of the QAuthZ authorization object used to validate 51# the client's x509 distinguished name. This object is 52# is only resolved at time of use, so can be deleted and 53# recreated on the fly while the NBD server is active. 54# If missing, it will default to denying access (since 4.0). 55# @max-connections: The maximum number of connections to allow at the same 56# time, 0 for unlimited. Setting this to 1 also stops 57# the server from advertising multiple client support 58# (since 5.2; default: 0). 59# 60# Returns: error if the server is already running. 61# 62# Since: 1.3 63## 64{ 'command': 'nbd-server-start', 65 'data': { 'addr': 'SocketAddressLegacy', 66 '*tls-creds': 'str', 67 '*tls-authz': 'str', 68 '*max-connections': 'uint32' }, 69 'allow-preconfig': true } 70 71## 72# @BlockExportOptionsNbdBase: 73# 74# An NBD block export (common options shared between nbd-server-add and 75# the NBD branch of block-export-add). 76# 77# @name: Export name. If unspecified, the @device parameter is used as the 78# export name. (Since 2.12) 79# 80# @description: Free-form description of the export, up to 4096 bytes. 81# (Since 5.0) 82# 83# Since: 5.0 84## 85{ 'struct': 'BlockExportOptionsNbdBase', 86 'data': { '*name': 'str', '*description': 'str' } } 87 88## 89# @BlockExportOptionsNbd: 90# 91# An NBD block export (distinct options used in the NBD branch of 92# block-export-add). 93# 94# @bitmaps: Also export each of the named dirty bitmaps reachable from 95# @device, so the NBD client can use NBD_OPT_SET_META_CONTEXT with 96# the metadata context name "qemu:dirty-bitmap:BITMAP" to inspect 97# each bitmap. 98# Since 7.1 bitmap may be specified by node/name pair. 99# 100# @allocation-depth: Also export the allocation depth map for @device, so 101# the NBD client can use NBD_OPT_SET_META_CONTEXT with 102# the metadata context name "qemu:allocation-depth" to 103# inspect allocation details. (since 5.2) 104# 105# Since: 5.2 106## 107{ 'struct': 'BlockExportOptionsNbd', 108 'base': 'BlockExportOptionsNbdBase', 109 'data': { '*bitmaps': ['BlockDirtyBitmapOrStr'], 110 '*allocation-depth': 'bool' } } 111 112## 113# @BlockExportOptionsVhostUserBlk: 114# 115# A vhost-user-blk block export. 116# 117# @addr: The vhost-user socket on which to listen. Both 'unix' and 'fd' 118# SocketAddress types are supported. Passed fds must be UNIX domain 119# sockets. 120# @logical-block-size: Logical block size in bytes. Defaults to 512 bytes. 121# @num-queues: Number of request virtqueues. Must be greater than 0. Defaults 122# to 1. 123# 124# Since: 5.2 125## 126{ 'struct': 'BlockExportOptionsVhostUserBlk', 127 'data': { 'addr': 'SocketAddress', 128 '*logical-block-size': 'size', 129 '*num-queues': 'uint16'} } 130 131## 132# @FuseExportAllowOther: 133# 134# Possible allow_other modes for FUSE exports. 135# 136# @off: Do not pass allow_other as a mount option. 137# 138# @on: Pass allow_other as a mount option. 139# 140# @auto: Try mounting with allow_other first, and if that fails, retry 141# without allow_other. 142# 143# Since: 6.1 144## 145{ 'enum': 'FuseExportAllowOther', 146 'data': ['off', 'on', 'auto'] } 147 148## 149# @BlockExportOptionsFuse: 150# 151# Options for exporting a block graph node on some (file) mountpoint 152# as a raw image. 153# 154# @mountpoint: Path on which to export the block device via FUSE. 155# This must point to an existing regular file. 156# 157# @growable: Whether writes beyond the EOF should grow the block node 158# accordingly. (default: false) 159# 160# @allow-other: If this is off, only qemu's user is allowed access to 161# this export. That cannot be changed even with chmod or 162# chown. 163# Enabling this option will allow other users access to 164# the export with the FUSE mount option "allow_other". 165# Note that using allow_other as a non-root user requires 166# user_allow_other to be enabled in the global fuse.conf 167# configuration file. 168# In auto mode (the default), the FUSE export driver will 169# first attempt to mount the export with allow_other, and 170# if that fails, try again without. 171# (since 6.1; default: auto) 172# 173# Since: 6.0 174## 175{ 'struct': 'BlockExportOptionsFuse', 176 'data': { 'mountpoint': 'str', 177 '*growable': 'bool', 178 '*allow-other': 'FuseExportAllowOther' }, 179 'if': 'CONFIG_FUSE' } 180 181## 182# @BlockExportOptionsVduseBlk: 183# 184# A vduse-blk block export. 185# 186# @num-queues: the number of virtqueues. Defaults to 1. 187# @queue-size: the size of virtqueue. Defaults to 256. 188# @logical-block-size: Logical block size in bytes. Range [512, PAGE_SIZE] 189# and must be power of 2. Defaults to 512 bytes. 190# 191# Since: 7.1 192## 193{ 'struct': 'BlockExportOptionsVduseBlk', 194 'data': { '*num-queues': 'uint16', 195 '*queue-size': 'uint16', 196 '*logical-block-size': 'size'} } 197 198## 199# @NbdServerAddOptions: 200# 201# An NBD block export, per legacy nbd-server-add command. 202# 203# @device: The device name or node name of the node to be exported 204# 205# @writable: Whether clients should be able to write to the device via the 206# NBD connection (default false). 207# 208# @bitmap: Also export a single dirty bitmap reachable from @device, so the 209# NBD client can use NBD_OPT_SET_META_CONTEXT with the metadata 210# context name "qemu:dirty-bitmap:BITMAP" to inspect the bitmap 211# (since 4.0). 212# 213# Since: 5.0 214## 215{ 'struct': 'NbdServerAddOptions', 216 'base': 'BlockExportOptionsNbdBase', 217 'data': { 'device': 'str', 218 '*writable': 'bool', '*bitmap': 'str' } } 219 220## 221# @nbd-server-add: 222# 223# Export a block node to QEMU's embedded NBD server. 224# 225# The export name will be used as the id for the resulting block export. 226# 227# Features: 228# @deprecated: This command is deprecated. Use @block-export-add instead. 229# 230# Returns: error if the server is not running, or export with the same name 231# already exists. 232# 233# Since: 1.3 234## 235{ 'command': 'nbd-server-add', 236 'data': 'NbdServerAddOptions', 'boxed': true, 'features': ['deprecated'], 237 'allow-preconfig': true } 238 239## 240# @BlockExportRemoveMode: 241# 242# Mode for removing a block export. 243# 244# @safe: Remove export if there are no existing connections, fail otherwise. 245# 246# @hard: Drop all connections immediately and remove export. 247# 248# TODO: Potential additional modes to be added in the future: 249# 250# hide: Just hide export from new clients, leave existing connections as is. 251# Remove export after all clients are disconnected. 252# 253# soft: Hide export from new clients, answer with ESHUTDOWN for all further 254# requests from existing clients. 255# 256# Since: 2.12 257## 258{'enum': 'BlockExportRemoveMode', 'data': ['safe', 'hard']} 259 260## 261# @nbd-server-remove: 262# 263# Remove NBD export by name. 264# 265# @name: Block export id. 266# 267# @mode: Mode of command operation. See @BlockExportRemoveMode description. 268# Default is 'safe'. 269# 270# Features: 271# @deprecated: This command is deprecated. Use @block-export-del instead. 272# 273# Returns: error if 274# - the server is not running 275# - export is not found 276# - mode is 'safe' and there are existing connections 277# 278# Since: 2.12 279## 280{ 'command': 'nbd-server-remove', 281 'data': {'name': 'str', '*mode': 'BlockExportRemoveMode'}, 282 'features': ['deprecated'], 283 'allow-preconfig': true } 284 285## 286# @nbd-server-stop: 287# 288# Stop QEMU's embedded NBD server, and unregister all devices previously 289# added via @nbd-server-add. 290# 291# Since: 1.3 292## 293{ 'command': 'nbd-server-stop', 294 'allow-preconfig': true } 295 296## 297# @BlockExportType: 298# 299# An enumeration of block export types 300# 301# @nbd: NBD export 302# @vhost-user-blk: vhost-user-blk export (since 5.2) 303# @fuse: FUSE export (since: 6.0) 304# @vduse-blk: vduse-blk export (since 7.1) 305# 306# Since: 4.2 307## 308{ 'enum': 'BlockExportType', 309 'data': [ 'nbd', 310 { 'name': 'vhost-user-blk', 311 'if': 'CONFIG_VHOST_USER_BLK_SERVER' }, 312 { 'name': 'fuse', 'if': 'CONFIG_FUSE' }, 313 { 'name': 'vduse-blk', 'if': 'CONFIG_VDUSE_BLK_EXPORT' } ] } 314 315## 316# @BlockExportOptions: 317# 318# Describes a block export, i.e. how single node should be exported on an 319# external interface. 320# 321# @id: A unique identifier for the block export (across the host for vduse-blk 322# export type or across all export types for other types) 323# 324# @node-name: The node name of the block node to be exported (since: 5.2) 325# 326# @writable: True if clients should be able to write to the export 327# (default false) 328# 329# @writethrough: If true, caches are flushed after every write request to the 330# export before completion is signalled. (since: 5.2; 331# default: false) 332# 333# @iothread: The name of the iothread object where the export will run. The 334# default is to use the thread currently associated with the 335# block node. (since: 5.2) 336# 337# @fixed-iothread: True prevents the block node from being moved to another 338# thread while the export is active. If true and @iothread is 339# given, export creation fails if the block node cannot be 340# moved to the iothread. The default is false. (since: 5.2) 341# 342# Since: 4.2 343## 344{ 'union': 'BlockExportOptions', 345 'base': { 'type': 'BlockExportType', 346 'id': 'str', 347 '*fixed-iothread': 'bool', 348 '*iothread': 'str', 349 'node-name': 'str', 350 '*writable': 'bool', 351 '*writethrough': 'bool' }, 352 'discriminator': 'type', 353 'data': { 354 'nbd': 'BlockExportOptionsNbd', 355 'vhost-user-blk': { 'type': 'BlockExportOptionsVhostUserBlk', 356 'if': 'CONFIG_VHOST_USER_BLK_SERVER' }, 357 'fuse': { 'type': 'BlockExportOptionsFuse', 358 'if': 'CONFIG_FUSE' }, 359 'vduse-blk': { 'type': 'BlockExportOptionsVduseBlk', 360 'if': 'CONFIG_VDUSE_BLK_EXPORT' } 361 } } 362 363## 364# @block-export-add: 365# 366# Creates a new block export. 367# 368# Since: 5.2 369## 370{ 'command': 'block-export-add', 371 'data': 'BlockExportOptions', 'boxed': true, 372 'allow-preconfig': true } 373 374## 375# @block-export-del: 376# 377# Request to remove a block export. This drops the user's reference to the 378# export, but the export may still stay around after this command returns until 379# the shutdown of the export has completed. 380# 381# @id: Block export id. 382# 383# @mode: Mode of command operation. See @BlockExportRemoveMode description. 384# Default is 'safe'. 385# 386# Returns: Error if the export is not found or @mode is 'safe' and the export 387# is still in use (e.g. by existing client connections) 388# 389# Since: 5.2 390## 391{ 'command': 'block-export-del', 392 'data': { 'id': 'str', '*mode': 'BlockExportRemoveMode' }, 393 'allow-preconfig': true } 394 395## 396# @BLOCK_EXPORT_DELETED: 397# 398# Emitted when a block export is removed and its id can be reused. 399# 400# @id: Block export id. 401# 402# Since: 5.2 403## 404{ 'event': 'BLOCK_EXPORT_DELETED', 405 'data': { 'id': 'str' } } 406 407## 408# @BlockExportInfo: 409# 410# Information about a single block export. 411# 412# @id: The unique identifier for the block export 413# 414# @type: The block export type 415# 416# @node-name: The node name of the block node that is exported 417# 418# @shutting-down: True if the export is shutting down (e.g. after a 419# block-export-del command, but before the shutdown has 420# completed) 421# 422# Since: 5.2 423## 424{ 'struct': 'BlockExportInfo', 425 'data': { 'id': 'str', 426 'type': 'BlockExportType', 427 'node-name': 'str', 428 'shutting-down': 'bool' } } 429 430## 431# @query-block-exports: 432# 433# Returns: A list of BlockExportInfo describing all block exports 434# 435# Since: 5.2 436## 437{ 'command': 'query-block-exports', 'returns': ['BlockExportInfo'], 438 'allow-preconfig': true } 439