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# 579bc6e893SMarkus Armbruster# Since: 1.3 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## 66cbad81ceSEric Blake# @BlockExportOptionsNbdBase: 675daa6bfdSKevin Wolf# 68cbad81ceSEric Blake# An NBD block export (common options shared between nbd-server-add and 69cbad81ceSEric Blake# the NBD branch 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# Since: 5.0 785daa6bfdSKevin Wolf## 79cbad81ceSEric Blake{ 'struct': 'BlockExportOptionsNbdBase', 80cbad81ceSEric Blake 'data': { '*name': 'str', '*description': 'str' } } 81cbad81ceSEric Blake 82cbad81ceSEric Blake## 83cbad81ceSEric Blake# @BlockExportOptionsNbd: 84cbad81ceSEric Blake# 85cbad81ceSEric Blake# An NBD block export (distinct options used in the NBD branch of 86cbad81ceSEric Blake# block-export-add). 87cbad81ceSEric Blake# 88cbad81ceSEric Blake# @bitmaps: Also export each of the named dirty bitmaps reachable from 89cbad81ceSEric Blake# @device, so the NBD client can use NBD_OPT_SET_META_CONTEXT with 90cbad81ceSEric Blake# the metadata context name "qemu:dirty-bitmap:BITMAP" to inspect 91cbad81ceSEric Blake# each bitmap. 92cbad81ceSEric Blake# 93dbc7b014SEric Blake# @allocation-depth: Also export the allocation depth map for @device, so 94dbc7b014SEric Blake# the NBD client can use NBD_OPT_SET_META_CONTEXT with 95dbc7b014SEric Blake# the metadata context name "qemu:allocation-depth" to 96dbc7b014SEric Blake# inspect allocation details. (since 5.2) 97dbc7b014SEric Blake# 98cbad81ceSEric Blake# Since: 5.2 99cbad81ceSEric Blake## 100143ea767SKevin Wolf{ 'struct': 'BlockExportOptionsNbd', 101cbad81ceSEric Blake 'base': 'BlockExportOptionsNbdBase', 102dbc7b014SEric Blake 'data': { '*bitmaps': ['str'], '*allocation-depth': 'bool' } } 1035daa6bfdSKevin Wolf 1045daa6bfdSKevin Wolf## 10590fc91d5SStefan Hajnoczi# @BlockExportOptionsVhostUserBlk: 10690fc91d5SStefan Hajnoczi# 10790fc91d5SStefan Hajnoczi# A vhost-user-blk block export. 10890fc91d5SStefan Hajnoczi# 10990fc91d5SStefan Hajnoczi# @addr: The vhost-user socket on which to listen. Both 'unix' and 'fd' 11090fc91d5SStefan Hajnoczi# SocketAddress types are supported. Passed fds must be UNIX domain 11190fc91d5SStefan Hajnoczi# sockets. 11290fc91d5SStefan Hajnoczi# @logical-block-size: Logical block size in bytes. Defaults to 512 bytes. 113d9b495f9SStefan Hajnoczi# @num-queues: Number of request virtqueues. Must be greater than 0. Defaults 114d9b495f9SStefan Hajnoczi# to 1. 11590fc91d5SStefan Hajnoczi# 11690fc91d5SStefan Hajnoczi# Since: 5.2 11790fc91d5SStefan Hajnoczi## 11890fc91d5SStefan Hajnoczi{ 'struct': 'BlockExportOptionsVhostUserBlk', 119d9b495f9SStefan Hajnoczi 'data': { 'addr': 'SocketAddress', 120d9b495f9SStefan Hajnoczi '*logical-block-size': 'size', 121d9b495f9SStefan Hajnoczi '*num-queues': 'uint16'} } 12290fc91d5SStefan Hajnoczi 12390fc91d5SStefan Hajnoczi## 1240c9b70d5SMax Reitz# @BlockExportOptionsFuse: 1250c9b70d5SMax Reitz# 1260c9b70d5SMax Reitz# Options for exporting a block graph node on some (file) mountpoint 1270c9b70d5SMax Reitz# as a raw image. 1280c9b70d5SMax Reitz# 1290c9b70d5SMax Reitz# @mountpoint: Path on which to export the block device via FUSE. 1300c9b70d5SMax Reitz# This must point to an existing regular file. 1310c9b70d5SMax Reitz# 132*4fba06d5SMax Reitz# @growable: Whether writes beyond the EOF should grow the block node 133*4fba06d5SMax Reitz# accordingly. (default: false) 134*4fba06d5SMax Reitz# 1350c9b70d5SMax Reitz# Since: 6.0 1360c9b70d5SMax Reitz## 1370c9b70d5SMax Reitz{ 'struct': 'BlockExportOptionsFuse', 138*4fba06d5SMax Reitz 'data': { 'mountpoint': 'str', 139*4fba06d5SMax Reitz '*growable': 'bool' }, 1400c9b70d5SMax Reitz 'if': 'defined(CONFIG_FUSE)' } 1410c9b70d5SMax Reitz 1420c9b70d5SMax Reitz## 143b6076afcSKevin Wolf# @NbdServerAddOptions: 144b6076afcSKevin Wolf# 145cbad81ceSEric Blake# An NBD block export, per legacy nbd-server-add command. 146b6076afcSKevin Wolf# 147b6076afcSKevin Wolf# @device: The device name or node name of the node to be exported 148b6076afcSKevin Wolf# 14930dbc81dSKevin Wolf# @writable: Whether clients should be able to write to the device via the 15030dbc81dSKevin Wolf# NBD connection (default false). 15130dbc81dSKevin Wolf# 152cbad81ceSEric Blake# @bitmap: Also export a single dirty bitmap reachable from @device, so the 153cbad81ceSEric Blake# NBD client can use NBD_OPT_SET_META_CONTEXT with the metadata 154cbad81ceSEric Blake# context name "qemu:dirty-bitmap:BITMAP" to inspect the bitmap 155cbad81ceSEric Blake# (since 4.0). 156cbad81ceSEric Blake# 157b6076afcSKevin Wolf# Since: 5.0 158b6076afcSKevin Wolf## 159b6076afcSKevin Wolf{ 'struct': 'NbdServerAddOptions', 160cbad81ceSEric Blake 'base': 'BlockExportOptionsNbdBase', 16130dbc81dSKevin Wolf 'data': { 'device': 'str', 162cbad81ceSEric Blake '*writable': 'bool', '*bitmap': 'str' } } 163b6076afcSKevin Wolf 164b6076afcSKevin Wolf## 1655daa6bfdSKevin Wolf# @nbd-server-add: 1665daa6bfdSKevin Wolf# 1675daa6bfdSKevin Wolf# Export a block node to QEMU's embedded NBD server. 1685daa6bfdSKevin Wolf# 169d53be9ceSKevin Wolf# The export name will be used as the id for the resulting block export. 170d53be9ceSKevin Wolf# 171443127e8SKevin Wolf# Features: 172443127e8SKevin Wolf# @deprecated: This command is deprecated. Use @block-export-add instead. 173443127e8SKevin Wolf# 1745daa6bfdSKevin Wolf# Returns: error if the server is not running, or export with the same name 1755daa6bfdSKevin Wolf# already exists. 1765daa6bfdSKevin Wolf# 1779bc6e893SMarkus Armbruster# Since: 1.3 1785daa6bfdSKevin Wolf## 1795daa6bfdSKevin Wolf{ 'command': 'nbd-server-add', 180443127e8SKevin Wolf 'data': 'NbdServerAddOptions', 'boxed': true, 'features': ['deprecated'] } 1815daa6bfdSKevin Wolf 1825daa6bfdSKevin Wolf## 1833c3bc462SKevin Wolf# @BlockExportRemoveMode: 1845daa6bfdSKevin Wolf# 1853c3bc462SKevin Wolf# Mode for removing a block export. 1865daa6bfdSKevin Wolf# 1875daa6bfdSKevin Wolf# @safe: Remove export if there are no existing connections, fail otherwise. 1885daa6bfdSKevin Wolf# 1895daa6bfdSKevin Wolf# @hard: Drop all connections immediately and remove export. 1905daa6bfdSKevin Wolf# 1915daa6bfdSKevin Wolf# Potential additional modes to be added in the future: 1925daa6bfdSKevin Wolf# 1935daa6bfdSKevin Wolf# hide: Just hide export from new clients, leave existing connections as is. 1945daa6bfdSKevin Wolf# Remove export after all clients are disconnected. 1955daa6bfdSKevin Wolf# 1965daa6bfdSKevin Wolf# soft: Hide export from new clients, answer with ESHUTDOWN for all further 1975daa6bfdSKevin Wolf# requests from existing clients. 1985daa6bfdSKevin Wolf# 1995daa6bfdSKevin Wolf# Since: 2.12 2005daa6bfdSKevin Wolf## 2013c3bc462SKevin Wolf{'enum': 'BlockExportRemoveMode', 'data': ['safe', 'hard']} 2025daa6bfdSKevin Wolf 2035daa6bfdSKevin Wolf## 2045daa6bfdSKevin Wolf# @nbd-server-remove: 2055daa6bfdSKevin Wolf# 2065daa6bfdSKevin Wolf# Remove NBD export by name. 2075daa6bfdSKevin Wolf# 2083c3bc462SKevin Wolf# @name: Block export id. 2095daa6bfdSKevin Wolf# 2103c3bc462SKevin Wolf# @mode: Mode of command operation. See @BlockExportRemoveMode description. 2115daa6bfdSKevin Wolf# Default is 'safe'. 2125daa6bfdSKevin Wolf# 213443127e8SKevin Wolf# Features: 214443127e8SKevin Wolf# @deprecated: This command is deprecated. Use @block-export-del instead. 215443127e8SKevin Wolf# 2165daa6bfdSKevin Wolf# Returns: error if 2175daa6bfdSKevin Wolf# - the server is not running 2185daa6bfdSKevin Wolf# - export is not found 2195daa6bfdSKevin Wolf# - mode is 'safe' and there are existing connections 2205daa6bfdSKevin Wolf# 2215daa6bfdSKevin Wolf# Since: 2.12 2225daa6bfdSKevin Wolf## 2235daa6bfdSKevin Wolf{ 'command': 'nbd-server-remove', 224443127e8SKevin Wolf 'data': {'name': 'str', '*mode': 'BlockExportRemoveMode'}, 225443127e8SKevin Wolf 'features': ['deprecated'] } 2265daa6bfdSKevin Wolf 2275daa6bfdSKevin Wolf## 2285daa6bfdSKevin Wolf# @nbd-server-stop: 2295daa6bfdSKevin Wolf# 2305daa6bfdSKevin Wolf# Stop QEMU's embedded NBD server, and unregister all devices previously 2315daa6bfdSKevin Wolf# added via @nbd-server-add. 2325daa6bfdSKevin Wolf# 2339bc6e893SMarkus Armbruster# Since: 1.3 2345daa6bfdSKevin Wolf## 2355daa6bfdSKevin Wolf{ 'command': 'nbd-server-stop' } 2365daa6bfdSKevin Wolf 2375daa6bfdSKevin Wolf## 2385daa6bfdSKevin Wolf# @BlockExportType: 2395daa6bfdSKevin Wolf# 2405daa6bfdSKevin Wolf# An enumeration of block export types 2415daa6bfdSKevin Wolf# 2425daa6bfdSKevin Wolf# @nbd: NBD export 24390fc91d5SStefan Hajnoczi# @vhost-user-blk: vhost-user-blk export (since 5.2) 2440c9b70d5SMax Reitz# @fuse: FUSE export (since: 6.0) 2455daa6bfdSKevin Wolf# 2465daa6bfdSKevin Wolf# Since: 4.2 2475daa6bfdSKevin Wolf## 2485daa6bfdSKevin Wolf{ 'enum': 'BlockExportType', 2490c9b70d5SMax Reitz 'data': [ 'nbd', 'vhost-user-blk', 2500c9b70d5SMax Reitz { 'name': 'fuse', 'if': 'defined(CONFIG_FUSE)' } ] } 2515daa6bfdSKevin Wolf 2525daa6bfdSKevin Wolf## 253143ea767SKevin Wolf# @BlockExportOptions: 2545daa6bfdSKevin Wolf# 2555daa6bfdSKevin Wolf# Describes a block export, i.e. how single node should be exported on an 2565daa6bfdSKevin Wolf# external interface. 2575daa6bfdSKevin Wolf# 258d53be9ceSKevin Wolf# @id: A unique identifier for the block export (across all export types) 259d53be9ceSKevin Wolf# 260b6076afcSKevin Wolf# @node-name: The node name of the block node to be exported (since: 5.2) 261b6076afcSKevin Wolf# 26230dbc81dSKevin Wolf# @writable: True if clients should be able to write to the export 26330dbc81dSKevin Wolf# (default false) 26430dbc81dSKevin Wolf# 265fefee85dSKevin Wolf# @writethrough: If true, caches are flushed after every write request to the 266fefee85dSKevin Wolf# export before completion is signalled. (since: 5.2; 267fefee85dSKevin Wolf# default: false) 268fefee85dSKevin Wolf# 269f51d23c8SStefan Hajnoczi# @iothread: The name of the iothread object where the export will run. The 270f51d23c8SStefan Hajnoczi# default is to use the thread currently associated with the 271f51d23c8SStefan Hajnoczi# block node. (since: 5.2) 272f51d23c8SStefan Hajnoczi# 273f51d23c8SStefan Hajnoczi# @fixed-iothread: True prevents the block node from being moved to another 274f51d23c8SStefan Hajnoczi# thread while the export is active. If true and @iothread is 275f51d23c8SStefan Hajnoczi# given, export creation fails if the block node cannot be 276f51d23c8SStefan Hajnoczi# moved to the iothread. The default is false. (since: 5.2) 277f51d23c8SStefan Hajnoczi# 2785daa6bfdSKevin Wolf# Since: 4.2 2795daa6bfdSKevin Wolf## 280143ea767SKevin Wolf{ 'union': 'BlockExportOptions', 281fefee85dSKevin Wolf 'base': { 'type': 'BlockExportType', 282d53be9ceSKevin Wolf 'id': 'str', 283f51d23c8SStefan Hajnoczi '*fixed-iothread': 'bool', 284f51d23c8SStefan Hajnoczi '*iothread': 'str', 285b6076afcSKevin Wolf 'node-name': 'str', 28630dbc81dSKevin Wolf '*writable': 'bool', 287fefee85dSKevin Wolf '*writethrough': 'bool' }, 2885daa6bfdSKevin Wolf 'discriminator': 'type', 2895daa6bfdSKevin Wolf 'data': { 29090fc91d5SStefan Hajnoczi 'nbd': 'BlockExportOptionsNbd', 2910c9b70d5SMax Reitz 'vhost-user-blk': 'BlockExportOptionsVhostUserBlk', 2920c9b70d5SMax Reitz 'fuse': { 'type': 'BlockExportOptionsFuse', 2930c9b70d5SMax Reitz 'if': 'defined(CONFIG_FUSE)' } 2945daa6bfdSKevin Wolf } } 29556ee8626SKevin Wolf 29656ee8626SKevin Wolf## 29756ee8626SKevin Wolf# @block-export-add: 29856ee8626SKevin Wolf# 29956ee8626SKevin Wolf# Creates a new block export. 30056ee8626SKevin Wolf# 30156ee8626SKevin Wolf# Since: 5.2 30256ee8626SKevin Wolf## 30356ee8626SKevin Wolf{ 'command': 'block-export-add', 30456ee8626SKevin Wolf 'data': 'BlockExportOptions', 'boxed': true } 3053c3bc462SKevin Wolf 3063c3bc462SKevin Wolf## 3073c3bc462SKevin Wolf# @block-export-del: 3083c3bc462SKevin Wolf# 3093c3bc462SKevin Wolf# Request to remove a block export. This drops the user's reference to the 3103c3bc462SKevin Wolf# export, but the export may still stay around after this command returns until 3113c3bc462SKevin Wolf# the shutdown of the export has completed. 3123c3bc462SKevin Wolf# 3133c3bc462SKevin Wolf# @id: Block export id. 3143c3bc462SKevin Wolf# 3153c3bc462SKevin Wolf# @mode: Mode of command operation. See @BlockExportRemoveMode description. 3163c3bc462SKevin Wolf# Default is 'safe'. 3173c3bc462SKevin Wolf# 3183c3bc462SKevin Wolf# Returns: Error if the export is not found or @mode is 'safe' and the export 3193c3bc462SKevin Wolf# is still in use (e.g. by existing client connections) 3203c3bc462SKevin Wolf# 3213c3bc462SKevin Wolf# Since: 5.2 3223c3bc462SKevin Wolf## 3233c3bc462SKevin Wolf{ 'command': 'block-export-del', 3243c3bc462SKevin Wolf 'data': { 'id': 'str', '*mode': 'BlockExportRemoveMode' } } 3251a9f7a80SKevin Wolf 3261a9f7a80SKevin Wolf## 3271a9f7a80SKevin Wolf# @BLOCK_EXPORT_DELETED: 3281a9f7a80SKevin Wolf# 3291a9f7a80SKevin Wolf# Emitted when a block export is removed and its id can be reused. 3301a9f7a80SKevin Wolf# 3311a9f7a80SKevin Wolf# @id: Block export id. 3321a9f7a80SKevin Wolf# 3331a9f7a80SKevin Wolf# Since: 5.2 3341a9f7a80SKevin Wolf## 3351a9f7a80SKevin Wolf{ 'event': 'BLOCK_EXPORT_DELETED', 3361a9f7a80SKevin Wolf 'data': { 'id': 'str' } } 3378cade320SKevin Wolf 3388cade320SKevin Wolf## 3398cade320SKevin Wolf# @BlockExportInfo: 3408cade320SKevin Wolf# 3418cade320SKevin Wolf# Information about a single block export. 3428cade320SKevin Wolf# 3438cade320SKevin Wolf# @id: The unique identifier for the block export 3448cade320SKevin Wolf# 3458cade320SKevin Wolf# @type: The block export type 3468cade320SKevin Wolf# 3478cade320SKevin Wolf# @node-name: The node name of the block node that is exported 3488cade320SKevin Wolf# 3498cade320SKevin Wolf# @shutting-down: True if the export is shutting down (e.g. after a 3508cade320SKevin Wolf# block-export-del command, but before the shutdown has 3518cade320SKevin Wolf# completed) 3528cade320SKevin Wolf# 3538cade320SKevin Wolf# Since: 5.2 3548cade320SKevin Wolf## 3558cade320SKevin Wolf{ 'struct': 'BlockExportInfo', 3568cade320SKevin Wolf 'data': { 'id': 'str', 3578cade320SKevin Wolf 'type': 'BlockExportType', 3588cade320SKevin Wolf 'node-name': 'str', 3598cade320SKevin Wolf 'shutting-down': 'bool' } } 3608cade320SKevin Wolf 3618cade320SKevin Wolf## 3628cade320SKevin Wolf# @query-block-exports: 3638cade320SKevin Wolf# 3648cade320SKevin Wolf# Returns: A list of BlockExportInfo describing all block exports 3658cade320SKevin Wolf# 3668cade320SKevin Wolf# Since: 5.2 3678cade320SKevin Wolf## 3688cade320SKevin Wolf{ 'command': 'query-block-exports', 'returns': ['BlockExportInfo'] } 369