From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH 5/8] add and use event_notifier_set_handler
Date: Wed, 26 May 2010 16:09:35 +0200 [thread overview]
Message-ID: <1274882978-9875-6-git-send-email-pbonzini@redhat.com> (raw)
In-Reply-To: <1274882978-9875-1-git-send-email-pbonzini@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
event_notifier.c | 7 +++++++
event_notifier.h | 3 +++
hw/virtio-pci.c | 9 +++------
3 files changed, 13 insertions(+), 6 deletions(-)
diff --git a/event_notifier.c b/event_notifier.c
index 0f7b8da..066adb9 100644
--- a/event_notifier.c
+++ b/event_notifier.c
@@ -11,6 +11,7 @@
*/
#include "event_notifier.h"
+#include "qemu-char.h"
#ifdef CONFIG_EVENTFD
#include <sys/eventfd.h>
#endif
@@ -38,6 +39,12 @@ int event_notifier_get_fd(EventNotifier *e)
return e->fd;
}
+int event_notifier_set_handler(EventNotifier *e,
+ EventNotifierHandler *handler)
+{
+ return qemu_set_fd_handler(e->fd, (IOHandler *)handler, NULL, e);
+}
+
int event_notifier_set(EventNotifier *e)
{
uint64_t value = 1;
diff --git a/event_notifier.h b/event_notifier.h
index 714d690..f6ec9ef 100644
--- a/event_notifier.h
+++ b/event_notifier.h
@@ -7,10 +7,13 @@ struct EventNotifier {
int fd;
};
+typedef void EventNotifierHandler(EventNotifier *);
+
int event_notifier_init(EventNotifier *, int active);
void event_notifier_cleanup(EventNotifier *);
int event_notifier_get_fd(EventNotifier *);
int event_notifier_set(EventNotifier *);
int event_notifier_test_and_clear(EventNotifier *);
+int event_notifier_set_handler(EventNotifier *, EventNotifierHandler *);
#endif
diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c
index 988c75c..a7ebc83 100644
--- a/hw/virtio-pci.c
+++ b/hw/virtio-pci.c
@@ -419,9 +419,8 @@ static unsigned virtio_pci_get_features(void *opaque)
return proxy->host_features;
}
-static void virtio_pci_guest_notifier_read(void *opaque)
+static void virtio_pci_guest_notifier_read(EventNotifier *n)
{
- EventNotifier *n = opaque;
VirtQueue *vq = virtqueue_from_guest_notifier(n);
if (event_notifier_test_and_clear(n)) {
virtio_irq(vq);
@@ -439,11 +438,9 @@ static int virtio_pci_set_guest_notifier(void *opaque, int n, bool assign)
if (r < 0) {
return r;
}
- qemu_set_fd_handler(event_notifier_get_fd(notifier),
- virtio_pci_guest_notifier_read, NULL, notifier);
+ event_notifier_set_handler(notifier, virtio_pci_guest_notifier_read);
} else {
- qemu_set_fd_handler(event_notifier_get_fd(notifier),
- NULL, NULL, NULL);
+ event_notifier_set_handler(notifier, NULL);
event_notifier_cleanup(notifier);
}
--
1.6.6.1
next prev parent reply other threads:[~2010-05-26 14:14 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-26 14:09 [Qemu-devel] [PATCH 0/8] Make event_notifier more useful and more used Paolo Bonzini
2010-05-26 14:09 ` [Qemu-devel] [PATCH 1/8] move event_notifier into the main directory Paolo Bonzini
2010-05-26 14:09 ` [Qemu-devel] [PATCH 2/8] add event_notifier_set Paolo Bonzini
2010-05-26 14:09 ` [Qemu-devel] [PATCH 3/8] remove event_notifier_test Paolo Bonzini
2010-05-26 14:09 ` [Qemu-devel] [PATCH 4/8] add and use virtqueue_from_guest_notifier Paolo Bonzini
2010-05-26 14:09 ` Paolo Bonzini [this message]
2010-05-26 14:09 ` [Qemu-devel] [PATCH 6/8] enable event_notifier to use pipes Paolo Bonzini
2010-05-26 18:19 ` Richard Henderson
2010-05-26 19:48 ` [Qemu-devel] " Paolo Bonzini
2010-05-26 14:09 ` [Qemu-devel] [PATCH 7/8] add Win32 implementation of event notifiers Paolo Bonzini
2010-05-26 14:09 ` [Qemu-devel] [PATCH 8/8] change ioevent to use " Paolo Bonzini
2010-05-27 14:21 ` [Qemu-devel] Re: [PATCH 0/8] Make event_notifier more useful and more used Michael S. Tsirkin
2010-05-27 15:37 ` Paolo Bonzini
2010-06-15 13:53 ` Paolo Bonzini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1274882978-9875-6-git-send-email-pbonzini@redhat.com \
--to=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).