xref: /openbmc/qemu/qapi/block-export.json (revision e3240ac5800f11d0a00262d76180d9a3227131fb)
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' }
9e5fb29d5SVladimir Sementsov-Ogievskiy{ 'include': 'block-core.json' }
105daa6bfdSKevin Wolf
115daa6bfdSKevin Wolf##
125daa6bfdSKevin Wolf# @NbdServerOptions:
135daa6bfdSKevin Wolf#
14a937b6aaSMarkus Armbruster# Keep this type consistent with the nbd-server-start arguments.  The
15a937b6aaSMarkus Armbruster# only intended difference is using SocketAddress instead of
16a937b6aaSMarkus Armbruster# SocketAddressLegacy.
175daa6bfdSKevin Wolf#
185daa6bfdSKevin Wolf# @addr: Address on which to listen.
19a937b6aaSMarkus Armbruster#
205daa6bfdSKevin Wolf# @tls-creds: ID of the TLS credentials object (since 2.6).
21a937b6aaSMarkus Armbruster#
225daa6bfdSKevin Wolf# @tls-authz: ID of the QAuthZ authorization object used to validate
23a937b6aaSMarkus Armbruster#     the client's x509 distinguished name.  This object is is only
24a937b6aaSMarkus Armbruster#     resolved at time of use, so can be deleted and recreated on the
25a937b6aaSMarkus Armbruster#     fly while the NBD server is active.  If missing, it will default
26a937b6aaSMarkus Armbruster#     to denying access (since 4.0).
27a937b6aaSMarkus Armbruster#
28a937b6aaSMarkus Armbruster# @max-connections: The maximum number of connections to allow at the
29a937b6aaSMarkus Armbruster#     same time, 0 for unlimited.  Setting this to 1 also stops the
30a937b6aaSMarkus Armbruster#     server from advertising multiple client support (since 5.2;
31a937b6aaSMarkus Armbruster#     default: 0)
325daa6bfdSKevin Wolf#
335daa6bfdSKevin Wolf# Since: 4.2
345daa6bfdSKevin Wolf##
355daa6bfdSKevin Wolf{ 'struct': 'NbdServerOptions',
365daa6bfdSKevin Wolf  'data': { 'addr': 'SocketAddress',
375daa6bfdSKevin Wolf            '*tls-creds': 'str',
381c8222b0SKevin Wolf            '*tls-authz': 'str',
391c8222b0SKevin Wolf            '*max-connections': 'uint32' } }
405daa6bfdSKevin Wolf
415daa6bfdSKevin Wolf##
425daa6bfdSKevin Wolf# @nbd-server-start:
435daa6bfdSKevin Wolf#
445daa6bfdSKevin Wolf# Start an NBD server listening on the given host and port.  Block
45a937b6aaSMarkus Armbruster# devices can then be exported using @nbd-server-add.  The NBD server
46a937b6aaSMarkus Armbruster# will present them as named exports; for example, another QEMU
47a937b6aaSMarkus Armbruster# instance could refer to them as "nbd:HOST:PORT:exportname=NAME".
485daa6bfdSKevin Wolf#
49a937b6aaSMarkus Armbruster# Keep this type consistent with the NbdServerOptions type.  The only
50a937b6aaSMarkus Armbruster# intended difference is using SocketAddressLegacy instead of
51a937b6aaSMarkus Armbruster# SocketAddress.
525daa6bfdSKevin Wolf#
535daa6bfdSKevin Wolf# @addr: Address on which to listen.
54a937b6aaSMarkus Armbruster#
555daa6bfdSKevin Wolf# @tls-creds: ID of the TLS credentials object (since 2.6).
56a937b6aaSMarkus Armbruster#
575daa6bfdSKevin Wolf# @tls-authz: ID of the QAuthZ authorization object used to validate
58a937b6aaSMarkus Armbruster#     the client's x509 distinguished name.  This object is is only
59a937b6aaSMarkus Armbruster#     resolved at time of use, so can be deleted and recreated on the
60a937b6aaSMarkus Armbruster#     fly while the NBD server is active.  If missing, it will default
61a937b6aaSMarkus Armbruster#     to denying access (since 4.0).
62a937b6aaSMarkus Armbruster#
63a937b6aaSMarkus Armbruster# @max-connections: The maximum number of connections to allow at the
64a937b6aaSMarkus Armbruster#     same time, 0 for unlimited.  Setting this to 1 also stops the
65a937b6aaSMarkus Armbruster#     server from advertising multiple client support (since 5.2;
66a937b6aaSMarkus Armbruster#     default: 0).
675daa6bfdSKevin Wolf#
685daa6bfdSKevin Wolf# Returns: error if the server is already running.
695daa6bfdSKevin Wolf#
709bc6e893SMarkus Armbruster# Since: 1.3
715daa6bfdSKevin Wolf##
725daa6bfdSKevin Wolf{ 'command': 'nbd-server-start',
735daa6bfdSKevin Wolf  'data': { 'addr': 'SocketAddressLegacy',
745daa6bfdSKevin Wolf            '*tls-creds': 'str',
751c8222b0SKevin Wolf            '*tls-authz': 'str',
76f55ba801SPaolo Bonzini            '*max-connections': 'uint32' },
77f55ba801SPaolo Bonzini  'allow-preconfig': true }
785daa6bfdSKevin Wolf
795daa6bfdSKevin Wolf##
80cbad81ceSEric Blake# @BlockExportOptionsNbdBase:
815daa6bfdSKevin Wolf#
82a937b6aaSMarkus Armbruster# An NBD block export (common options shared between nbd-server-add
83a937b6aaSMarkus Armbruster# and the NBD branch of block-export-add).
845daa6bfdSKevin Wolf#
85a937b6aaSMarkus Armbruster# @name: Export name.  If unspecified, the @device parameter is used
86a937b6aaSMarkus Armbruster#     as the export name.  (Since 2.12)
875daa6bfdSKevin Wolf#
885daa6bfdSKevin Wolf# @description: Free-form description of the export, up to 4096 bytes.
895daa6bfdSKevin Wolf#     (Since 5.0)
905daa6bfdSKevin Wolf#
915daa6bfdSKevin Wolf# Since: 5.0
925daa6bfdSKevin Wolf##
93cbad81ceSEric Blake{ 'struct': 'BlockExportOptionsNbdBase',
94cbad81ceSEric Blake  'data': { '*name': 'str', '*description': 'str' } }
95cbad81ceSEric Blake
96cbad81ceSEric Blake##
97cbad81ceSEric Blake# @BlockExportOptionsNbd:
98cbad81ceSEric Blake#
99cbad81ceSEric Blake# An NBD block export (distinct options used in the NBD branch of
100cbad81ceSEric Blake# block-export-add).
101cbad81ceSEric Blake#
102cbad81ceSEric Blake# @bitmaps: Also export each of the named dirty bitmaps reachable from
103cbad81ceSEric Blake#     @device, so the NBD client can use NBD_OPT_SET_META_CONTEXT with
104cbad81ceSEric Blake#     the metadata context name "qemu:dirty-bitmap:BITMAP" to inspect
105a937b6aaSMarkus Armbruster#     each bitmap.  Since 7.1 bitmap may be specified by node/name
106a937b6aaSMarkus Armbruster#     pair.
107cbad81ceSEric Blake#
108a937b6aaSMarkus Armbruster# @allocation-depth: Also export the allocation depth map for @device,
109a937b6aaSMarkus Armbruster#     so the NBD client can use NBD_OPT_SET_META_CONTEXT with the
110a937b6aaSMarkus Armbruster#     metadata context name "qemu:allocation-depth" to inspect
111a937b6aaSMarkus Armbruster#     allocation details.  (since 5.2)
112dbc7b014SEric Blake#
113cbad81ceSEric Blake# Since: 5.2
114cbad81ceSEric Blake##
115143ea767SKevin Wolf{ 'struct': 'BlockExportOptionsNbd',
116cbad81ceSEric Blake  'base': 'BlockExportOptionsNbdBase',
117e5fb29d5SVladimir Sementsov-Ogievskiy  'data': { '*bitmaps': ['BlockDirtyBitmapOrStr'],
118e5fb29d5SVladimir Sementsov-Ogievskiy            '*allocation-depth': 'bool' } }
1195daa6bfdSKevin Wolf
1205daa6bfdSKevin Wolf##
12190fc91d5SStefan Hajnoczi# @BlockExportOptionsVhostUserBlk:
12290fc91d5SStefan Hajnoczi#
12390fc91d5SStefan Hajnoczi# A vhost-user-blk block export.
12490fc91d5SStefan Hajnoczi#
125a937b6aaSMarkus Armbruster# @addr: The vhost-user socket on which to listen.  Both 'unix' and
126a937b6aaSMarkus Armbruster#     'fd' SocketAddress types are supported.  Passed fds must be UNIX
127a937b6aaSMarkus Armbruster#     domain sockets.
128a937b6aaSMarkus Armbruster#
129a937b6aaSMarkus Armbruster# @logical-block-size: Logical block size in bytes.  Defaults to 512
130a937b6aaSMarkus Armbruster#     bytes.
131a937b6aaSMarkus Armbruster#
132a937b6aaSMarkus Armbruster# @num-queues: Number of request virtqueues.  Must be greater than 0.
133a937b6aaSMarkus Armbruster#     Defaults to 1.
13490fc91d5SStefan Hajnoczi#
13590fc91d5SStefan Hajnoczi# Since: 5.2
13690fc91d5SStefan Hajnoczi##
13790fc91d5SStefan Hajnoczi{ 'struct': 'BlockExportOptionsVhostUserBlk',
138d9b495f9SStefan Hajnoczi  'data': { 'addr': 'SocketAddress',
139d9b495f9SStefan Hajnoczi	    '*logical-block-size': 'size',
140d9b495f9SStefan Hajnoczi            '*num-queues': 'uint16'} }
14190fc91d5SStefan Hajnoczi
14290fc91d5SStefan Hajnoczi##
1438fc54f94SMax Reitz# @FuseExportAllowOther:
1448fc54f94SMax Reitz#
1458fc54f94SMax Reitz# Possible allow_other modes for FUSE exports.
1468fc54f94SMax Reitz#
1478fc54f94SMax Reitz# @off: Do not pass allow_other as a mount option.
1488fc54f94SMax Reitz#
1498fc54f94SMax Reitz# @on: Pass allow_other as a mount option.
1508fc54f94SMax Reitz#
1518fc54f94SMax Reitz# @auto: Try mounting with allow_other first, and if that fails, retry
1528fc54f94SMax Reitz#     without allow_other.
1538fc54f94SMax Reitz#
1548fc54f94SMax Reitz# Since: 6.1
1558fc54f94SMax Reitz##
1568fc54f94SMax Reitz{ 'enum': 'FuseExportAllowOther',
1578fc54f94SMax Reitz  'data': ['off', 'on', 'auto'] }
1588fc54f94SMax Reitz
1598fc54f94SMax Reitz##
1600c9b70d5SMax Reitz# @BlockExportOptionsFuse:
1610c9b70d5SMax Reitz#
1620c9b70d5SMax Reitz# Options for exporting a block graph node on some (file) mountpoint
1630c9b70d5SMax Reitz# as a raw image.
1640c9b70d5SMax Reitz#
165a937b6aaSMarkus Armbruster# @mountpoint: Path on which to export the block device via FUSE. This
166a937b6aaSMarkus Armbruster#     must point to an existing regular file.
1670c9b70d5SMax Reitz#
1684fba06d5SMax Reitz# @growable: Whether writes beyond the EOF should grow the block node
1694fba06d5SMax Reitz#     accordingly.  (default: false)
1704fba06d5SMax Reitz#
1718fc54f94SMax Reitz# @allow-other: If this is off, only qemu's user is allowed access to
172a937b6aaSMarkus Armbruster#     this export.  That cannot be changed even with chmod or chown.
173a937b6aaSMarkus Armbruster#     Enabling this option will allow other users access to the export
174a937b6aaSMarkus Armbruster#     with the FUSE mount option "allow_other". Note that using
175a937b6aaSMarkus Armbruster#     allow_other as a non-root user requires user_allow_other to be
176a937b6aaSMarkus Armbruster#     enabled in the global fuse.conf configuration file.  In auto
177a937b6aaSMarkus Armbruster#     mode (the default), the FUSE export driver will first attempt to
178a937b6aaSMarkus Armbruster#     mount the export with allow_other, and if that fails, try again
179a937b6aaSMarkus Armbruster#     without.  (since 6.1; default: auto)
1808fc54f94SMax Reitz#
1810c9b70d5SMax Reitz# Since: 6.0
1820c9b70d5SMax Reitz##
1830c9b70d5SMax Reitz{ 'struct': 'BlockExportOptionsFuse',
1844fba06d5SMax Reitz  'data': { 'mountpoint': 'str',
1858fc54f94SMax Reitz            '*growable': 'bool',
1868fc54f94SMax Reitz            '*allow-other': 'FuseExportAllowOther' },
1878a9f1e1dSMarc-André Lureau  'if': 'CONFIG_FUSE' }
1880c9b70d5SMax Reitz
1890c9b70d5SMax Reitz##
1902a2359b8SXie Yongji# @BlockExportOptionsVduseBlk:
1912a2359b8SXie Yongji#
1922a2359b8SXie Yongji# A vduse-blk block export.
1932a2359b8SXie Yongji#
194779d82e1SXie Yongji# @name: the name of VDUSE device (must be unique across the host).
195a937b6aaSMarkus Armbruster#
1962a2359b8SXie Yongji# @num-queues: the number of virtqueues.  Defaults to 1.
197a937b6aaSMarkus Armbruster#
1982a2359b8SXie Yongji# @queue-size: the size of virtqueue.  Defaults to 256.
199a937b6aaSMarkus Armbruster#
200a937b6aaSMarkus Armbruster# @logical-block-size: Logical block size in bytes.  Range [512,
201a937b6aaSMarkus Armbruster#     PAGE_SIZE] and must be power of 2. Defaults to 512 bytes.
202a937b6aaSMarkus Armbruster#
203a937b6aaSMarkus Armbruster# @serial: the serial number of virtio block device.  Defaults to
204a937b6aaSMarkus Armbruster#     empty string.
2052a2359b8SXie Yongji#
2062a2359b8SXie Yongji# Since: 7.1
2072a2359b8SXie Yongji##
2082a2359b8SXie Yongji{ 'struct': 'BlockExportOptionsVduseBlk',
209779d82e1SXie Yongji  'data': { 'name': 'str',
210779d82e1SXie Yongji            '*num-queues': 'uint16',
2112a2359b8SXie Yongji            '*queue-size': 'uint16',
2120862a087SXie Yongji            '*logical-block-size': 'size',
2130862a087SXie Yongji            '*serial': 'str' } }
2142a2359b8SXie Yongji
2152a2359b8SXie Yongji##
216b6076afcSKevin Wolf# @NbdServerAddOptions:
217b6076afcSKevin Wolf#
218cbad81ceSEric Blake# An NBD block export, per legacy nbd-server-add command.
219b6076afcSKevin Wolf#
220b6076afcSKevin Wolf# @device: The device name or node name of the node to be exported
221b6076afcSKevin Wolf#
222a937b6aaSMarkus Armbruster# @writable: Whether clients should be able to write to the device via
223a937b6aaSMarkus Armbruster#     the NBD connection (default false).
22430dbc81dSKevin Wolf#
225a937b6aaSMarkus Armbruster# @bitmap: Also export a single dirty bitmap reachable from @device,
226a937b6aaSMarkus Armbruster#     so the NBD client can use NBD_OPT_SET_META_CONTEXT with the
227a937b6aaSMarkus Armbruster#     metadata context name "qemu:dirty-bitmap:BITMAP" to inspect the
228a937b6aaSMarkus Armbruster#     bitmap (since 4.0).
229cbad81ceSEric Blake#
230b6076afcSKevin Wolf# Since: 5.0
231b6076afcSKevin Wolf##
232b6076afcSKevin Wolf{ 'struct': 'NbdServerAddOptions',
233cbad81ceSEric Blake  'base': 'BlockExportOptionsNbdBase',
23430dbc81dSKevin Wolf  'data': { 'device': 'str',
235cbad81ceSEric Blake            '*writable': 'bool', '*bitmap': 'str' } }
236b6076afcSKevin Wolf
237b6076afcSKevin Wolf##
2385daa6bfdSKevin Wolf# @nbd-server-add:
2395daa6bfdSKevin Wolf#
2405daa6bfdSKevin Wolf# Export a block node to QEMU's embedded NBD server.
2415daa6bfdSKevin Wolf#
242a937b6aaSMarkus Armbruster# The export name will be used as the id for the resulting block
243a937b6aaSMarkus Armbruster# export.
244d53be9ceSKevin Wolf#
245443127e8SKevin Wolf# Features:
246443127e8SKevin Wolf#
247a937b6aaSMarkus Armbruster# @deprecated: This command is deprecated.  Use @block-export-add
248a937b6aaSMarkus Armbruster#     instead.
249a937b6aaSMarkus Armbruster#
250a937b6aaSMarkus Armbruster# Returns: error if the server is not running, or export with the same
251a937b6aaSMarkus Armbruster#     name already exists.
2525daa6bfdSKevin Wolf#
2539bc6e893SMarkus Armbruster# Since: 1.3
2545daa6bfdSKevin Wolf##
2555daa6bfdSKevin Wolf{ 'command': 'nbd-server-add',
256f55ba801SPaolo Bonzini  'data': 'NbdServerAddOptions', 'boxed': true, 'features': ['deprecated'],
257f55ba801SPaolo Bonzini  'allow-preconfig': true }
2585daa6bfdSKevin Wolf
2595daa6bfdSKevin Wolf##
2603c3bc462SKevin Wolf# @BlockExportRemoveMode:
2615daa6bfdSKevin Wolf#
2623c3bc462SKevin Wolf# Mode for removing a block export.
2635daa6bfdSKevin Wolf#
264a937b6aaSMarkus Armbruster# @safe: Remove export if there are no existing connections, fail
265a937b6aaSMarkus Armbruster#     otherwise.
2665daa6bfdSKevin Wolf#
2675daa6bfdSKevin Wolf# @hard: Drop all connections immediately and remove export.
2685daa6bfdSKevin Wolf#
269*e3240ac5SMarkus Armbruster# TODO: Potential additional modes to be added in the future:
2705daa6bfdSKevin Wolf#
271*e3240ac5SMarkus Armbruster#     - hide: Just hide export from new clients, leave existing
272*e3240ac5SMarkus Armbruster#       connections as is.  Remove export after all clients are
273*e3240ac5SMarkus Armbruster#       disconnected.
2745daa6bfdSKevin Wolf#
275*e3240ac5SMarkus Armbruster#     - soft: Hide export from new clients, answer with ESHUTDOWN for
276*e3240ac5SMarkus Armbruster#       all further requests from existing clients.
2775daa6bfdSKevin Wolf#
2785daa6bfdSKevin Wolf# Since: 2.12
2795daa6bfdSKevin Wolf##
2803c3bc462SKevin Wolf{'enum': 'BlockExportRemoveMode', 'data': ['safe', 'hard']}
2815daa6bfdSKevin Wolf
2825daa6bfdSKevin Wolf##
2835daa6bfdSKevin Wolf# @nbd-server-remove:
2845daa6bfdSKevin Wolf#
2855daa6bfdSKevin Wolf# Remove NBD export by name.
2865daa6bfdSKevin Wolf#
2873c3bc462SKevin Wolf# @name: Block export id.
2885daa6bfdSKevin Wolf#
289a937b6aaSMarkus Armbruster# @mode: Mode of command operation.  See @BlockExportRemoveMode
290a937b6aaSMarkus Armbruster#     description.  Default is 'safe'.
2915daa6bfdSKevin Wolf#
292443127e8SKevin Wolf# Features:
293a937b6aaSMarkus Armbruster#
294a937b6aaSMarkus Armbruster# @deprecated: This command is deprecated.  Use @block-export-del
295a937b6aaSMarkus Armbruster#     instead.
296443127e8SKevin Wolf#
2975daa6bfdSKevin Wolf# Returns: error if
298c1101028SMarkus Armbruster#
2995daa6bfdSKevin Wolf#     - the server is not running
3005daa6bfdSKevin Wolf#     - export is not found
3015daa6bfdSKevin Wolf#     - mode is 'safe' and there are existing connections
3025daa6bfdSKevin Wolf#
3035daa6bfdSKevin Wolf# Since: 2.12
3045daa6bfdSKevin Wolf##
3055daa6bfdSKevin Wolf{ 'command': 'nbd-server-remove',
306443127e8SKevin Wolf  'data': {'name': 'str', '*mode': 'BlockExportRemoveMode'},
307f55ba801SPaolo Bonzini  'features': ['deprecated'],
308f55ba801SPaolo Bonzini  'allow-preconfig': true }
3095daa6bfdSKevin Wolf
3105daa6bfdSKevin Wolf##
3115daa6bfdSKevin Wolf# @nbd-server-stop:
3125daa6bfdSKevin Wolf#
313a937b6aaSMarkus Armbruster# Stop QEMU's embedded NBD server, and unregister all devices
314a937b6aaSMarkus Armbruster# previously added via @nbd-server-add.
3155daa6bfdSKevin Wolf#
3169bc6e893SMarkus Armbruster# Since: 1.3
3175daa6bfdSKevin Wolf##
318f55ba801SPaolo Bonzini{ 'command': 'nbd-server-stop',
319f55ba801SPaolo Bonzini  'allow-preconfig': true }
3205daa6bfdSKevin Wolf
3215daa6bfdSKevin Wolf##
3225daa6bfdSKevin Wolf# @BlockExportType:
3235daa6bfdSKevin Wolf#
3245daa6bfdSKevin Wolf# An enumeration of block export types
3255daa6bfdSKevin Wolf#
3265daa6bfdSKevin Wolf# @nbd: NBD export
327a937b6aaSMarkus Armbruster#
32890fc91d5SStefan Hajnoczi# @vhost-user-blk: vhost-user-blk export (since 5.2)
329a937b6aaSMarkus Armbruster#
3300c9b70d5SMax Reitz# @fuse: FUSE export (since: 6.0)
331a937b6aaSMarkus Armbruster#
3322a2359b8SXie Yongji# @vduse-blk: vduse-blk export (since 7.1)
3335daa6bfdSKevin Wolf#
3345daa6bfdSKevin Wolf# Since: 4.2
3355daa6bfdSKevin Wolf##
3365daa6bfdSKevin Wolf{ 'enum': 'BlockExportType',
337bb01ea73SPhilippe Mathieu-Daudé  'data': [ 'nbd',
3383a8fa0edSPhilippe Mathieu-Daude            { 'name': 'vhost-user-blk',
3393a8fa0edSPhilippe Mathieu-Daude              'if': 'CONFIG_VHOST_USER_BLK_SERVER' },
3402a2359b8SXie Yongji            { 'name': 'fuse', 'if': 'CONFIG_FUSE' },
3412a2359b8SXie Yongji            { 'name': 'vduse-blk', 'if': 'CONFIG_VDUSE_BLK_EXPORT' } ] }
3425daa6bfdSKevin Wolf
3435daa6bfdSKevin Wolf##
344143ea767SKevin Wolf# @BlockExportOptions:
3455daa6bfdSKevin Wolf#
346a937b6aaSMarkus Armbruster# Describes a block export, i.e. how single node should be exported on
347a937b6aaSMarkus Armbruster# an external interface.
3485daa6bfdSKevin Wolf#
349a937b6aaSMarkus Armbruster# @id: A unique identifier for the block export (across all export
350a937b6aaSMarkus Armbruster#     types)
351d53be9ceSKevin Wolf#
352a937b6aaSMarkus Armbruster# @node-name: The node name of the block node to be exported
353a937b6aaSMarkus Armbruster#     (since: 5.2)
354b6076afcSKevin Wolf#
35530dbc81dSKevin Wolf# @writable: True if clients should be able to write to the export
35630dbc81dSKevin Wolf#     (default false)
35730dbc81dSKevin Wolf#
358a937b6aaSMarkus Armbruster# @writethrough: If true, caches are flushed after every write request
359a937b6aaSMarkus Armbruster#     to the export before completion is signalled.  (since: 5.2;
360fefee85dSKevin Wolf#     default: false)
361fefee85dSKevin Wolf#
362a937b6aaSMarkus Armbruster# @iothread: The name of the iothread object where the export will
363a937b6aaSMarkus Armbruster#     run.  The default is to use the thread currently associated with
364a937b6aaSMarkus Armbruster#     the block node.  (since: 5.2)
365f51d23c8SStefan Hajnoczi#
366a937b6aaSMarkus Armbruster# @fixed-iothread: True prevents the block node from being moved to
367a937b6aaSMarkus Armbruster#     another thread while the export is active.  If true and
368a937b6aaSMarkus Armbruster#     @iothread is given, export creation fails if the block node
369a937b6aaSMarkus Armbruster#     cannot be moved to the iothread.  The default is false.
370a937b6aaSMarkus Armbruster#     (since: 5.2)
371f51d23c8SStefan Hajnoczi#
3725daa6bfdSKevin Wolf# Since: 4.2
3735daa6bfdSKevin Wolf##
374143ea767SKevin Wolf{ 'union': 'BlockExportOptions',
375fefee85dSKevin Wolf  'base': { 'type': 'BlockExportType',
376d53be9ceSKevin Wolf            'id': 'str',
377f51d23c8SStefan Hajnoczi            '*fixed-iothread': 'bool',
378f51d23c8SStefan Hajnoczi            '*iothread': 'str',
379b6076afcSKevin Wolf            'node-name': 'str',
38030dbc81dSKevin Wolf            '*writable': 'bool',
381fefee85dSKevin Wolf            '*writethrough': 'bool' },
3825daa6bfdSKevin Wolf  'discriminator': 'type',
3835daa6bfdSKevin Wolf  'data': {
38490fc91d5SStefan Hajnoczi      'nbd': 'BlockExportOptionsNbd',
385bb01ea73SPhilippe Mathieu-Daudé      'vhost-user-blk': { 'type': 'BlockExportOptionsVhostUserBlk',
386bb01ea73SPhilippe Mathieu-Daudé                          'if': 'CONFIG_VHOST_USER_BLK_SERVER' },
3870c9b70d5SMax Reitz      'fuse': { 'type': 'BlockExportOptionsFuse',
3882a2359b8SXie Yongji                'if': 'CONFIG_FUSE' },
3892a2359b8SXie Yongji      'vduse-blk': { 'type': 'BlockExportOptionsVduseBlk',
3902a2359b8SXie Yongji                     'if': 'CONFIG_VDUSE_BLK_EXPORT' }
3915daa6bfdSKevin Wolf   } }
39256ee8626SKevin Wolf
39356ee8626SKevin Wolf##
39456ee8626SKevin Wolf# @block-export-add:
39556ee8626SKevin Wolf#
39656ee8626SKevin Wolf# Creates a new block export.
39756ee8626SKevin Wolf#
39856ee8626SKevin Wolf# Since: 5.2
39956ee8626SKevin Wolf##
40056ee8626SKevin Wolf{ 'command': 'block-export-add',
401f55ba801SPaolo Bonzini  'data': 'BlockExportOptions', 'boxed': true,
402f55ba801SPaolo Bonzini  'allow-preconfig': true }
4033c3bc462SKevin Wolf
4043c3bc462SKevin Wolf##
4053c3bc462SKevin Wolf# @block-export-del:
4063c3bc462SKevin Wolf#
407a937b6aaSMarkus Armbruster# Request to remove a block export.  This drops the user's reference
408a937b6aaSMarkus Armbruster# to the export, but the export may still stay around after this
409a937b6aaSMarkus Armbruster# command returns until the shutdown of the export has completed.
4103c3bc462SKevin Wolf#
4113c3bc462SKevin Wolf# @id: Block export id.
4123c3bc462SKevin Wolf#
413a937b6aaSMarkus Armbruster# @mode: Mode of command operation.  See @BlockExportRemoveMode
414a937b6aaSMarkus Armbruster#     description.  Default is 'safe'.
4153c3bc462SKevin Wolf#
416a937b6aaSMarkus Armbruster# Returns: Error if the export is not found or @mode is 'safe' and the
417a937b6aaSMarkus Armbruster#     export is still in use (e.g. by existing client connections)
4183c3bc462SKevin Wolf#
4193c3bc462SKevin Wolf# Since: 5.2
4203c3bc462SKevin Wolf##
4213c3bc462SKevin Wolf{ 'command': 'block-export-del',
422f55ba801SPaolo Bonzini  'data': { 'id': 'str', '*mode': 'BlockExportRemoveMode' },
423f55ba801SPaolo Bonzini  'allow-preconfig': true }
4241a9f7a80SKevin Wolf
4251a9f7a80SKevin Wolf##
4261a9f7a80SKevin Wolf# @BLOCK_EXPORT_DELETED:
4271a9f7a80SKevin Wolf#
4281a9f7a80SKevin Wolf# Emitted when a block export is removed and its id can be reused.
4291a9f7a80SKevin Wolf#
4301a9f7a80SKevin Wolf# @id: Block export id.
4311a9f7a80SKevin Wolf#
4321a9f7a80SKevin Wolf# Since: 5.2
4331a9f7a80SKevin Wolf##
4341a9f7a80SKevin Wolf{ 'event': 'BLOCK_EXPORT_DELETED',
4351a9f7a80SKevin Wolf  'data': { 'id': 'str' } }
4368cade320SKevin Wolf
4378cade320SKevin Wolf##
4388cade320SKevin Wolf# @BlockExportInfo:
4398cade320SKevin Wolf#
4408cade320SKevin Wolf# Information about a single block export.
4418cade320SKevin Wolf#
4428cade320SKevin Wolf# @id: The unique identifier for the block export
4438cade320SKevin Wolf#
4448cade320SKevin Wolf# @type: The block export type
4458cade320SKevin Wolf#
4468cade320SKevin Wolf# @node-name: The node name of the block node that is exported
4478cade320SKevin Wolf#
4488cade320SKevin Wolf# @shutting-down: True if the export is shutting down (e.g. after a
449a937b6aaSMarkus Armbruster#     block-export-del command, but before the shutdown has completed)
4508cade320SKevin Wolf#
4518cade320SKevin Wolf# Since: 5.2
4528cade320SKevin Wolf##
4538cade320SKevin Wolf{ 'struct': 'BlockExportInfo',
4548cade320SKevin Wolf  'data': { 'id': 'str',
4558cade320SKevin Wolf            'type': 'BlockExportType',
4568cade320SKevin Wolf            'node-name': 'str',
4578cade320SKevin Wolf            'shutting-down': 'bool' } }
4588cade320SKevin Wolf
4598cade320SKevin Wolf##
4608cade320SKevin Wolf# @query-block-exports:
4618cade320SKevin Wolf#
4628cade320SKevin Wolf# Returns: A list of BlockExportInfo describing all block exports
4638cade320SKevin Wolf#
4648cade320SKevin Wolf# Since: 5.2
4658cade320SKevin Wolf##
466f55ba801SPaolo Bonzini{ 'command': 'query-block-exports', 'returns': ['BlockExportInfo'],
467f55ba801SPaolo Bonzini  'allow-preconfig': true }
468