diff options
author | Markus Armbruster <armbru@redhat.com> | 2017-04-26 09:36:41 +0200 |
---|---|---|
committer | Markus Armbruster <armbru@redhat.com> | 2017-05-09 09:14:40 +0200 |
commit | bd269ebc82fbaa5fe7ce5bc7c1770ac8acecd884 (patch) | |
tree | 82ef0cd9da0812afc7021d5690c14f72e8e13177 /qemu-nbd.c | |
parent | 62cf396b5d397948c5ac4d04d09596ca14f6c173 (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 'qemu-nbd.c')
-rw-r--r-- | qemu-nbd.c | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/qemu-nbd.c b/qemu-nbd.c index 82d08597b0..b7ab86bfa7 100644 --- a/qemu-nbd.c +++ b/qemu-nbd.c @@ -57,7 +57,7 @@ static NBDExport *exp; static bool newproto; static int verbose; static char *srcpath; -static SocketAddressLegacy *saddr; +static SocketAddress *saddr; static int persistent = 0; static enum { RUNNING, TERMINATE, TERMINATING, TERMINATED } state; static int shared = 1; @@ -387,21 +387,20 @@ static void nbd_update_server_watch(void) } -static SocketAddressLegacy *nbd_build_socket_address(const char *sockpath, +static SocketAddress *nbd_build_socket_address(const char *sockpath, const char *bindto, const char *port) { - SocketAddressLegacy *saddr; + SocketAddress *saddr; - saddr = g_new0(SocketAddressLegacy, 1); + saddr = g_new0(SocketAddress, 1); if (sockpath) { - saddr->type = SOCKET_ADDRESS_LEGACY_KIND_UNIX; - saddr->u.q_unix.data = g_new0(UnixSocketAddress, 1); - saddr->u.q_unix.data->path = g_strdup(sockpath); + saddr->type = SOCKET_ADDRESS_TYPE_UNIX; + saddr->u.q_unix.path = g_strdup(sockpath); } else { InetSocketAddress *inet; - saddr->type = SOCKET_ADDRESS_LEGACY_KIND_INET; - inet = saddr->u.inet.data = g_new0(InetSocketAddress, 1); + saddr->type = SOCKET_ADDRESS_TYPE_INET; + inet = &saddr->u.inet; inet->host = g_strdup(bindto); if (port) { inet->port = g_strdup(port); |