void virtio_bus_start_ioeventfd(VirtioBusState *bus) { VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(bus); DeviceState *proxy = DEVICE(BUS(bus)->parent); VirtIODevice *vdev; int n, r; if (!k->ioeventfd_started || k->ioeventfd_started(proxy)) { return; } if (k->ioeventfd_disabled(proxy)) { return; } vdev = virtio_bus_get_device(bus); for (n = 0; n < VIRTIO_QUEUE_MAX; n++) { if (!virtio_queue_get_num(vdev, n)) { continue; } r = set_host_notifier_internal(proxy, bus, n, true, true); if (r < 0) { goto assign_error; } } k->ioeventfd_set_started(proxy, true, false); return; assign_error: while (--n >= 0) { if (!virtio_queue_get_num(vdev, n)) { continue; } r = set_host_notifier_internal(proxy, bus, n, false, false); assert(r >= 0); } k->ioeventfd_set_started(proxy, false, true); error_report("%s: failed. Fallback to userspace (slower).", __func__); }