Received: from eggs.gnu.org ([2001:4830:134:3::10]:46147) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bG7l8-0002mK-8m for qemu-devel@nongnu.org; Thu, 23 Jun 2016 12:45:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bG7l2-0004t6-Ky for qemu-devel@nongnu.org; Thu, 23 Jun 2016 12:45:41 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57645) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bG7l2-0004t0-BB for qemu-devel@nongnu.org; Thu, 23 Jun 2016 12:45:36 -0400 Date: Thu, 23 Jun 2016 19:45:33 +0300 From: "Michael S. Tsirkin" Message-ID: <20160623193935-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> <1989832798.1342784.1466673097795.JavaMail.zimbra@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <1989832798.1342784.1466673097795.JavaMail.zimbra@redhat.com> 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: =?iso-8859-1?Q?Marc-Andr=E9?= Lureau Cc: marcandre lureau , qemu-devel@nongnu.org, mukawa@igel.co.jp, yuanhan liu , victork@redhat.com, jonshin@cisco.com On Thu, Jun 23, 2016 at 05:11:37AM -0400, Marc-Andr=E9 Lureau wrote: > Hi >=20 > ----- Original Message ----- > > On Tue, Jun 21, 2016 at 12:02:51PM +0200, marcandre.lureau@redhat.com= wrote: > > > From: Marc-Andr=E9 Lureau > > >=20 > > > The chardev waits for an initial connection before starting qemu, > > > vhost-user wants the backend negotiation to be completed. vhost-use= r is > > > started in the net_vhost_user_event callback, which is synchronousl= y > > > called after the socket is connected. > > >=20 > > > Signed-off-by: Marc-Andr=E9 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 = *peer, > > > 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? >=20 > It should wait for an initial valid connection (see the test case). Onl= y after vhost_user_start() should it keep going. We could have VhostUserS= tate.ready set to true when done, or we could check after qmp_set_link(..= , true) status, like I did here. Does that make sense? >=20 > thanks I'd prefer something well contained. A dedicated flags sounds reasonable. commit d39c87d70763f2755d1d7a719817b06f0281fb01 Author: Wen Congyang Date: Wed Nov 11 14:53:29 2015 +0800 vhost-user: set link down when the char device is closed was a quick hack. Disconnect should be transparent to guest and not cause dhcp renegotiation and stuff. The reason it's there is because we do not yet handle tx packets when disconnected, so it reduces the chance of tx watchdog if we tell gue= st it should not transmit anything new. Once we fix that we will drop the link down thing, so don't rely on link state please. --=20 MST