From 04a8cabca46b7516593e08ca1afccb630da08bd2 Mon Sep 17 00:00:00 2001 From: "Daniel P. Berrange" Date: Wed, 21 Sep 2016 10:03:16 +0200 Subject: [PATCH 1/3] char: fix waiting for TLS and telnet connection MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit RH-Author: Daniel P. Berrange Message-id: <1474452196-24433-1-git-send-email-berrange@redhat.com> Patchwork-id: 72398 O-Subject: [RHEV-7.3 qemu-kvm-rhev PATCH] char: fix waiting for TLS and telnet connection Bugzilla: 1300773 RH-Acked-by: Marc-André Lureau RH-Acked-by: Stefan Hajnoczi RH-Acked-by: Miroslav Rezanina From: Marc-André Lureau Since commit d7a04fd7d5008, tcp_chr_wait_connected() was introduced, so vhost-user could wait until a backend started successfully. In vhost-user case, the chr socket must be plain unix, and the chr+vhost setup happens synchronously during qemu startup. However, with TLS and telnet socket, initial socket setup happens asynchronously, and s->connected is not set after the socket is accepted. In order for tcp_chr_wait_connected() to not keep accepting new connections and proceed with the last accepted socket, it can check for s->ioc instead. Signed-off-by: Marc-André Lureau Reviewed-by: Daniel P. Berrange Message-id: 20160816083332.15088-1-marcandre.lureau@redhat.com Signed-off-by: Peter Maydell (cherry picked from commit 1dc8a6695c731abb7461c637b2512c3670d82be4) Signed-off-by: Miroslav Rezanina --- qemu-char.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/qemu-char.c b/qemu-char.c index 47cbb46..8c2cc55 100644 --- a/qemu-char.c +++ b/qemu-char.c @@ -3146,7 +3146,9 @@ static int tcp_chr_wait_connected(CharDriverState *chr, Error **errp) TCPCharDriver *s = chr->opaque; QIOChannelSocket *sioc; - while (!s->connected) { + /* It can't wait on s->connected, since it is set asynchronously + * in TLS and telnet cases, only wait for an accepted socket */ + while (!s->ioc) { if (s->is_listen) { fprintf(stderr, "QEMU waiting for connection on: %s\n", chr->filename); -- 1.8.3.1