]> git.proxmox.com Git - mirror_qemu.git/blame - qapi/block-export.json
block: add more commands to preconfig mode
[mirror_qemu.git] / qapi / block-export.json
CommitLineData
5daa6bfd
KW
1# -*- Mode: Python -*-
2# vim: filetype=python
3
4##
5# == Block device exports
6##
7
8{ 'include': 'sockets.json' }
e5fb29d5 9{ 'include': 'block-core.json' }
5daa6bfd
KW
10
11##
12# @NbdServerOptions:
13#
14# Keep this type consistent with the nbd-server-start arguments. The only
15# intended difference is using SocketAddress instead of SocketAddressLegacy.
16#
17# @addr: Address on which to listen.
18# @tls-creds: ID of the TLS credentials object (since 2.6).
19# @tls-authz: ID of the QAuthZ authorization object used to validate
20# the client's x509 distinguished name. This object is
21# is only resolved at time of use, so can be deleted and
22# recreated on the fly while the NBD server is active.
23# If missing, it will default to denying access (since 4.0).
1c8222b0 24# @max-connections: The maximum number of connections to allow at the same
58a6fdcc
EB
25# time, 0 for unlimited. Setting this to 1 also stops
26# the server from advertising multiple client support
27# (since 5.2; default: 0)
5daa6bfd
KW
28#
29# Since: 4.2
30##
31{ 'struct': 'NbdServerOptions',
32 'data': { 'addr': 'SocketAddress',
33 '*tls-creds': 'str',
1c8222b0
KW
34 '*tls-authz': 'str',
35 '*max-connections': 'uint32' } }
5daa6bfd
KW
36
37##
38# @nbd-server-start:
39#
40# Start an NBD server listening on the given host and port. Block
41# devices can then be exported using @nbd-server-add. The NBD
42# server will present them as named exports; for example, another
43# QEMU instance could refer to them as "nbd:HOST:PORT:exportname=NAME".
44#
45# Keep this type consistent with the NbdServerOptions type. The only intended
46# difference is using SocketAddressLegacy instead of SocketAddress.
47#
48# @addr: Address on which to listen.
49# @tls-creds: ID of the TLS credentials object (since 2.6).
50# @tls-authz: ID of the QAuthZ authorization object used to validate
51# the client's x509 distinguished name. This object is
52# is only resolved at time of use, so can be deleted and
53# recreated on the fly while the NBD server is active.
54# If missing, it will default to denying access (since 4.0).
1c8222b0 55# @max-connections: The maximum number of connections to allow at the same
58a6fdcc
EB
56# time, 0 for unlimited. Setting this to 1 also stops
57# the server from advertising multiple client support
58# (since 5.2; default: 0).
5daa6bfd
KW
59#
60# Returns: error if the server is already running.
61#
9bc6e893 62# Since: 1.3
5daa6bfd
KW
63##
64{ 'command': 'nbd-server-start',
65 'data': { 'addr': 'SocketAddressLegacy',
66 '*tls-creds': 'str',
1c8222b0 67 '*tls-authz': 'str',
f55ba801
PB
68 '*max-connections': 'uint32' },
69 'allow-preconfig': true }
5daa6bfd
KW
70
71##
cbad81ce 72# @BlockExportOptionsNbdBase:
5daa6bfd 73#
cbad81ce
EB
74# An NBD block export (common options shared between nbd-server-add and
75# the NBD branch of block-export-add).
5daa6bfd
KW
76#
77# @name: Export name. If unspecified, the @device parameter is used as the
78# export name. (Since 2.12)
79#
80# @description: Free-form description of the export, up to 4096 bytes.
81# (Since 5.0)
82#
5daa6bfd
KW
83# Since: 5.0
84##
cbad81ce
EB
85{ 'struct': 'BlockExportOptionsNbdBase',
86 'data': { '*name': 'str', '*description': 'str' } }
87
88##
89# @BlockExportOptionsNbd:
90#
91# An NBD block export (distinct options used in the NBD branch of
92# block-export-add).
93#
94# @bitmaps: Also export each of the named dirty bitmaps reachable from
95# @device, so the NBD client can use NBD_OPT_SET_META_CONTEXT with
96# the metadata context name "qemu:dirty-bitmap:BITMAP" to inspect
97# each bitmap.
e5fb29d5 98# Since 7.1 bitmap may be specified by node/name pair.
cbad81ce 99#
dbc7b014
EB
100# @allocation-depth: Also export the allocation depth map for @device, so
101# the NBD client can use NBD_OPT_SET_META_CONTEXT with
102# the metadata context name "qemu:allocation-depth" to
103# inspect allocation details. (since 5.2)
104#
cbad81ce
EB
105# Since: 5.2
106##
143ea767 107{ 'struct': 'BlockExportOptionsNbd',
cbad81ce 108 'base': 'BlockExportOptionsNbdBase',
e5fb29d5
VSO
109 'data': { '*bitmaps': ['BlockDirtyBitmapOrStr'],
110 '*allocation-depth': 'bool' } }
b6076afc 111
90fc91d5
SH
112##
113# @BlockExportOptionsVhostUserBlk:
114#
115# A vhost-user-blk block export.
116#
117# @addr: The vhost-user socket on which to listen. Both 'unix' and 'fd'
118# SocketAddress types are supported. Passed fds must be UNIX domain
119# sockets.
120# @logical-block-size: Logical block size in bytes. Defaults to 512 bytes.
d9b495f9
SH
121# @num-queues: Number of request virtqueues. Must be greater than 0. Defaults
122# to 1.
90fc91d5
SH
123#
124# Since: 5.2
125##
126{ 'struct': 'BlockExportOptionsVhostUserBlk',
d9b495f9
SH
127 'data': { 'addr': 'SocketAddress',
128 '*logical-block-size': 'size',
129 '*num-queues': 'uint16'} }
90fc91d5 130
8fc54f94
HR
131##
132# @FuseExportAllowOther:
133#
134# Possible allow_other modes for FUSE exports.
135#
136# @off: Do not pass allow_other as a mount option.
137#
138# @on: Pass allow_other as a mount option.
139#
140# @auto: Try mounting with allow_other first, and if that fails, retry
141# without allow_other.
142#
143# Since: 6.1
144##
145{ 'enum': 'FuseExportAllowOther',
146 'data': ['off', 'on', 'auto'] }
147
0c9b70d5
HR
148##
149# @BlockExportOptionsFuse:
150#
151# Options for exporting a block graph node on some (file) mountpoint
152# as a raw image.
153#
154# @mountpoint: Path on which to export the block device via FUSE.
155# This must point to an existing regular file.
156#
4fba06d5
HR
157# @growable: Whether writes beyond the EOF should grow the block node
158# accordingly. (default: false)
159#
8fc54f94
HR
160# @allow-other: If this is off, only qemu's user is allowed access to
161# this export. That cannot be changed even with chmod or
162# chown.
163# Enabling this option will allow other users access to
164# the export with the FUSE mount option "allow_other".
165# Note that using allow_other as a non-root user requires
166# user_allow_other to be enabled in the global fuse.conf
167# configuration file.
168# In auto mode (the default), the FUSE export driver will
169# first attempt to mount the export with allow_other, and
170# if that fails, try again without.
171# (since 6.1; default: auto)
172#
0c9b70d5
HR
173# Since: 6.0
174##
175{ 'struct': 'BlockExportOptionsFuse',
4fba06d5 176 'data': { 'mountpoint': 'str',
8fc54f94
HR
177 '*growable': 'bool',
178 '*allow-other': 'FuseExportAllowOther' },
8a9f1e1d 179 'if': 'CONFIG_FUSE' }
0c9b70d5 180
b6076afc
KW
181##
182# @NbdServerAddOptions:
183#
cbad81ce 184# An NBD block export, per legacy nbd-server-add command.
b6076afc
KW
185#
186# @device: The device name or node name of the node to be exported
187#
30dbc81d
KW
188# @writable: Whether clients should be able to write to the device via the
189# NBD connection (default false).
190#
cbad81ce
EB
191# @bitmap: Also export a single dirty bitmap reachable from @device, so the
192# NBD client can use NBD_OPT_SET_META_CONTEXT with the metadata
193# context name "qemu:dirty-bitmap:BITMAP" to inspect the bitmap
194# (since 4.0).
195#
b6076afc
KW
196# Since: 5.0
197##
198{ 'struct': 'NbdServerAddOptions',
cbad81ce 199 'base': 'BlockExportOptionsNbdBase',
30dbc81d 200 'data': { 'device': 'str',
cbad81ce 201 '*writable': 'bool', '*bitmap': 'str' } }
5daa6bfd
KW
202
203##
204# @nbd-server-add:
205#
206# Export a block node to QEMU's embedded NBD server.
207#
d53be9ce
KW
208# The export name will be used as the id for the resulting block export.
209#
443127e8
KW
210# Features:
211# @deprecated: This command is deprecated. Use @block-export-add instead.
212#
5daa6bfd
KW
213# Returns: error if the server is not running, or export with the same name
214# already exists.
215#
9bc6e893 216# Since: 1.3
5daa6bfd
KW
217##
218{ 'command': 'nbd-server-add',
f55ba801
PB
219 'data': 'NbdServerAddOptions', 'boxed': true, 'features': ['deprecated'],
220 'allow-preconfig': true }
5daa6bfd
KW
221
222##
3c3bc462 223# @BlockExportRemoveMode:
5daa6bfd 224#
3c3bc462 225# Mode for removing a block export.
5daa6bfd
KW
226#
227# @safe: Remove export if there are no existing connections, fail otherwise.
228#
229# @hard: Drop all connections immediately and remove export.
230#
97cd74f7 231# TODO: Potential additional modes to be added in the future:
5daa6bfd 232#
97cd74f7
VT
233# hide: Just hide export from new clients, leave existing connections as is.
234# Remove export after all clients are disconnected.
5daa6bfd 235#
97cd74f7
VT
236# soft: Hide export from new clients, answer with ESHUTDOWN for all further
237# requests from existing clients.
5daa6bfd
KW
238#
239# Since: 2.12
240##
3c3bc462 241{'enum': 'BlockExportRemoveMode', 'data': ['safe', 'hard']}
5daa6bfd
KW
242
243##
244# @nbd-server-remove:
245#
246# Remove NBD export by name.
247#
3c3bc462 248# @name: Block export id.
5daa6bfd 249#
3c3bc462 250# @mode: Mode of command operation. See @BlockExportRemoveMode description.
5daa6bfd
KW
251# Default is 'safe'.
252#
443127e8
KW
253# Features:
254# @deprecated: This command is deprecated. Use @block-export-del instead.
255#
5daa6bfd
KW
256# Returns: error if
257# - the server is not running
258# - export is not found
259# - mode is 'safe' and there are existing connections
260#
261# Since: 2.12
262##
263{ 'command': 'nbd-server-remove',
443127e8 264 'data': {'name': 'str', '*mode': 'BlockExportRemoveMode'},
f55ba801
PB
265 'features': ['deprecated'],
266 'allow-preconfig': true }
5daa6bfd
KW
267
268##
269# @nbd-server-stop:
270#
271# Stop QEMU's embedded NBD server, and unregister all devices previously
272# added via @nbd-server-add.
273#
9bc6e893 274# Since: 1.3
5daa6bfd 275##
f55ba801
PB
276{ 'command': 'nbd-server-stop',
277 'allow-preconfig': true }
5daa6bfd
KW
278
279##
280# @BlockExportType:
281#
282# An enumeration of block export types
283#
284# @nbd: NBD export
90fc91d5 285# @vhost-user-blk: vhost-user-blk export (since 5.2)
0c9b70d5 286# @fuse: FUSE export (since: 6.0)
5daa6bfd
KW
287#
288# Since: 4.2
289##
290{ 'enum': 'BlockExportType',
bb01ea73 291 'data': [ 'nbd',
3a8fa0ed
PMD
292 { 'name': 'vhost-user-blk',
293 'if': 'CONFIG_VHOST_USER_BLK_SERVER' },
8a9f1e1d 294 { 'name': 'fuse', 'if': 'CONFIG_FUSE' } ] }
5daa6bfd
KW
295
296##
143ea767 297# @BlockExportOptions:
5daa6bfd
KW
298#
299# Describes a block export, i.e. how single node should be exported on an
300# external interface.
301#
d53be9ce
KW
302# @id: A unique identifier for the block export (across all export types)
303#
b6076afc
KW
304# @node-name: The node name of the block node to be exported (since: 5.2)
305#
30dbc81d
KW
306# @writable: True if clients should be able to write to the export
307# (default false)
308#
fefee85d
KW
309# @writethrough: If true, caches are flushed after every write request to the
310# export before completion is signalled. (since: 5.2;
311# default: false)
312#
f51d23c8
SH
313# @iothread: The name of the iothread object where the export will run. The
314# default is to use the thread currently associated with the
315# block node. (since: 5.2)
316#
317# @fixed-iothread: True prevents the block node from being moved to another
318# thread while the export is active. If true and @iothread is
319# given, export creation fails if the block node cannot be
320# moved to the iothread. The default is false. (since: 5.2)
321#
5daa6bfd
KW
322# Since: 4.2
323##
143ea767 324{ 'union': 'BlockExportOptions',
fefee85d 325 'base': { 'type': 'BlockExportType',
d53be9ce 326 'id': 'str',
d9b495f9
SH
327 '*fixed-iothread': 'bool',
328 '*iothread': 'str',
b6076afc 329 'node-name': 'str',
30dbc81d 330 '*writable': 'bool',
fefee85d 331 '*writethrough': 'bool' },
5daa6bfd
KW
332 'discriminator': 'type',
333 'data': {
90fc91d5 334 'nbd': 'BlockExportOptionsNbd',
bb01ea73
PMD
335 'vhost-user-blk': { 'type': 'BlockExportOptionsVhostUserBlk',
336 'if': 'CONFIG_VHOST_USER_BLK_SERVER' },
0c9b70d5 337 'fuse': { 'type': 'BlockExportOptionsFuse',
8a9f1e1d 338 'if': 'CONFIG_FUSE' }
5daa6bfd 339 } }
56ee8626
KW
340
341##
342# @block-export-add:
343#
344# Creates a new block export.
345#
346# Since: 5.2
347##
348{ 'command': 'block-export-add',
f55ba801
PB
349 'data': 'BlockExportOptions', 'boxed': true,
350 'allow-preconfig': true }
3c3bc462
KW
351
352##
353# @block-export-del:
354#
355# Request to remove a block export. This drops the user's reference to the
356# export, but the export may still stay around after this command returns until
357# the shutdown of the export has completed.
358#
359# @id: Block export id.
360#
361# @mode: Mode of command operation. See @BlockExportRemoveMode description.
362# Default is 'safe'.
363#
364# Returns: Error if the export is not found or @mode is 'safe' and the export
365# is still in use (e.g. by existing client connections)
366#
367# Since: 5.2
368##
369{ 'command': 'block-export-del',
f55ba801
PB
370 'data': { 'id': 'str', '*mode': 'BlockExportRemoveMode' },
371 'allow-preconfig': true }
1a9f7a80
KW
372
373##
374# @BLOCK_EXPORT_DELETED:
375#
376# Emitted when a block export is removed and its id can be reused.
377#
378# @id: Block export id.
379#
380# Since: 5.2
381##
382{ 'event': 'BLOCK_EXPORT_DELETED',
383 'data': { 'id': 'str' } }
8cade320
KW
384
385##
386# @BlockExportInfo:
387#
388# Information about a single block export.
389#
390# @id: The unique identifier for the block export
391#
392# @type: The block export type
393#
394# @node-name: The node name of the block node that is exported
395#
396# @shutting-down: True if the export is shutting down (e.g. after a
397# block-export-del command, but before the shutdown has
398# completed)
399#
23e46452 400# Since: 5.2
8cade320
KW
401##
402{ 'struct': 'BlockExportInfo',
403 'data': { 'id': 'str',
404 'type': 'BlockExportType',
405 'node-name': 'str',
406 'shutting-down': 'bool' } }
407
408##
409# @query-block-exports:
410#
411# Returns: A list of BlockExportInfo describing all block exports
412#
413# Since: 5.2
414##
f55ba801
PB
415{ 'command': 'query-block-exports', 'returns': ['BlockExportInfo'],
416 'allow-preconfig': true }