int vhost_dev_enable_notifiers(struct vhost_dev *hdev, VirtIODevice *vdev)

{

    BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(vdev)));

    VirtioBusState *vbus = VIRTIO_BUS(qbus);

    VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(vbus);

    int i, r;

    if (!k->set_host_notifier) {

        fprintf(stderr, "binding does not support host notifiers\n");

        r = -ENOSYS;

        goto fail;

    }



    for (i = 0; i < hdev->nvqs; ++i) {

        r = k->set_host_notifier(qbus->parent, hdev->vq_index + i, true);

        if (r < 0) {

            fprintf(stderr, "vhost VQ %d notifier binding failed: %d\n", i, -r);

            goto fail_vq;

        }

    }



    return 0;

fail_vq:

    while (--i >= 0) {

        r = k->set_host_notifier(qbus->parent, hdev->vq_index + i, false);

        if (r < 0) {

            fprintf(stderr, "vhost VQ %d notifier cleanup error: %d\n", i, -r);

            fflush(stderr);

        }

        assert (r >= 0);

    }

fail:

    return r;

}

int vhost_dev_enable_notifiers(struct vhost_dev *hdev, VirtIODevice *vdev)

{

    BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(vdev)));

    VirtioBusState *vbus = VIRTIO_BUS(qbus);

    VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(vbus);

    int i, r;

    if (!k->set_host_notifier) {

        fprintf(stderr, "binding does not support host notifiers\n");

        r = -ENOSYS;

        goto fail;

    }



    for (i = 0; i < hdev->nvqs; ++i) {

        r = k->set_host_notifier(qbus->parent, hdev->vq_index + i, true);

        if (r < 0) {

            fprintf(stderr, "vhost VQ %d notifier binding failed: %d\n", i, -r);

            goto fail_vq;

        }

    }



    return 0;

fail_vq:

    while (--i >= 0) {

        r = k->set_host_notifier(qbus->parent, hdev->vq_index + i, false);

        if (r < 0) {

            fprintf(stderr, "vhost VQ %d notifier cleanup error: %d\n", i, -r);

            fflush(stderr);

        }

        assert (r >= 0);

    }

fail:

    return r;

}

    int i, r;         r = k->set_host_notifier(qbus->parent, hdev->vq_index + i, false);         if (r < 0) {         assert (r >= 0);
int FUNC_0(struct vhost_dev *VAR_0, VirtIODevice *VAR_1)

{

    BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(VAR_1)));

    VirtioBusState *vbus = VIRTIO_BUS(qbus);

    VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(vbus);

    int VAR_2, VAR_3;

    if (!k->set_host_notifier) {

        fprintf(stderr, "binding does not support host notifiers\n");

        VAR_3 = -ENOSYS;

        goto fail;

    }



    for (VAR_2 = 0; VAR_2 < VAR_0->nvqs; ++VAR_2) {

        VAR_3 = k->set_host_notifier(qbus->parent, VAR_0->vq_index + VAR_2, true);

        if (VAR_3 < 0) {

            fprintf(stderr, "vhost VQ %d notifier binding failed: %d\n", VAR_2, -VAR_3);

            goto fail_vq;

        }

    }



    return 0;

fail_vq:

    while (--VAR_2 >= 0) {

        VAR_3 = k->set_host_notifier(qbus->parent, VAR_0->vq_index + VAR_2, false);

        if (VAR_3 < 0) {

            fprintf(stderr, "vhost VQ %d notifier cleanup error: %d\n", VAR_2, -VAR_3);

            fflush(stderr);

        }

        assert (VAR_3 >= 0);

    }

fail:

    return VAR_3;

}

int FUNC_0(struct vhost_dev *VAR_0, VirtIODevice *VAR_1)
{ BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(VAR_1))); VirtioBusState *vbus = VIRTIO_BUS(qbus); VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(vbus); int VAR_2, VAR_3; if (!k->set_host_notifier) { fprintf(stderr, "binding does not support host notifiers\n"); VAR_3 = -ENOSYS; goto fail; } for (VAR_2 = 0; VAR_2 < VAR_0->nvqs; ++VAR_2) { VAR_3 = k->set_host_notifier(qbus->parent, VAR_0->vq_index + VAR_2, true); if (VAR_3 < 0) { fprintf(stderr, "vhost VQ %d notifier binding failed: %d\n", VAR_2, -VAR_3); goto fail_vq; } } return 0; fail_vq:
while (--VAR_2 >= 0) { VAR_3 = k->set_host_notifier(qbus->parent, VAR_0->vq_index + VAR_2, false); if (VAR_3 < 0) { fprintf(stderr, "vhost VQ %d notifier cleanup error: %d\n", VAR_2, -VAR_3); fflush(stderr); } assert (VAR_3 >= 0); } fail:
return VAR_3; }