Skip to content
  • Stefan Hajnoczi's avatar
    fcccb271
    virtio: notify virtqueue via host notifier when available · fcccb271
    Stefan Hajnoczi authored
    
    
    Host notifiers are used in several cases:
    1. Traditional ioeventfd where virtqueue notifications are handled in
       the main loop thread.
    2. IOThreads (aio_handle_output) where virtqueue notifications are
       handled in an IOThread AioContext.
    3. vhost where virtqueue notifications are handled by kernel vhost or
       a vhost-user device backend.
    
    Most virtqueue notifications from the guest use the ioeventfd mechanism,
    but there are corner cases where QEMU code calls virtio_queue_notify().
    This currently honors the host notifier for the IOThreads
    aio_handle_output case, but not for the vhost case.  The result is that
    vhost does not receive virtqueue notifications from QEMU when
    virtio_queue_notify() is called.
    
    This patch extends virtio_queue_notify() to set the host notifier
    whenever it is enabled instead of calling the vq->(aio_)handle_output()
    function directly.  We track the host notifier state for each virtqueue
    separately since some devices may use it only for certain virtqueues.
    
    This fixes the vhost case although it does add a trip through the
    eventfd for the traditional ioeventfd case.  I don't think it's worth
    adding a fast path for the traditional ioeventfd case because calling
    virtio_queue_notify() is rare when ioeventfd is enabled.
    
    Reported-by: default avatarFelipe Franciosi <felipe@nutanix.com>
    Signed-off-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
    Message-Id: <20191105140946.165584-1-stefanha@redhat.com>
    Reviewed-by: default avatarMichael S. Tsirkin <mst@redhat.com>
    Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
    fcccb271
    virtio: notify virtqueue via host notifier when available
    Stefan Hajnoczi authored
    
    
    Host notifiers are used in several cases:
    1. Traditional ioeventfd where virtqueue notifications are handled in
       the main loop thread.
    2. IOThreads (aio_handle_output) where virtqueue notifications are
       handled in an IOThread AioContext.
    3. vhost where virtqueue notifications are handled by kernel vhost or
       a vhost-user device backend.
    
    Most virtqueue notifications from the guest use the ioeventfd mechanism,
    but there are corner cases where QEMU code calls virtio_queue_notify().
    This currently honors the host notifier for the IOThreads
    aio_handle_output case, but not for the vhost case.  The result is that
    vhost does not receive virtqueue notifications from QEMU when
    virtio_queue_notify() is called.
    
    This patch extends virtio_queue_notify() to set the host notifier
    whenever it is enabled instead of calling the vq->(aio_)handle_output()
    function directly.  We track the host notifier state for each virtqueue
    separately since some devices may use it only for certain virtqueues.
    
    This fixes the vhost case although it does add a trip through the
    eventfd for the traditional ioeventfd case.  I don't think it's worth
    adding a fast path for the traditional ioeventfd case because calling
    virtio_queue_notify() is rare when ioeventfd is enabled.
    
    Reported-by: default avatarFelipe Franciosi <felipe@nutanix.com>
    Signed-off-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
    Message-Id: <20191105140946.165584-1-stefanha@redhat.com>
    Reviewed-by: default avatarMichael S. Tsirkin <mst@redhat.com>
    Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
Loading