From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B8FF5C433FE for ; Mon, 7 Dec 2020 16:44:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8D8C62311A for ; Mon, 7 Dec 2020 16:44:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727760AbgLGQoH (ORCPT ); Mon, 7 Dec 2020 11:44:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32928 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725804AbgLGQoH (ORCPT ); Mon, 7 Dec 2020 11:44:07 -0500 Received: from mail-ej1-x644.google.com (mail-ej1-x644.google.com [IPv6:2a00:1450:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A66B3C061793 for ; Mon, 7 Dec 2020 08:43:26 -0800 (PST) Received: by mail-ej1-x644.google.com with SMTP id ce23so16644478ejb.8 for ; Mon, 07 Dec 2020 08:43:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=trwWkN08RC97k3KH48B9gNQriEKWSyCbtbzCxwfGmWE=; b=B1EfYNbMVMFOaHv5Q1+MqxN4scHz/Hv2fxp5bGgVC+k0ctBrJNkDB5ON3sGBLmaQW5 blaRzeSuWIpqS+bVQsZMBPxJI8qZqkB3vAkb7ZKE/z1Y2OwARk5Rn2HNXDzI7jOlrvf4 RNSG3KDnMlyl33wXV01uXcO2Fn3qrf6AB/zxTIeRuxVzkPpRx14EgA0CNunoi2Bl4rGC 5qAN0mMe6htUVLfW/sP/mFXpYntXPXC2gICjdEpOUEJvh+hE+akT2xtD0KWG30J3Gniq Dg6xvPp/SY/g5caQK0EmruRZ2vgxERtmT1abew+RC1FKJZNx/gw5mhLQw18Yzijrqefe e8iA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=trwWkN08RC97k3KH48B9gNQriEKWSyCbtbzCxwfGmWE=; b=e1SUiXCJzeNyksHXeoM+PJND72I6AfNcPvTS00GlShFdt3MvNfU9HRAzeuyWlLiO/A cn6r6ZbBEZkYCMtj9xnVSm6pgtgI9H4409E7lTkjD480awkRZ2ONH8NvizmcvxsUTdDH s1SCRdprfOiyD6vFvEUcZHw7nGFtNGvKKvH0Chb6uK0lOnvBuvUvVkhf1DujfPIIhTvD H8ENY3nI78E0gS7BRvjXfnYBscbP48v6FHJGdlEv17Ve52MjO1Yz+L94CxstxHmpwLD3 CjPQPNIJpvFW2pX5JWLwy67LGmdXuSX0C874k2BmkS10LwoO1GY+8mW92w4rqyDIo2Qu fvcw== X-Gm-Message-State: AOAM533peNG4B43Fof2dEb6d91Pe2aK0ft6A060Hq9BgpUWUG53cnyi4 GAdJbxcT7sZ4A5uKyhToVSA= X-Google-Smtp-Source: ABdhPJwY9MeoSxGwRPyIJV5M0g2NpLCkzQk4QntsuJ7EEGm36J5EQc7Tf8qRkCsQBxMYB/d2Z8WFeA== X-Received: by 2002:a17:906:ae41:: with SMTP id lf1mr20055824ejb.369.1607359405393; Mon, 07 Dec 2020 08:43:25 -0800 (PST) Received: from localhost ([51.15.41.238]) by smtp.gmail.com with ESMTPSA id w20sm14259249edi.12.2020.12.07.08.43.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Dec 2020 08:43:24 -0800 (PST) Date: Mon, 7 Dec 2020 16:43:23 +0000 From: Stefan Hajnoczi To: Eugenio =?iso-8859-1?Q?P=E9rez?= Cc: qemu-devel@nongnu.org, Lars Ganrot , virtualization@lists.linux-foundation.org, Salil Mehta , "Michael S. Tsirkin" , Liran Alon , Rob Miller , Max Gurtovoy , Alex Barba , Stefan Hajnoczi , Jim Harford , Jason Wang , Harpreet Singh Anand , Christophe Fontaine , vm , Daniel Daly , Michael Lilja , Stefano Garzarella , Nitin Shrivastav , Lee Ballard , Dmytro Kazantsev , Juan Quintela , kvm@vger.kernel.org, Howard Cai , Xiao W Wang , Sean Mooney , Parav Pandit , Eli Cohen , Siwei Liu , Stephen Finucane Subject: Re: [RFC PATCH 04/27] vhost: add vhost_kernel_set_vring_enable Message-ID: <20201207164323.GK203660@stefanha-x1.localdomain> References: <20201120185105.279030-1-eperezma@redhat.com> <20201120185105.279030-5-eperezma@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="ogUXNSQj4OI1q3LQ" Content-Disposition: inline In-Reply-To: <20201120185105.279030-5-eperezma@redhat.com> Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org --ogUXNSQj4OI1q3LQ Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Nov 20, 2020 at 07:50:42PM +0100, Eugenio P=E9rez wrote: > Signed-off-by: Eugenio P=E9rez > --- > hw/virtio/vhost-backend.c | 29 +++++++++++++++++++++++++++++ > 1 file changed, 29 insertions(+) >=20 > diff --git a/hw/virtio/vhost-backend.c b/hw/virtio/vhost-backend.c > index 222bbcc62d..317f1f96fa 100644 > --- a/hw/virtio/vhost-backend.c > +++ b/hw/virtio/vhost-backend.c > @@ -201,6 +201,34 @@ static int vhost_kernel_get_vq_index(struct vhost_de= v *dev, int idx) > return idx - dev->vq_index; > } > =20 > +static int vhost_kernel_set_vq_enable(struct vhost_dev *dev, unsigned id= x, > + bool enable) > +{ > + struct vhost_vring_file file =3D { > + .index =3D idx, > + }; > + > + if (!enable) { > + file.fd =3D -1; /* Pass -1 to unbind from file. */ > + } else { > + struct vhost_net *vn_dev =3D container_of(dev, struct vhost_net,= dev); > + file.fd =3D vn_dev->backend; > + } > + > + return vhost_kernel_net_set_backend(dev, &file); This is vhost-net specific even though the function appears to be generic. Is there a plan to extend this to all devices? > +} > + > +static int vhost_kernel_set_vring_enable(struct vhost_dev *dev, int enab= le) > +{ > + int i; > + > + for (i =3D 0; i < dev->nvqs; ++i) { > + vhost_kernel_set_vq_enable(dev, i, enable); > + } > + > + return 0; > +} I suggest exposing the per-vq interface (vhost_kernel_set_vq_enable()) in VhostOps so it follows the ioctl interface. vhost_kernel_set_vring_enable() can be moved to vhost.c can loop over all vqs if callers find it convenient to loop over all vqs. --ogUXNSQj4OI1q3LQ Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEEhpWov9P5fNqsNXdanKSrs4Grc8gFAl/OW6sACgkQnKSrs4Gr c8jcDwgAvhR1DPn/758yBurYSAd5bodrjz48KqGTFPhHnHIzAsDSztsiZ/VKnhlt lkf8slJQyaaQ5G9Po4HX6CNdMSNmkBT1mz0lk6dnr75aHQ/hijqknpXM1og/4MRQ lCUyXQhHsLGZ3ETT8Is/Bgg99b3T0SykRSzhlpzIMaPqGgzvzTNdh1u0SFKi3W3o Vke/ZS/yZ2K0F+sNwQzPGp5JflOTagn1QuGO8JslZinLNh8y3C05n/6ZCWbM9Jl9 ABaBPHhenGFmH672WMK839qEawHgEUS6aziPnVfPczqudEqinJpHT9Oc6xMeBG1D mv3UoTm7iaY08guxGcO5yO6FILXe/g== =IdPX -----END PGP SIGNATURE----- --ogUXNSQj4OI1q3LQ--