diff options
author | Marc-André Lureau <marcandre.lureau@redhat.com> | 2016-12-20 15:36:57 +0100 |
---|---|---|
committer | Marc-André Lureau <marcandre.lureau@redhat.com> | 2017-05-04 15:34:41 +0400 |
commit | bc763d71440552b677bc372e8261b9d127330657 (patch) | |
tree | 3db68e21a2a9394efdb5e32f972ad724081e408b /chardev/char-socket.c | |
parent | bbcde969b242fc4b3ab84097f7783cfe0920e69f (diff) |
char-socket: update local address after listen
This is mainly useful to know the actual bound port when using port 0.
For example, when starting qemu with socket on port 0, before:
QEMU waiting for connection on: disconnected:tcp:localhost:0,server
After:
QEMU waiting for connection on: disconnected:tcp:localhost:32454,server
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Diffstat (limited to 'chardev/char-socket.c')
-rw-r--r-- | chardev/char-socket.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/chardev/char-socket.c b/chardev/char-socket.c index 511a82960d..f24961ad16 100644 --- a/chardev/char-socket.c +++ b/chardev/char-socket.c @@ -911,6 +911,11 @@ static void qmp_chardev_open_socket(Chardev *chr, if (qio_channel_socket_listen_sync(sioc, s->addr, errp) < 0) { goto error; } + + qapi_free_SocketAddress(s->addr); + s->addr = socket_local_address(sioc->fd, errp); + update_disconnected_filename(s); + s->listen_ioc = sioc; if (is_waitconnect && qemu_chr_wait_connected(chr, errp) < 0) { |