static void vhost_virtqueue_stop(struct vhost_dev *dev,

                                    struct VirtIODevice *vdev,

                                    struct vhost_virtqueue *vq,

                                    unsigned idx)

{

    int vhost_vq_index = dev->vhost_ops->vhost_get_vq_index(dev, idx);

    struct vhost_vring_state state = {

        .index = vhost_vq_index,

    };

    int r;



    r = dev->vhost_ops->vhost_get_vring_base(dev, &state);

    if (r < 0) {

        VHOST_OPS_DEBUG("vhost VQ %d ring restore failed: %d", idx, r);





    } else {

        virtio_queue_set_last_avail_idx(vdev, idx, state.num);

    }

    virtio_queue_invalidate_signalled_used(vdev, idx);

    virtio_queue_update_used_idx(vdev, idx);



    /* In the cross-endian case, we need to reset the vring endianness to

     * native as legacy devices expect so by default.


    if (vhost_needs_vring_endian(vdev)) {

        vhost_virtqueue_set_vring_endian_legacy(dev,

                                                !virtio_is_big_endian(vdev),

                                                vhost_vq_index);

    }



    vhost_memory_unmap(dev, vq->used, virtio_queue_get_used_size(vdev, idx),

                       1, virtio_queue_get_used_size(vdev, idx));

    vhost_memory_unmap(dev, vq->avail, virtio_queue_get_avail_size(vdev, idx),

                       0, virtio_queue_get_avail_size(vdev, idx));

    vhost_memory_unmap(dev, vq->desc, virtio_queue_get_desc_size(vdev, idx),

                       0, virtio_queue_get_desc_size(vdev, idx));

}
static void vhost_virtqueue_stop(struct vhost_dev *dev,

                                    struct VirtIODevice *vdev,

                                    struct vhost_virtqueue *vq,

                                    unsigned idx)

{

    int vhost_vq_index = dev->vhost_ops->vhost_get_vq_index(dev, idx);

    struct vhost_vring_state state = {

        .index = vhost_vq_index,

    };

    int r;



    r = dev->vhost_ops->vhost_get_vring_base(dev, &state);

    if (r < 0) {

        VHOST_OPS_DEBUG("vhost VQ %d ring restore failed: %d", idx, r);





    } else {

        virtio_queue_set_last_avail_idx(vdev, idx, state.num);

    }

    virtio_queue_invalidate_signalled_used(vdev, idx);

    virtio_queue_update_used_idx(vdev, idx);



    /* In the cross-endian case, we need to reset the vring endianness to

     * native as legacy devices expect so by default.


    if (vhost_needs_vring_endian(vdev)) {

        vhost_virtqueue_set_vring_endian_legacy(dev,

                                                !virtio_is_big_endian(vdev),

                                                vhost_vq_index);

    }



    vhost_memory_unmap(dev, vq->used, virtio_queue_get_used_size(vdev, idx),

                       1, virtio_queue_get_used_size(vdev, idx));

    vhost_memory_unmap(dev, vq->avail, virtio_queue_get_avail_size(vdev, idx),

                       0, virtio_queue_get_avail_size(vdev, idx));

    vhost_memory_unmap(dev, vq->desc, virtio_queue_get_desc_size(vdev, idx),

                       0, virtio_queue_get_desc_size(vdev, idx));

}
static void FUNC_0(struct vhost_dev *VAR_0,

                                    struct VirtIODevice *VAR_1,

                                    struct vhost_virtqueue *VAR_2,

                                    unsigned VAR_3)

{

    int VAR_4 = VAR_0->vhost_ops->vhost_get_vq_index(VAR_0, VAR_3);

    struct vhost_vring_state VAR_5 = {

        .index = VAR_4,

    };

    int VAR_6;



    VAR_6 = VAR_0->vhost_ops->vhost_get_vring_base(VAR_0, &VAR_5);

    if (VAR_6 < 0) {

        VHOST_OPS_DEBUG("vhost VQ %d ring restore failed: %d", VAR_3, VAR_6);





    } else {

        virtio_queue_set_last_avail_idx(VAR_1, VAR_3, VAR_5.num);

    }

    virtio_queue_invalidate_signalled_used(VAR_1, VAR_3);

    virtio_queue_update_used_idx(VAR_1, VAR_3);



    /* In the cross-endian case, we need to reset the vring endianness to

     * native as legacy devices expect so by default.


    if (vhost_needs_vring_endian(VAR_1)) {

        vhost_virtqueue_set_vring_endian_legacy(VAR_0,

                                                !virtio_is_big_endian(VAR_1),

                                                VAR_4);

    }



    vhost_memory_unmap(VAR_0, VAR_2->used, virtio_queue_get_used_size(VAR_1, VAR_3),

                       1, virtio_queue_get_used_size(VAR_1, VAR_3));

    vhost_memory_unmap(VAR_0, VAR_2->avail, virtio_queue_get_avail_size(VAR_1, VAR_3),

                       0, virtio_queue_get_avail_size(VAR_1, VAR_3));

    vhost_memory_unmap(VAR_0, VAR_2->desc, virtio_queue_get_desc_size(VAR_1, VAR_3),

                       0, virtio_queue_get_desc_size(VAR_1, VAR_3));

}
static void FUNC_0(struct vhost_dev *VAR_0,
struct VirtIODevice *VAR_1,
struct vhost_virtqueue *VAR_2,
unsigned VAR_3)
{ int VAR_4 = VAR_0->vhost_ops->vhost_get_vq_index(VAR_0, VAR_3); struct vhost_vring_state VAR_5 = { .index = VAR_4,
}; int VAR_6; VAR_6 = VAR_0->vhost_ops->vhost_get_vring_base(VAR_0, &VAR_5); if (VAR_6 < 0) { VHOST_OPS_DEBUG("vhost VQ %d ring restore failed: %d", VAR_3, VAR_6); } else { virtio_queue_set_last_avail_idx(VAR_1, VAR_3, VAR_5.num); } virtio_queue_invalidate_signalled_used(VAR_1, VAR_3); virtio_queue_update_used_idx(VAR_1, VAR_3); /* In the cross-endian case, we need to reset the vring endianness to
* native as legacy devices expect so by default.
if (vhost_needs_vring_endian(VAR_1)) { vhost_virtqueue_set_vring_endian_legacy(VAR_0,
!virtio_is_big_endian(VAR_1),
VAR_4); } vhost_memory_unmap(VAR_0, VAR_2->used, virtio_queue_get_used_size(VAR_1, VAR_3),
1, virtio_queue_get_used_size(VAR_1, VAR_3)); vhost_memory_unmap(VAR_0, VAR_2->avail, virtio_queue_get_avail_size(VAR_1, VAR_3),
0, virtio_queue_get_avail_size(VAR_1, VAR_3)); vhost_memory_unmap(VAR_0, VAR_2->desc, virtio_queue_get_desc_size(VAR_1, VAR_3),
0, virtio_queue_get_desc_size(VAR_1, VAR_3)); }