Stefan Hajnoczi
2020-Dec-07 16:43 UTC
[RFC PATCH 04/27] vhost: add vhost_kernel_set_vring_enable
On Fri, Nov 20, 2020 at 07:50:42PM +0100, Eugenio P?rez wrote:> Signed-off-by: Eugenio P?rez <eperezma at redhat.com> > --- > hw/virtio/vhost-backend.c | 29 +++++++++++++++++++++++++++++ > 1 file changed, 29 insertions(+) > > 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_dev *dev, int idx) > return idx - dev->vq_index; > } > > +static int vhost_kernel_set_vq_enable(struct vhost_dev *dev, unsigned idx, > + bool enable) > +{ > + struct vhost_vring_file file = { > + .index = idx, > + }; > + > + if (!enable) { > + file.fd = -1; /* Pass -1 to unbind from file. */ > + } else { > + struct vhost_net *vn_dev = container_of(dev, struct vhost_net, dev); > + file.fd = 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 enable) > +{ > + int i; > + > + for (i = 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. -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 488 bytes Desc: not available URL: <http://lists.linuxfoundation.org/pipermail/virtualization/attachments/20201207/dbc7a49c/attachment.sig>