[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 09/16] virtio-pci: support host notifiers in TCG mod
From: |
zwu . kernel |
Subject: |
[Qemu-devel] [PATCH 09/16] virtio-pci: support host notifiers in TCG mode |
Date: |
Thu, 19 Apr 2012 10:39:02 +0800 |
From: Stefan Hajnoczi <address@hidden>
Normally host notifiers are only used together with vhost-net in KVM
mode. It is occassionally useful to use vhost with TCG mode, mainly for
testing and development. This isn't hard to achieve, simply fall back
to notifying the host notifier manually from qemu if KVM mode is
disabled.
Signed-off-by: Stefan Hajnoczi <address@hidden>
---
hw/virtio-pci.c | 23 ++++++++++++++++++++---
hw/virtio.c | 7 +++++++
2 files changed, 27 insertions(+), 3 deletions(-)
diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c
index 4a4413d..dcd58d0 100644
--- a/hw/virtio-pci.c
+++ b/hw/virtio-pci.c
@@ -281,6 +281,25 @@ void virtio_pci_reset(DeviceState *d)
proxy->flags &= ~VIRTIO_PCI_FLAG_BUS_MASTER_BUG;
}
+static void virtio_pci_queue_notify(VirtIOPCIProxy *proxy, uint32_t n)
+{
+ VirtQueue *vq;
+ EventNotifier *notifier;
+
+ if (n >= VIRTIO_PCI_QUEUE_MAX) {
+ return;
+ }
+
+ vq = virtio_get_queue(proxy->vdev, n);
+ notifier = virtio_queue_get_host_notifier(vq);
+ if (event_notifier_valid(notifier)) {
+ printf("notifying vq %u host notifier from userspace\n", n);
+ event_notifier_notify(notifier);
+ } else {
+ virtio_queue_notify_vq(vq);
+ }
+}
+
static void virtio_ioport_write(void *opaque, uint32_t addr, uint32_t val)
{
VirtIOPCIProxy *proxy = opaque;
@@ -310,9 +329,7 @@ static void virtio_ioport_write(void *opaque, uint32_t
addr, uint32_t val)
vdev->queue_sel = val;
break;
case VIRTIO_PCI_QUEUE_NOTIFY:
- if (val < VIRTIO_PCI_QUEUE_MAX) {
- virtio_queue_notify(vdev, val);
- }
+ virtio_pci_queue_notify(proxy, val);
break;
case VIRTIO_PCI_STATUS:
if (!(val & VIRTIO_CONFIG_S_DRIVER_OK)) {
diff --git a/hw/virtio.c b/hw/virtio.c
index 064aecf..e491850 100644
--- a/hw/virtio.c
+++ b/hw/virtio.c
@@ -527,6 +527,11 @@ void virtio_reset(void *opaque)
vdev->vq[i].signalled_used = 0;
vdev->vq[i].signalled_used_valid = false;
vdev->vq[i].notification = true;
+
+ assert(!event_notifier_valid(&vdev->vq[i].guest_notifier));
+ assert(!event_notifier_valid(&vdev->vq[i].host_notifier));
+ vdev->vq[i].guest_notifier = EVENT_NOTIFIER_INITIALIZER;
+ vdev->vq[i].host_notifier = EVENT_NOTIFIER_INITIALIZER;
}
}
@@ -887,6 +892,8 @@ VirtIODevice *virtio_common_init(const char *name, uint16_t
device_id,
for(i = 0; i < VIRTIO_PCI_QUEUE_MAX; i++) {
vdev->vq[i].vector = VIRTIO_NO_VECTOR;
vdev->vq[i].vdev = vdev;
+ vdev->vq[i].guest_notifier = EVENT_NOTIFIER_INITIALIZER;
+ vdev->vq[i].host_notifier = EVENT_NOTIFIER_INITIALIZER;
}
vdev->name = name;
--
1.7.6
- [Qemu-devel] [PATCH 02/16] vhost: Pass device path to vhost_dev_init(), (continued)
- [Qemu-devel] [PATCH 02/16] vhost: Pass device path to vhost_dev_init(), zwu . kernel, 2012/04/18
- [Qemu-devel] [PATCH 05/16] virtio-scsi: Build virtio-scsi.o against vhost.o, zwu . kernel, 2012/04/18
- [Qemu-devel] [PATCH 04/16] virtio-scsi: Fix tgpt typo to tpgt and use uint16_t, zwu . kernel, 2012/04/18
- [Qemu-devel] [PATCH 07/16] virtio-scsi: Start/stop vhost, zwu . kernel, 2012/04/18
- [Qemu-devel] [PATCH 03/16] virtio-scsi: Add vhost_vring_target ioctl struct, zwu . kernel, 2012/04/18
- [Qemu-devel] [PATCH 06/16] virtio-scsi: Open and initialize /dev/vhost-scsi, zwu . kernel, 2012/04/18
- [Qemu-devel] [PATCH 01/16] virtio-scsi: Add wwpn and tgpt properties, zwu . kernel, 2012/04/18
- [Qemu-devel] [PATCH 13/16] virtio-scsi: WIP VHOST_SCSI_SET_ENDPOINT call, zwu . kernel, 2012/04/18
- [Qemu-devel] [PATCH 12/16] virtio-scsi: use the vhost-scsi host device, zwu . kernel, 2012/04/18
- [Qemu-devel] [PATCH 14/16] vhost-scsi: enable vhost notifiers for multiple queues, zwu . kernel, 2012/04/18
- [Qemu-devel] [PATCH 09/16] virtio-pci: support host notifiers in TCG mode,
zwu . kernel <=
- [Qemu-devel] [PATCH 11/16] vhost-scsi: add -vhost-scsi host device, zwu . kernel, 2012/04/18
- [Qemu-devel] [PATCH 08/16] notifier: add validity check and notify function, zwu . kernel, 2012/04/18
- [Qemu-devel] [PATCH 15/16] vhost-scsi: move some definitions to its header file, zwu . kernel, 2012/04/18
- [Qemu-devel] [PATCH 10/16] virtio-pci: check that event notification worked, zwu . kernel, 2012/04/18
- [Qemu-devel] [PATCH 16/16] vhost-scsi: clear endpoint on stopped, zwu . kernel, 2012/04/18
- Re: [Qemu-devel] [PATCH 00/16] QEMU vhost-scsi support, Paolo Bonzini, 2012/04/19