@@ -165,6 +165,7 @@ static gboolean net_stream_send(QIOChannel *ioc,
s->ioc_write_tag = 0;
}
if (s->listener) {
+ qemu_set_info_str(&s->nc, "listening");
qio_net_listener_set_client_func(s->listener, net_stream_listen,
s, NULL);
}
@@ -173,7 +174,6 @@ 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, "listening");
qapi_event_send_netdev_stream_disconnected(s->nc.name);
net_stream_arm_reconnect(s);
@@ -272,9 +272,11 @@ static void net_stream_server_listening(QIOTask *task, gpointer opaque)
QIOChannelSocket *listen_sioc = QIO_CHANNEL_SOCKET(s->listen_ioc);
SocketAddress *addr;
int ret;
+ Error *err = NULL;
- if (listen_sioc->fd < 0) {
- qemu_set_info_str(&s->nc, "connection error");
+ if (qio_task_propagate_error(task, &err)) {
+ qemu_set_info_str(&s->nc, "error: %s", error_get_pretty(err));
+ error_free(err);
return;
}
@@ -327,9 +329,11 @@ static void net_stream_client_connected(QIOTask *task, gpointer opaque)
SocketAddress *addr;
gchar *uri;
int ret;
+ Error *err = NULL;
- if (sioc->fd < 0) {
- qemu_set_info_str(&s->nc, "connection error");
+ if (qio_task_propagate_error(task, &err)) {
+ qemu_set_info_str(&s->nc, "error: %s", error_get_pretty(err));
+ error_free(err);
goto error;
}
@@ -384,6 +388,7 @@ static gboolean net_stream_reconnect(gpointer data)
static void net_stream_arm_reconnect(NetStreamState *s)
{
if (s->reconnect && s->timer_tag == 0) {
+ qemu_set_info_str(&s->nc, "connecting");
s->timer_tag = g_timeout_add_seconds(s->reconnect,
net_stream_reconnect, s);
}
The network stream backend uses the async QIO socket APIs for listening and connecting sockets. It does not check the task object completion status, however, instead just looking at whether the socket FD is -1 or not. By checking the task completion, we can set a useful error message for users instead of the non-actionable "connection error" string. eg so users will see: (qemu) info network net: index=0,type=stream,error: Failed to connect to '/foo.unix': No such file or directory Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> --- net/stream.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)