[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 1/6] qio: Make port 0 work for qio
From: |
Juan Quintela |
Subject: |
[Qemu-devel] [PATCH 1/6] qio: Make port 0 work for qio |
Date: |
Mon, 30 Oct 2017 12:21:07 +0100 |
For tcp sockets we read back what is the socket/address. So we know
what is the port that we are listening into.
Looked all callers of the function, and they just create the addr, use
it, and drop it, so no problem that we always update the port in the
address.
Signed-off-by: Juan Quintela <address@hidden>
CC: Daniel P. Berrange <address@hidden>
---
util/qemu-sockets.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c
index b47fb45885..b099c88dd1 100644
--- a/util/qemu-sockets.c
+++ b/util/qemu-sockets.c
@@ -322,13 +322,16 @@ listen_failed:
listen_ok:
if (update_addr) {
+ SocketAddress *addr;
+
+ addr = socket_local_address(slisten, errp);
g_free(saddr->host);
- saddr->host = g_strdup(uaddr);
+ saddr->host = g_strdup(addr->u.inet.host);
g_free(saddr->port);
- saddr->port = g_strdup_printf("%d",
- inet_getport(e) - port_offset);
+ saddr->port = g_strdup(addr->u.inet.port);
saddr->has_ipv6 = saddr->ipv6 = e->ai_family == PF_INET6;
saddr->has_ipv4 = saddr->ipv4 = e->ai_family != PF_INET6;
+ qapi_free_SocketAddress(addr);
}
freeaddrinfo(res);
return slisten;
@@ -1047,7 +1050,7 @@ int socket_listen(SocketAddress *addr, Error **errp)
switch (addr->type) {
case SOCKET_ADDRESS_TYPE_INET:
- fd = inet_listen_saddr(&addr->u.inet, 0, false, errp);
+ fd = inet_listen_saddr(&addr->u.inet, 0, true, errp);
break;
case SOCKET_ADDRESS_TYPE_UNIX:
--
2.13.6
- [Qemu-devel] [PATCH 0/6] Improve info migrate output on destination, Juan Quintela, 2017/10/30
- [Qemu-devel] [PATCH 2/6] migration: print features as on off, Juan Quintela, 2017/10/30
- [Qemu-devel] [PATCH 3/6] migration: free addr in the same function that we created it, Juan Quintela, 2017/10/30
- [Qemu-devel] [PATCH 1/6] qio: Make port 0 work for qio,
Juan Quintela <=
- [Qemu-devel] [PATCH 4/6] migration: Create uri parameter, Juan Quintela, 2017/10/30
- [Qemu-devel] [PATCH 5/6] migration: Now set the migration uri, Juan Quintela, 2017/10/30
- [Qemu-devel] [PATCH 6/6] migration: make migrate uri parameter optional, Juan Quintela, 2017/10/30
- Re: [Qemu-devel] [PATCH 0/6] Improve info migrate output on destination, Fam Zheng, 2017/10/30