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# 57*9bc6e893SMarkus 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## 124b6076afcSKevin Wolf# @NbdServerAddOptions: 125b6076afcSKevin Wolf# 126cbad81ceSEric Blake# An NBD block export, per legacy nbd-server-add command. 127b6076afcSKevin Wolf# 128b6076afcSKevin Wolf# @device: The device name or node name of the node to be exported 129b6076afcSKevin Wolf# 13030dbc81dSKevin Wolf# @writable: Whether clients should be able to write to the device via the 13130dbc81dSKevin Wolf# NBD connection (default false). 13230dbc81dSKevin Wolf# 133cbad81ceSEric Blake# @bitmap: Also export a single dirty bitmap reachable from @device, so the 134cbad81ceSEric Blake# NBD client can use NBD_OPT_SET_META_CONTEXT with the metadata 135cbad81ceSEric Blake# context name "qemu:dirty-bitmap:BITMAP" to inspect the bitmap 136cbad81ceSEric Blake# (since 4.0). 137cbad81ceSEric Blake# 138b6076afcSKevin Wolf# Since: 5.0 139b6076afcSKevin Wolf## 140b6076afcSKevin Wolf{ 'struct': 'NbdServerAddOptions', 141cbad81ceSEric Blake 'base': 'BlockExportOptionsNbdBase', 14230dbc81dSKevin Wolf 'data': { 'device': 'str', 143cbad81ceSEric Blake '*writable': 'bool', '*bitmap': 'str' } } 144b6076afcSKevin Wolf 145b6076afcSKevin Wolf## 1465daa6bfdSKevin Wolf# @nbd-server-add: 1475daa6bfdSKevin Wolf# 1485daa6bfdSKevin Wolf# Export a block node to QEMU's embedded NBD server. 1495daa6bfdSKevin Wolf# 150d53be9ceSKevin Wolf# The export name will be used as the id for the resulting block export. 151d53be9ceSKevin Wolf# 152443127e8SKevin Wolf# Features: 153443127e8SKevin Wolf# @deprecated: This command is deprecated. Use @block-export-add instead. 154443127e8SKevin Wolf# 1555daa6bfdSKevin Wolf# Returns: error if the server is not running, or export with the same name 1565daa6bfdSKevin Wolf# already exists. 1575daa6bfdSKevin Wolf# 158*9bc6e893SMarkus Armbruster# Since: 1.3 1595daa6bfdSKevin Wolf## 1605daa6bfdSKevin Wolf{ 'command': 'nbd-server-add', 161443127e8SKevin Wolf 'data': 'NbdServerAddOptions', 'boxed': true, 'features': ['deprecated'] } 1625daa6bfdSKevin Wolf 1635daa6bfdSKevin Wolf## 1643c3bc462SKevin Wolf# @BlockExportRemoveMode: 1655daa6bfdSKevin Wolf# 1663c3bc462SKevin Wolf# Mode for removing a block export. 1675daa6bfdSKevin Wolf# 1685daa6bfdSKevin Wolf# @safe: Remove export if there are no existing connections, fail otherwise. 1695daa6bfdSKevin Wolf# 1705daa6bfdSKevin Wolf# @hard: Drop all connections immediately and remove export. 1715daa6bfdSKevin Wolf# 1725daa6bfdSKevin Wolf# Potential additional modes to be added in the future: 1735daa6bfdSKevin Wolf# 1745daa6bfdSKevin Wolf# hide: Just hide export from new clients, leave existing connections as is. 1755daa6bfdSKevin Wolf# Remove export after all clients are disconnected. 1765daa6bfdSKevin Wolf# 1775daa6bfdSKevin Wolf# soft: Hide export from new clients, answer with ESHUTDOWN for all further 1785daa6bfdSKevin Wolf# requests from existing clients. 1795daa6bfdSKevin Wolf# 1805daa6bfdSKevin Wolf# Since: 2.12 1815daa6bfdSKevin Wolf## 1823c3bc462SKevin Wolf{'enum': 'BlockExportRemoveMode', 'data': ['safe', 'hard']} 1835daa6bfdSKevin Wolf 1845daa6bfdSKevin Wolf## 1855daa6bfdSKevin Wolf# @nbd-server-remove: 1865daa6bfdSKevin Wolf# 1875daa6bfdSKevin Wolf# Remove NBD export by name. 1885daa6bfdSKevin Wolf# 1893c3bc462SKevin Wolf# @name: Block export id. 1905daa6bfdSKevin Wolf# 1913c3bc462SKevin Wolf# @mode: Mode of command operation. See @BlockExportRemoveMode description. 1925daa6bfdSKevin Wolf# Default is 'safe'. 1935daa6bfdSKevin Wolf# 194443127e8SKevin Wolf# Features: 195443127e8SKevin Wolf# @deprecated: This command is deprecated. Use @block-export-del instead. 196443127e8SKevin Wolf# 1975daa6bfdSKevin Wolf# Returns: error if 1985daa6bfdSKevin Wolf# - the server is not running 1995daa6bfdSKevin Wolf# - export is not found 2005daa6bfdSKevin Wolf# - mode is 'safe' and there are existing connections 2015daa6bfdSKevin Wolf# 2025daa6bfdSKevin Wolf# Since: 2.12 2035daa6bfdSKevin Wolf## 2045daa6bfdSKevin Wolf{ 'command': 'nbd-server-remove', 205443127e8SKevin Wolf 'data': {'name': 'str', '*mode': 'BlockExportRemoveMode'}, 206443127e8SKevin Wolf 'features': ['deprecated'] } 2075daa6bfdSKevin Wolf 2085daa6bfdSKevin Wolf## 2095daa6bfdSKevin Wolf# @nbd-server-stop: 2105daa6bfdSKevin Wolf# 2115daa6bfdSKevin Wolf# Stop QEMU's embedded NBD server, and unregister all devices previously 2125daa6bfdSKevin Wolf# added via @nbd-server-add. 2135daa6bfdSKevin Wolf# 214*9bc6e893SMarkus Armbruster# Since: 1.3 2155daa6bfdSKevin Wolf## 2165daa6bfdSKevin Wolf{ 'command': 'nbd-server-stop' } 2175daa6bfdSKevin Wolf 2185daa6bfdSKevin Wolf## 2195daa6bfdSKevin Wolf# @BlockExportType: 2205daa6bfdSKevin Wolf# 2215daa6bfdSKevin Wolf# An enumeration of block export types 2225daa6bfdSKevin Wolf# 2235daa6bfdSKevin Wolf# @nbd: NBD export 22490fc91d5SStefan Hajnoczi# @vhost-user-blk: vhost-user-blk export (since 5.2) 2255daa6bfdSKevin Wolf# 2265daa6bfdSKevin Wolf# Since: 4.2 2275daa6bfdSKevin Wolf## 2285daa6bfdSKevin Wolf{ 'enum': 'BlockExportType', 22990fc91d5SStefan Hajnoczi 'data': [ 'nbd', 'vhost-user-blk' ] } 2305daa6bfdSKevin Wolf 2315daa6bfdSKevin Wolf## 232143ea767SKevin Wolf# @BlockExportOptions: 2335daa6bfdSKevin Wolf# 2345daa6bfdSKevin Wolf# Describes a block export, i.e. how single node should be exported on an 2355daa6bfdSKevin Wolf# external interface. 2365daa6bfdSKevin Wolf# 237d53be9ceSKevin Wolf# @id: A unique identifier for the block export (across all export types) 238d53be9ceSKevin Wolf# 239b6076afcSKevin Wolf# @node-name: The node name of the block node to be exported (since: 5.2) 240b6076afcSKevin Wolf# 24130dbc81dSKevin Wolf# @writable: True if clients should be able to write to the export 24230dbc81dSKevin Wolf# (default false) 24330dbc81dSKevin Wolf# 244fefee85dSKevin Wolf# @writethrough: If true, caches are flushed after every write request to the 245fefee85dSKevin Wolf# export before completion is signalled. (since: 5.2; 246fefee85dSKevin Wolf# default: false) 247fefee85dSKevin Wolf# 248f51d23c8SStefan Hajnoczi# @iothread: The name of the iothread object where the export will run. The 249f51d23c8SStefan Hajnoczi# default is to use the thread currently associated with the 250f51d23c8SStefan Hajnoczi# block node. (since: 5.2) 251f51d23c8SStefan Hajnoczi# 252f51d23c8SStefan Hajnoczi# @fixed-iothread: True prevents the block node from being moved to another 253f51d23c8SStefan Hajnoczi# thread while the export is active. If true and @iothread is 254f51d23c8SStefan Hajnoczi# given, export creation fails if the block node cannot be 255f51d23c8SStefan Hajnoczi# moved to the iothread. The default is false. (since: 5.2) 256f51d23c8SStefan Hajnoczi# 2575daa6bfdSKevin Wolf# Since: 4.2 2585daa6bfdSKevin Wolf## 259143ea767SKevin Wolf{ 'union': 'BlockExportOptions', 260fefee85dSKevin Wolf 'base': { 'type': 'BlockExportType', 261d53be9ceSKevin Wolf 'id': 'str', 262f51d23c8SStefan Hajnoczi '*fixed-iothread': 'bool', 263f51d23c8SStefan Hajnoczi '*iothread': 'str', 264b6076afcSKevin Wolf 'node-name': 'str', 26530dbc81dSKevin Wolf '*writable': 'bool', 266fefee85dSKevin Wolf '*writethrough': 'bool' }, 2675daa6bfdSKevin Wolf 'discriminator': 'type', 2685daa6bfdSKevin Wolf 'data': { 26990fc91d5SStefan Hajnoczi 'nbd': 'BlockExportOptionsNbd', 27090fc91d5SStefan Hajnoczi 'vhost-user-blk': 'BlockExportOptionsVhostUserBlk' 2715daa6bfdSKevin Wolf } } 27256ee8626SKevin Wolf 27356ee8626SKevin Wolf## 27456ee8626SKevin Wolf# @block-export-add: 27556ee8626SKevin Wolf# 27656ee8626SKevin Wolf# Creates a new block export. 27756ee8626SKevin Wolf# 27856ee8626SKevin Wolf# Since: 5.2 27956ee8626SKevin Wolf## 28056ee8626SKevin Wolf{ 'command': 'block-export-add', 28156ee8626SKevin Wolf 'data': 'BlockExportOptions', 'boxed': true } 2823c3bc462SKevin Wolf 2833c3bc462SKevin Wolf## 2843c3bc462SKevin Wolf# @block-export-del: 2853c3bc462SKevin Wolf# 2863c3bc462SKevin Wolf# Request to remove a block export. This drops the user's reference to the 2873c3bc462SKevin Wolf# export, but the export may still stay around after this command returns until 2883c3bc462SKevin Wolf# the shutdown of the export has completed. 2893c3bc462SKevin Wolf# 2903c3bc462SKevin Wolf# @id: Block export id. 2913c3bc462SKevin Wolf# 2923c3bc462SKevin Wolf# @mode: Mode of command operation. See @BlockExportRemoveMode description. 2933c3bc462SKevin Wolf# Default is 'safe'. 2943c3bc462SKevin Wolf# 2953c3bc462SKevin Wolf# Returns: Error if the export is not found or @mode is 'safe' and the export 2963c3bc462SKevin Wolf# is still in use (e.g. by existing client connections) 2973c3bc462SKevin Wolf# 2983c3bc462SKevin Wolf# Since: 5.2 2993c3bc462SKevin Wolf## 3003c3bc462SKevin Wolf{ 'command': 'block-export-del', 3013c3bc462SKevin Wolf 'data': { 'id': 'str', '*mode': 'BlockExportRemoveMode' } } 3021a9f7a80SKevin Wolf 3031a9f7a80SKevin Wolf## 3041a9f7a80SKevin Wolf# @BLOCK_EXPORT_DELETED: 3051a9f7a80SKevin Wolf# 3061a9f7a80SKevin Wolf# Emitted when a block export is removed and its id can be reused. 3071a9f7a80SKevin Wolf# 3081a9f7a80SKevin Wolf# @id: Block export id. 3091a9f7a80SKevin Wolf# 3101a9f7a80SKevin Wolf# Since: 5.2 3111a9f7a80SKevin Wolf## 3121a9f7a80SKevin Wolf{ 'event': 'BLOCK_EXPORT_DELETED', 3131a9f7a80SKevin Wolf 'data': { 'id': 'str' } } 3148cade320SKevin Wolf 3158cade320SKevin Wolf## 3168cade320SKevin Wolf# @BlockExportInfo: 3178cade320SKevin Wolf# 3188cade320SKevin Wolf# Information about a single block export. 3198cade320SKevin Wolf# 3208cade320SKevin Wolf# @id: The unique identifier for the block export 3218cade320SKevin Wolf# 3228cade320SKevin Wolf# @type: The block export type 3238cade320SKevin Wolf# 3248cade320SKevin Wolf# @node-name: The node name of the block node that is exported 3258cade320SKevin Wolf# 3268cade320SKevin Wolf# @shutting-down: True if the export is shutting down (e.g. after a 3278cade320SKevin Wolf# block-export-del command, but before the shutdown has 3288cade320SKevin Wolf# completed) 3298cade320SKevin Wolf# 3308cade320SKevin Wolf# Since: 5.2 3318cade320SKevin Wolf## 3328cade320SKevin Wolf{ 'struct': 'BlockExportInfo', 3338cade320SKevin Wolf 'data': { 'id': 'str', 3348cade320SKevin Wolf 'type': 'BlockExportType', 3358cade320SKevin Wolf 'node-name': 'str', 3368cade320SKevin Wolf 'shutting-down': 'bool' } } 3378cade320SKevin Wolf 3388cade320SKevin Wolf## 3398cade320SKevin Wolf# @query-block-exports: 3408cade320SKevin Wolf# 3418cade320SKevin Wolf# Returns: A list of BlockExportInfo describing all block exports 3428cade320SKevin Wolf# 3438cade320SKevin Wolf# Since: 5.2 3448cade320SKevin Wolf## 3458cade320SKevin Wolf{ 'command': 'query-block-exports', 'returns': ['BlockExportInfo'] } 346