diff options
author | Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | 2021-06-10 13:07:35 +0300 |
---|---|---|
committer | Eric Blake <eblake@redhat.com> | 2021-06-18 10:59:53 -0500 |
commit | c5423704184c43cadd7b3c5ff0aea3925c5509bc (patch) | |
tree | 9ec78685f696ba2344ff9686108bdd7d8385106d /util/qemu-sockets.c | |
parent | fb392b548eb4c6c2b2c7689e7fc6b1d2077d4f02 (diff) | |
download | qemu-c5423704184c43cadd7b3c5ff0aea3925c5509bc.zip qemu-c5423704184c43cadd7b3c5ff0aea3925c5509bc.tar.gz qemu-c5423704184c43cadd7b3c5ff0aea3925c5509bc.tar.bz2 |
qemu-sockets: introduce socket_address_parse_named_fd()
Add function that transforms named fd inside SocketAddress structure
into number representation. This way it may be then used in a context
where current monitor is not available.
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Message-Id: <20210610100802.5888-6-vsementsov@virtuozzo.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
[eblake: comment tweak]
Signed-off-by: Eric Blake <eblake@redhat.com>
Diffstat (limited to 'util/qemu-sockets.c')
-rw-r--r-- | util/qemu-sockets.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c index c415c34..080a240 100644 --- a/util/qemu-sockets.c +++ b/util/qemu-sockets.c @@ -1164,6 +1164,25 @@ static int socket_get_fd(const char *fdstr, Error **errp) return fd; } +int socket_address_parse_named_fd(SocketAddress *addr, Error **errp) +{ + int fd; + + if (addr->type != SOCKET_ADDRESS_TYPE_FD) { + return 0; + } + + fd = socket_get_fd(addr->u.fd.str, errp); + if (fd < 0) { + return fd; + } + + g_free(addr->u.fd.str); + addr->u.fd.str = g_strdup_printf("%d", fd); + + return 0; +} + int socket_connect(SocketAddress *addr, Error **errp) { int fd; |