diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2012-07-05 17:16:29 +0200 |
---|---|---|
committer | Avi Kivity <avi@redhat.com> | 2012-07-12 14:08:11 +0300 |
commit | b1f416aa8d870fab71030abc9401cfc77b948e8e (patch) | |
tree | 85ce6fbf099085dcb82a1dbddd52d18585c989c6 /hw/virtio.c | |
parent | 6bf819f0a2a77dc8504651f369293f0efac54fe5 (diff) |
virtio: move common ioeventfd handling out of virtio-pci
All transports can use the same event handler for the ioeventfd, though
the exact setup (address/memory region) will be specific.
This lets virtio use event_notifier_set_handler.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'hw/virtio.c')
-rw-r--r-- | hw/virtio.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/hw/virtio.c b/hw/virtio.c index 168abe4864..197edf00f4 100644 --- a/hw/virtio.c +++ b/hw/virtio.c @@ -988,6 +988,28 @@ EventNotifier *virtio_queue_get_guest_notifier(VirtQueue *vq) { return &vq->guest_notifier; } + +static void virtio_queue_host_notifier_read(EventNotifier *n) +{ + VirtQueue *vq = container_of(n, VirtQueue, host_notifier); + if (event_notifier_test_and_clear(n)) { + virtio_queue_notify_vq(vq); + } +} + +void virtio_queue_set_host_notifier_fd_handler(VirtQueue *vq, bool assign) +{ + if (assign) { + event_notifier_set_handler(&vq->host_notifier, + virtio_queue_host_notifier_read); + } else { + event_notifier_set_handler(&vq->host_notifier, NULL); + /* Test and clear notifier before after disabling event, + * in case poll callback didn't have time to run. */ + virtio_queue_host_notifier_read(&vq->host_notifier); + } +} + EventNotifier *virtio_queue_get_host_notifier(VirtQueue *vq) { return &vq->host_notifier; |