[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL v2 31/36] chardev: teach socket to accept no addresses
From: |
marcandre . lureau |
Subject: |
[PULL v2 31/36] chardev: teach socket to accept no addresses |
Date: |
Tue, 21 Dec 2021 10:58:50 +0400 |
From: Marc-André Lureau <marcandre.lureau@redhat.com>
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>
---
chardev/char-socket.c | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/chardev/char-socket.c b/chardev/char-socket.c
index 836cfa0bc21b..a2b02e021d6b 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;
}
--
2.34.1.8.g35151cf07204
- [PULL v2 21/36] backends: move dbus-vmstate1.xml to backends/, (continued)
- [PULL v2 21/36] backends: move dbus-vmstate1.xml to backends/, marcandre . lureau, 2021/12/21
- [PULL v2 22/36] docs: move D-Bus VMState documentation to source XML, marcandre . lureau, 2021/12/21
- [PULL v2 23/36] docs: add dbus-display documentation, marcandre . lureau, 2021/12/21
- [PULL v2 24/36] build-sys: set glib dependency version, marcandre . lureau, 2021/12/21
- [PULL v2 25/36] ui: add a D-Bus display backend, marcandre . lureau, 2021/12/21
- [PULL v2 26/36] ui/dbus: add p2p=on/off option, marcandre . lureau, 2021/12/21
- [PULL v2 27/36] tests/qtests: add qtest_qmp_add_client(), marcandre . lureau, 2021/12/21
- [PULL v2 28/36] tests: start dbus-display-test, marcandre . lureau, 2021/12/21
- [PULL v2 29/36] audio: add "dbus" audio backend, marcandre . lureau, 2021/12/21
- [PULL v2 30/36] ui/dbus: add clipboard interface, marcandre . lureau, 2021/12/21
- [PULL v2 31/36] chardev: teach socket to accept no addresses,
marcandre . lureau <=
- [PULL v2 32/36] chardev: make socket derivable, marcandre . lureau, 2021/12/21
- [PULL v2 33/36] option: add g_auto for QemuOpts, marcandre . lureau, 2021/12/21
- [PULL v2 34/36] ui/dbus: add chardev backend & interface, marcandre . lureau, 2021/12/21
- [PULL v2 35/36] ui/dbus: register D-Bus VC handler, marcandre . lureau, 2021/12/21
- [PULL v2 36/36] MAINTAINERS: update D-Bus section, marcandre . lureau, 2021/12/21
- Re: [PULL v2 00/36] ui: D-Bus display backend, Richard Henderson, 2021/12/21