mirror of https://github.com/xemu-project/xemu.git
virtio: inline set_host_notifier_internal
This is only called from virtio_bus_set_host_notifier. Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
This commit is contained in:
parent
fa283a4a8b
commit
2bd3c31a60
|
@ -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)
|
int virtio_bus_start_ioeventfd(VirtioBusState *bus)
|
||||||
{
|
{
|
||||||
VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(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)
|
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);
|
VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(bus);
|
||||||
DeviceState *proxy = DEVICE(BUS(bus)->parent);
|
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) {
|
if (!k->ioeventfd_assign) {
|
||||||
return -ENOSYS;
|
return -ENOSYS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (assign) {
|
if (assign) {
|
||||||
assert(!bus->ioeventfd_started);
|
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 {
|
} else {
|
||||||
if (!bus->ioeventfd_started) {
|
if (!bus->ioeventfd_started) {
|
||||||
return 0;
|
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)
|
static char *virtio_bus_get_dev_path(DeviceState *dev)
|
||||||
|
|
Loading…
Reference in New Issue