Received: from eggs.gnu.org ([2001:4830:134:3::10]:60959)
by lists.gnu.org with esmtp (Exim 4.71)
(envelope-from
) id 1YqJNQ-0001Vd-GM
for qemu-devel@nongnu.org; Thu, 07 May 2015 06:50:01 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
(envelope-from ) id 1YqJNM-0007Q1-A5
for qemu-devel@nongnu.org; Thu, 07 May 2015 06:50:00 -0400
Received: from mailout2.w1.samsung.com ([210.118.77.12]:22608)
by eggs.gnu.org with esmtp (Exim 4.71)
(envelope-from ) id 1YqJNM-0007Px-5V
for qemu-devel@nongnu.org; Thu, 07 May 2015 06:49:56 -0400
Received: from eucpsbgm1.samsung.com (unknown [203.254.199.244])
by mailout2.w1.samsung.com
(Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5
2014)) with ESMTP id <0NNZ008CR7F7O620@mailout2.w1.samsung.com> for
qemu-devel@nongnu.org; Thu, 07 May 2015 11:49:55 +0100 (BST)
Received: from fedinw7x64 ([106.109.131.169])
by eusync1.samsung.com (Oracle Communications Messaging Server
7.0.5.31.0 64bit (built May 5 2014))
with ESMTPA id <0NNZ0093B7F6SK30@eusync1.samsung.com> for
qemu-devel@nongnu.org; Thu, 07 May 2015 11:49:55 +0100 (BST)
From: Pavel Fedin
Date: Thu, 07 May 2015 13:49:54 +0300
Message-id: <016001d088b3$8da9bfa0$a8fd3ee0$@samsung.com>
MIME-version: 1.0
Content-type: text/plain; charset=us-ascii
Content-transfer-encoding: 7bit
Content-language: ru
Subject: [Qemu-devel] [PATCH v2 2/3] virtio-mmio: introduce
set_guest_notifiers
List-Id:
List-Unsubscribe: ,
List-Archive:
List-Post:
List-Help:
List-Subscribe: ,
To: qemu-devel@nongnu.org
Same as host notifier of virtio-mmio, most of codes came from virtio-pci.
The kvm-arm does not yet support irqfd, need to fix the hard-coded part
after
kvm-arm gets irqfd support.
Signed-off-by: Ying-Shiuan Pan
Signed-off-by: Pavel Fedin
---
hw/virtio/virtio-mmio.c | 61
+++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 61 insertions(+)
diff --git a/hw/virtio/virtio-mmio.c b/hw/virtio/virtio-mmio.c
index 6b40d56..8756240 100644
--- a/hw/virtio/virtio-mmio.c
+++ b/hw/virtio/virtio-mmio.c
@@ -394,6 +394,66 @@ static void virtio_mmio_reset(DeviceState *d)
proxy->guest_page_shift = 0;
}
+static int virtio_mmio_set_guest_notifier(DeviceState *d, int n, bool
assign,
+ bool with_irqfd)
+{
+ VirtIOMMIOProxy *proxy = VIRTIO_MMIO(d);
+ VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus);
+ VirtioDeviceClass *vdc = VIRTIO_DEVICE_GET_CLASS(vdev);
+ VirtQueue *vq = virtio_get_queue(vdev, n);
+ EventNotifier *notifier = virtio_queue_get_guest_notifier(vq);
+
+ if (assign) {
+ int r = event_notifier_init(notifier, 0);
+ if (r < 0) {
+ return r;
+ }
+ virtio_queue_set_guest_notifier_fd_handler(vq, true, with_irqfd);
+ } else {
+ virtio_queue_set_guest_notifier_fd_handler(vq, false, with_irqfd);
+ event_notifier_cleanup(notifier);
+ }
+
+ if (vdc->guest_notifier_mask) {
+ vdc->guest_notifier_mask(vdev, n, !assign);
+ }
+
+ return 0;
+}
+
+static int virtio_mmio_set_guest_notifiers(DeviceState *d, int nvqs,
+ bool assign)
+{
+ VirtIOMMIOProxy *proxy = VIRTIO_MMIO(d);
+ VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus);
+ /* TODO: need to check if kvm-arm supports irqfd */
+ bool with_irqfd = false;
+ int r, n;
+
+ nvqs = MIN(nvqs, VIRTIO_PCI_QUEUE_MAX);
+
+ for (n = 0; n < nvqs; n++) {
+ if (!virtio_queue_get_num(vdev, n)) {
+ break;
+ }
+
+ r = virtio_mmio_set_guest_notifier(d, n, assign, with_irqfd);
+ if (r < 0) {
+ goto assign_error;
+ }
+ }
+
+ return 0;
+
+assign_error:
+ /* We get here on assignment failure. Recover by undoing for VQs 0 ..
n. */
+ assert(assign);
+ while (--n >= 0) {
+ virtio_mmio_set_guest_notifier(d, n, !assign, false);
+ }
+ return r;
+}
+
static int virtio_mmio_set_host_notifier(DeviceState *opaque, int n,
bool assign)
{
@@ -471,6 +531,7 @@ static void virtio_mmio_bus_class_init(ObjectClass
*klass, void *data)
k->save_config = virtio_mmio_save_config;
k->load_config = virtio_mmio_load_config;
k->set_host_notifier = virtio_mmio_set_host_notifier;
+ k->set_guest_notifiers = virtio_mmio_set_guest_notifiers;
k->get_features = virtio_mmio_get_features;
k->device_plugged = virtio_mmio_device_plugged;
k->has_variable_vring_alignment = true;
--
1.9.5.msysgit.0
Kind regards,
Pavel Fedin
Expert Engineer
Samsung Electronics Research center Russia