[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 15/47] virtio: inline set_host_notifier_internal
From: |
Michael S. Tsirkin |
Subject: |
[Qemu-devel] [PULL 15/47] virtio: inline set_host_notifier_internal |
Date: |
Sun, 30 Oct 2016 23:24:02 +0200 |
From: Paolo Bonzini <address@hidden>
This is only called from virtio_bus_set_host_notifier.
Reviewed-by: Stefan Hajnoczi <address@hidden>
Reviewed-by: Cornelia Huck <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
Reviewed-by: Michael S. Tsirkin <address@hidden>
Signed-off-by: Michael S. Tsirkin <address@hidden>
---
hw/virtio/virtio-bus.c | 62 +++++++++++++++++++++-----------------------------
1 file changed, 26 insertions(+), 36 deletions(-)
diff --git a/hw/virtio/virtio-bus.c b/hw/virtio/virtio-bus.c
index 670746c..bf61f66 100644
--- a/hw/virtio/virtio-bus.c
+++ b/hw/virtio/virtio-bus.c
@@ -147,41 +147,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: %s (%d)",
- __func__, strerror(-r), 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 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);
@@ -234,20 +199,45 @@ 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: %s (%d)",
+ __func__, strerror(-r), 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 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)
--
MST
- [Qemu-devel] [PULL 05/47] virtio: move ioeventfd_started flag to VirtioBusState, (continued)
- [Qemu-devel] [PULL 05/47] virtio: move ioeventfd_started flag to VirtioBusState, Michael S. Tsirkin, 2016/10/30
- [Qemu-devel] [PULL 06/47] virtio: add start_ioeventfd and stop_ioeventfd to VirtioDeviceClass, Michael S. Tsirkin, 2016/10/30
- [Qemu-devel] [PULL 07/47] virtio: introduce virtio_device_ioeventfd_enabled, Michael S. Tsirkin, 2016/10/30
- [Qemu-devel] [PULL 09/47] virtio-scsi: always use dataplane path if ioeventfd is active, Michael S. Tsirkin, 2016/10/30
- [Qemu-devel] [PULL 08/47] virtio-blk: always use dataplane path if ioeventfd is active, Michael S. Tsirkin, 2016/10/30
- [Qemu-devel] [PULL 10/47] Revert "virtio: Introduce virtio_add_queue_aio", Michael S. Tsirkin, 2016/10/30
- [Qemu-devel] [PULL 11/47] virtio: remove set_handler argument from set_host_notifier_internal, Michael S. Tsirkin, 2016/10/30
- [Qemu-devel] [PULL 12/47] virtio: remove ioeventfd_disabled altogether, Michael S. Tsirkin, 2016/10/30
- [Qemu-devel] [PULL 13/47] virtio: use virtio_bus_set_host_notifier to start/stop ioeventfd, Michael S. Tsirkin, 2016/10/30
- [Qemu-devel] [PULL 14/47] virtio: inline virtio_queue_set_host_notifier_fd_handler, Michael S. Tsirkin, 2016/10/30
- [Qemu-devel] [PULL 15/47] virtio: inline set_host_notifier_internal,
Michael S. Tsirkin <=
- [Qemu-devel] [PULL 16/47] cryptodev: introduce cryptodev backend interface, Michael S. Tsirkin, 2016/10/30
- [Qemu-devel] [PULL 17/47] cryptodev: add symmetric algorithm operation stuff, Michael S. Tsirkin, 2016/10/30
- [Qemu-devel] [PULL 18/47] virtio-crypto: introduce virtio_crypto.h, Michael S. Tsirkin, 2016/10/30
- [Qemu-devel] [PULL 19/47] cryptodev: introduce a new cryptodev backend, Michael S. Tsirkin, 2016/10/30
- [Qemu-devel] [PULL 20/47] virtio-crypto: add virtio crypto device emulation, Michael S. Tsirkin, 2016/10/30
- [Qemu-devel] [PULL 21/47] virtio-crypto-pci: add virtio crypto pci support, Michael S. Tsirkin, 2016/10/30
- [Qemu-devel] [PULL 22/47] virtio-crypto: set capacity of algorithms supported, Michael S. Tsirkin, 2016/10/30
- [Qemu-devel] [PULL 23/47] virtio-crypto: add control queue handler, Michael S. Tsirkin, 2016/10/30
- [Qemu-devel] [PULL 24/47] virtio-crypto: add data queue processing handler, Michael S. Tsirkin, 2016/10/30
- [Qemu-devel] [PULL 25/47] cryptodev: introduce an unified wrapper for crypto operation, Michael S. Tsirkin, 2016/10/30