On Fri, Nov 20, 2020 at 07:50:42PM +0100, Eugenio Pérez wrote: > Signed-off-by: Eugenio Pérez <eperezma@xxxxxxxxxx> > --- > 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.
Attachment:
signature.asc
Description: PGP signature
_______________________________________________ Virtualization mailing list Virtualization@xxxxxxxxxxxxxxxxxxxxxxxxxx https://lists.linuxfoundation.org/mailman/listinfo/virtualization