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# @writable: Whether clients should be able to write to the device via the 785daa6bfdSKevin Wolf# NBD connection (default false). 795daa6bfdSKevin Wolf# 805daa6bfdSKevin Wolf# @bitmap: Also export the dirty bitmap reachable from @device, so the 815daa6bfdSKevin Wolf# NBD client can use NBD_OPT_SET_META_CONTEXT with 825daa6bfdSKevin Wolf# "qemu:dirty-bitmap:NAME" to inspect the bitmap. (since 4.0) 835daa6bfdSKevin Wolf# 845daa6bfdSKevin Wolf# Since: 5.0 855daa6bfdSKevin Wolf## 86143ea767SKevin Wolf{ 'struct': 'BlockExportOptionsNbd', 87b6076afcSKevin Wolf 'data': { '*name': 'str', '*description': 'str', 885daa6bfdSKevin Wolf '*writable': 'bool', '*bitmap': 'str' } } 895daa6bfdSKevin Wolf 905daa6bfdSKevin Wolf## 91b6076afcSKevin Wolf# @NbdServerAddOptions: 92b6076afcSKevin Wolf# 93b6076afcSKevin Wolf# An NBD block export. 94b6076afcSKevin Wolf# 95b6076afcSKevin Wolf# @device: The device name or node name of the node to be exported 96b6076afcSKevin Wolf# 97b6076afcSKevin Wolf# Since: 5.0 98b6076afcSKevin Wolf## 99b6076afcSKevin Wolf{ 'struct': 'NbdServerAddOptions', 100b6076afcSKevin Wolf 'base': 'BlockExportOptionsNbd', 101b6076afcSKevin Wolf 'data': { 'device': 'str' } } 102b6076afcSKevin Wolf 103b6076afcSKevin Wolf## 1045daa6bfdSKevin Wolf# @nbd-server-add: 1055daa6bfdSKevin Wolf# 1065daa6bfdSKevin Wolf# Export a block node to QEMU's embedded NBD server. 1075daa6bfdSKevin Wolf# 108d53be9ceSKevin Wolf# The export name will be used as the id for the resulting block export. 109d53be9ceSKevin Wolf# 1105daa6bfdSKevin Wolf# Returns: error if the server is not running, or export with the same name 1115daa6bfdSKevin Wolf# already exists. 1125daa6bfdSKevin Wolf# 1135daa6bfdSKevin Wolf# Since: 1.3.0 1145daa6bfdSKevin Wolf## 1155daa6bfdSKevin Wolf{ 'command': 'nbd-server-add', 116b6076afcSKevin Wolf 'data': 'NbdServerAddOptions', 'boxed': true } 1175daa6bfdSKevin Wolf 1185daa6bfdSKevin Wolf## 1193c3bc462SKevin Wolf# @BlockExportRemoveMode: 1205daa6bfdSKevin Wolf# 1213c3bc462SKevin Wolf# Mode for removing a block export. 1225daa6bfdSKevin Wolf# 1235daa6bfdSKevin Wolf# @safe: Remove export if there are no existing connections, fail otherwise. 1245daa6bfdSKevin Wolf# 1255daa6bfdSKevin Wolf# @hard: Drop all connections immediately and remove export. 1265daa6bfdSKevin Wolf# 1275daa6bfdSKevin Wolf# Potential additional modes to be added in the future: 1285daa6bfdSKevin Wolf# 1295daa6bfdSKevin Wolf# hide: Just hide export from new clients, leave existing connections as is. 1305daa6bfdSKevin Wolf# Remove export after all clients are disconnected. 1315daa6bfdSKevin Wolf# 1325daa6bfdSKevin Wolf# soft: Hide export from new clients, answer with ESHUTDOWN for all further 1335daa6bfdSKevin Wolf# requests from existing clients. 1345daa6bfdSKevin Wolf# 1355daa6bfdSKevin Wolf# Since: 2.12 1365daa6bfdSKevin Wolf## 1373c3bc462SKevin Wolf{'enum': 'BlockExportRemoveMode', 'data': ['safe', 'hard']} 1385daa6bfdSKevin Wolf 1395daa6bfdSKevin Wolf## 1405daa6bfdSKevin Wolf# @nbd-server-remove: 1415daa6bfdSKevin Wolf# 1425daa6bfdSKevin Wolf# Remove NBD export by name. 1435daa6bfdSKevin Wolf# 1443c3bc462SKevin Wolf# @name: Block export id. 1455daa6bfdSKevin Wolf# 1463c3bc462SKevin Wolf# @mode: Mode of command operation. See @BlockExportRemoveMode description. 1475daa6bfdSKevin Wolf# Default is 'safe'. 1485daa6bfdSKevin Wolf# 1495daa6bfdSKevin Wolf# Returns: error if 1505daa6bfdSKevin Wolf# - the server is not running 1515daa6bfdSKevin Wolf# - export is not found 1525daa6bfdSKevin Wolf# - mode is 'safe' and there are existing connections 1535daa6bfdSKevin Wolf# 1545daa6bfdSKevin Wolf# Since: 2.12 1555daa6bfdSKevin Wolf## 1565daa6bfdSKevin Wolf{ 'command': 'nbd-server-remove', 1573c3bc462SKevin Wolf 'data': {'name': 'str', '*mode': 'BlockExportRemoveMode'} } 1585daa6bfdSKevin Wolf 1595daa6bfdSKevin Wolf## 1605daa6bfdSKevin Wolf# @nbd-server-stop: 1615daa6bfdSKevin Wolf# 1625daa6bfdSKevin Wolf# Stop QEMU's embedded NBD server, and unregister all devices previously 1635daa6bfdSKevin Wolf# added via @nbd-server-add. 1645daa6bfdSKevin Wolf# 1655daa6bfdSKevin Wolf# Since: 1.3.0 1665daa6bfdSKevin Wolf## 1675daa6bfdSKevin Wolf{ 'command': 'nbd-server-stop' } 1685daa6bfdSKevin Wolf 1695daa6bfdSKevin Wolf## 1705daa6bfdSKevin Wolf# @BlockExportType: 1715daa6bfdSKevin Wolf# 1725daa6bfdSKevin Wolf# An enumeration of block export types 1735daa6bfdSKevin Wolf# 1745daa6bfdSKevin Wolf# @nbd: NBD export 1755daa6bfdSKevin Wolf# 1765daa6bfdSKevin Wolf# Since: 4.2 1775daa6bfdSKevin Wolf## 1785daa6bfdSKevin Wolf{ 'enum': 'BlockExportType', 1795daa6bfdSKevin Wolf 'data': [ 'nbd' ] } 1805daa6bfdSKevin Wolf 1815daa6bfdSKevin Wolf## 182143ea767SKevin Wolf# @BlockExportOptions: 1835daa6bfdSKevin Wolf# 1845daa6bfdSKevin Wolf# Describes a block export, i.e. how single node should be exported on an 1855daa6bfdSKevin Wolf# external interface. 1865daa6bfdSKevin Wolf# 187d53be9ceSKevin Wolf# @id: A unique identifier for the block export (across all export types) 188d53be9ceSKevin Wolf# 189b6076afcSKevin Wolf# @node-name: The node name of the block node to be exported (since: 5.2) 190b6076afcSKevin Wolf# 191fefee85dSKevin Wolf# @writethrough: If true, caches are flushed after every write request to the 192fefee85dSKevin Wolf# export before completion is signalled. (since: 5.2; 193fefee85dSKevin Wolf# default: false) 194fefee85dSKevin Wolf# 1955daa6bfdSKevin Wolf# Since: 4.2 1965daa6bfdSKevin Wolf## 197143ea767SKevin Wolf{ 'union': 'BlockExportOptions', 198fefee85dSKevin Wolf 'base': { 'type': 'BlockExportType', 199d53be9ceSKevin Wolf 'id': 'str', 200b6076afcSKevin Wolf 'node-name': 'str', 201fefee85dSKevin Wolf '*writethrough': 'bool' }, 2025daa6bfdSKevin Wolf 'discriminator': 'type', 2035daa6bfdSKevin Wolf 'data': { 204143ea767SKevin Wolf 'nbd': 'BlockExportOptionsNbd' 2055daa6bfdSKevin Wolf } } 20656ee8626SKevin Wolf 20756ee8626SKevin Wolf## 20856ee8626SKevin Wolf# @block-export-add: 20956ee8626SKevin Wolf# 21056ee8626SKevin Wolf# Creates a new block export. 21156ee8626SKevin Wolf# 21256ee8626SKevin Wolf# Since: 5.2 21356ee8626SKevin Wolf## 21456ee8626SKevin Wolf{ 'command': 'block-export-add', 21556ee8626SKevin Wolf 'data': 'BlockExportOptions', 'boxed': true } 2163c3bc462SKevin Wolf 2173c3bc462SKevin Wolf## 2183c3bc462SKevin Wolf# @block-export-del: 2193c3bc462SKevin Wolf# 2203c3bc462SKevin Wolf# Request to remove a block export. This drops the user's reference to the 2213c3bc462SKevin Wolf# export, but the export may still stay around after this command returns until 2223c3bc462SKevin Wolf# the shutdown of the export has completed. 2233c3bc462SKevin Wolf# 2243c3bc462SKevin Wolf# @id: Block export id. 2253c3bc462SKevin Wolf# 2263c3bc462SKevin Wolf# @mode: Mode of command operation. See @BlockExportRemoveMode description. 2273c3bc462SKevin Wolf# Default is 'safe'. 2283c3bc462SKevin Wolf# 2293c3bc462SKevin Wolf# Returns: Error if the export is not found or @mode is 'safe' and the export 2303c3bc462SKevin Wolf# is still in use (e.g. by existing client connections) 2313c3bc462SKevin Wolf# 2323c3bc462SKevin Wolf# Since: 5.2 2333c3bc462SKevin Wolf## 2343c3bc462SKevin Wolf{ 'command': 'block-export-del', 2353c3bc462SKevin Wolf 'data': { 'id': 'str', '*mode': 'BlockExportRemoveMode' } } 236*1a9f7a80SKevin Wolf 237*1a9f7a80SKevin Wolf## 238*1a9f7a80SKevin Wolf# @BLOCK_EXPORT_DELETED: 239*1a9f7a80SKevin Wolf# 240*1a9f7a80SKevin Wolf# Emitted when a block export is removed and its id can be reused. 241*1a9f7a80SKevin Wolf# 242*1a9f7a80SKevin Wolf# @id: Block export id. 243*1a9f7a80SKevin Wolf# 244*1a9f7a80SKevin Wolf# Since: 5.2 245*1a9f7a80SKevin Wolf## 246*1a9f7a80SKevin Wolf{ 'event': 'BLOCK_EXPORT_DELETED', 247*1a9f7a80SKevin Wolf 'data': { 'id': 'str' } } 248