diff options
author | Marc-André Lureau | 2021-07-25 21:59:12 +0200 |
---|---|---|
committer | Marc-André Lureau | 2021-12-21 07:50:22 +0100 |
commit | 1b87751fb122479429ee90c7efeab64f588c7641 (patch) | |
tree | dcf200a634f6ba01c12f5e5d833dd7442a785d93 /chardev | |
parent | ui/dbus: add clipboard interface (diff) | |
download | qemu-1b87751fb122479429ee90c7efeab64f588c7641.tar.gz qemu-1b87751fb122479429ee90c7efeab64f588c7641.tar.xz qemu-1b87751fb122479429ee90c7efeab64f588c7641.zip |
chardev: teach socket to accept no addresses
The following patches are going to use CharSocket as a base class for
sockets that are created with a given fd (without a given address).
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Diffstat (limited to 'chardev')
-rw-r--r-- | chardev/char-socket.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/chardev/char-socket.c b/chardev/char-socket.c index 836cfa0bc2..a2b02e021d 100644 --- a/chardev/char-socket.c +++ b/chardev/char-socket.c @@ -1248,6 +1248,10 @@ static int qmp_chardev_open_socket_server(Chardev *chr, qio_net_listener_set_name(s->listener, name); g_free(name); + if (s->addr->type == SOCKET_ADDRESS_TYPE_FD && !*s->addr->u.fd.str) { + goto skip_listen; + } + if (qio_net_listener_open_sync(s->listener, s->addr, 1, errp) < 0) { object_unref(OBJECT(s->listener)); s->listener = NULL; @@ -1256,6 +1260,8 @@ static int qmp_chardev_open_socket_server(Chardev *chr, qapi_free_SocketAddress(s->addr); s->addr = socket_local_address(s->listener->sioc[0]->fd, errp); + +skip_listen: update_disconnected_filename(s); if (is_waitconnect) { @@ -1466,9 +1472,9 @@ static void qemu_chr_parse_socket(QemuOpts *opts, ChardevBackend *backend, SocketAddressLegacy *addr; ChardevSocket *sock; - if ((!!path + !!fd + !!host) != 1) { + if ((!!path + !!fd + !!host) > 1) { error_setg(errp, - "Exactly one of 'path', 'fd' or 'host' required"); + "None or one of 'path', 'fd' or 'host' option required."); return; } @@ -1542,12 +1548,10 @@ static void qemu_chr_parse_socket(QemuOpts *opts, ChardevBackend *backend, .has_ipv6 = qemu_opt_get(opts, "ipv6"), .ipv6 = qemu_opt_get_bool(opts, "ipv6", 0), }; - } else if (fd) { + } else { addr->type = SOCKET_ADDRESS_TYPE_FD; addr->u.fd.data = g_new(String, 1); addr->u.fd.data->str = g_strdup(fd); - } else { - g_assert_not_reached(); } sock->addr = addr; } |