From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45614) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z2iR0-0002hW-2d for qemu-devel@nongnu.org; Wed, 10 Jun 2015 12:01:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z2iQw-0006Mg-0U for qemu-devel@nongnu.org; Wed, 10 Jun 2015 12:00:58 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41127) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z2iQv-0006LP-CV for qemu-devel@nongnu.org; Wed, 10 Jun 2015 12:00:53 -0400 Date: Wed, 10 Jun 2015 18:00:50 +0200 From: "Michael S. Tsirkin" Message-ID: <20150610180013-mutt-send-email-mst@redhat.com> References: <1433943783-20125-1-git-send-email-thibaut.collet@6wind.com> <1433943783-20125-3-git-send-email-thibaut.collet@6wind.com> <20150610173321-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 2/2] vhost user: Add RARP injection for legacy guest 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 05:48:47PM +0200, Thibaut Collet wrote: > I have involved QEMU because QEMU prepares the rarp. I agree that backe= nd has > probably all the information to do that. > But backend does not know if the guest supports the=A0VIRTIO_NET_F_GUES= T_ANNOUNCE Why not? Backend has the acked feature mask. > and will send a useless rarp. > Maybe this duplication of requests is not very important and in this ca= se this > patch is not mandatory. >=20 > On Wed, Jun 10, 2015 at 5:34 PM, Michael S. Tsirkin wr= ote: >=20 > On Wed, Jun 10, 2015 at 03:43:03PM +0200, Thibaut Collet wrote: > > In case of live migration with legacy guest (without > VIRTIO_NET_F_GUEST_ANNOUNCE) > > a message is added between QEMU and the vhost client/backend. > > This message provides the RARP content, prepared by QEMU, to the = vhost > > client/backend. > > The vhost client/backend is responsible to send the RARP. > > > > Signed-off-by: Thibaut Collet > > --- > >=A0 docs/specs/vhost-user.txt=A0 =A0|=A0 =A016 ++++++++++++++++ > >=A0 hw/net/vhost_net.c=A0 =A0 =A0 =A0 =A0 |=A0 =A0 8 ++++++++ > >=A0 hw/virtio/vhost-user.c=A0 =A0 =A0 |=A0 =A011 ++++++++++- > >=A0 linux-headers/linux/vhost.h |=A0 =A0 9 +++++++++ > >=A0 4 files changed, 43 insertions(+), 1 deletion(-) > > > > diff --git a/docs/specs/vhost-user.txt b/docs/specs/vhost-user.tx= t > > index 2c8e934..ef5d475 100644 > > --- a/docs/specs/vhost-user.txt > > +++ b/docs/specs/vhost-user.txt > > @@ -97,6 +97,7 @@ typedef struct VhostUserMsg { > >=A0 =A0 =A0 =A0 =A0 uint64_t u64; > >=A0 =A0 =A0 =A0 =A0 struct vhost_vring_state state; > >=A0 =A0 =A0 =A0 =A0 struct vhost_vring_addr addr; > > +=A0 =A0 =A0 =A0 struct vhost_inject_rarp rarp; > >=A0 =A0 =A0 =A0 =A0 VhostUserMemory memory; > >=A0 =A0 =A0 }; > >=A0 } QEMU_PACKED VhostUserMsg; > > @@ -132,6 +133,12 @@ Multi queue support > >=A0 The protocol supports multiple queues by setting all index fie= lds in the > sent > >=A0 messages to a properly calculated value. > > > > +Live migration support > > +---------------------- > > +The protocol supports live migration. GARP from the migrated gue= st is > done > > +through the VIRTIO_NET_F_GUEST_ANNOUNCE mechanism for guest that > supports it or > > +through RARP. > > + > >=A0 Message types > >=A0 ------------- > > > > @@ -269,3 +276,12 @@ Message types > >=A0 =A0 =A0 =A0 Bits (0-7) of the payload contain the vring index.= Bit 8 is the > >=A0 =A0 =A0 =A0 invalid FD flag. This flag is set when there is no= file descriptor > >=A0 =A0 =A0 =A0 in the ancillary data. > > + > > + * VHOST_USER_NET_INJECT_RARP > > + > > +=A0 =A0 =A0 Id: 15 > > +=A0 =A0 =A0 Master payload: rarp content > > + > > +=A0 =A0 =A0 Provide the RARP message to send to the guest after = a live > migration. This > > +=A0 =A0 =A0 message is sent only for guest that does not support > > +=A0 =A0 =A0 VIRTIO_NET_F_GUEST_ANNOUNCE. >=20 > I don't see why this is needed. > Can't backend simply send rarp itself? > Why do we need to involve QEMU? >=20 >=20 >=20 > > diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c > > index 4a42325..f66d48d 100644 > > --- a/hw/net/vhost_net.c > > +++ b/hw/net/vhost_net.c > > @@ -369,10 +369,18 @@ void vhost_net_stop(VirtIODevice *dev, > NetClientState *ncs, > > > >=A0 void vhost_net_inject_rarp(struct vhost_net *net, const uint8_= t *buf, > size_t size) > >=A0 { > > +=A0 =A0 struct vhost_inject_rarp inject_rarp; > > +=A0 =A0 memcpy(&inject_rarp.rarp, buf, size); > > + > >=A0 =A0 =A0 if ((net->dev.acked_features & (1 << VIRTIO_NET_F_GUES= T_ANNOUNCE)) =3D > =3D 0) { > > +=A0 =A0 =A0 =A0 const VhostOps *vhost_ops =3D net->dev.vhost_ops= ; > > +=A0 =A0 =A0 =A0 int r; > > + > >=A0 =A0 =A0 =A0 =A0 fprintf(stderr, > >=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 "Warning: Guest with no VIRTIO= _NET_F_GUEST_ANNOUNCE > support. RARP must be sent by vhost-user backend\n"); > >=A0 =A0 =A0 =A0 =A0 fflush(stderr); > > +=A0 =A0 =A0 =A0 r =3D vhost_ops->vhost_call(&net->dev, VHOST_NET= _INJECT_RARP, & > inject_rarp); > > +=A0 =A0 =A0 =A0 assert(r >=3D 0); > >=A0 =A0 =A0 } > >=A0 } > > > > diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c > > index d6f2163..2e752ab 100644 > > --- a/hw/virtio/vhost-user.c > > +++ b/hw/virtio/vhost-user.c > > @@ -41,6 +41,7 @@ typedef enum VhostUserRequest { > >=A0 =A0 =A0 VHOST_USER_SET_VRING_KICK =3D 12, > >=A0 =A0 =A0 VHOST_USER_SET_VRING_CALL =3D 13, > >=A0 =A0 =A0 VHOST_USER_SET_VRING_ERR =3D 14, > > +=A0 =A0 VHOST_USER_NET_INJECT_RARP =3D 15, > >=A0 =A0 =A0 VHOST_USER_MAX > >=A0 } VhostUserRequest; > > > > @@ -70,6 +71,7 @@ typedef struct VhostUserMsg { > >=A0 =A0 =A0 =A0 =A0 uint64_t u64; > >=A0 =A0 =A0 =A0 =A0 struct vhost_vring_state state; > >=A0 =A0 =A0 =A0 =A0 struct vhost_vring_addr addr; > > +=A0 =A0 =A0 =A0 struct vhost_inject_rarp rarp; > >=A0 =A0 =A0 =A0 =A0 VhostUserMemory memory; > >=A0 =A0 =A0 }; > >=A0 } QEMU_PACKED VhostUserMsg; > > @@ -104,7 +106,8 @@ static unsigned long int ioctl_to_vhost_user_= request > [VHOST_USER_MAX] =3D { > >=A0 =A0 =A0 VHOST_GET_VRING_BASE,=A0 =A0/* VHOST_USER_GET_VRING_BA= SE */ > >=A0 =A0 =A0 VHOST_SET_VRING_KICK,=A0 =A0/* VHOST_USER_SET_VRING_KI= CK */ > >=A0 =A0 =A0 VHOST_SET_VRING_CALL,=A0 =A0/* VHOST_USER_SET_VRING_CA= LL */ > > -=A0 =A0 VHOST_SET_VRING_ERR=A0 =A0 =A0/* VHOST_USER_SET_VRING_ER= R */ > > +=A0 =A0 VHOST_SET_VRING_ERR,=A0 =A0 /* VHOST_USER_SET_VRING_ERR = */ > > +=A0 =A0 VHOST_NET_INJECT_RARP=A0 =A0/* VHOST_USER_NET_INJECT_RAR= P */ > >=A0 }; > > > >=A0 static VhostUserRequest vhost_user_request_translate(unsigned = long int > request) > > @@ -287,6 +290,12 @@ static int vhost_user_call(struct vhost_dev = *dev, > unsigned long int request, > >=A0 =A0 =A0 =A0 =A0 =A0 =A0 msg.u64 |=3D VHOST_USER_VRING_NOFD_MAS= K; > >=A0 =A0 =A0 =A0 =A0 } > >=A0 =A0 =A0 =A0 =A0 break; > > + > > +=A0 =A0 case VHOST_NET_INJECT_RARP: > > +=A0 =A0 =A0 =A0 memcpy(&msg.rarp, arg, sizeof(struct vhost_injec= t_rarp)); > > +=A0 =A0 =A0 =A0 msg.size =3D sizeof(struct vhost_inject_rarp); > > +=A0 =A0 =A0 =A0 break; > > + > >=A0 =A0 =A0 default: > >=A0 =A0 =A0 =A0 =A0 error_report("vhost-user trying to send unhand= led ioctl"); > >=A0 =A0 =A0 =A0 =A0 return -1; > > diff --git a/linux-headers/linux/vhost.h b/linux-headers/linux/vh= ost.h > > index c656f61..1920134 100644 > > --- a/linux-headers/linux/vhost.h > > +++ b/linux-headers/linux/vhost.h > > @@ -63,6 +63,10 @@ struct vhost_memory { > >=A0 =A0 =A0 =A0struct vhost_memory_region regions[0]; > >=A0 }; > > > > +struct vhost_inject_rarp { > > +=A0 =A0 =A0__u8 rarp[60]; > > +}; > > + > >=A0 /* ioctls */ > > > >=A0 #define VHOST_VIRTIO 0xAF > > @@ -121,6 +125,11 @@ struct vhost_memory { > >=A0 =A0* device.=A0 This can be used to stop the ring (e.g. for mi= gration). */ > >=A0 #define VHOST_NET_SET_BACKEND _IOW(VHOST_VIRTIO, 0x30, struct > vhost_vring_file) > > > > +/* Inject a RARP in case of live migration for guest that does n= ot > support > > + * VIRTIO_NET_F_GUEST_ANNOUNCE */ > > +#define VHOST_NET_INJECT_RARP _IOW(VHOST_VIRTIO, 0x31, struct > vhost_inject_rarp) > > + > > + > >=A0 /* Feature bits */ > >=A0 /* Log all write descriptors. Can be changed while device is a= ctive. */ > >=A0 #define VHOST_F_LOG_ALL 26 > > -- > > 1.7.10.4 >=20 >=20