aboutsummaryrefslogtreecommitdiff
path: root/blockdev-nbd.c
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2017-04-26 09:36:41 +0200
committerMarkus Armbruster <armbru@redhat.com>2017-05-09 09:14:40 +0200
commitbd269ebc82fbaa5fe7ce5bc7c1770ac8acecd884 (patch)
tree82ef0cd9da0812afc7021d5690c14f72e8e13177 /blockdev-nbd.c
parent62cf396b5d397948c5ac4d04d09596ca14f6c173 (diff)
sockets: Limit SocketAddressLegacy to external interfaces
SocketAddressLegacy is a simple union, and simple unions are awkward: they have their variant members wrapped in a "data" object on the wire, and require additional indirections in C. SocketAddress is the equivalent flat union. Convert all users of SocketAddressLegacy to SocketAddress, except for existing external interfaces. See also commit fce5d53..9445673 and 85a82e8..c5f1ae3. Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <1493192202-3184-7-git-send-email-armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> [Minor editing accident fixed, commit message and a comment tweaked] Signed-off-by: Markus Armbruster <armbru@redhat.com>
Diffstat (limited to 'blockdev-nbd.c')
-rw-r--r--blockdev-nbd.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/blockdev-nbd.c b/blockdev-nbd.c
index 6b0c699c22..dd0860f4a6 100644
--- a/blockdev-nbd.c
+++ b/blockdev-nbd.c
@@ -99,9 +99,8 @@ static QCryptoTLSCreds *nbd_get_tls_creds(const char *id, Error **errp)
}
-void qmp_nbd_server_start(SocketAddressLegacy *addr,
- bool has_tls_creds, const char *tls_creds,
- Error **errp)
+void nbd_server_start(SocketAddress *addr, const char *tls_creds,
+ Error **errp)
{
if (nbd_server) {
error_setg(errp, "NBD server already running");
@@ -118,14 +117,14 @@ void qmp_nbd_server_start(SocketAddressLegacy *addr,
goto error;
}
- if (has_tls_creds) {
+ if (tls_creds) {
nbd_server->tlscreds = nbd_get_tls_creds(tls_creds, errp);
if (!nbd_server->tlscreds) {
goto error;
}
- /* TODO SOCKET_ADDRESS_LEGACY_KIND_FD where fd has AF_INET or AF_INET6 */
- if (addr->type != SOCKET_ADDRESS_LEGACY_KIND_INET) {
+ /* TODO SOCKET_ADDRESS_TYPE_FD where fd has AF_INET or AF_INET6 */
+ if (addr->type != SOCKET_ADDRESS_TYPE_INET) {
error_setg(errp, "TLS is only supported with IPv4/IPv6");
goto error;
}
@@ -145,6 +144,16 @@ void qmp_nbd_server_start(SocketAddressLegacy *addr,
nbd_server = NULL;
}
+void qmp_nbd_server_start(SocketAddressLegacy *addr,
+ bool has_tls_creds, const char *tls_creds,
+ Error **errp)
+{
+ SocketAddress *addr_flat = socket_address_flatten(addr);
+
+ nbd_server_start(addr_flat, tls_creds, errp);
+ qapi_free_SocketAddress(addr_flat);
+}
+
void qmp_nbd_server_add(const char *device, bool has_writable, bool writable,
Error **errp)
{