From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Cc: borntraeger@de.ibm.com, cornelia.huck@de.ibm.com, mst@redhat.com,
famz@redhat.com
Subject: [Qemu-devel] [PATCH 04/12] virtio: introduce virtio_device_ioeventfd_enabled
Date: Wed, 21 Sep 2016 15:18:51 +0200 [thread overview]
Message-ID: <1474463939-12223-5-git-send-email-pbonzini@redhat.com> (raw)
In-Reply-To: <1474463939-12223-1-git-send-email-pbonzini@redhat.com>
This will be used to forbid iothread configuration when the
proxy does not allow using ioeventfd. To simplify the implementation,
change the direction of the ioeventfd_disabled callback too.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
hw/s390x/virtio-ccw.c | 6 +++---
hw/virtio/virtio-bus.c | 10 +++++++++-
hw/virtio/virtio-mmio.c | 6 +++---
hw/virtio/virtio-pci.c | 6 +++---
hw/virtio/virtio.c | 8 ++++++++
include/hw/virtio/virtio-bus.h | 8 +++++---
include/hw/virtio/virtio.h | 1 +
7 files changed, 32 insertions(+), 13 deletions(-)
diff --git a/hw/s390x/virtio-ccw.c b/hw/s390x/virtio-ccw.c
index 3e450eb..86c1340 100644
--- a/hw/s390x/virtio-ccw.c
+++ b/hw/s390x/virtio-ccw.c
@@ -59,11 +59,11 @@ static void virtio_ccw_stop_ioeventfd(VirtioCcwDevice *dev)
virtio_bus_stop_ioeventfd(&dev->bus);
}
-static bool virtio_ccw_ioeventfd_disabled(DeviceState *d)
+static bool virtio_ccw_ioeventfd_enabled(DeviceState *d)
{
VirtioCcwDevice *dev = VIRTIO_CCW_DEVICE(d);
- return !(dev->flags & VIRTIO_CCW_FLAG_USE_IOEVENTFD);
+ return (dev->flags & VIRTIO_CCW_FLAG_USE_IOEVENTFD) != 0;
}
static int virtio_ccw_ioeventfd_assign(DeviceState *d, EventNotifier *notifier,
@@ -1569,7 +1569,7 @@ static void virtio_ccw_bus_class_init(ObjectClass *klass, void *data)
k->device_plugged = virtio_ccw_device_plugged;
k->post_plugged = virtio_ccw_post_plugged;
k->device_unplugged = virtio_ccw_device_unplugged;
- k->ioeventfd_disabled = virtio_ccw_ioeventfd_disabled;
+ k->ioeventfd_enabled = virtio_ccw_ioeventfd_enabled;
k->ioeventfd_assign = virtio_ccw_ioeventfd_assign;
}
diff --git a/hw/virtio/virtio-bus.c b/hw/virtio/virtio-bus.c
index 94e202d..f60efd7 100644
--- a/hw/virtio/virtio-bus.c
+++ b/hw/virtio/virtio-bus.c
@@ -191,7 +191,7 @@ int virtio_bus_start_ioeventfd(VirtioBusState *bus)
VirtioDeviceClass *vdc = VIRTIO_DEVICE_GET_CLASS(vdev);
int r;
- if (!k->ioeventfd_assign || k->ioeventfd_disabled(proxy)) {
+ if (!k->ioeventfd_assign || !k->ioeventfd_enabled(proxy)) {
return -ENOSYS;
}
if (bus->ioeventfd_started || bus->ioeventfd_disabled) {
@@ -218,6 +218,14 @@ void virtio_bus_stop_ioeventfd(VirtioBusState *bus)
bus->ioeventfd_started = false;
}
+bool virtio_bus_ioeventfd_enabled(VirtIODevice *vdev)
+{
+ VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(bus);
+ DeviceState *proxy = DEVICE(BUS(bus)->parent);
+
+ return k->ioeventfd_enabled(proxy);
+}
+
/*
* This function switches from/to the generic ioeventfd handler.
* assign==false means 'use generic ioeventfd handler'.
diff --git a/hw/virtio/virtio-mmio.c b/hw/virtio/virtio-mmio.c
index 04a9655..a30270f 100644
--- a/hw/virtio/virtio-mmio.c
+++ b/hw/virtio/virtio-mmio.c
@@ -92,9 +92,9 @@ typedef struct {
bool format_transport_address;
} VirtIOMMIOProxy;
-static bool virtio_mmio_ioeventfd_disabled(DeviceState *d)
+static bool virtio_mmio_ioeventfd_enabled(DeviceState *d)
{
- return !kvm_eventfds_enabled();
+ return kvm_eventfds_enabled();
}
static int virtio_mmio_ioeventfd_assign(DeviceState *d,
@@ -531,7 +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_guest_notifiers = virtio_mmio_set_guest_notifiers;
- k->ioeventfd_disabled = virtio_mmio_ioeventfd_disabled;
+ k->ioeventfd_enabled = virtio_mmio_ioeventfd_enabled;
k->ioeventfd_assign = virtio_mmio_ioeventfd_assign;
k->has_variable_vring_alignment = true;
bus_class->max_dev = 1;
diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
index a5d8c8d..158ffe5 100644
--- a/hw/virtio/virtio-pci.c
+++ b/hw/virtio/virtio-pci.c
@@ -262,11 +262,11 @@ static int virtio_pci_load_queue(DeviceState *d, int n, QEMUFile *f)
return 0;
}
-static bool virtio_pci_ioeventfd_disabled(DeviceState *d)
+static bool virtio_pci_ioeventfd_enabled(DeviceState *d)
{
VirtIOPCIProxy *proxy = to_virtio_pci_proxy(d);
- return !(proxy->flags & VIRTIO_PCI_FLAG_USE_IOEVENTFD);
+ return (proxy->flags & VIRTIO_PCI_FLAG_USE_IOEVENTFD) != 0;
}
#define QEMU_VIRTIO_PCI_QUEUE_MEM_MULT 0x1000
@@ -2424,7 +2424,7 @@ static void virtio_pci_bus_class_init(ObjectClass *klass, void *data)
k->device_plugged = virtio_pci_device_plugged;
k->device_unplugged = virtio_pci_device_unplugged;
k->query_nvectors = virtio_pci_query_nvectors;
- k->ioeventfd_disabled = virtio_pci_ioeventfd_disabled;
+ k->ioeventfd_enabled = virtio_pci_ioeventfd_enabled;
k->ioeventfd_assign = virtio_pci_ioeventfd_assign;
}
diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
index 2919113..84abd08 100644
--- a/hw/virtio/virtio.c
+++ b/hw/virtio/virtio.c
@@ -2021,6 +2021,14 @@ static void virtio_device_class_init(ObjectClass *klass, void *data)
vdc->stop_ioeventfd = virtio_device_stop_ioeventfd_impl;
}
+bool virtio_device_ioeventfd_enabled(VirtIODevice *vdev)
+{
+ BusState *qbus = qdev_get_parent_bus(DEVICE(vdev));
+ VirtioBusState *vbus = VIRTIO_BUS(qbus);
+
+ return virtio_bus_ioeventfd_enabled(vbus);
+}
+
static const TypeInfo virtio_device_info = {
.name = TYPE_VIRTIO_DEVICE,
.parent = TYPE_DEVICE,
diff --git a/include/hw/virtio/virtio-bus.h b/include/hw/virtio/virtio-bus.h
index 01b11c5..0abc890 100644
--- a/include/hw/virtio/virtio-bus.h
+++ b/include/hw/virtio/virtio-bus.h
@@ -71,10 +71,10 @@ typedef struct VirtioBusClass {
int (*query_nvectors)(DeviceState *d);
/*
* ioeventfd handling: if the transport implements ioeventfd_assign,
- * it must implement ioeventfd_disabled as well.
+ * it must implement ioeventfd_enabled as well.
*/
- /* Returns true if the ioeventfd has been disabled for the device. */
- bool (*ioeventfd_disabled)(DeviceState *d);
+ /* Returns true if the ioeventfd is enabled for the device. */
+ bool (*ioeventfd_enabled)(DeviceState *d);
/*
* Assigns/deassigns the ioeventfd backing for the transport on
* the device for queue number n. Returns an error value on
@@ -134,6 +134,8 @@ static inline VirtIODevice *virtio_bus_get_device(VirtioBusState *bus)
return (VirtIODevice *)qdev;
}
+/* Return whether the proxy allows ioeventfd. */
+bool virtio_bus_ioeventfd_enabled(VirtioBusState *bus);
/* Start the ioeventfd. */
int virtio_bus_start_ioeventfd(VirtioBusState *bus);
/* Stop the ioeventfd. */
diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h
index f283217..ec50f7a 100644
--- a/include/hw/virtio/virtio.h
+++ b/include/hw/virtio/virtio.h
@@ -274,6 +274,7 @@ void virtio_queue_set_guest_notifier_fd_handler(VirtQueue *vq, bool assign,
bool with_irqfd);
int virtio_device_start_ioeventfd(VirtIODevice *vdev);
void virtio_device_stop_ioeventfd(VirtIODevice *vdev);
+bool virtio_device_ioeventfd_enabled(VirtIODevice *vdev);
EventNotifier *virtio_queue_get_host_notifier(VirtQueue *vq);
void virtio_queue_set_host_notifier_fd_handler(VirtQueue *vq, bool assign,
bool set_handler);
--
2.7.4
next prev parent reply other threads:[~2016-09-21 13:20 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-21 13:18 [Qemu-devel] [PATCH 00/12] virtio: cleanup ioeventfd start/stop Paolo Bonzini
2016-09-21 13:18 ` [Qemu-devel] [PATCH 01/12] virtio: move ioeventfd_disabled flag to VirtioBusState Paolo Bonzini
2016-09-29 14:32 ` Stefan Hajnoczi
2016-09-21 13:18 ` [Qemu-devel] [PATCH 02/12] virtio: move ioeventfd_started " Paolo Bonzini
2016-09-29 14:36 ` Stefan Hajnoczi
2016-09-21 13:18 ` [Qemu-devel] [PATCH 03/12] virtio: add start_ioeventfd and stop_ioeventfd to VirtioDeviceClass Paolo Bonzini
2016-09-30 13:12 ` Stefan Hajnoczi
2016-09-21 13:18 ` Paolo Bonzini [this message]
2016-09-30 13:19 ` [Qemu-devel] [PATCH 04/12] virtio: introduce virtio_device_ioeventfd_enabled Stefan Hajnoczi
2016-09-21 13:18 ` [Qemu-devel] [PATCH 05/12] virtio-blk: always use dataplane path if ioeventfd is active Paolo Bonzini
2016-09-21 13:18 ` [Qemu-devel] [PATCH 06/12] virtio-scsi: " Paolo Bonzini
2016-09-21 13:18 ` [Qemu-devel] [PATCH 07/12] Revert "virtio: Introduce virtio_add_queue_aio" Paolo Bonzini
2016-09-30 13:28 ` Stefan Hajnoczi
2016-09-21 13:18 ` [Qemu-devel] [PATCH 08/12] virtio: remove set_handler argument from set_host_notifier_internal Paolo Bonzini
2016-09-30 13:31 ` Stefan Hajnoczi
2016-09-21 13:18 ` [Qemu-devel] [PATCH 09/12] virtio: remove ioeventfd_disabled altogether Paolo Bonzini
2016-09-21 13:18 ` [Qemu-devel] [PATCH 10/12] virtio: do not export set_host_notifier_internal Paolo Bonzini
2016-09-30 13:34 ` Stefan Hajnoczi
2016-09-21 13:18 ` [Qemu-devel] [PATCH 11/12] virtio: inline virtio_queue_set_host_notifier_fd_handler Paolo Bonzini
2016-09-21 13:18 ` [Qemu-devel] [PATCH 12/12] virtio: inline set_host_notifier_internal Paolo Bonzini
2016-09-30 13:37 ` Stefan Hajnoczi
2016-09-21 14:01 ` [Qemu-devel] [PATCH 00/12] virtio: cleanup ioeventfd start/stop Christian Borntraeger
2016-09-21 16:43 ` Paolo Bonzini
2016-09-27 14:45 ` Christian Borntraeger
2016-09-27 16:44 ` Paolo Bonzini
2016-09-28 6:58 ` Christian Borntraeger
2016-09-21 17:31 ` Michael S. Tsirkin
2016-09-30 13:38 ` Stefan Hajnoczi
2016-10-09 22:01 ` Michael S. Tsirkin
2016-10-10 8:31 ` 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=1474463939-12223-5-git-send-email-pbonzini@redhat.com \
--to=pbonzini@redhat.com \
--cc=borntraeger@de.ibm.com \
--cc=cornelia.huck@de.ibm.com \
--cc=famz@redhat.com \
--cc=mst@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).