From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33253) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bZajA-00079i-WC for qemu-devel@nongnu.org; Tue, 16 Aug 2016 05:32:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bZaj6-0002td-OH for qemu-devel@nongnu.org; Tue, 16 Aug 2016 05:32:07 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59674) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bZaj6-0002tY-J4 for qemu-devel@nongnu.org; Tue, 16 Aug 2016 05:32:04 -0400 Date: Tue, 16 Aug 2016 10:31:59 +0100 From: "Daniel P. Berrange" Message-ID: <20160816093159.GB25115@redhat.com> Reply-To: "Daniel P. Berrange" References: <20160816083332.15088-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20160816083332.15088-1-marcandre.lureau@redhat.com> Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH for-2.7] char: fix waiting for TLS and telnet connection List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: =?utf-8?Q?Marc-Andr=C3=A9?= Lureau Cc: qemu-devel@nongnu.org, dl.soluz@gmx.net On Tue, Aug 16, 2016 at 12:33:32PM +0400, Marc-Andr=C3=A9 Lureau wrote: > 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. >=20 > 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. >=20 > Signed-off-by: Marc-Andr=C3=A9 Lureau > --- > qemu-char.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) >=20 > diff --git a/qemu-char.c b/qemu-char.c > index 8a0ab05..5f82ebb 100644 > --- a/qemu-char.c > +++ b/qemu-char.c > @@ -3176,7 +3176,9 @@ static int tcp_chr_wait_connected(CharDriverState= *chr, Error **errp) > TCPCharDriver *s =3D chr->opaque; > QIOChannelSocket *sioc; > =20 > - 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); Reviewed-by: Daniel P. Berrange This is a definite must fix for 2.7.0. Also shows we really badly need unit tests for the chardev stuff :-) Regards, Daniel --=20 |: http://berrange.com -o- http://www.flickr.com/photos/dberrange= / :| |: http://libvirt.org -o- http://virt-manager.or= g :| |: http://autobuild.org -o- http://search.cpan.org/~danberr= / :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vn= c :|