1*5daa6bfdSKevin Wolf# -*- Mode: Python -*- 2*5daa6bfdSKevin Wolf# vim: filetype=python 3*5daa6bfdSKevin Wolf 4*5daa6bfdSKevin Wolf## 5*5daa6bfdSKevin Wolf# == Block device exports 6*5daa6bfdSKevin Wolf## 7*5daa6bfdSKevin Wolf 8*5daa6bfdSKevin Wolf{ 'include': 'sockets.json' } 9*5daa6bfdSKevin Wolf 10*5daa6bfdSKevin Wolf## 11*5daa6bfdSKevin Wolf# @NbdServerOptions: 12*5daa6bfdSKevin Wolf# 13*5daa6bfdSKevin Wolf# Keep this type consistent with the nbd-server-start arguments. The only 14*5daa6bfdSKevin Wolf# intended difference is using SocketAddress instead of SocketAddressLegacy. 15*5daa6bfdSKevin Wolf# 16*5daa6bfdSKevin Wolf# @addr: Address on which to listen. 17*5daa6bfdSKevin Wolf# @tls-creds: ID of the TLS credentials object (since 2.6). 18*5daa6bfdSKevin Wolf# @tls-authz: ID of the QAuthZ authorization object used to validate 19*5daa6bfdSKevin Wolf# the client's x509 distinguished name. This object is 20*5daa6bfdSKevin Wolf# is only resolved at time of use, so can be deleted and 21*5daa6bfdSKevin Wolf# recreated on the fly while the NBD server is active. 22*5daa6bfdSKevin Wolf# If missing, it will default to denying access (since 4.0). 23*5daa6bfdSKevin Wolf# 24*5daa6bfdSKevin Wolf# Since: 4.2 25*5daa6bfdSKevin Wolf## 26*5daa6bfdSKevin Wolf{ 'struct': 'NbdServerOptions', 27*5daa6bfdSKevin Wolf 'data': { 'addr': 'SocketAddress', 28*5daa6bfdSKevin Wolf '*tls-creds': 'str', 29*5daa6bfdSKevin Wolf '*tls-authz': 'str'} } 30*5daa6bfdSKevin Wolf 31*5daa6bfdSKevin Wolf## 32*5daa6bfdSKevin Wolf# @nbd-server-start: 33*5daa6bfdSKevin Wolf# 34*5daa6bfdSKevin Wolf# Start an NBD server listening on the given host and port. Block 35*5daa6bfdSKevin Wolf# devices can then be exported using @nbd-server-add. The NBD 36*5daa6bfdSKevin Wolf# server will present them as named exports; for example, another 37*5daa6bfdSKevin Wolf# QEMU instance could refer to them as "nbd:HOST:PORT:exportname=NAME". 38*5daa6bfdSKevin Wolf# 39*5daa6bfdSKevin Wolf# Keep this type consistent with the NbdServerOptions type. The only intended 40*5daa6bfdSKevin Wolf# difference is using SocketAddressLegacy instead of SocketAddress. 41*5daa6bfdSKevin Wolf# 42*5daa6bfdSKevin Wolf# @addr: Address on which to listen. 43*5daa6bfdSKevin Wolf# @tls-creds: ID of the TLS credentials object (since 2.6). 44*5daa6bfdSKevin Wolf# @tls-authz: ID of the QAuthZ authorization object used to validate 45*5daa6bfdSKevin Wolf# the client's x509 distinguished name. This object is 46*5daa6bfdSKevin Wolf# is only resolved at time of use, so can be deleted and 47*5daa6bfdSKevin Wolf# recreated on the fly while the NBD server is active. 48*5daa6bfdSKevin Wolf# If missing, it will default to denying access (since 4.0). 49*5daa6bfdSKevin Wolf# 50*5daa6bfdSKevin Wolf# Returns: error if the server is already running. 51*5daa6bfdSKevin Wolf# 52*5daa6bfdSKevin Wolf# Since: 1.3.0 53*5daa6bfdSKevin Wolf## 54*5daa6bfdSKevin Wolf{ 'command': 'nbd-server-start', 55*5daa6bfdSKevin Wolf 'data': { 'addr': 'SocketAddressLegacy', 56*5daa6bfdSKevin Wolf '*tls-creds': 'str', 57*5daa6bfdSKevin Wolf '*tls-authz': 'str'} } 58*5daa6bfdSKevin Wolf 59*5daa6bfdSKevin Wolf## 60*5daa6bfdSKevin Wolf# @BlockExportNbd: 61*5daa6bfdSKevin Wolf# 62*5daa6bfdSKevin Wolf# An NBD block export. 63*5daa6bfdSKevin Wolf# 64*5daa6bfdSKevin Wolf# @device: The device name or node name of the node to be exported 65*5daa6bfdSKevin Wolf# 66*5daa6bfdSKevin Wolf# @name: Export name. If unspecified, the @device parameter is used as the 67*5daa6bfdSKevin Wolf# export name. (Since 2.12) 68*5daa6bfdSKevin Wolf# 69*5daa6bfdSKevin Wolf# @description: Free-form description of the export, up to 4096 bytes. 70*5daa6bfdSKevin Wolf# (Since 5.0) 71*5daa6bfdSKevin Wolf# 72*5daa6bfdSKevin Wolf# @writable: Whether clients should be able to write to the device via the 73*5daa6bfdSKevin Wolf# NBD connection (default false). 74*5daa6bfdSKevin Wolf# 75*5daa6bfdSKevin Wolf# @bitmap: Also export the dirty bitmap reachable from @device, so the 76*5daa6bfdSKevin Wolf# NBD client can use NBD_OPT_SET_META_CONTEXT with 77*5daa6bfdSKevin Wolf# "qemu:dirty-bitmap:NAME" to inspect the bitmap. (since 4.0) 78*5daa6bfdSKevin Wolf# 79*5daa6bfdSKevin Wolf# Since: 5.0 80*5daa6bfdSKevin Wolf## 81*5daa6bfdSKevin Wolf{ 'struct': 'BlockExportNbd', 82*5daa6bfdSKevin Wolf 'data': {'device': 'str', '*name': 'str', '*description': 'str', 83*5daa6bfdSKevin Wolf '*writable': 'bool', '*bitmap': 'str' } } 84*5daa6bfdSKevin Wolf 85*5daa6bfdSKevin Wolf## 86*5daa6bfdSKevin Wolf# @nbd-server-add: 87*5daa6bfdSKevin Wolf# 88*5daa6bfdSKevin Wolf# Export a block node to QEMU's embedded NBD server. 89*5daa6bfdSKevin Wolf# 90*5daa6bfdSKevin Wolf# Returns: error if the server is not running, or export with the same name 91*5daa6bfdSKevin Wolf# already exists. 92*5daa6bfdSKevin Wolf# 93*5daa6bfdSKevin Wolf# Since: 1.3.0 94*5daa6bfdSKevin Wolf## 95*5daa6bfdSKevin Wolf{ 'command': 'nbd-server-add', 96*5daa6bfdSKevin Wolf 'data': 'BlockExportNbd', 'boxed': true } 97*5daa6bfdSKevin Wolf 98*5daa6bfdSKevin Wolf## 99*5daa6bfdSKevin Wolf# @NbdServerRemoveMode: 100*5daa6bfdSKevin Wolf# 101*5daa6bfdSKevin Wolf# Mode for removing an NBD export. 102*5daa6bfdSKevin Wolf# 103*5daa6bfdSKevin Wolf# @safe: Remove export if there are no existing connections, fail otherwise. 104*5daa6bfdSKevin Wolf# 105*5daa6bfdSKevin Wolf# @hard: Drop all connections immediately and remove export. 106*5daa6bfdSKevin Wolf# 107*5daa6bfdSKevin Wolf# Potential additional modes to be added in the future: 108*5daa6bfdSKevin Wolf# 109*5daa6bfdSKevin Wolf# hide: Just hide export from new clients, leave existing connections as is. 110*5daa6bfdSKevin Wolf# Remove export after all clients are disconnected. 111*5daa6bfdSKevin Wolf# 112*5daa6bfdSKevin Wolf# soft: Hide export from new clients, answer with ESHUTDOWN for all further 113*5daa6bfdSKevin Wolf# requests from existing clients. 114*5daa6bfdSKevin Wolf# 115*5daa6bfdSKevin Wolf# Since: 2.12 116*5daa6bfdSKevin Wolf## 117*5daa6bfdSKevin Wolf{'enum': 'NbdServerRemoveMode', 'data': ['safe', 'hard']} 118*5daa6bfdSKevin Wolf 119*5daa6bfdSKevin Wolf## 120*5daa6bfdSKevin Wolf# @nbd-server-remove: 121*5daa6bfdSKevin Wolf# 122*5daa6bfdSKevin Wolf# Remove NBD export by name. 123*5daa6bfdSKevin Wolf# 124*5daa6bfdSKevin Wolf# @name: Export name. 125*5daa6bfdSKevin Wolf# 126*5daa6bfdSKevin Wolf# @mode: Mode of command operation. See @NbdServerRemoveMode description. 127*5daa6bfdSKevin Wolf# Default is 'safe'. 128*5daa6bfdSKevin Wolf# 129*5daa6bfdSKevin Wolf# Returns: error if 130*5daa6bfdSKevin Wolf# - the server is not running 131*5daa6bfdSKevin Wolf# - export is not found 132*5daa6bfdSKevin Wolf# - mode is 'safe' and there are existing connections 133*5daa6bfdSKevin Wolf# 134*5daa6bfdSKevin Wolf# Since: 2.12 135*5daa6bfdSKevin Wolf## 136*5daa6bfdSKevin Wolf{ 'command': 'nbd-server-remove', 137*5daa6bfdSKevin Wolf 'data': {'name': 'str', '*mode': 'NbdServerRemoveMode'} } 138*5daa6bfdSKevin Wolf 139*5daa6bfdSKevin Wolf## 140*5daa6bfdSKevin Wolf# @nbd-server-stop: 141*5daa6bfdSKevin Wolf# 142*5daa6bfdSKevin Wolf# Stop QEMU's embedded NBD server, and unregister all devices previously 143*5daa6bfdSKevin Wolf# added via @nbd-server-add. 144*5daa6bfdSKevin Wolf# 145*5daa6bfdSKevin Wolf# Since: 1.3.0 146*5daa6bfdSKevin Wolf## 147*5daa6bfdSKevin Wolf{ 'command': 'nbd-server-stop' } 148*5daa6bfdSKevin Wolf 149*5daa6bfdSKevin Wolf## 150*5daa6bfdSKevin Wolf# @BlockExportType: 151*5daa6bfdSKevin Wolf# 152*5daa6bfdSKevin Wolf# An enumeration of block export types 153*5daa6bfdSKevin Wolf# 154*5daa6bfdSKevin Wolf# @nbd: NBD export 155*5daa6bfdSKevin Wolf# 156*5daa6bfdSKevin Wolf# Since: 4.2 157*5daa6bfdSKevin Wolf## 158*5daa6bfdSKevin Wolf{ 'enum': 'BlockExportType', 159*5daa6bfdSKevin Wolf 'data': [ 'nbd' ] } 160*5daa6bfdSKevin Wolf 161*5daa6bfdSKevin Wolf## 162*5daa6bfdSKevin Wolf# @BlockExport: 163*5daa6bfdSKevin Wolf# 164*5daa6bfdSKevin Wolf# Describes a block export, i.e. how single node should be exported on an 165*5daa6bfdSKevin Wolf# external interface. 166*5daa6bfdSKevin Wolf# 167*5daa6bfdSKevin Wolf# Since: 4.2 168*5daa6bfdSKevin Wolf## 169*5daa6bfdSKevin Wolf{ 'union': 'BlockExport', 170*5daa6bfdSKevin Wolf 'base': { 'type': 'BlockExportType' }, 171*5daa6bfdSKevin Wolf 'discriminator': 'type', 172*5daa6bfdSKevin Wolf 'data': { 173*5daa6bfdSKevin Wolf 'nbd': 'BlockExportNbd' 174*5daa6bfdSKevin Wolf } } 175