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. 9690fc91d5SStefan Hajnoczi# 9790fc91d5SStefan Hajnoczi# Since: 5.2 9890fc91d5SStefan Hajnoczi## 9990fc91d5SStefan Hajnoczi{ 'struct': 'BlockExportOptionsVhostUserBlk', 10090fc91d5SStefan Hajnoczi 'data': { 'addr': 'SocketAddress', '*logical-block-size': 'size' } } 10190fc91d5SStefan Hajnoczi 10290fc91d5SStefan Hajnoczi## 103b6076afcSKevin Wolf# @NbdServerAddOptions: 104b6076afcSKevin Wolf# 105b6076afcSKevin Wolf# An NBD block export. 106b6076afcSKevin Wolf# 107b6076afcSKevin Wolf# @device: The device name or node name of the node to be exported 108b6076afcSKevin Wolf# 10930dbc81dSKevin Wolf# @writable: Whether clients should be able to write to the device via the 11030dbc81dSKevin Wolf# NBD connection (default false). 11130dbc81dSKevin Wolf# 112b6076afcSKevin Wolf# Since: 5.0 113b6076afcSKevin Wolf## 114b6076afcSKevin Wolf{ 'struct': 'NbdServerAddOptions', 115b6076afcSKevin Wolf 'base': 'BlockExportOptionsNbd', 11630dbc81dSKevin Wolf 'data': { 'device': 'str', 11730dbc81dSKevin Wolf '*writable': 'bool' } } 118b6076afcSKevin Wolf 119b6076afcSKevin Wolf## 1205daa6bfdSKevin Wolf# @nbd-server-add: 1215daa6bfdSKevin Wolf# 1225daa6bfdSKevin Wolf# Export a block node to QEMU's embedded NBD server. 1235daa6bfdSKevin Wolf# 124d53be9ceSKevin Wolf# The export name will be used as the id for the resulting block export. 125d53be9ceSKevin Wolf# 126443127e8SKevin Wolf# Features: 127443127e8SKevin Wolf# @deprecated: This command is deprecated. Use @block-export-add instead. 128443127e8SKevin Wolf# 1295daa6bfdSKevin Wolf# Returns: error if the server is not running, or export with the same name 1305daa6bfdSKevin Wolf# already exists. 1315daa6bfdSKevin Wolf# 1325daa6bfdSKevin Wolf# Since: 1.3.0 1335daa6bfdSKevin Wolf## 1345daa6bfdSKevin Wolf{ 'command': 'nbd-server-add', 135443127e8SKevin Wolf 'data': 'NbdServerAddOptions', 'boxed': true, 'features': ['deprecated'] } 1365daa6bfdSKevin Wolf 1375daa6bfdSKevin Wolf## 1383c3bc462SKevin Wolf# @BlockExportRemoveMode: 1395daa6bfdSKevin Wolf# 1403c3bc462SKevin Wolf# Mode for removing a block export. 1415daa6bfdSKevin Wolf# 1425daa6bfdSKevin Wolf# @safe: Remove export if there are no existing connections, fail otherwise. 1435daa6bfdSKevin Wolf# 1445daa6bfdSKevin Wolf# @hard: Drop all connections immediately and remove export. 1455daa6bfdSKevin Wolf# 1465daa6bfdSKevin Wolf# Potential additional modes to be added in the future: 1475daa6bfdSKevin Wolf# 1485daa6bfdSKevin Wolf# hide: Just hide export from new clients, leave existing connections as is. 1495daa6bfdSKevin Wolf# Remove export after all clients are disconnected. 1505daa6bfdSKevin Wolf# 1515daa6bfdSKevin Wolf# soft: Hide export from new clients, answer with ESHUTDOWN for all further 1525daa6bfdSKevin Wolf# requests from existing clients. 1535daa6bfdSKevin Wolf# 1545daa6bfdSKevin Wolf# Since: 2.12 1555daa6bfdSKevin Wolf## 1563c3bc462SKevin Wolf{'enum': 'BlockExportRemoveMode', 'data': ['safe', 'hard']} 1575daa6bfdSKevin Wolf 1585daa6bfdSKevin Wolf## 1595daa6bfdSKevin Wolf# @nbd-server-remove: 1605daa6bfdSKevin Wolf# 1615daa6bfdSKevin Wolf# Remove NBD export by name. 1625daa6bfdSKevin Wolf# 1633c3bc462SKevin Wolf# @name: Block export id. 1645daa6bfdSKevin Wolf# 1653c3bc462SKevin Wolf# @mode: Mode of command operation. See @BlockExportRemoveMode description. 1665daa6bfdSKevin Wolf# Default is 'safe'. 1675daa6bfdSKevin Wolf# 168443127e8SKevin Wolf# Features: 169443127e8SKevin Wolf# @deprecated: This command is deprecated. Use @block-export-del instead. 170443127e8SKevin Wolf# 1715daa6bfdSKevin Wolf# Returns: error if 1725daa6bfdSKevin Wolf# - the server is not running 1735daa6bfdSKevin Wolf# - export is not found 1745daa6bfdSKevin Wolf# - mode is 'safe' and there are existing connections 1755daa6bfdSKevin Wolf# 1765daa6bfdSKevin Wolf# Since: 2.12 1775daa6bfdSKevin Wolf## 1785daa6bfdSKevin Wolf{ 'command': 'nbd-server-remove', 179443127e8SKevin Wolf 'data': {'name': 'str', '*mode': 'BlockExportRemoveMode'}, 180443127e8SKevin Wolf 'features': ['deprecated'] } 1815daa6bfdSKevin Wolf 1825daa6bfdSKevin Wolf## 1835daa6bfdSKevin Wolf# @nbd-server-stop: 1845daa6bfdSKevin Wolf# 1855daa6bfdSKevin Wolf# Stop QEMU's embedded NBD server, and unregister all devices previously 1865daa6bfdSKevin Wolf# added via @nbd-server-add. 1875daa6bfdSKevin Wolf# 1885daa6bfdSKevin Wolf# Since: 1.3.0 1895daa6bfdSKevin Wolf## 1905daa6bfdSKevin Wolf{ 'command': 'nbd-server-stop' } 1915daa6bfdSKevin Wolf 1925daa6bfdSKevin Wolf## 1935daa6bfdSKevin Wolf# @BlockExportType: 1945daa6bfdSKevin Wolf# 1955daa6bfdSKevin Wolf# An enumeration of block export types 1965daa6bfdSKevin Wolf# 1975daa6bfdSKevin Wolf# @nbd: NBD export 19890fc91d5SStefan Hajnoczi# @vhost-user-blk: vhost-user-blk export (since 5.2) 1995daa6bfdSKevin Wolf# 2005daa6bfdSKevin Wolf# Since: 4.2 2015daa6bfdSKevin Wolf## 2025daa6bfdSKevin Wolf{ 'enum': 'BlockExportType', 20390fc91d5SStefan Hajnoczi 'data': [ 'nbd', 'vhost-user-blk' ] } 2045daa6bfdSKevin Wolf 2055daa6bfdSKevin Wolf## 206143ea767SKevin Wolf# @BlockExportOptions: 2075daa6bfdSKevin Wolf# 2085daa6bfdSKevin Wolf# Describes a block export, i.e. how single node should be exported on an 2095daa6bfdSKevin Wolf# external interface. 2105daa6bfdSKevin Wolf# 211d53be9ceSKevin Wolf# @id: A unique identifier for the block export (across all export types) 212d53be9ceSKevin Wolf# 213b6076afcSKevin Wolf# @node-name: The node name of the block node to be exported (since: 5.2) 214b6076afcSKevin Wolf# 21530dbc81dSKevin Wolf# @writable: True if clients should be able to write to the export 21630dbc81dSKevin Wolf# (default false) 21730dbc81dSKevin Wolf# 218fefee85dSKevin Wolf# @writethrough: If true, caches are flushed after every write request to the 219fefee85dSKevin Wolf# export before completion is signalled. (since: 5.2; 220fefee85dSKevin Wolf# default: false) 221fefee85dSKevin Wolf# 222*f51d23c8SStefan Hajnoczi# @iothread: The name of the iothread object where the export will run. The 223*f51d23c8SStefan Hajnoczi# default is to use the thread currently associated with the 224*f51d23c8SStefan Hajnoczi# block node. (since: 5.2) 225*f51d23c8SStefan Hajnoczi# 226*f51d23c8SStefan Hajnoczi# @fixed-iothread: True prevents the block node from being moved to another 227*f51d23c8SStefan Hajnoczi# thread while the export is active. If true and @iothread is 228*f51d23c8SStefan Hajnoczi# given, export creation fails if the block node cannot be 229*f51d23c8SStefan Hajnoczi# moved to the iothread. The default is false. (since: 5.2) 230*f51d23c8SStefan Hajnoczi# 2315daa6bfdSKevin Wolf# Since: 4.2 2325daa6bfdSKevin Wolf## 233143ea767SKevin Wolf{ 'union': 'BlockExportOptions', 234fefee85dSKevin Wolf 'base': { 'type': 'BlockExportType', 235d53be9ceSKevin Wolf 'id': 'str', 236*f51d23c8SStefan Hajnoczi '*fixed-iothread': 'bool', 237*f51d23c8SStefan Hajnoczi '*iothread': 'str', 238b6076afcSKevin Wolf 'node-name': 'str', 23930dbc81dSKevin Wolf '*writable': 'bool', 240fefee85dSKevin Wolf '*writethrough': 'bool' }, 2415daa6bfdSKevin Wolf 'discriminator': 'type', 2425daa6bfdSKevin Wolf 'data': { 24390fc91d5SStefan Hajnoczi 'nbd': 'BlockExportOptionsNbd', 24490fc91d5SStefan Hajnoczi 'vhost-user-blk': 'BlockExportOptionsVhostUserBlk' 2455daa6bfdSKevin Wolf } } 24656ee8626SKevin Wolf 24756ee8626SKevin Wolf## 24856ee8626SKevin Wolf# @block-export-add: 24956ee8626SKevin Wolf# 25056ee8626SKevin Wolf# Creates a new block export. 25156ee8626SKevin Wolf# 25256ee8626SKevin Wolf# Since: 5.2 25356ee8626SKevin Wolf## 25456ee8626SKevin Wolf{ 'command': 'block-export-add', 25556ee8626SKevin Wolf 'data': 'BlockExportOptions', 'boxed': true } 2563c3bc462SKevin Wolf 2573c3bc462SKevin Wolf## 2583c3bc462SKevin Wolf# @block-export-del: 2593c3bc462SKevin Wolf# 2603c3bc462SKevin Wolf# Request to remove a block export. This drops the user's reference to the 2613c3bc462SKevin Wolf# export, but the export may still stay around after this command returns until 2623c3bc462SKevin Wolf# the shutdown of the export has completed. 2633c3bc462SKevin Wolf# 2643c3bc462SKevin Wolf# @id: Block export id. 2653c3bc462SKevin Wolf# 2663c3bc462SKevin Wolf# @mode: Mode of command operation. See @BlockExportRemoveMode description. 2673c3bc462SKevin Wolf# Default is 'safe'. 2683c3bc462SKevin Wolf# 2693c3bc462SKevin Wolf# Returns: Error if the export is not found or @mode is 'safe' and the export 2703c3bc462SKevin Wolf# is still in use (e.g. by existing client connections) 2713c3bc462SKevin Wolf# 2723c3bc462SKevin Wolf# Since: 5.2 2733c3bc462SKevin Wolf## 2743c3bc462SKevin Wolf{ 'command': 'block-export-del', 2753c3bc462SKevin Wolf 'data': { 'id': 'str', '*mode': 'BlockExportRemoveMode' } } 2761a9f7a80SKevin Wolf 2771a9f7a80SKevin Wolf## 2781a9f7a80SKevin Wolf# @BLOCK_EXPORT_DELETED: 2791a9f7a80SKevin Wolf# 2801a9f7a80SKevin Wolf# Emitted when a block export is removed and its id can be reused. 2811a9f7a80SKevin Wolf# 2821a9f7a80SKevin Wolf# @id: Block export id. 2831a9f7a80SKevin Wolf# 2841a9f7a80SKevin Wolf# Since: 5.2 2851a9f7a80SKevin Wolf## 2861a9f7a80SKevin Wolf{ 'event': 'BLOCK_EXPORT_DELETED', 2871a9f7a80SKevin Wolf 'data': { 'id': 'str' } } 2888cade320SKevin Wolf 2898cade320SKevin Wolf## 2908cade320SKevin Wolf# @BlockExportInfo: 2918cade320SKevin Wolf# 2928cade320SKevin Wolf# Information about a single block export. 2938cade320SKevin Wolf# 2948cade320SKevin Wolf# @id: The unique identifier for the block export 2958cade320SKevin Wolf# 2968cade320SKevin Wolf# @type: The block export type 2978cade320SKevin Wolf# 2988cade320SKevin Wolf# @node-name: The node name of the block node that is exported 2998cade320SKevin Wolf# 3008cade320SKevin Wolf# @shutting-down: True if the export is shutting down (e.g. after a 3018cade320SKevin Wolf# block-export-del command, but before the shutdown has 3028cade320SKevin Wolf# completed) 3038cade320SKevin Wolf# 3048cade320SKevin Wolf# Since: 5.2 3058cade320SKevin Wolf## 3068cade320SKevin Wolf{ 'struct': 'BlockExportInfo', 3078cade320SKevin Wolf 'data': { 'id': 'str', 3088cade320SKevin Wolf 'type': 'BlockExportType', 3098cade320SKevin Wolf 'node-name': 'str', 3108cade320SKevin Wolf 'shutting-down': 'bool' } } 3118cade320SKevin Wolf 3128cade320SKevin Wolf## 3138cade320SKevin Wolf# @query-block-exports: 3148cade320SKevin Wolf# 3158cade320SKevin Wolf# Returns: A list of BlockExportInfo describing all block exports 3168cade320SKevin Wolf# 3178cade320SKevin Wolf# Since: 5.2 3188cade320SKevin Wolf## 3198cade320SKevin Wolf{ 'command': 'query-block-exports', 'returns': ['BlockExportInfo'] } 320