From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58845) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bm2a5-0005np-NV for qemu-devel@nongnu.org; Mon, 19 Sep 2016 13:42:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bm2a1-0005J2-Ee for qemu-devel@nongnu.org; Mon, 19 Sep 2016 13:42:12 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49940) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bm2a1-0005Ij-4J for qemu-devel@nongnu.org; Mon, 19 Sep 2016 13:42:09 -0400 Date: Mon, 19 Sep 2016 20:42:07 +0300 From: "Michael S. Tsirkin" Message-ID: <20160919204026-mutt-send-email-mst@kernel.org> References: <1471596663-31298-1-git-send-email-felipe@nutanix.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] Avoid additional GET_FEATURES call on vhost-user List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Felipe Franciosi Cc: =?iso-8859-1?Q?Marc-Andr=E9?= Lureau , "qemu-devel@nongnu.org" Thanks for the reminder. 2.8 is open now so I can integrate this. I would appreciate it if you could rebase this top of commit d1b4259f1ab18af24e6a297edb6a8f71691f3256 Author: Maxime Coquelin Date: Tue Sep 13 15:30:30 2016 +0200 virtio-bus: Plug devices after features are negotiated test and repost if it still works. Thanks! On Mon, Sep 19, 2016 at 05:25:49PM +0000, Felipe Franciosi wrote: > Gentle ping. >=20 > =20 >=20 > Thanks, >=20 > Felipe >=20 > =20 >=20 > From: Marc-Andr=E9 Lureau > Date: Thursday, 25 August 2016 at 12:14 > To: Felipe Franciosi , "qemu-devel@nongnu.org" > , "Michael S. Tsirkin" > Subject: Re: [Qemu-devel] [PATCH] Avoid additional GET_FEATURES call on > vhost-user >=20 > =20 >=20 > Hi >=20 > =20 >=20 > On Sat, Aug 20, 2016 at 3:28 AM Felipe Franciosi > wrote: >=20 > Vhost-user requires an early GET_FEATURES call to determine if = the > slave supports protocol feature negotiation. An extra GET_FEATU= RES > call is made after vhost_backend_init() to actually set the dev= ice > features. >=20 > This patch moves the actual setting of the device features to b= oth > implementations (kernel/user) of vhost_backend_init(), therefor= e > eliminating the need for a second call. >=20 > Signed-off-by: Felipe Franciosi >=20 >=20 >=20 > Reviewed-by: Marc-Andr=E9 Lureau >=20 > =20 >=20 > --- > hw/virtio/vhost-backend.c | 27 ++++++++++++++++++--------- > hw/virtio/vhost-user.c | 1 + > hw/virtio/vhost.c | 9 --------- > 3 files changed, 19 insertions(+), 18 deletions(-) >=20 > diff --git a/hw/virtio/vhost-backend.c b/hw/virtio/vhost-backen= d.c > index 7681f15..a519fe2 100644 > --- a/hw/virtio/vhost-backend.c > +++ b/hw/virtio/vhost-backend.c > @@ -25,15 +25,6 @@ static int vhost_kernel_call(struct vhost_de= v *dev, > unsigned long int request, > return ioctl(fd, request, arg); > } >=20 > -static int vhost_kernel_init(struct vhost_dev *dev, void *opaq= ue) > -{ > - assert(dev->vhost_ops->backend_type =3D=3D VHOST_BACKEND_T= YPE_KERNEL); > - > - dev->opaque =3D opaque; > - > - return 0; > -} > - > static int vhost_kernel_cleanup(struct vhost_dev *dev) > { > int fd =3D (uintptr_t) dev->opaque; > @@ -172,6 +163,24 @@ static int vhost_kernel_get_vq_index(struc= t > vhost_dev *dev, int idx) > return idx - dev->vq_index; > } >=20 > +static int vhost_kernel_init(struct vhost_dev *dev, void *opaq= ue) > +{ > + uint64_t features; > + int r; > + > + assert(dev->vhost_ops->backend_type =3D=3D VHOST_BACKEND_T= YPE_KERNEL); > + > + dev->opaque =3D opaque; > + > + r =3D vhost_kernel_get_features(dev, &features); > + if (r < 0) { > + return r; > + } > + dev->features =3D features; > + > + return 0; > +} > + > static const VhostOps kernel_ops =3D { > .backend_type =3D VHOST_BACKEND_TYPE_KERNEL, > .vhost_backend_init =3D vhost_kernel_init, > diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c > index b57454a..684f6d7 100644 > --- a/hw/virtio/vhost-user.c > +++ b/hw/virtio/vhost-user.c > @@ -578,6 +578,7 @@ static int vhost_user_init(struct vhost_dev= *dev, > void *opaque) > if (err < 0) { > return err; > } > + dev->features =3D features; >=20 > if (virtio_has_feature(features, VHOST_USER_F_PROTOCOL_FEA= TURES)) > { > dev->backend_features |=3D 1ULL << > VHOST_USER_F_PROTOCOL_FEATURES; > diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c > index 3d0c807..cb9870a 100644 > --- a/hw/virtio/vhost.c > +++ b/hw/virtio/vhost.c > @@ -1037,7 +1037,6 @@ static void vhost_virtqueue_cleanup(struc= t > vhost_virtqueue *vq) > int vhost_dev_init(struct vhost_dev *hdev, void *opaque, > VhostBackendType backend_type, uint32_t > busyloop_timeout) > { > - uint64_t features; > int i, r, n_initialized_vqs =3D 0; >=20 > hdev->migration_blocker =3D NULL; > @@ -1063,12 +1062,6 @@ int vhost_dev_init(struct vhost_dev *hde= v, void > *opaque, > goto fail; > } >=20 > - r =3D hdev->vhost_ops->vhost_get_features(hdev, &features)= ; > - if (r < 0) { > - VHOST_OPS_DEBUG("vhost_get_features failed"); > - goto fail; > - } > - > for (i =3D 0; i < hdev->nvqs; ++i, ++n_initialized_vqs) { > r =3D vhost_virtqueue_init(hdev, hdev->vqs + i, hdev->= vq_index + > i); > if (r < 0) { > @@ -1086,8 +1079,6 @@ int vhost_dev_init(struct vhost_dev *hdev= , void > *opaque, > } > } >=20 > - hdev->features =3D features; > - > hdev->memory_listener =3D (MemoryListener) { > .begin =3D vhost_begin, > .commit =3D vhost_commit, > -- > 1.9.5 >=20 >=20 > -- >=20 > Marc-Andr=E9 Lureau >=20