From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51022) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bIYBR-000406-Dg for qemu-devel@nongnu.org; Thu, 30 Jun 2016 05:22:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bIYBM-0005wW-H2 for qemu-devel@nongnu.org; Thu, 30 Jun 2016 05:22:52 -0400 Received: from mx4-phx2.redhat.com ([209.132.183.25]:54161) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bIYBM-0005wI-9o for qemu-devel@nongnu.org; Thu, 30 Jun 2016 05:22:48 -0400 Date: Thu, 30 Jun 2016 05:22:43 -0400 (EDT) From: =?utf-8?Q?Marc-Andr=C3=A9?= Lureau Message-ID: <820501303.1010048.1467278563588.JavaMail.zimbra@redhat.com> In-Reply-To: <20160630063833.GG2831@yliu-dev.sh.intel.com> References: <20160624135110.17260-1-marcandre.lureau@redhat.com> <20160624135110.17260-23-marcandre.lureau@redhat.com> <20160630063833.GG2831@yliu-dev.sh.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v2 22/23] vhost-user: wait until backend init is completed List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Yuanhan Liu Cc: marcandre lureau , qemu-devel@nongnu.org, mukawa@igel.co.jp, victork@redhat.com, jonshin@cisco.com, mst@redhat.com Hi ----- Original Message ----- > On Fri, Jun 24, 2016 at 03:51:09PM +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 | 12 +++++++++++- > > 1 file changed, 11 insertions(+), 1 deletion(-) > >=20 > > diff --git a/net/vhost-user.c b/net/vhost-user.c > > index 95ed2d2..4badd9e 100644 > > --- a/net/vhost-user.c > > +++ b/net/vhost-user.c > > @@ -24,6 +24,7 @@ typedef struct VhostUserState { > > VHostNetState *vhost_net; > > int watch; > > uint64_t acked_features; > > + bool started; > > } VhostUserState; > > =20 > > typedef struct VhostUserChardevProps { > > @@ -211,6 +212,7 @@ static void net_vhost_user_event(void *opaque, int > > event) > > return; > > } > > qmp_set_link(name, true, &err); > > + s->started =3D true; > > break; > > case CHR_EVENT_CLOSED: > > qmp_set_link(name, false, &err); > > @@ -248,7 +250,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 (!s->started); >=20 >=20 > I haven't looked at your patchset carefully yet, but I did a quick test, > and showed that above code piece just breaks vhost-user: it's a dead loop > that vhost-user net will be initiated again and again. Interesting, thanks a lot for testing! The vhost-user-test works just fine, as well as vhost-user-bridge. > The dead loop is due to, we check "s->started" corresponding to last nc, > while we set "s->started" corresponding to the first nc. I see, that makes sense with multiqueue, I'll update the code. It would be = really nice to have a basic multiqueue test in vhost-user-test. thanks