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). 235daa6bfdSKevin Wolf# 245daa6bfdSKevin Wolf# Since: 4.2 255daa6bfdSKevin Wolf## 265daa6bfdSKevin Wolf{ 'struct': 'NbdServerOptions', 275daa6bfdSKevin Wolf 'data': { 'addr': 'SocketAddress', 285daa6bfdSKevin Wolf '*tls-creds': 'str', 295daa6bfdSKevin Wolf '*tls-authz': 'str'} } 305daa6bfdSKevin Wolf 315daa6bfdSKevin Wolf## 325daa6bfdSKevin Wolf# @nbd-server-start: 335daa6bfdSKevin Wolf# 345daa6bfdSKevin Wolf# Start an NBD server listening on the given host and port. Block 355daa6bfdSKevin Wolf# devices can then be exported using @nbd-server-add. The NBD 365daa6bfdSKevin Wolf# server will present them as named exports; for example, another 375daa6bfdSKevin Wolf# QEMU instance could refer to them as "nbd:HOST:PORT:exportname=NAME". 385daa6bfdSKevin Wolf# 395daa6bfdSKevin Wolf# Keep this type consistent with the NbdServerOptions type. The only intended 405daa6bfdSKevin Wolf# difference is using SocketAddressLegacy instead of SocketAddress. 415daa6bfdSKevin Wolf# 425daa6bfdSKevin Wolf# @addr: Address on which to listen. 435daa6bfdSKevin Wolf# @tls-creds: ID of the TLS credentials object (since 2.6). 445daa6bfdSKevin Wolf# @tls-authz: ID of the QAuthZ authorization object used to validate 455daa6bfdSKevin Wolf# the client's x509 distinguished name. This object is 465daa6bfdSKevin Wolf# is only resolved at time of use, so can be deleted and 475daa6bfdSKevin Wolf# recreated on the fly while the NBD server is active. 485daa6bfdSKevin Wolf# If missing, it will default to denying access (since 4.0). 495daa6bfdSKevin Wolf# 505daa6bfdSKevin Wolf# Returns: error if the server is already running. 515daa6bfdSKevin Wolf# 525daa6bfdSKevin Wolf# Since: 1.3.0 535daa6bfdSKevin Wolf## 545daa6bfdSKevin Wolf{ 'command': 'nbd-server-start', 555daa6bfdSKevin Wolf 'data': { 'addr': 'SocketAddressLegacy', 565daa6bfdSKevin Wolf '*tls-creds': 'str', 575daa6bfdSKevin Wolf '*tls-authz': 'str'} } 585daa6bfdSKevin Wolf 595daa6bfdSKevin Wolf## 60143ea767SKevin Wolf# @BlockExportOptionsNbd: 615daa6bfdSKevin Wolf# 625daa6bfdSKevin Wolf# An NBD block export. 635daa6bfdSKevin Wolf# 645daa6bfdSKevin Wolf# @device: The device name or node name of the node to be exported 655daa6bfdSKevin Wolf# 665daa6bfdSKevin Wolf# @name: Export name. If unspecified, the @device parameter is used as the 675daa6bfdSKevin Wolf# export name. (Since 2.12) 685daa6bfdSKevin Wolf# 695daa6bfdSKevin Wolf# @description: Free-form description of the export, up to 4096 bytes. 705daa6bfdSKevin Wolf# (Since 5.0) 715daa6bfdSKevin Wolf# 725daa6bfdSKevin Wolf# @writable: Whether clients should be able to write to the device via the 735daa6bfdSKevin Wolf# NBD connection (default false). 745daa6bfdSKevin Wolf# 755daa6bfdSKevin Wolf# @bitmap: Also export the dirty bitmap reachable from @device, so the 765daa6bfdSKevin Wolf# NBD client can use NBD_OPT_SET_META_CONTEXT with 775daa6bfdSKevin Wolf# "qemu:dirty-bitmap:NAME" to inspect the bitmap. (since 4.0) 785daa6bfdSKevin Wolf# 795daa6bfdSKevin Wolf# Since: 5.0 805daa6bfdSKevin Wolf## 81143ea767SKevin Wolf{ 'struct': 'BlockExportOptionsNbd', 825daa6bfdSKevin Wolf 'data': {'device': 'str', '*name': 'str', '*description': 'str', 835daa6bfdSKevin Wolf '*writable': 'bool', '*bitmap': 'str' } } 845daa6bfdSKevin Wolf 855daa6bfdSKevin Wolf## 865daa6bfdSKevin Wolf# @nbd-server-add: 875daa6bfdSKevin Wolf# 885daa6bfdSKevin Wolf# Export a block node to QEMU's embedded NBD server. 895daa6bfdSKevin Wolf# 905daa6bfdSKevin Wolf# Returns: error if the server is not running, or export with the same name 915daa6bfdSKevin Wolf# already exists. 925daa6bfdSKevin Wolf# 935daa6bfdSKevin Wolf# Since: 1.3.0 945daa6bfdSKevin Wolf## 955daa6bfdSKevin Wolf{ 'command': 'nbd-server-add', 96143ea767SKevin Wolf 'data': 'BlockExportOptionsNbd', 'boxed': true } 975daa6bfdSKevin Wolf 985daa6bfdSKevin Wolf## 995daa6bfdSKevin Wolf# @NbdServerRemoveMode: 1005daa6bfdSKevin Wolf# 1015daa6bfdSKevin Wolf# Mode for removing an NBD export. 1025daa6bfdSKevin Wolf# 1035daa6bfdSKevin Wolf# @safe: Remove export if there are no existing connections, fail otherwise. 1045daa6bfdSKevin Wolf# 1055daa6bfdSKevin Wolf# @hard: Drop all connections immediately and remove export. 1065daa6bfdSKevin Wolf# 1075daa6bfdSKevin Wolf# Potential additional modes to be added in the future: 1085daa6bfdSKevin Wolf# 1095daa6bfdSKevin Wolf# hide: Just hide export from new clients, leave existing connections as is. 1105daa6bfdSKevin Wolf# Remove export after all clients are disconnected. 1115daa6bfdSKevin Wolf# 1125daa6bfdSKevin Wolf# soft: Hide export from new clients, answer with ESHUTDOWN for all further 1135daa6bfdSKevin Wolf# requests from existing clients. 1145daa6bfdSKevin Wolf# 1155daa6bfdSKevin Wolf# Since: 2.12 1165daa6bfdSKevin Wolf## 1175daa6bfdSKevin Wolf{'enum': 'NbdServerRemoveMode', 'data': ['safe', 'hard']} 1185daa6bfdSKevin Wolf 1195daa6bfdSKevin Wolf## 1205daa6bfdSKevin Wolf# @nbd-server-remove: 1215daa6bfdSKevin Wolf# 1225daa6bfdSKevin Wolf# Remove NBD export by name. 1235daa6bfdSKevin Wolf# 1245daa6bfdSKevin Wolf# @name: Export name. 1255daa6bfdSKevin Wolf# 1265daa6bfdSKevin Wolf# @mode: Mode of command operation. See @NbdServerRemoveMode description. 1275daa6bfdSKevin Wolf# Default is 'safe'. 1285daa6bfdSKevin Wolf# 1295daa6bfdSKevin Wolf# Returns: error if 1305daa6bfdSKevin Wolf# - the server is not running 1315daa6bfdSKevin Wolf# - export is not found 1325daa6bfdSKevin Wolf# - mode is 'safe' and there are existing connections 1335daa6bfdSKevin Wolf# 1345daa6bfdSKevin Wolf# Since: 2.12 1355daa6bfdSKevin Wolf## 1365daa6bfdSKevin Wolf{ 'command': 'nbd-server-remove', 1375daa6bfdSKevin Wolf 'data': {'name': 'str', '*mode': 'NbdServerRemoveMode'} } 1385daa6bfdSKevin Wolf 1395daa6bfdSKevin Wolf## 1405daa6bfdSKevin Wolf# @nbd-server-stop: 1415daa6bfdSKevin Wolf# 1425daa6bfdSKevin Wolf# Stop QEMU's embedded NBD server, and unregister all devices previously 1435daa6bfdSKevin Wolf# added via @nbd-server-add. 1445daa6bfdSKevin Wolf# 1455daa6bfdSKevin Wolf# Since: 1.3.0 1465daa6bfdSKevin Wolf## 1475daa6bfdSKevin Wolf{ 'command': 'nbd-server-stop' } 1485daa6bfdSKevin Wolf 1495daa6bfdSKevin Wolf## 1505daa6bfdSKevin Wolf# @BlockExportType: 1515daa6bfdSKevin Wolf# 1525daa6bfdSKevin Wolf# An enumeration of block export types 1535daa6bfdSKevin Wolf# 1545daa6bfdSKevin Wolf# @nbd: NBD export 1555daa6bfdSKevin Wolf# 1565daa6bfdSKevin Wolf# Since: 4.2 1575daa6bfdSKevin Wolf## 1585daa6bfdSKevin Wolf{ 'enum': 'BlockExportType', 1595daa6bfdSKevin Wolf 'data': [ 'nbd' ] } 1605daa6bfdSKevin Wolf 1615daa6bfdSKevin Wolf## 162143ea767SKevin Wolf# @BlockExportOptions: 1635daa6bfdSKevin Wolf# 1645daa6bfdSKevin Wolf# Describes a block export, i.e. how single node should be exported on an 1655daa6bfdSKevin Wolf# external interface. 1665daa6bfdSKevin Wolf# 1675daa6bfdSKevin Wolf# Since: 4.2 1685daa6bfdSKevin Wolf## 169143ea767SKevin Wolf{ 'union': 'BlockExportOptions', 1705daa6bfdSKevin Wolf 'base': { 'type': 'BlockExportType' }, 1715daa6bfdSKevin Wolf 'discriminator': 'type', 1725daa6bfdSKevin Wolf 'data': { 173143ea767SKevin Wolf 'nbd': 'BlockExportOptionsNbd' 1745daa6bfdSKevin Wolf } } 175*56ee8626SKevin Wolf 176*56ee8626SKevin Wolf## 177*56ee8626SKevin Wolf# @block-export-add: 178*56ee8626SKevin Wolf# 179*56ee8626SKevin Wolf# Creates a new block export. 180*56ee8626SKevin Wolf# 181*56ee8626SKevin Wolf# Since: 5.2 182*56ee8626SKevin Wolf## 183*56ee8626SKevin Wolf{ 'command': 'block-export-add', 184*56ee8626SKevin Wolf 'data': 'BlockExportOptions', 'boxed': true } 185