mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-03 15:53:54 -06:00
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>
This commit is contained in:
parent
fb392b548e
commit
c542370418
2 changed files with 30 additions and 0 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue