Received: from eggs.gnu.org ([2001:4830:134:3::10]:32926) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bG0fp-00054m-KB for qemu-devel@nongnu.org; Thu, 23 Jun 2016 05:11:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bG0fl-00036L-Bm for qemu-devel@nongnu.org; Thu, 23 Jun 2016 05:11:44 -0400 Received: from mx4-phx2.redhat.com ([209.132.183.25]:36992) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bG0fl-00036F-3b for qemu-devel@nongnu.org; Thu, 23 Jun 2016 05:11:41 -0400 Date: Thu, 23 Jun 2016 05:11:37 -0400 (EDT) From: =?utf-8?Q?Marc-Andr=C3=A9?= Lureau Message-ID: <1989832798.1342784.1466673097795.JavaMail.zimbra@redhat.com> In-Reply-To: <20160623072424-mutt-send-email-mst@redhat.com> References: <1466503372-28334-1-git-send-email-marcandre.lureau@redhat.com> <1466503372-28334-24-git-send-email-marcandre.lureau@redhat.com> <20160623072424-mutt-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH 23/24] vhost-user: wait until link is up List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Michael S. Tsirkin" Cc: marcandre lureau , qemu-devel@nongnu.org, mukawa@igel.co.jp, yuanhan liu , victork@redhat.com, jonshin@cisco.com Hi ----- Original Message ----- > On Tue, Jun 21, 2016 at 12:02:51PM +0200, marcandre.lureau@redhat.com wro= te: > > From: Marc-Andr=C3=A9 Lureau > >=20 > > The chardev waits for an initial connection before starting qemu, > > vhost-user wants the backend negotiation to be completed. vhost-user is > > started in the net_vhost_user_event callback, which is synchronously > > called after the socket is connected. > >=20 > > Signed-off-by: Marc-Andr=C3=A9 Lureau > > --- > > net/vhost-user.c | 10 +++++++++- > > 1 file changed, 9 insertions(+), 1 deletion(-) > >=20 > > diff --git a/net/vhost-user.c b/net/vhost-user.c > > index 95ed2d2..bb4a253 100644 > > --- a/net/vhost-user.c > > +++ b/net/vhost-user.c > > @@ -248,7 +248,15 @@ static int net_vhost_user_init(NetClientState *pee= r, > > const char *device, > > s->chr =3D chr; > > } > > =20 > > - qemu_chr_add_handlers(chr, NULL, NULL, net_vhost_user_event, > > nc[0].name); > > + do { > > + Error *err =3D NULL; > > + if (qemu_chr_wait_connected(chr, &err) < 0) { > > + error_report_err(err); > > + return -1; > > + } > > + qemu_chr_add_handlers(chr, NULL, NULL, > > + net_vhost_user_event, nc[0].name); > > + } while (nc->link_down); > > =20 > > assert(s->vhost_net !=3D NULL); >=20 >=20 > I don't get why this makes sense. > Why should vhost user poke at link down at all? It should wait for an initial valid connection (see the test case). Only af= ter vhost_user_start() should it keep going. We could have VhostUserState.r= eady set to true when done, or we could check after qmp_set_link(.., true) = status, like I did here. Does that make sense? thanks