bool virtio_bus_ioeventfd_enabled(VirtioBusState *bus) { VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(bus); DeviceState *proxy = DEVICE(BUS(bus)->parent); return k->ioeventfd_assign && k->ioeventfd_enabled(proxy); }
int virtio_bus_start_ioeventfd(VirtioBusState *bus) { VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(bus); DeviceState *proxy = DEVICE(BUS(bus)->parent); VirtIODevice *vdev = virtio_bus_get_device(bus); VirtioDeviceClass *vdc = VIRTIO_DEVICE_GET_CLASS(vdev); int r; if (!k->ioeventfd_assign || !k->ioeventfd_enabled(proxy)) { return -ENOSYS; } if (bus->ioeventfd_started) { return 0; } /* Only set our notifier if we have ownership. */ if (!bus->ioeventfd_grabbed) { r = vdc->start_ioeventfd(vdev); if (r < 0) { error_report("%s: failed. Fallback to userspace (slower).", __func__); return r; } } bus->ioeventfd_started = true; return 0; }