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