Stefan Hajnoczi
2020-Dec-08 07:34 UTC
[RFC PATCH 09/27] vhost: Route host->guest notification through qemu
On Fri, Nov 20, 2020 at 07:50:47PM +0100, Eugenio P?rez wrote:> Signed-off-by: Eugenio P?rez <eperezma at redhat.com> > --- > hw/virtio/vhost-sw-lm-ring.c | 3 +++ > hw/virtio/vhost.c | 20 ++++++++++++++++++++ > 2 files changed, 23 insertions(+)I'm not sure I understand what is going here. The guest notifier masking feature exists to support MSI masking semantics. It looks like this patch repurposes the notifier to decouple the vhost hdev from the virtio device's irqfd? But this breaks MSI masking. I think you need to set up your own eventfd and assign it to the vhost hdev's call fd instead of using the mask notifier.> > diff --git a/hw/virtio/vhost-sw-lm-ring.c b/hw/virtio/vhost-sw-lm-ring.c > index 0192e77831..cbf53965cd 100644 > --- a/hw/virtio/vhost-sw-lm-ring.c > +++ b/hw/virtio/vhost-sw-lm-ring.c > @@ -50,6 +50,9 @@ VhostShadowVirtqueue *vhost_sw_lm_shadow_vq(struct vhost_dev *dev, int idx) > r = dev->vhost_ops->vhost_set_vring_kick(dev, &file); > assert(r == 0); > > + vhost_virtqueue_mask(dev, dev->vdev, idx, true); > + vhost_virtqueue_pending(dev, idx);Why is the mask notifier cleared? Could we lose a guest notification here?> + > return svq; > } > > diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c > index 1d55e26d45..9352c56bfa 100644 > --- a/hw/virtio/vhost.c > +++ b/hw/virtio/vhost.c > @@ -960,12 +960,29 @@ static void handle_sw_lm_vq(VirtIODevice *vdev, VirtQueue *vq) > vhost_vring_kick(svq); > } > > +static void vhost_handle_call(EventNotifier *n) > +{ > + struct vhost_virtqueue *hvq = container_of(n, > + struct vhost_virtqueue, > + masked_notifier); > + struct vhost_dev *vdev = hvq->dev; > + int idx = vdev->vq_index + (hvq == &vdev->vqs[0] ? 0 : 1);vhost-net-specific hack> + VirtQueue *vq = virtio_get_queue(vdev->vdev, idx); > + > + if (event_notifier_test_and_clear(n)) { > + virtio_queue_invalidate_signalled_used(vdev->vdev, idx); > + virtio_notify_irqfd(vdev->vdev, vq);/* TODO push used elements into vq? */ -------------- 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/20201208/5269790e/attachment.sig>