qapi: merge common parts of NbdServerOptions and nbd-server-start data

Instead of comment
"Keep this type consistent with the nbd-server-start arguments", we
can simply merge these things.

Note that each field of new base already has "since" tag, equal in both
original copies. So "since" information is saved.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
Message-ID: <20250219191914.440451-1-vsementsov@yandex-team.ru>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
This commit is contained in:
Vladimir Sementsov-Ogievskiy 2025-02-19 22:19:14 +03:00 committed by Eric Blake
parent e2668ba1ed
commit 57f3962bf1
2 changed files with 44 additions and 54 deletions

View File

@ -219,12 +219,12 @@ void nbd_server_start_options(NbdServerOptions *arg, Error **errp)
arg->tls_authz, arg->max_connections, errp);
}
void qmp_nbd_server_start(SocketAddressLegacy *addr,
bool has_handshake_max_secs,
void qmp_nbd_server_start(bool has_handshake_max_secs,
uint32_t handshake_max_secs,
const char *tls_creds,
const char *tls_authz,
bool has_max_connections, uint32_t max_connections,
SocketAddressLegacy *addr,
Error **errp)
{
SocketAddress *addr_flat = socket_address_flatten(addr);

View File

@ -9,53 +9,7 @@
{ 'include': 'block-core.json' }
##
# @NbdServerOptions:
#
# Keep this type consistent with the nbd-server-start arguments. The
# only intended difference is using SocketAddress instead of
# SocketAddressLegacy.
#
# @addr: Address on which to listen.
#
# @handshake-max-seconds: Time limit, in seconds, at which a client
# that has not completed the negotiation handshake will be
# disconnected, 0 for no limit (since 10.0; default: 10).
#
# @tls-creds: ID of the TLS credentials object (since 2.6).
#
# @tls-authz: ID of the QAuthZ authorization object used to validate
# the client's x509 distinguished name. This object is is only
# resolved at time of use, so can be deleted and recreated on the
# fly while the NBD server is active. If missing, it will default
# to denying access (since 4.0).
#
# @max-connections: The maximum number of connections to allow at the
# same time, 0 for unlimited. Setting this to 1 also stops the
# server from advertising multiple client support (since 5.2;
# default: 100)
#
# Since: 4.2
##
{ 'struct': 'NbdServerOptions',
'data': { 'addr': 'SocketAddress',
'*handshake-max-seconds': 'uint32',
'*tls-creds': 'str',
'*tls-authz': 'str',
'*max-connections': 'uint32' } }
##
# @nbd-server-start:
#
# Start an NBD server listening on the given host and port. Block
# devices can then be exported using @nbd-server-add. The NBD server
# will present them as named exports; for example, another QEMU
# instance could refer to them as "nbd:HOST:PORT:exportname=NAME".
#
# Keep this type consistent with the NbdServerOptions type. The only
# intended difference is using SocketAddressLegacy instead of
# SocketAddress.
#
# @addr: Address on which to listen.
# @NbdServerOptionsBase:
#
# @handshake-max-seconds: Time limit, in seconds, at which a client
# that has not completed the negotiation handshake will be
@ -73,6 +27,46 @@
# same time, 0 for unlimited. Setting this to 1 also stops the
# server from advertising multiple client support (since 5.2;
# default: 100).
##
{ 'struct': 'NbdServerOptionsBase',
'data': { '*handshake-max-seconds': 'uint32',
'*tls-creds': 'str',
'*tls-authz': 'str',
'*max-connections': 'uint32' } }
##
# @NbdServerOptions:
#
# Keep this type consistent with the NbdServerOptionsLegacy type. The
# only intended difference is using SocketAddress instead of
# SocketAddressLegacy.
#
# @addr: Address on which to listen (since 4.2).
##
{ 'struct': 'NbdServerOptions',
'base': 'NbdServerOptionsBase',
'data': { 'addr': 'SocketAddress' } }
##
# @NbdServerOptionsLegacy:
#
# Keep this type consistent with the NbdServerOptions type. The only
# intended difference is using SocketAddressLegacy instead of
# SocketAddress.
#
# @addr: Address on which to listen (since 1.3).
##
{ 'struct': 'NbdServerOptionsLegacy',
'base': 'NbdServerOptionsBase',
'data': { 'addr': 'SocketAddressLegacy' } }
##
# @nbd-server-start:
#
# Start an NBD server listening on the given host and port. Block
# devices can then be exported using @nbd-server-add. The NBD server
# will present them as named exports; for example, another QEMU
# instance could refer to them as "nbd:HOST:PORT:exportname=NAME".
#
# Errors:
# - if the server is already running
@ -80,11 +74,7 @@
# Since: 1.3
##
{ 'command': 'nbd-server-start',
'data': { 'addr': 'SocketAddressLegacy',
'*handshake-max-seconds': 'uint32',
'*tls-creds': 'str',
'*tls-authz': 'str',
'*max-connections': 'uint32' },
'data': 'NbdServerOptionsLegacy',
'allow-preconfig': true }
##