qemu/hw/virtio
Stefan Hajnoczi fcccb271e0 virtio: notify virtqueue via host notifier when available
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: Felipe Franciosi <felipe@nutanix.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-Id: <20191105140946.165584-1-stefanha@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2019-11-06 06:35:00 -05:00
..
Kconfig virtio-pmem: add virtio device 2019-07-02 12:59:22 -04:00
Makefile.objs virtio: add vhost-user-fs-pci device 2019-10-05 17:43:55 -04:00
trace-events hw/virtio/virtio-mmio: Convert DPRINTF to trace and log 2019-05-22 15:33:20 +02:00
vhost-backend.c Include qemu/main-loop.h less 2019-08-16 13:31:52 +02:00
vhost-scsi-pci.c Include hw/qdev-properties.h less 2019-08-16 13:31:53 +02:00
vhost-stub.c vhost-user: simplify vhost_user_init/vhost_user_cleanup 2019-03-12 21:22:31 -04:00
vhost-user-blk-pci.c Include hw/qdev-properties.h less 2019-08-16 13:31:53 +02:00
vhost-user-fs-pci.c virtio: add vhost-user-fs-pci device 2019-10-05 17:43:55 -04:00
vhost-user-fs.c virtio: add vhost-user-fs base device 2019-10-05 17:43:55 -04:00
vhost-user-input-pci.c Add vhost-user-input-pci 2019-05-10 14:52:47 +02:00
vhost-user-scsi-pci.c Include hw/qdev-properties.h less 2019-08-16 13:31:53 +02:00
vhost-user.c Include qemu/main-loop.h less 2019-08-16 13:31:52 +02:00
vhost-vsock-pci.c Include hw/qdev-properties.h less 2019-08-16 13:31:53 +02:00
vhost-vsock.c Include hw/qdev-properties.h less 2019-08-16 13:31:53 +02:00
vhost.c virtio/vhost: Use auto_rcu_read macros 2019-10-29 18:56:45 -04:00
virtio-9p-pci.c Include hw/qdev-properties.h less 2019-08-16 13:31:53 +02:00
virtio-balloon-pci.c Include hw/qdev-properties.h less 2019-08-16 13:31:53 +02:00
virtio-balloon.c Include hw/qdev-properties.h less 2019-08-16 13:31:53 +02:00
virtio-blk-pci.c Include hw/qdev-properties.h less 2019-08-16 13:31:53 +02:00
virtio-bus.c virtio: notify virtqueue via host notifier when available 2019-11-06 06:35:00 -05:00
virtio-crypto-pci.c Include hw/qdev-properties.h less 2019-08-16 13:31:53 +02:00
virtio-crypto.c Include hw/qdev-properties.h less 2019-08-16 13:31:53 +02:00
virtio-input-host-pci.c Include qemu/module.h where needed, drop it from qemu-common.h 2019-06-12 13:18:33 +02:00
virtio-input-pci.c Include hw/qdev-properties.h less 2019-08-16 13:31:53 +02:00
virtio-mmio.c hw/virtio: Factorize virtio-mmio headers 2019-10-22 09:38:42 +02:00
virtio-net-pci.c Include hw/qdev-properties.h less 2019-08-16 13:31:53 +02:00
virtio-pci.c virtio,vhost: fixes, features, cleanups. 2019-09-04 17:22:34 +01:00
virtio-pci.h virtio-pci: Add Function Level Reset support 2019-09-04 06:33:10 -04:00
virtio-pmem-pci.c virtio pmem: remove transitional names 2019-07-12 10:57:27 -04:00
virtio-pmem-pci.h virtio-pci: Proxy for virtio-pmem 2019-07-04 17:00:32 -04:00
virtio-pmem.c Include sysemu/hostmem.h less 2019-08-16 13:31:53 +02:00
virtio-rng-pci.c Include qemu/module.h where needed, drop it from qemu-common.h 2019-06-12 13:18:33 +02:00
virtio-rng.c virtio: Free rnd virqueue at unrealize() 2019-10-25 07:46:22 -04:00
virtio-scsi-pci.c Include hw/qdev-properties.h less 2019-08-16 13:31:53 +02:00
virtio-serial-pci.c Include hw/qdev-properties.h less 2019-08-16 13:31:53 +02:00
virtio.c virtio: notify virtqueue via host notifier when available 2019-11-06 06:35:00 -05:00