diff options
author | Laurent Vivier <lvivier@redhat.com> | 2022-10-21 11:09:18 +0200 |
---|---|---|
committer | Jason Wang <jasowang@redhat.com> | 2022-10-28 13:28:52 +0800 |
commit | 18bf1c94565b1b594873aaea9dfd47c83abd8543 (patch) | |
tree | 0e463462e1107c445897ef80cc118ba09e9399b9 /util | |
parent | 784e7a2531040824f88f33494be256a9e331e219 (diff) | |
download | qemu-18bf1c94565b1b594873aaea9dfd47c83abd8543.zip qemu-18bf1c94565b1b594873aaea9dfd47c83abd8543.tar.gz qemu-18bf1c94565b1b594873aaea9dfd47c83abd8543.tar.bz2 |
qemu-sockets: move and rename SocketAddress_to_str()
Rename SocketAddress_to_str() to socket_uri() and move it to
util/qemu-sockets.c close to socket_parse().
socket_uri() generates a string from a SocketAddress while
socket_parse() generates a SocketAddress from a string.
Signed-off-by: Laurent Vivier <lvivier@redhat.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
Diffstat (limited to 'util')
-rw-r--r-- | util/qemu-sockets.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c index 83f4bd6..9f6f655 100644 --- a/util/qemu-sockets.c +++ b/util/qemu-sockets.c @@ -1077,6 +1077,26 @@ int unix_connect(const char *path, Error **errp) return sock; } +char *socket_uri(SocketAddress *addr) +{ + switch (addr->type) { + case SOCKET_ADDRESS_TYPE_INET: + return g_strdup_printf("tcp:%s:%s", + addr->u.inet.host, + addr->u.inet.port); + case SOCKET_ADDRESS_TYPE_UNIX: + return g_strdup_printf("unix:%s", + addr->u.q_unix.path); + case SOCKET_ADDRESS_TYPE_FD: + return g_strdup_printf("fd:%s", addr->u.fd.str); + case SOCKET_ADDRESS_TYPE_VSOCK: + return g_strdup_printf("tcp:%s:%s", + addr->u.vsock.cid, + addr->u.vsock.port); + default: + return g_strdup("unknown address type"); + } +} SocketAddress *socket_parse(const char *str, Error **errp) { |