Received: from eggs.gnu.org ([2001:4830:134:3::10]:41995) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z2gyD-0001qQ-1v for qemu-devel@nongnu.org; Wed, 10 Jun 2015 10:27:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z2gy7-0008RY-PG for qemu-devel@nongnu.org; Wed, 10 Jun 2015 10:27:08 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40861) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z2gy7-0008QS-Fo for qemu-devel@nongnu.org; Wed, 10 Jun 2015 10:27:03 -0400 Date: Wed, 10 Jun 2015 16:27:00 +0200 From: "Michael S. Tsirkin" Message-ID: <20150610162619-mutt-send-email-mst@redhat.com> References: <1433943783-20125-1-git-send-email-thibaut.collet@6wind.com> <1433943783-20125-2-git-send-email-thibaut.collet@6wind.com> <20150610154748-mutt-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v3 1/2] vhost user: add support of live migration List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Thibaut Collet Cc: Jason Wang , qemu-devel , Stefan Hajnoczi On Wed, Jun 10, 2015 at 04:22:10PM +0200, Thibaut Collet wrote: > I am not sure to understand your comments. >=20 > Could you confirm that the useless warning is: > + =A0 =A0 =A0 =A0fprintf(stderr, > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0"Warning: Guest with no VIRTIO_NET_F_G= UEST_ANNOUNCE support. > RARP must be sent by vhost-user backend\n"); Yes. > >=A0Can you move this out to vhost-user? It's not a generic function, i= s it? >=20 > Which part of the code do you think it must be moved in a specific file= ? vhost_net_inject_rarp is vhost-user specific. >=20 > On Wed, Jun 10, 2015 at 3:52 PM, Michael S. Tsirkin wr= ote: >=20 > On Wed, Jun 10, 2015 at 03:43:02PM +0200, Thibaut Collet wrote: > > Some vhost client/backend are able to support live migration. > > To provide this service the following features must be added: > > 1. GARP from guest after live migration: > >=A0 =A0 the VIRTIO_NET_F_GUEST_ANNOUNCE capability is added to vho= st-net when > netdev > >=A0 =A0 backend is vhost-user to let virtio-net NIC manages GARP a= fter > migration. > > 2. RARP on vhost-user: > >=A0 =A0 After a live migration RARP are automatically sent to any = interfaces. > A > >=A0 =A0 receive callback is added to vhost-user to catch this pack= et. If guest > >=A0 =A0 supports VIRTIO_NET_F_GUEST_ANNOUNCE this packet is discar= ded to avoid > >=A0 =A0 message duplication (already done by virtio-net NIC). For = legacy guest > >=A0 =A0 without VIRTIO_NET_F_GUEST_ANNOUNCE a warning message is d= isplayed to > >=A0 =A0 alert the user. RARP must be sent to the vhost client/back= end. > > > > Signed-off-by: Thibaut Collet > > --- > >=A0 hw/net/vhost_net.c=A0 =A0 =A0 |=A0 =A015 +++++++++++++++ > >=A0 include/net/vhost_net.h |=A0 =A0 1 + > >=A0 net/vhost-user.c=A0 =A0 =A0 =A0 |=A0 =A021 +++++++++++++++++++= -- > >=A0 3 files changed, 35 insertions(+), 2 deletions(-) > > > > diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c > > index 426b23e..4a42325 100644 > > --- a/hw/net/vhost_net.c > > +++ b/hw/net/vhost_net.c > > @@ -82,6 +82,8 @@ static const int user_feature_bits[] =3D { > >=A0 =A0 =A0 VIRTIO_NET_F_CTRL_MAC_ADDR, > >=A0 =A0 =A0 VIRTIO_NET_F_CTRL_GUEST_OFFLOADS, > > > > +=A0 =A0 VIRTIO_NET_F_GUEST_ANNOUNCE, > > + > >=A0 =A0 =A0 VIRTIO_NET_F_MQ, > > > >=A0 =A0 =A0 VHOST_INVALID_FEATURE_BIT > > @@ -365,6 +367,15 @@ void vhost_net_stop(VirtIODevice *dev, > NetClientState *ncs, > >=A0 =A0 =A0 assert(r >=3D 0); > >=A0 } > > > > +void vhost_net_inject_rarp(struct vhost_net *net, const uint8_t = *buf, > size_t size) > > +{ > > +=A0 =A0 if ((net->dev.acked_features & (1 << VIRTIO_NET_F_GUEST_= ANNOUNCE)) =3D > =3D 0) { > > +=A0 =A0 =A0 =A0 fprintf(stderr, > > +=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 "Warning: Guest with no VIRTIO_N= ET_F_GUEST_ANNOUNCE > support. RARP must be sent by vhost-user backend\n"); > > +=A0 =A0 =A0 =A0 fflush(stderr); >=20 > And maybe it does, then you are just filling log up with useless > warnings. Pls add some ifdef so this isn't normally compiled in. >=20 > > +=A0 =A0 } >=20 > Can you move this out to vhost-user? It's not a generic function, i= s it? >=20 > > +} > > + > >=A0 void vhost_net_cleanup(struct vhost_net *net) > >=A0 { > >=A0 =A0 =A0 vhost_dev_cleanup(&net->dev); > > @@ -427,6 +438,10 @@ void vhost_net_stop(VirtIODevice *dev, > >=A0 { > >=A0 } > > > > +void vhost_net_inject_rarp(struct vhost_net *net, const uint8_t = *buf, > size_t size); > > +{ > > +} > > + > >=A0 void vhost_net_cleanup(struct vhost_net *net) > >=A0 { > >=A0 } > > diff --git a/include/net/vhost_net.h b/include/net/vhost_net.h > > index b1c18a3..e82a0f9 100644 > > --- a/include/net/vhost_net.h > > +++ b/include/net/vhost_net.h > > @@ -20,6 +20,7 @@ bool vhost_net_query(VHostNetState *net, VirtIO= Device > *dev); > >=A0 int vhost_net_start(VirtIODevice *dev, NetClientState *ncs, in= t > total_queues); > >=A0 void vhost_net_stop(VirtIODevice *dev, NetClientState *ncs, in= t > total_queues); > > > > +void vhost_net_inject_rarp(VHostNetState *net, const uint8_t *bu= f, > size_t size); > >=A0 void vhost_net_cleanup(VHostNetState *net); > > > >=A0 unsigned vhost_net_get_features(VHostNetState *net, unsigned f= eatures); > > diff --git a/net/vhost-user.c b/net/vhost-user.c > > index 8d26728..69c2313 100644 > > --- a/net/vhost-user.c > > +++ b/net/vhost-user.c > > @@ -66,6 +66,24 @@ static void vhost_user_stop(VhostUserState *s) > >=A0 =A0 =A0 s->vhost_net =3D 0; > >=A0 } > > > > +static ssize_t vhost_user_receive(NetClientState *nc, const uint= 8_t > *buf, > > +=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 size_t size) > > +{ > > +=A0 =A0 if (size =3D=3D 60) { > > +=A0 =A0 =A0 =A0 /* Assume it is a RARP request sent automaticall= y after a > > +=A0 =A0 =A0 =A0 =A0* live migration */ > > +=A0 =A0 =A0 =A0 /* The RARP must be sent if guest does not suppo= rt > > +=A0 =A0 =A0 =A0 =A0* VIRTIO_NET_F_GUEST_ANNOUNCE */ > > +=A0 =A0 =A0 =A0 VhostUserState *s =3D DO_UPCAST(VhostUserState, = nc, nc); > > + > > +=A0 =A0 =A0 =A0 vhost_net_inject_rarp(s->vhost_net, buf, size); > > +=A0 =A0 } else { > > +=A0 =A0 =A0 =A0 fprintf(stderr,"Vhost user receives unexpected p= ackets\n"); > > +=A0 =A0 =A0 =A0 fflush(stderr); > > +=A0 =A0 } > > +=A0 =A0 return size; > > +} > > + > >=A0 static void vhost_user_cleanup(NetClientState *nc) > >=A0 { > >=A0 =A0 =A0 VhostUserState *s =3D DO_UPCAST(VhostUserState, nc, nc= ); > > @@ -91,6 +109,7 @@ static bool vhost_user_has_ufo(NetClientState = *nc) > >=A0 static NetClientInfo net_vhost_user_info =3D { > >=A0 =A0 =A0 =A0 =A0 .type =3D NET_CLIENT_OPTIONS_KIND_VHOST_USER, > >=A0 =A0 =A0 =A0 =A0 .size =3D sizeof(VhostUserState), > > +=A0 =A0 =A0 =A0 .receive =3D vhost_user_receive, > >=A0 =A0 =A0 =A0 =A0 .cleanup =3D vhost_user_cleanup, > >=A0 =A0 =A0 =A0 =A0 .has_vnet_hdr =3D vhost_user_has_vnet_hdr, > >=A0 =A0 =A0 =A0 =A0 .has_ufo =3D vhost_user_has_ufo, > > @@ -147,8 +166,6 @@ static int net_vhost_user_init(NetClientState= *peer, > const char *device, > > > >=A0 =A0 =A0 =A0 =A0 s =3D DO_UPCAST(VhostUserState, nc, nc); > > > > -=A0 =A0 =A0 =A0 /* We don't provide a receive callback */ > > -=A0 =A0 =A0 =A0 s->nc.receive_disabled =3D 1; > >=A0 =A0 =A0 =A0 =A0 s->chr =3D chr; > >=A0 =A0 =A0 =A0 =A0 s->nc.queue_index =3D i; > > > > -- > > 1.7.10.4 >=20 >=20