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# 575daa6bfdSKevin Wolf# Since: 1.3.0 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## 66143ea767SKevin Wolf# @BlockExportOptionsNbd: 675daa6bfdSKevin Wolf# 68b6076afcSKevin Wolf# An NBD block export (options shared between nbd-server-add and the NBD branch 69b6076afcSKevin Wolf# 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# @bitmap: Also export the dirty bitmap reachable from @device, so the 785daa6bfdSKevin Wolf# NBD client can use NBD_OPT_SET_META_CONTEXT with 795daa6bfdSKevin Wolf# "qemu:dirty-bitmap:NAME" to inspect the bitmap. (since 4.0) 805daa6bfdSKevin Wolf# 815daa6bfdSKevin Wolf# Since: 5.0 825daa6bfdSKevin Wolf## 83143ea767SKevin Wolf{ 'struct': 'BlockExportOptionsNbd', 84b6076afcSKevin Wolf 'data': { '*name': 'str', '*description': 'str', 8530dbc81dSKevin Wolf '*bitmap': 'str' } } 865daa6bfdSKevin Wolf 875daa6bfdSKevin Wolf## 8890fc91d5SStefan Hajnoczi# @BlockExportOptionsVhostUserBlk: 8990fc91d5SStefan Hajnoczi# 9090fc91d5SStefan Hajnoczi# A vhost-user-blk block export. 9190fc91d5SStefan Hajnoczi# 9290fc91d5SStefan Hajnoczi# @addr: The vhost-user socket on which to listen. Both 'unix' and 'fd' 9390fc91d5SStefan Hajnoczi# SocketAddress types are supported. Passed fds must be UNIX domain 9490fc91d5SStefan Hajnoczi# sockets. 9590fc91d5SStefan Hajnoczi# @logical-block-size: Logical block size in bytes. Defaults to 512 bytes. 96*d9b495f9SStefan Hajnoczi# @num-queues: Number of request virtqueues. Must be greater than 0. Defaults 97*d9b495f9SStefan Hajnoczi# to 1. 9890fc91d5SStefan Hajnoczi# 9990fc91d5SStefan Hajnoczi# Since: 5.2 10090fc91d5SStefan Hajnoczi## 10190fc91d5SStefan Hajnoczi{ 'struct': 'BlockExportOptionsVhostUserBlk', 102*d9b495f9SStefan Hajnoczi 'data': { 'addr': 'SocketAddress', 103*d9b495f9SStefan Hajnoczi '*logical-block-size': 'size', 104*d9b495f9SStefan Hajnoczi '*num-queues': 'uint16'} } 10590fc91d5SStefan Hajnoczi 10690fc91d5SStefan Hajnoczi## 107b6076afcSKevin Wolf# @NbdServerAddOptions: 108b6076afcSKevin Wolf# 109b6076afcSKevin Wolf# An NBD block export. 110b6076afcSKevin Wolf# 111b6076afcSKevin Wolf# @device: The device name or node name of the node to be exported 112b6076afcSKevin Wolf# 11330dbc81dSKevin Wolf# @writable: Whether clients should be able to write to the device via the 11430dbc81dSKevin Wolf# NBD connection (default false). 11530dbc81dSKevin Wolf# 116b6076afcSKevin Wolf# Since: 5.0 117b6076afcSKevin Wolf## 118b6076afcSKevin Wolf{ 'struct': 'NbdServerAddOptions', 119b6076afcSKevin Wolf 'base': 'BlockExportOptionsNbd', 12030dbc81dSKevin Wolf 'data': { 'device': 'str', 12130dbc81dSKevin Wolf '*writable': 'bool' } } 122b6076afcSKevin Wolf 123b6076afcSKevin Wolf## 1245daa6bfdSKevin Wolf# @nbd-server-add: 1255daa6bfdSKevin Wolf# 1265daa6bfdSKevin Wolf# Export a block node to QEMU's embedded NBD server. 1275daa6bfdSKevin Wolf# 128d53be9ceSKevin Wolf# The export name will be used as the id for the resulting block export. 129d53be9ceSKevin Wolf# 130443127e8SKevin Wolf# Features: 131443127e8SKevin Wolf# @deprecated: This command is deprecated. Use @block-export-add instead. 132443127e8SKevin Wolf# 1335daa6bfdSKevin Wolf# Returns: error if the server is not running, or export with the same name 1345daa6bfdSKevin Wolf# already exists. 1355daa6bfdSKevin Wolf# 1365daa6bfdSKevin Wolf# Since: 1.3.0 1375daa6bfdSKevin Wolf## 1385daa6bfdSKevin Wolf{ 'command': 'nbd-server-add', 139443127e8SKevin Wolf 'data': 'NbdServerAddOptions', 'boxed': true, 'features': ['deprecated'] } 1405daa6bfdSKevin Wolf 1415daa6bfdSKevin Wolf## 1423c3bc462SKevin Wolf# @BlockExportRemoveMode: 1435daa6bfdSKevin Wolf# 1443c3bc462SKevin Wolf# Mode for removing a block export. 1455daa6bfdSKevin Wolf# 1465daa6bfdSKevin Wolf# @safe: Remove export if there are no existing connections, fail otherwise. 1475daa6bfdSKevin Wolf# 1485daa6bfdSKevin Wolf# @hard: Drop all connections immediately and remove export. 1495daa6bfdSKevin Wolf# 1505daa6bfdSKevin Wolf# Potential additional modes to be added in the future: 1515daa6bfdSKevin Wolf# 1525daa6bfdSKevin Wolf# hide: Just hide export from new clients, leave existing connections as is. 1535daa6bfdSKevin Wolf# Remove export after all clients are disconnected. 1545daa6bfdSKevin Wolf# 1555daa6bfdSKevin Wolf# soft: Hide export from new clients, answer with ESHUTDOWN for all further 1565daa6bfdSKevin Wolf# requests from existing clients. 1575daa6bfdSKevin Wolf# 1585daa6bfdSKevin Wolf# Since: 2.12 1595daa6bfdSKevin Wolf## 1603c3bc462SKevin Wolf{'enum': 'BlockExportRemoveMode', 'data': ['safe', 'hard']} 1615daa6bfdSKevin Wolf 1625daa6bfdSKevin Wolf## 1635daa6bfdSKevin Wolf# @nbd-server-remove: 1645daa6bfdSKevin Wolf# 1655daa6bfdSKevin Wolf# Remove NBD export by name. 1665daa6bfdSKevin Wolf# 1673c3bc462SKevin Wolf# @name: Block export id. 1685daa6bfdSKevin Wolf# 1693c3bc462SKevin Wolf# @mode: Mode of command operation. See @BlockExportRemoveMode description. 1705daa6bfdSKevin Wolf# Default is 'safe'. 1715daa6bfdSKevin Wolf# 172443127e8SKevin Wolf# Features: 173443127e8SKevin Wolf# @deprecated: This command is deprecated. Use @block-export-del instead. 174443127e8SKevin Wolf# 1755daa6bfdSKevin Wolf# Returns: error if 1765daa6bfdSKevin Wolf# - the server is not running 1775daa6bfdSKevin Wolf# - export is not found 1785daa6bfdSKevin Wolf# - mode is 'safe' and there are existing connections 1795daa6bfdSKevin Wolf# 1805daa6bfdSKevin Wolf# Since: 2.12 1815daa6bfdSKevin Wolf## 1825daa6bfdSKevin Wolf{ 'command': 'nbd-server-remove', 183443127e8SKevin Wolf 'data': {'name': 'str', '*mode': 'BlockExportRemoveMode'}, 184443127e8SKevin Wolf 'features': ['deprecated'] } 1855daa6bfdSKevin Wolf 1865daa6bfdSKevin Wolf## 1875daa6bfdSKevin Wolf# @nbd-server-stop: 1885daa6bfdSKevin Wolf# 1895daa6bfdSKevin Wolf# Stop QEMU's embedded NBD server, and unregister all devices previously 1905daa6bfdSKevin Wolf# added via @nbd-server-add. 1915daa6bfdSKevin Wolf# 1925daa6bfdSKevin Wolf# Since: 1.3.0 1935daa6bfdSKevin Wolf## 1945daa6bfdSKevin Wolf{ 'command': 'nbd-server-stop' } 1955daa6bfdSKevin Wolf 1965daa6bfdSKevin Wolf## 1975daa6bfdSKevin Wolf# @BlockExportType: 1985daa6bfdSKevin Wolf# 1995daa6bfdSKevin Wolf# An enumeration of block export types 2005daa6bfdSKevin Wolf# 2015daa6bfdSKevin Wolf# @nbd: NBD export 20290fc91d5SStefan Hajnoczi# @vhost-user-blk: vhost-user-blk export (since 5.2) 2035daa6bfdSKevin Wolf# 2045daa6bfdSKevin Wolf# Since: 4.2 2055daa6bfdSKevin Wolf## 2065daa6bfdSKevin Wolf{ 'enum': 'BlockExportType', 20790fc91d5SStefan Hajnoczi 'data': [ 'nbd', 'vhost-user-blk' ] } 2085daa6bfdSKevin Wolf 2095daa6bfdSKevin Wolf## 210143ea767SKevin Wolf# @BlockExportOptions: 2115daa6bfdSKevin Wolf# 2125daa6bfdSKevin Wolf# Describes a block export, i.e. how single node should be exported on an 2135daa6bfdSKevin Wolf# external interface. 2145daa6bfdSKevin Wolf# 215d53be9ceSKevin Wolf# @id: A unique identifier for the block export (across all export types) 216d53be9ceSKevin Wolf# 217b6076afcSKevin Wolf# @node-name: The node name of the block node to be exported (since: 5.2) 218b6076afcSKevin Wolf# 21930dbc81dSKevin Wolf# @writable: True if clients should be able to write to the export 22030dbc81dSKevin Wolf# (default false) 22130dbc81dSKevin Wolf# 222fefee85dSKevin Wolf# @writethrough: If true, caches are flushed after every write request to the 223fefee85dSKevin Wolf# export before completion is signalled. (since: 5.2; 224fefee85dSKevin Wolf# default: false) 225fefee85dSKevin Wolf# 226f51d23c8SStefan Hajnoczi# @iothread: The name of the iothread object where the export will run. The 227f51d23c8SStefan Hajnoczi# default is to use the thread currently associated with the 228f51d23c8SStefan Hajnoczi# block node. (since: 5.2) 229f51d23c8SStefan Hajnoczi# 230f51d23c8SStefan Hajnoczi# @fixed-iothread: True prevents the block node from being moved to another 231f51d23c8SStefan Hajnoczi# thread while the export is active. If true and @iothread is 232f51d23c8SStefan Hajnoczi# given, export creation fails if the block node cannot be 233f51d23c8SStefan Hajnoczi# moved to the iothread. The default is false. (since: 5.2) 234f51d23c8SStefan Hajnoczi# 2355daa6bfdSKevin Wolf# Since: 4.2 2365daa6bfdSKevin Wolf## 237143ea767SKevin Wolf{ 'union': 'BlockExportOptions', 238fefee85dSKevin Wolf 'base': { 'type': 'BlockExportType', 239d53be9ceSKevin Wolf 'id': 'str', 240f51d23c8SStefan Hajnoczi '*fixed-iothread': 'bool', 241f51d23c8SStefan Hajnoczi '*iothread': 'str', 242b6076afcSKevin Wolf 'node-name': 'str', 24330dbc81dSKevin Wolf '*writable': 'bool', 244fefee85dSKevin Wolf '*writethrough': 'bool' }, 2455daa6bfdSKevin Wolf 'discriminator': 'type', 2465daa6bfdSKevin Wolf 'data': { 24790fc91d5SStefan Hajnoczi 'nbd': 'BlockExportOptionsNbd', 24890fc91d5SStefan Hajnoczi 'vhost-user-blk': 'BlockExportOptionsVhostUserBlk' 2495daa6bfdSKevin Wolf } } 25056ee8626SKevin Wolf 25156ee8626SKevin Wolf## 25256ee8626SKevin Wolf# @block-export-add: 25356ee8626SKevin Wolf# 25456ee8626SKevin Wolf# Creates a new block export. 25556ee8626SKevin Wolf# 25656ee8626SKevin Wolf# Since: 5.2 25756ee8626SKevin Wolf## 25856ee8626SKevin Wolf{ 'command': 'block-export-add', 25956ee8626SKevin Wolf 'data': 'BlockExportOptions', 'boxed': true } 2603c3bc462SKevin Wolf 2613c3bc462SKevin Wolf## 2623c3bc462SKevin Wolf# @block-export-del: 2633c3bc462SKevin Wolf# 2643c3bc462SKevin Wolf# Request to remove a block export. This drops the user's reference to the 2653c3bc462SKevin Wolf# export, but the export may still stay around after this command returns until 2663c3bc462SKevin Wolf# the shutdown of the export has completed. 2673c3bc462SKevin Wolf# 2683c3bc462SKevin Wolf# @id: Block export id. 2693c3bc462SKevin Wolf# 2703c3bc462SKevin Wolf# @mode: Mode of command operation. See @BlockExportRemoveMode description. 2713c3bc462SKevin Wolf# Default is 'safe'. 2723c3bc462SKevin Wolf# 2733c3bc462SKevin Wolf# Returns: Error if the export is not found or @mode is 'safe' and the export 2743c3bc462SKevin Wolf# is still in use (e.g. by existing client connections) 2753c3bc462SKevin Wolf# 2763c3bc462SKevin Wolf# Since: 5.2 2773c3bc462SKevin Wolf## 2783c3bc462SKevin Wolf{ 'command': 'block-export-del', 2793c3bc462SKevin Wolf 'data': { 'id': 'str', '*mode': 'BlockExportRemoveMode' } } 2801a9f7a80SKevin Wolf 2811a9f7a80SKevin Wolf## 2821a9f7a80SKevin Wolf# @BLOCK_EXPORT_DELETED: 2831a9f7a80SKevin Wolf# 2841a9f7a80SKevin Wolf# Emitted when a block export is removed and its id can be reused. 2851a9f7a80SKevin Wolf# 2861a9f7a80SKevin Wolf# @id: Block export id. 2871a9f7a80SKevin Wolf# 2881a9f7a80SKevin Wolf# Since: 5.2 2891a9f7a80SKevin Wolf## 2901a9f7a80SKevin Wolf{ 'event': 'BLOCK_EXPORT_DELETED', 2911a9f7a80SKevin Wolf 'data': { 'id': 'str' } } 2928cade320SKevin Wolf 2938cade320SKevin Wolf## 2948cade320SKevin Wolf# @BlockExportInfo: 2958cade320SKevin Wolf# 2968cade320SKevin Wolf# Information about a single block export. 2978cade320SKevin Wolf# 2988cade320SKevin Wolf# @id: The unique identifier for the block export 2998cade320SKevin Wolf# 3008cade320SKevin Wolf# @type: The block export type 3018cade320SKevin Wolf# 3028cade320SKevin Wolf# @node-name: The node name of the block node that is exported 3038cade320SKevin Wolf# 3048cade320SKevin Wolf# @shutting-down: True if the export is shutting down (e.g. after a 3058cade320SKevin Wolf# block-export-del command, but before the shutdown has 3068cade320SKevin Wolf# completed) 3078cade320SKevin Wolf# 3088cade320SKevin Wolf# Since: 5.2 3098cade320SKevin Wolf## 3108cade320SKevin Wolf{ 'struct': 'BlockExportInfo', 3118cade320SKevin Wolf 'data': { 'id': 'str', 3128cade320SKevin Wolf 'type': 'BlockExportType', 3138cade320SKevin Wolf 'node-name': 'str', 3148cade320SKevin Wolf 'shutting-down': 'bool' } } 3158cade320SKevin Wolf 3168cade320SKevin Wolf## 3178cade320SKevin Wolf# @query-block-exports: 3188cade320SKevin Wolf# 3198cade320SKevin Wolf# Returns: A list of BlockExportInfo describing all block exports 3208cade320SKevin Wolf# 3218cade320SKevin Wolf# Since: 5.2 3228cade320SKevin Wolf## 3238cade320SKevin Wolf{ 'command': 'query-block-exports', 'returns': ['BlockExportInfo'] } 324