[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 12/12] virtio: inline set_host_notifier_internal
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PATCH 12/12] virtio: inline set_host_notifier_internal |
Date: |
Wed, 21 Sep 2016 15:18:59 +0200 |
This is only called from virtio_bus_set_host_notifier.
Signed-off-by: Paolo Bonzini <address@hidden>
---
hw/virtio/virtio-bus.c | 60 +++++++++++++++++++++-----------------------------
1 file changed, 25 insertions(+), 35 deletions(-)
diff --git a/hw/virtio/virtio-bus.c b/hw/virtio/virtio-bus.c
index b8f0527..1f3526d 100644
--- a/hw/virtio/virtio-bus.c
+++ b/hw/virtio/virtio-bus.c
@@ -146,40 +146,6 @@ void virtio_bus_set_vdev_config(VirtioBusState *bus,
uint8_t *config)
}
}
-static int set_host_notifier_internal(DeviceState *proxy, VirtioBusState *bus,
- int n, bool assign)
-{
- VirtIODevice *vdev = virtio_bus_get_device(bus);
- VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(bus);
- VirtQueue *vq = virtio_get_queue(vdev, n);
- EventNotifier *notifier = virtio_queue_get_host_notifier(vq);
- int r = 0;
-
- if (assign) {
- r = event_notifier_init(notifier, 1);
- if (r < 0) {
- error_report("%s: unable to init event notifier: %d", __func__, r);
- return r;
- }
- r = k->ioeventfd_assign(proxy, notifier, n, true);
- if (r < 0) {
- error_report("%s: unable to assign ioeventfd: %d", __func__, r);
- goto cleanup_event_notifier;
- }
- return 0;
- } else {
- k->ioeventfd_assign(proxy, notifier, n, false);
- }
-
-cleanup_event_notifier:
- /* Test and clear notifier before after disabling event,
- * in case poll callback didn't have time to run.
- */
- virtio_queue_host_notifier_read(notifier);
- event_notifier_cleanup(notifier);
- return r;
-}
-
int virtio_bus_start_ioeventfd(VirtioBusState *bus)
{
VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(bus);
@@ -229,20 +195,44 @@ bool virtio_bus_ioeventfd_enabled(VirtioBusState *bus)
*/
int virtio_bus_set_host_notifier(VirtioBusState *bus, int n, bool assign)
{
+ VirtIODevice *vdev = virtio_bus_get_device(bus);
VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(bus);
DeviceState *proxy = DEVICE(BUS(bus)->parent);
+ VirtQueue *vq = virtio_get_queue(vdev, n);
+ EventNotifier *notifier = virtio_queue_get_host_notifier(vq);
+ int r = 0;
if (!k->ioeventfd_assign) {
return -ENOSYS;
}
+
if (assign) {
assert(!bus->ioeventfd_started);
+ r = event_notifier_init(notifier, 1);
+ if (r < 0) {
+ error_report("%s: unable to init event notifier: %d", __func__, r);
+ return r;
+ }
+ r = k->ioeventfd_assign(proxy, notifier, n, true);
+ if (r < 0) {
+ error_report("%s: unable to assign ioeventfd: %d", __func__, r);
+ goto cleanup_event_notifier;
+ }
+ return 0;
} else {
if (!bus->ioeventfd_started) {
return 0;
}
+ k->ioeventfd_assign(proxy, notifier, n, false);
}
- return set_host_notifier_internal(proxy, bus, n, assign);
+
+cleanup_event_notifier:
+ /* Test and clear notifier before after disabling event,
+ * in case poll callback didn't have time to run.
+ */
+ virtio_queue_host_notifier_read(notifier);
+ event_notifier_cleanup(notifier);
+ return r;
}
static char *virtio_bus_get_dev_path(DeviceState *dev)
--
2.7.4
- Re: [Qemu-devel] [PATCH 03/12] virtio: add start_ioeventfd and stop_ioeventfd to VirtioDeviceClass, (continued)
- [Qemu-devel] [PATCH 07/12] Revert "virtio: Introduce virtio_add_queue_aio", Paolo Bonzini, 2016/09/21
- [Qemu-devel] [PATCH 06/12] virtio-scsi: always use dataplane path if ioeventfd is active, Paolo Bonzini, 2016/09/21
- [Qemu-devel] [PATCH 11/12] virtio: inline virtio_queue_set_host_notifier_fd_handler, Paolo Bonzini, 2016/09/21
- [Qemu-devel] [PATCH 10/12] virtio: do not export set_host_notifier_internal, Paolo Bonzini, 2016/09/21
- [Qemu-devel] [PATCH 09/12] virtio: remove ioeventfd_disabled altogether, Paolo Bonzini, 2016/09/21
- [Qemu-devel] [PATCH 08/12] virtio: remove set_handler argument from set_host_notifier_internal, Paolo Bonzini, 2016/09/21
- [Qemu-devel] [PATCH 12/12] virtio: inline set_host_notifier_internal,
Paolo Bonzini <=
- Re: [Qemu-devel] [PATCH 00/12] virtio: cleanup ioeventfd start/stop, Christian Borntraeger, 2016/09/21
Re: [Qemu-devel] [PATCH 00/12] virtio: cleanup ioeventfd start/stop, Michael S. Tsirkin, 2016/09/21
Re: [Qemu-devel] [PATCH 00/12] virtio: cleanup ioeventfd start/stop, Stefan Hajnoczi, 2016/09/30