|
Justin M. Forbes |
272dfe |
Add binding API to set host/guest notifiers.
|
|
Justin M. Forbes |
272dfe |
Will be used by vhost.
|
|
Justin M. Forbes |
272dfe |
|
|
Justin M. Forbes |
272dfe |
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
|
|
Justin M. Forbes |
272dfe |
---
|
|
Justin M. Forbes |
272dfe |
hw/virtio.c | 13 ++++++++++---
|
|
Justin M. Forbes |
272dfe |
hw/virtio.h | 5 ++++-
|
|
Justin M. Forbes |
272dfe |
2 files changed, 14 insertions(+), 4 deletions(-)
|
|
Justin M. Forbes |
272dfe |
|
|
Justin M. Forbes |
272dfe |
diff --git a/hw/virtio.c b/hw/virtio.c
|
|
Justin M. Forbes |
272dfe |
index fa7184a..c2b80aa 100644
|
|
Justin M. Forbes |
272dfe |
--- a/hw/virtio.c
|
|
Justin M. Forbes |
272dfe |
+++ b/hw/virtio.c
|
|
Justin M. Forbes |
272dfe |
@@ -594,6 +594,12 @@ VirtQueue *virtio_add_queue(VirtIODevice *vdev, int queue_size,
|
|
Justin M. Forbes |
272dfe |
return &vdev->vq[i];
|
|
Justin M. Forbes |
272dfe |
}
|
|
Justin M. Forbes |
272dfe |
|
|
Justin M. Forbes |
272dfe |
+void virtio_irq(VirtIODevice *vdev, VirtQueue *vq)
|
|
Justin M. Forbes |
272dfe |
+{
|
|
Justin M. Forbes |
272dfe |
+ vdev->isr |= 0x01;
|
|
Justin M. Forbes |
272dfe |
+ virtio_notify_vector(vdev, vq->vector);
|
|
Justin M. Forbes |
272dfe |
+}
|
|
Justin M. Forbes |
272dfe |
+
|
|
Justin M. Forbes |
272dfe |
void virtio_notify(VirtIODevice *vdev, VirtQueue *vq)
|
|
Justin M. Forbes |
272dfe |
{
|
|
Justin M. Forbes |
272dfe |
/* Always notify when queue is empty (when feature acknowledge) */
|
|
Justin M. Forbes |
272dfe |
@@ -602,8 +608,7 @@ void virtio_notify(VirtIODevice *vdev, VirtQueue *vq)
|
|
Justin M. Forbes |
272dfe |
(vq->inuse || vring_avail_idx(vq) != vq->last_avail_idx)))
|
|
Justin M. Forbes |
272dfe |
return;
|
|
Justin M. Forbes |
272dfe |
|
|
Justin M. Forbes |
272dfe |
- vdev->isr |= 0x01;
|
|
Justin M. Forbes |
272dfe |
- virtio_notify_vector(vdev, vq->vector);
|
|
Justin M. Forbes |
272dfe |
+ virtio_irq(vdev, vq);
|
|
Justin M. Forbes |
272dfe |
}
|
|
Justin M. Forbes |
272dfe |
|
|
Justin M. Forbes |
272dfe |
void virtio_notify_config(VirtIODevice *vdev)
|
|
Justin M. Forbes |
272dfe |
@@ -716,8 +721,10 @@ VirtIODevice *virtio_common_init(const char *name, uint16_t device_id,
|
|
Justin M. Forbes |
272dfe |
vdev->queue_sel = 0;
|
|
Justin M. Forbes |
272dfe |
vdev->config_vector = VIRTIO_NO_VECTOR;
|
|
Justin M. Forbes |
272dfe |
vdev->vq = qemu_mallocz(sizeof(VirtQueue) * VIRTIO_PCI_QUEUE_MAX);
|
|
Justin M. Forbes |
272dfe |
- for(i = 0; i < VIRTIO_PCI_QUEUE_MAX; i++)
|
|
Justin M. Forbes |
272dfe |
+ for(i = 0; i < VIRTIO_PCI_QUEUE_MAX; i++) {
|
|
Justin M. Forbes |
272dfe |
vdev->vq[i].vector = VIRTIO_NO_VECTOR;
|
|
Justin M. Forbes |
272dfe |
+ vdev->vq[i].vdev = vdev;
|
|
Justin M. Forbes |
272dfe |
+ }
|
|
Justin M. Forbes |
272dfe |
|
|
Justin M. Forbes |
272dfe |
vdev->name = name;
|
|
Justin M. Forbes |
272dfe |
vdev->config_len = config_size;
|
|
Justin M. Forbes |
272dfe |
diff --git a/hw/virtio.h b/hw/virtio.h
|
|
Justin M. Forbes |
272dfe |
index 3994cc9..10a0959 100644
|
|
Justin M. Forbes |
272dfe |
--- a/hw/virtio.h
|
|
Justin M. Forbes |
272dfe |
+++ b/hw/virtio.h
|
|
Justin M. Forbes |
272dfe |
@@ -18,6 +18,7 @@
|
|
Justin M. Forbes |
272dfe |
#include "net.h"
|
|
Justin M. Forbes |
272dfe |
#include "qdev.h"
|
|
Justin M. Forbes |
272dfe |
#include "sysemu.h"
|
|
Justin M. Forbes |
272dfe |
+#include "notifier.h"
|
|
Justin M. Forbes |
272dfe |
|
|
Justin M. Forbes |
272dfe |
/* from Linux's linux/virtio_config.h */
|
|
Justin M. Forbes |
272dfe |
|
|
Justin M. Forbes |
272dfe |
@@ -88,6 +89,8 @@ typedef struct {
|
|
Justin M. Forbes |
272dfe |
int (*load_config)(void * opaque, QEMUFile *f);
|
|
Justin M. Forbes |
272dfe |
int (*load_queue)(void * opaque, int n, QEMUFile *f);
|
|
Justin M. Forbes |
272dfe |
unsigned (*get_features)(void * opaque);
|
|
Justin M. Forbes |
272dfe |
+ int (*guest_notifier)(void * opaque, int n, bool assigned);
|
|
Justin M. Forbes |
272dfe |
+ int (*host_notifier)(void * opaque, int n, bool assigned);
|
|
Justin M. Forbes |
272dfe |
} VirtIOBindings;
|
|
Justin M. Forbes |
272dfe |
|
|
Justin M. Forbes |
272dfe |
#define VIRTIO_PCI_QUEUE_MAX 64
|
|
Justin M. Forbes |
272dfe |
@@ -180,5 +183,5 @@ void virtio_net_exit(VirtIODevice *vdev);
|
|
Justin M. Forbes |
272dfe |
DEFINE_PROP_BIT("indirect_desc", _state, _field, \
|
|
Justin M. Forbes |
272dfe |
VIRTIO_RING_F_INDIRECT_DESC, true)
|
|
Justin M. Forbes |
272dfe |
|
|
Justin M. Forbes |
272dfe |
-
|
|
Justin M. Forbes |
272dfe |
+void virtio_irq(VirtIODevice *vdev, VirtQueue *vq);
|
|
Justin M. Forbes |
272dfe |
#endif
|
|
Justin M. Forbes |
272dfe |
--
|
|
Justin M. Forbes |
272dfe |
1.6.6.144.g5c3af
|