static void chr_read(void *opaque, const void *buf, size_t size)

{

    VirtIORNG *vrng = opaque;

    size_t len;

    int offset;



    if (!is_guest_ready(vrng)) {

        return;

    }



    offset = 0;

    while (offset < size) {

        if (!pop_an_elem(vrng)) {

            break;

        }

        len = iov_from_buf(vrng->elem.in_sg, vrng->elem.in_num,

                           0, buf + offset, size - offset);

        offset += len;



        virtqueue_push(vrng->vq, &vrng->elem, len);

        vrng->popped = false;

    }

    virtio_notify(&vrng->vdev, vrng->vq);



    /*

     * Lastly, if we had multiple elems queued by the guest, and we

     * didn't have enough data to fill them all, indicate we want more

     * data.

     */

    len = pop_an_elem(vrng);

    if (len) {

        rng_backend_request_entropy(vrng->rng, size, chr_read, vrng);

    }

}

static void chr_read(void *opaque, const void *buf, size_t size)

{

    VirtIORNG *vrng = opaque;

    size_t len;

    int offset;



    if (!is_guest_ready(vrng)) {

        return;

    }



    offset = 0;

    while (offset < size) {

        if (!pop_an_elem(vrng)) {

            break;

        }

        len = iov_from_buf(vrng->elem.in_sg, vrng->elem.in_num,

                           0, buf + offset, size - offset);

        offset += len;



        virtqueue_push(vrng->vq, &vrng->elem, len);

        vrng->popped = false;

    }

    virtio_notify(&vrng->vdev, vrng->vq);



    









    len = pop_an_elem(vrng);

    if (len) {

        rng_backend_request_entropy(vrng->rng, size, chr_read, vrng);

    }

}

static void FUNC_0(void *VAR_0, const void *VAR_1, size_t VAR_2)

{

    VirtIORNG *vrng = VAR_0;

    size_t len;

    int VAR_3;



    if (!is_guest_ready(vrng)) {

        return;

    }



    VAR_3 = 0;

    while (VAR_3 < VAR_2) {

        if (!pop_an_elem(vrng)) {

            break;

        }

        len = iov_from_buf(vrng->elem.in_sg, vrng->elem.in_num,

                           0, VAR_1 + VAR_3, VAR_2 - VAR_3);

        VAR_3 += len;



        virtqueue_push(vrng->vq, &vrng->elem, len);

        vrng->popped = false;

    }

    virtio_notify(&vrng->vdev, vrng->vq);



    









    len = pop_an_elem(vrng);

    if (len) {

        rng_backend_request_entropy(vrng->rng, VAR_2, FUNC_0, vrng);

    }

}

static void FUNC_0(void *VAR_0, const void *VAR_1, size_t VAR_2)
{ VirtIORNG *vrng = VAR_0; size_t len; int VAR_3; if (!is_guest_ready(vrng)) { return; } VAR_3 = 0; while (VAR_3 < VAR_2) { if (!pop_an_elem(vrng)) { break; } len = iov_from_buf(vrng->elem.in_sg, vrng->elem.in_num,
0, VAR_1 + VAR_3, VAR_2 - VAR_3); VAR_3 += len; virtqueue_push(vrng->vq, &vrng->elem, len); vrng->popped = false; } virtio_notify(&vrng->vdev, vrng->vq); len = pop_an_elem(vrng); if (len) { rng_backend_request_entropy(vrng->rng, VAR_2, FUNC_0, vrng); } }