static int vfio_set_trigger_eventfd(VFIOINTp *intp,

                                    eventfd_user_side_handler_t handler)

{

    VFIODevice *vbasedev = &intp->vdev->vbasedev;

    struct vfio_irq_set *irq_set;

    int argsz, ret;

    int32_t *pfd;



    argsz = sizeof(*irq_set) + sizeof(*pfd);

    irq_set = g_malloc0(argsz);

    irq_set->argsz = argsz;

    irq_set->flags = VFIO_IRQ_SET_DATA_EVENTFD | VFIO_IRQ_SET_ACTION_TRIGGER;

    irq_set->index = intp->pin;

    irq_set->start = 0;

    irq_set->count = 1;

    pfd = (int32_t *)&irq_set->data;

    *pfd = event_notifier_get_fd(&intp->interrupt);

    qemu_set_fd_handler(*pfd, (IOHandler *)handler, NULL, intp);

    ret = ioctl(vbasedev->fd, VFIO_DEVICE_SET_IRQS, irq_set);

    g_free(irq_set);

    if (ret < 0) {

        error_report("vfio: Failed to set trigger eventfd: %m");

        qemu_set_fd_handler(*pfd, NULL, NULL, NULL);

    }

    return ret;

}

static int vfio_set_trigger_eventfd(VFIOINTp *intp,

                                    eventfd_user_side_handler_t handler)

{

    VFIODevice *vbasedev = &intp->vdev->vbasedev;

    struct vfio_irq_set *irq_set;

    int argsz, ret;

    int32_t *pfd;



    argsz = sizeof(*irq_set) + sizeof(*pfd);

    irq_set = g_malloc0(argsz);

    irq_set->argsz = argsz;

    irq_set->flags = VFIO_IRQ_SET_DATA_EVENTFD | VFIO_IRQ_SET_ACTION_TRIGGER;

    irq_set->index = intp->pin;

    irq_set->start = 0;

    irq_set->count = 1;

    pfd = (int32_t *)&irq_set->data;

    *pfd = event_notifier_get_fd(&intp->interrupt);

    qemu_set_fd_handler(*pfd, (IOHandler *)handler, NULL, intp);

    ret = ioctl(vbasedev->fd, VFIO_DEVICE_SET_IRQS, irq_set);

    g_free(irq_set);

    if (ret < 0) {

        error_report("vfio: Failed to set trigger eventfd: %m");

        qemu_set_fd_handler(*pfd, NULL, NULL, NULL);

    }

    return ret;

}

static int FUNC_0(VFIOINTp *VAR_0,

                                    eventfd_user_side_handler_t VAR_1)

{

    VFIODevice *vbasedev = &VAR_0->vdev->vbasedev;

    struct vfio_irq_set *VAR_2;

    int VAR_3, VAR_4;

    int32_t *pfd;



    VAR_3 = sizeof(*VAR_2) + sizeof(*pfd);

    VAR_2 = g_malloc0(VAR_3);

    VAR_2->VAR_3 = VAR_3;

    VAR_2->flags = VFIO_IRQ_SET_DATA_EVENTFD | VFIO_IRQ_SET_ACTION_TRIGGER;

    VAR_2->index = VAR_0->pin;

    VAR_2->start = 0;

    VAR_2->count = 1;

    pfd = (int32_t *)&VAR_2->data;

    *pfd = event_notifier_get_fd(&VAR_0->interrupt);

    qemu_set_fd_handler(*pfd, (IOHandler *)VAR_1, NULL, VAR_0);

    VAR_4 = ioctl(vbasedev->fd, VFIO_DEVICE_SET_IRQS, VAR_2);

    g_free(VAR_2);

    if (VAR_4 < 0) {

        error_report("vfio: Failed to set trigger eventfd: %m");

        qemu_set_fd_handler(*pfd, NULL, NULL, NULL);

    }

    return VAR_4;

}

static int FUNC_0(VFIOINTp *VAR_0,
eventfd_user_side_handler_t VAR_1)
{ VFIODevice *vbasedev = &VAR_0->vdev->vbasedev; struct vfio_irq_set *VAR_2; int VAR_3, VAR_4; int32_t *pfd; VAR_3 = sizeof(*VAR_2) + sizeof(*pfd); VAR_2 = g_malloc0(VAR_3); VAR_2->VAR_3 = VAR_3; VAR_2->flags = VFIO_IRQ_SET_DATA_EVENTFD | VFIO_IRQ_SET_ACTION_TRIGGER; VAR_2->index = VAR_0->pin; VAR_2->start = 0; VAR_2->count = 1; pfd = (int32_t *)&VAR_2->data; *pfd = event_notifier_get_fd(&VAR_0->interrupt); qemu_set_fd_handler(*pfd, (IOHandler *)VAR_1, NULL, VAR_0); VAR_4 = ioctl(vbasedev->fd, VFIO_DEVICE_SET_IRQS, VAR_2); g_free(VAR_2); if (VAR_4 < 0) { error_report("vfio: Failed to set trigger eventfd: %m"); qemu_set_fd_handler(*pfd, NULL, NULL, NULL); } return VAR_4; }