From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH 4/8] add and use virtqueue_from_guest_notifier
Date: Wed, 26 May 2010 16:09:34 +0200 [thread overview]
Message-ID: <1274882978-9875-5-git-send-email-pbonzini@redhat.com> (raw)
In-Reply-To: <1274882978-9875-1-git-send-email-pbonzini@redhat.com>
This changes the opaque pointer passed to the handler, from being
the virtqueue to being the eventnotifier. It is useful as soon as
the eventnotifier will be able to set its own (type-safe) handler.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
I don't have a vhost-enabled machine yet. So only compile-tested
for now, but pretty trivial.
hw/virtio-pci.c | 6 +++---
hw/virtio.c | 5 +++++
hw/virtio.h | 1 +
3 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c
index 7ddf612..988c75c 100644
--- a/hw/virtio-pci.c
+++ b/hw/virtio-pci.c
@@ -421,8 +421,8 @@ static unsigned virtio_pci_get_features(void *opaque)
static void virtio_pci_guest_notifier_read(void *opaque)
{
- VirtQueue *vq = opaque;
- EventNotifier *n = virtio_queue_get_guest_notifier(vq);
+ EventNotifier *n = opaque;
+ VirtQueue *vq = virtqueue_from_guest_notifier(n);
if (event_notifier_test_and_clear(n)) {
virtio_irq(vq);
}
@@ -440,7 +440,7 @@ static int virtio_pci_set_guest_notifier(void *opaque, int n, bool assign)
return r;
}
qemu_set_fd_handler(event_notifier_get_fd(notifier),
- virtio_pci_guest_notifier_read, NULL, vq);
+ virtio_pci_guest_notifier_read, NULL, notifier);
} else {
qemu_set_fd_handler(event_notifier_get_fd(notifier),
NULL, NULL, NULL);
diff --git a/hw/virtio.c b/hw/virtio.c
index 4475bb3..bfce44b 100644
--- a/hw/virtio.c
+++ b/hw/virtio.c
@@ -805,6 +805,11 @@ VirtQueue *virtio_get_queue(VirtIODevice *vdev, int n)
return vdev->vq + n;
}
+VirtQueue *virtqueue_from_guest_notifier(EventNotifier *e)
+{
+ return container_of(e, VirtQueue, guest_notifier);
+}
+
EventNotifier *virtio_queue_get_guest_notifier(VirtQueue *vq)
{
return &vq->guest_notifier;
diff --git a/hw/virtio.h b/hw/virtio.h
index e4306cd..d6a5b00 100644
--- a/hw/virtio.h
+++ b/hw/virtio.h
@@ -210,6 +210,7 @@ target_phys_addr_t virtio_queue_get_ring_size(VirtIODevice *vdev, int n);
uint16_t virtio_queue_get_last_avail_idx(VirtIODevice *vdev, int n);
void virtio_queue_set_last_avail_idx(VirtIODevice *vdev, int n, uint16_t idx);
VirtQueue *virtio_get_queue(VirtIODevice *vdev, int n);
+VirtQueue *virtqueue_from_guest_notifier(EventNotifier *vq);
EventNotifier *virtio_queue_get_guest_notifier(VirtQueue *vq);
EventNotifier *virtio_queue_get_host_notifier(VirtQueue *vq);
void virtio_irq(VirtQueue *vq);
--
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 ` Paolo Bonzini [this message]
2010-05-26 14:09 ` [Qemu-devel] [PATCH 5/8] add and use event_notifier_set_handler Paolo Bonzini
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-5-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).