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# 579bc6e893SMarkus Armbruster# Since: 1.3 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## 66cbad81ceSEric Blake# @BlockExportOptionsNbdBase: 675daa6bfdSKevin Wolf# 68cbad81ceSEric Blake# An NBD block export (common options shared between nbd-server-add and 69cbad81ceSEric Blake# the NBD branch of block-export-add). 705daa6bfdSKevin Wolf# 715daa6bfdSKevin Wolf# @name: Export name. If unspecified, the @device parameter is used as the 725daa6bfdSKevin Wolf# export name. (Since 2.12) 735daa6bfdSKevin Wolf# 745daa6bfdSKevin Wolf# @description: Free-form description of the export, up to 4096 bytes. 755daa6bfdSKevin Wolf# (Since 5.0) 765daa6bfdSKevin Wolf# 775daa6bfdSKevin Wolf# Since: 5.0 785daa6bfdSKevin Wolf## 79cbad81ceSEric Blake{ 'struct': 'BlockExportOptionsNbdBase', 80cbad81ceSEric Blake 'data': { '*name': 'str', '*description': 'str' } } 81cbad81ceSEric Blake 82cbad81ceSEric Blake## 83cbad81ceSEric Blake# @BlockExportOptionsNbd: 84cbad81ceSEric Blake# 85cbad81ceSEric Blake# An NBD block export (distinct options used in the NBD branch of 86cbad81ceSEric Blake# block-export-add). 87cbad81ceSEric Blake# 88cbad81ceSEric Blake# @bitmaps: Also export each of the named dirty bitmaps reachable from 89cbad81ceSEric Blake# @device, so the NBD client can use NBD_OPT_SET_META_CONTEXT with 90cbad81ceSEric Blake# the metadata context name "qemu:dirty-bitmap:BITMAP" to inspect 91cbad81ceSEric Blake# each bitmap. 92cbad81ceSEric Blake# 93dbc7b014SEric Blake# @allocation-depth: Also export the allocation depth map for @device, so 94dbc7b014SEric Blake# the NBD client can use NBD_OPT_SET_META_CONTEXT with 95dbc7b014SEric Blake# the metadata context name "qemu:allocation-depth" to 96dbc7b014SEric Blake# inspect allocation details. (since 5.2) 97dbc7b014SEric Blake# 98cbad81ceSEric Blake# Since: 5.2 99cbad81ceSEric Blake## 100143ea767SKevin Wolf{ 'struct': 'BlockExportOptionsNbd', 101cbad81ceSEric Blake 'base': 'BlockExportOptionsNbdBase', 102dbc7b014SEric Blake 'data': { '*bitmaps': ['str'], '*allocation-depth': 'bool' } } 1035daa6bfdSKevin Wolf 1045daa6bfdSKevin Wolf## 10590fc91d5SStefan Hajnoczi# @BlockExportOptionsVhostUserBlk: 10690fc91d5SStefan Hajnoczi# 10790fc91d5SStefan Hajnoczi# A vhost-user-blk block export. 10890fc91d5SStefan Hajnoczi# 10990fc91d5SStefan Hajnoczi# @addr: The vhost-user socket on which to listen. Both 'unix' and 'fd' 11090fc91d5SStefan Hajnoczi# SocketAddress types are supported. Passed fds must be UNIX domain 11190fc91d5SStefan Hajnoczi# sockets. 11290fc91d5SStefan Hajnoczi# @logical-block-size: Logical block size in bytes. Defaults to 512 bytes. 113d9b495f9SStefan Hajnoczi# @num-queues: Number of request virtqueues. Must be greater than 0. Defaults 114d9b495f9SStefan Hajnoczi# to 1. 11590fc91d5SStefan Hajnoczi# 11690fc91d5SStefan Hajnoczi# Since: 5.2 11790fc91d5SStefan Hajnoczi## 11890fc91d5SStefan Hajnoczi{ 'struct': 'BlockExportOptionsVhostUserBlk', 119d9b495f9SStefan Hajnoczi 'data': { 'addr': 'SocketAddress', 120d9b495f9SStefan Hajnoczi '*logical-block-size': 'size', 121d9b495f9SStefan Hajnoczi '*num-queues': 'uint16'} } 12290fc91d5SStefan Hajnoczi 12390fc91d5SStefan Hajnoczi## 124*0c9b70d5SMax Reitz# @BlockExportOptionsFuse: 125*0c9b70d5SMax Reitz# 126*0c9b70d5SMax Reitz# Options for exporting a block graph node on some (file) mountpoint 127*0c9b70d5SMax Reitz# as a raw image. 128*0c9b70d5SMax Reitz# 129*0c9b70d5SMax Reitz# @mountpoint: Path on which to export the block device via FUSE. 130*0c9b70d5SMax Reitz# This must point to an existing regular file. 131*0c9b70d5SMax Reitz# 132*0c9b70d5SMax Reitz# Since: 6.0 133*0c9b70d5SMax Reitz## 134*0c9b70d5SMax Reitz{ 'struct': 'BlockExportOptionsFuse', 135*0c9b70d5SMax Reitz 'data': { 'mountpoint': 'str' }, 136*0c9b70d5SMax Reitz 'if': 'defined(CONFIG_FUSE)' } 137*0c9b70d5SMax Reitz 138*0c9b70d5SMax Reitz## 139b6076afcSKevin Wolf# @NbdServerAddOptions: 140b6076afcSKevin Wolf# 141cbad81ceSEric Blake# An NBD block export, per legacy nbd-server-add command. 142b6076afcSKevin Wolf# 143b6076afcSKevin Wolf# @device: The device name or node name of the node to be exported 144b6076afcSKevin Wolf# 14530dbc81dSKevin Wolf# @writable: Whether clients should be able to write to the device via the 14630dbc81dSKevin Wolf# NBD connection (default false). 14730dbc81dSKevin Wolf# 148cbad81ceSEric Blake# @bitmap: Also export a single dirty bitmap reachable from @device, so the 149cbad81ceSEric Blake# NBD client can use NBD_OPT_SET_META_CONTEXT with the metadata 150cbad81ceSEric Blake# context name "qemu:dirty-bitmap:BITMAP" to inspect the bitmap 151cbad81ceSEric Blake# (since 4.0). 152cbad81ceSEric Blake# 153b6076afcSKevin Wolf# Since: 5.0 154b6076afcSKevin Wolf## 155b6076afcSKevin Wolf{ 'struct': 'NbdServerAddOptions', 156cbad81ceSEric Blake 'base': 'BlockExportOptionsNbdBase', 15730dbc81dSKevin Wolf 'data': { 'device': 'str', 158cbad81ceSEric Blake '*writable': 'bool', '*bitmap': 'str' } } 159b6076afcSKevin Wolf 160b6076afcSKevin Wolf## 1615daa6bfdSKevin Wolf# @nbd-server-add: 1625daa6bfdSKevin Wolf# 1635daa6bfdSKevin Wolf# Export a block node to QEMU's embedded NBD server. 1645daa6bfdSKevin Wolf# 165d53be9ceSKevin Wolf# The export name will be used as the id for the resulting block export. 166d53be9ceSKevin Wolf# 167443127e8SKevin Wolf# Features: 168443127e8SKevin Wolf# @deprecated: This command is deprecated. Use @block-export-add instead. 169443127e8SKevin Wolf# 1705daa6bfdSKevin Wolf# Returns: error if the server is not running, or export with the same name 1715daa6bfdSKevin Wolf# already exists. 1725daa6bfdSKevin Wolf# 1739bc6e893SMarkus Armbruster# Since: 1.3 1745daa6bfdSKevin Wolf## 1755daa6bfdSKevin Wolf{ 'command': 'nbd-server-add', 176443127e8SKevin Wolf 'data': 'NbdServerAddOptions', 'boxed': true, 'features': ['deprecated'] } 1775daa6bfdSKevin Wolf 1785daa6bfdSKevin Wolf## 1793c3bc462SKevin Wolf# @BlockExportRemoveMode: 1805daa6bfdSKevin Wolf# 1813c3bc462SKevin Wolf# Mode for removing a block export. 1825daa6bfdSKevin Wolf# 1835daa6bfdSKevin Wolf# @safe: Remove export if there are no existing connections, fail otherwise. 1845daa6bfdSKevin Wolf# 1855daa6bfdSKevin Wolf# @hard: Drop all connections immediately and remove export. 1865daa6bfdSKevin Wolf# 1875daa6bfdSKevin Wolf# Potential additional modes to be added in the future: 1885daa6bfdSKevin Wolf# 1895daa6bfdSKevin Wolf# hide: Just hide export from new clients, leave existing connections as is. 1905daa6bfdSKevin Wolf# Remove export after all clients are disconnected. 1915daa6bfdSKevin Wolf# 1925daa6bfdSKevin Wolf# soft: Hide export from new clients, answer with ESHUTDOWN for all further 1935daa6bfdSKevin Wolf# requests from existing clients. 1945daa6bfdSKevin Wolf# 1955daa6bfdSKevin Wolf# Since: 2.12 1965daa6bfdSKevin Wolf## 1973c3bc462SKevin Wolf{'enum': 'BlockExportRemoveMode', 'data': ['safe', 'hard']} 1985daa6bfdSKevin Wolf 1995daa6bfdSKevin Wolf## 2005daa6bfdSKevin Wolf# @nbd-server-remove: 2015daa6bfdSKevin Wolf# 2025daa6bfdSKevin Wolf# Remove NBD export by name. 2035daa6bfdSKevin Wolf# 2043c3bc462SKevin Wolf# @name: Block export id. 2055daa6bfdSKevin Wolf# 2063c3bc462SKevin Wolf# @mode: Mode of command operation. See @BlockExportRemoveMode description. 2075daa6bfdSKevin Wolf# Default is 'safe'. 2085daa6bfdSKevin Wolf# 209443127e8SKevin Wolf# Features: 210443127e8SKevin Wolf# @deprecated: This command is deprecated. Use @block-export-del instead. 211443127e8SKevin Wolf# 2125daa6bfdSKevin Wolf# Returns: error if 2135daa6bfdSKevin Wolf# - the server is not running 2145daa6bfdSKevin Wolf# - export is not found 2155daa6bfdSKevin Wolf# - mode is 'safe' and there are existing connections 2165daa6bfdSKevin Wolf# 2175daa6bfdSKevin Wolf# Since: 2.12 2185daa6bfdSKevin Wolf## 2195daa6bfdSKevin Wolf{ 'command': 'nbd-server-remove', 220443127e8SKevin Wolf 'data': {'name': 'str', '*mode': 'BlockExportRemoveMode'}, 221443127e8SKevin Wolf 'features': ['deprecated'] } 2225daa6bfdSKevin Wolf 2235daa6bfdSKevin Wolf## 2245daa6bfdSKevin Wolf# @nbd-server-stop: 2255daa6bfdSKevin Wolf# 2265daa6bfdSKevin Wolf# Stop QEMU's embedded NBD server, and unregister all devices previously 2275daa6bfdSKevin Wolf# added via @nbd-server-add. 2285daa6bfdSKevin Wolf# 2299bc6e893SMarkus Armbruster# Since: 1.3 2305daa6bfdSKevin Wolf## 2315daa6bfdSKevin Wolf{ 'command': 'nbd-server-stop' } 2325daa6bfdSKevin Wolf 2335daa6bfdSKevin Wolf## 2345daa6bfdSKevin Wolf# @BlockExportType: 2355daa6bfdSKevin Wolf# 2365daa6bfdSKevin Wolf# An enumeration of block export types 2375daa6bfdSKevin Wolf# 2385daa6bfdSKevin Wolf# @nbd: NBD export 23990fc91d5SStefan Hajnoczi# @vhost-user-blk: vhost-user-blk export (since 5.2) 240*0c9b70d5SMax Reitz# @fuse: FUSE export (since: 6.0) 2415daa6bfdSKevin Wolf# 2425daa6bfdSKevin Wolf# Since: 4.2 2435daa6bfdSKevin Wolf## 2445daa6bfdSKevin Wolf{ 'enum': 'BlockExportType', 245*0c9b70d5SMax Reitz 'data': [ 'nbd', 'vhost-user-blk', 246*0c9b70d5SMax Reitz { 'name': 'fuse', 'if': 'defined(CONFIG_FUSE)' } ] } 2475daa6bfdSKevin Wolf 2485daa6bfdSKevin Wolf## 249143ea767SKevin Wolf# @BlockExportOptions: 2505daa6bfdSKevin Wolf# 2515daa6bfdSKevin Wolf# Describes a block export, i.e. how single node should be exported on an 2525daa6bfdSKevin Wolf# external interface. 2535daa6bfdSKevin Wolf# 254d53be9ceSKevin Wolf# @id: A unique identifier for the block export (across all export types) 255d53be9ceSKevin Wolf# 256b6076afcSKevin Wolf# @node-name: The node name of the block node to be exported (since: 5.2) 257b6076afcSKevin Wolf# 25830dbc81dSKevin Wolf# @writable: True if clients should be able to write to the export 25930dbc81dSKevin Wolf# (default false) 26030dbc81dSKevin Wolf# 261fefee85dSKevin Wolf# @writethrough: If true, caches are flushed after every write request to the 262fefee85dSKevin Wolf# export before completion is signalled. (since: 5.2; 263fefee85dSKevin Wolf# default: false) 264fefee85dSKevin Wolf# 265f51d23c8SStefan Hajnoczi# @iothread: The name of the iothread object where the export will run. The 266f51d23c8SStefan Hajnoczi# default is to use the thread currently associated with the 267f51d23c8SStefan Hajnoczi# block node. (since: 5.2) 268f51d23c8SStefan Hajnoczi# 269f51d23c8SStefan Hajnoczi# @fixed-iothread: True prevents the block node from being moved to another 270f51d23c8SStefan Hajnoczi# thread while the export is active. If true and @iothread is 271f51d23c8SStefan Hajnoczi# given, export creation fails if the block node cannot be 272f51d23c8SStefan Hajnoczi# moved to the iothread. The default is false. (since: 5.2) 273f51d23c8SStefan Hajnoczi# 2745daa6bfdSKevin Wolf# Since: 4.2 2755daa6bfdSKevin Wolf## 276143ea767SKevin Wolf{ 'union': 'BlockExportOptions', 277fefee85dSKevin Wolf 'base': { 'type': 'BlockExportType', 278d53be9ceSKevin Wolf 'id': 'str', 279f51d23c8SStefan Hajnoczi '*fixed-iothread': 'bool', 280f51d23c8SStefan Hajnoczi '*iothread': 'str', 281b6076afcSKevin Wolf 'node-name': 'str', 28230dbc81dSKevin Wolf '*writable': 'bool', 283fefee85dSKevin Wolf '*writethrough': 'bool' }, 2845daa6bfdSKevin Wolf 'discriminator': 'type', 2855daa6bfdSKevin Wolf 'data': { 28690fc91d5SStefan Hajnoczi 'nbd': 'BlockExportOptionsNbd', 287*0c9b70d5SMax Reitz 'vhost-user-blk': 'BlockExportOptionsVhostUserBlk', 288*0c9b70d5SMax Reitz 'fuse': { 'type': 'BlockExportOptionsFuse', 289*0c9b70d5SMax Reitz 'if': 'defined(CONFIG_FUSE)' } 2905daa6bfdSKevin Wolf } } 29156ee8626SKevin Wolf 29256ee8626SKevin Wolf## 29356ee8626SKevin Wolf# @block-export-add: 29456ee8626SKevin Wolf# 29556ee8626SKevin Wolf# Creates a new block export. 29656ee8626SKevin Wolf# 29756ee8626SKevin Wolf# Since: 5.2 29856ee8626SKevin Wolf## 29956ee8626SKevin Wolf{ 'command': 'block-export-add', 30056ee8626SKevin Wolf 'data': 'BlockExportOptions', 'boxed': true } 3013c3bc462SKevin Wolf 3023c3bc462SKevin Wolf## 3033c3bc462SKevin Wolf# @block-export-del: 3043c3bc462SKevin Wolf# 3053c3bc462SKevin Wolf# Request to remove a block export. This drops the user's reference to the 3063c3bc462SKevin Wolf# export, but the export may still stay around after this command returns until 3073c3bc462SKevin Wolf# the shutdown of the export has completed. 3083c3bc462SKevin Wolf# 3093c3bc462SKevin Wolf# @id: Block export id. 3103c3bc462SKevin Wolf# 3113c3bc462SKevin Wolf# @mode: Mode of command operation. See @BlockExportRemoveMode description. 3123c3bc462SKevin Wolf# Default is 'safe'. 3133c3bc462SKevin Wolf# 3143c3bc462SKevin Wolf# Returns: Error if the export is not found or @mode is 'safe' and the export 3153c3bc462SKevin Wolf# is still in use (e.g. by existing client connections) 3163c3bc462SKevin Wolf# 3173c3bc462SKevin Wolf# Since: 5.2 3183c3bc462SKevin Wolf## 3193c3bc462SKevin Wolf{ 'command': 'block-export-del', 3203c3bc462SKevin Wolf 'data': { 'id': 'str', '*mode': 'BlockExportRemoveMode' } } 3211a9f7a80SKevin Wolf 3221a9f7a80SKevin Wolf## 3231a9f7a80SKevin Wolf# @BLOCK_EXPORT_DELETED: 3241a9f7a80SKevin Wolf# 3251a9f7a80SKevin Wolf# Emitted when a block export is removed and its id can be reused. 3261a9f7a80SKevin Wolf# 3271a9f7a80SKevin Wolf# @id: Block export id. 3281a9f7a80SKevin Wolf# 3291a9f7a80SKevin Wolf# Since: 5.2 3301a9f7a80SKevin Wolf## 3311a9f7a80SKevin Wolf{ 'event': 'BLOCK_EXPORT_DELETED', 3321a9f7a80SKevin Wolf 'data': { 'id': 'str' } } 3338cade320SKevin Wolf 3348cade320SKevin Wolf## 3358cade320SKevin Wolf# @BlockExportInfo: 3368cade320SKevin Wolf# 3378cade320SKevin Wolf# Information about a single block export. 3388cade320SKevin Wolf# 3398cade320SKevin Wolf# @id: The unique identifier for the block export 3408cade320SKevin Wolf# 3418cade320SKevin Wolf# @type: The block export type 3428cade320SKevin Wolf# 3438cade320SKevin Wolf# @node-name: The node name of the block node that is exported 3448cade320SKevin Wolf# 3458cade320SKevin Wolf# @shutting-down: True if the export is shutting down (e.g. after a 3468cade320SKevin Wolf# block-export-del command, but before the shutdown has 3478cade320SKevin Wolf# completed) 3488cade320SKevin Wolf# 3498cade320SKevin Wolf# Since: 5.2 3508cade320SKevin Wolf## 3518cade320SKevin Wolf{ 'struct': 'BlockExportInfo', 3528cade320SKevin Wolf 'data': { 'id': 'str', 3538cade320SKevin Wolf 'type': 'BlockExportType', 3548cade320SKevin Wolf 'node-name': 'str', 3558cade320SKevin Wolf 'shutting-down': 'bool' } } 3568cade320SKevin Wolf 3578cade320SKevin Wolf## 3588cade320SKevin Wolf# @query-block-exports: 3598cade320SKevin Wolf# 3608cade320SKevin Wolf# Returns: A list of BlockExportInfo describing all block exports 3618cade320SKevin Wolf# 3628cade320SKevin Wolf# Since: 5.2 3638cade320SKevin Wolf## 3648cade320SKevin Wolf{ 'command': 'query-block-exports', 'returns': ['BlockExportInfo'] } 365