aboutsummaryrefslogtreecommitdiff
path: root/net
diff options
context:
space:
mode:
authorDaniel P. Berrangé <berrange@redhat.com>2024-01-04 16:29:40 +0000
committerThomas Huth <thuth@redhat.com>2024-01-11 11:39:26 +0100
commitcc91ca64d826acc0214ebf9428f5130b37deecd8 (patch)
tree69b3c97341f7db6f740848a518de737a93b467fd /net
parenta298293866b277cb40ab24dcedda36c2b89ed2ab (diff)
downloadqemu-cc91ca64d826acc0214ebf9428f5130b37deecd8.zip
qemu-cc91ca64d826acc0214ebf9428f5130b37deecd8.tar.gz
qemu-cc91ca64d826acc0214ebf9428f5130b37deecd8.tar.bz2
net: add explicit info about connecting/listening state
When running 'info network', if the stream backend is still in the process of connecting, or waiting for an incoming connection, no information is displayed. There is also no way to distinguish whether the server is still in the process of setting up the listener socket, or whether it is ready to accept incoming client connections. This leads to a race condition in the netdev-socket qtest which launches a server process followed by a client process. Under high load conditions it is possible for the client to attempt to connect before the server is accepting clients. For the scenarios which do not set the 'reconnect' option, this opens up a race which can lead to the test scenario failing to reach the expected state. Now that 'info network' can distinguish between initialization phase and the listening phase, the netdev-socket qtest will correctly synchronize, such that the client QEMU is not spawned until the server is ready. This should solve the non-deterministic failures seen with the netdev-socket qtest. Signed-off-by: "Daniel P. Berrangé" <berrange@redhat.com> Message-ID: <20240104162942.211458-5-berrange@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Thomas Huth <thuth@redhat.com>
Diffstat (limited to 'net')
-rw-r--r--net/stream.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/net/stream.c b/net/stream.c
index 9204b4c..0defb21 100644
--- a/net/stream.c
+++ b/net/stream.c
@@ -173,7 +173,7 @@ static gboolean net_stream_send(QIOChannel *ioc,
net_socket_rs_init(&s->rs, net_stream_rs_finalize, false);
s->nc.link_down = true;
- qemu_set_info_str(&s->nc, "%s", "");
+ qemu_set_info_str(&s->nc, "listening");
qapi_event_send_netdev_stream_disconnected(s->nc.name);
net_stream_arm_reconnect(s);
@@ -292,6 +292,7 @@ static void net_stream_server_listening(QIOTask *task, gpointer opaque)
s->nc.link_down = true;
s->listener = qio_net_listener_new();
+ qemu_set_info_str(&s->nc, "listening");
net_socket_rs_init(&s->rs, net_stream_rs_finalize, false);
qio_net_listener_set_client_func(s->listener, net_stream_listen, s, NULL);
qio_net_listener_add(s->listener, listen_sioc);
@@ -309,6 +310,7 @@ static int net_stream_server_init(NetClientState *peer,
nc = qemu_new_net_client(&net_stream_info, peer, model, name);
s = DO_UPCAST(NetStreamState, nc, nc);
+ qemu_set_info_str(&s->nc, "initializing");
s->listen_ioc = QIO_CHANNEL(listen_sioc);
qio_channel_socket_listen_async(listen_sioc, addr, 0,
@@ -400,6 +402,7 @@ static int net_stream_client_init(NetClientState *peer,
nc = qemu_new_net_client(&net_stream_info, peer, model, name);
s = DO_UPCAST(NetStreamState, nc, nc);
+ qemu_set_info_str(&s->nc, "connecting");
s->ioc = QIO_CHANNEL(sioc);
s->nc.link_down = true;