static int qemu_rdma_get_buffer(void *opaque, uint8_t *buf,

                                int64_t pos, int size)

{

    QEMUFileRDMA *r = opaque;

    RDMAContext *rdma = r->rdma;

    RDMAControlHeader head;

    int ret = 0;



    CHECK_ERROR_STATE();



    /*

     * First, we hold on to the last SEND message we

     * were given and dish out the bytes until we run

     * out of bytes.

     */

    r->len = qemu_rdma_fill(r->rdma, buf, size, 0);

    if (r->len) {

        return r->len;

    }



    /*

     * Once we run out, we block and wait for another

     * SEND message to arrive.

     */

    ret = qemu_rdma_exchange_recv(rdma, &head, RDMA_CONTROL_QEMU_FILE);



    if (ret < 0) {

        rdma->error_state = ret;

        return ret;

    }



    /*

     * SEND was received with new bytes, now try again.

     */

    return qemu_rdma_fill(r->rdma, buf, size, 0);

}

static int qemu_rdma_get_buffer(void *opaque, uint8_t *buf,

                                int64_t pos, int size)

{

    QEMUFileRDMA *r = opaque;

    RDMAContext *rdma = r->rdma;

    RDMAControlHeader head;

    int ret = 0;



    CHECK_ERROR_STATE();



    









    r->len = qemu_rdma_fill(r->rdma, buf, size, 0);

    if (r->len) {

        return r->len;

    }



    







    ret = qemu_rdma_exchange_recv(rdma, &head, RDMA_CONTROL_QEMU_FILE);



    if (ret < 0) {

        rdma->error_state = ret;

        return ret;

    }



    





    return qemu_rdma_fill(r->rdma, buf, size, 0);

}

static int FUNC_0(void *VAR_0, uint8_t *VAR_1,

                                int64_t VAR_2, int VAR_3)

{

    QEMUFileRDMA *r = VAR_0;

    RDMAContext *rdma = r->rdma;

    RDMAControlHeader head;

    int VAR_4 = 0;



    CHECK_ERROR_STATE();



    









    r->len = qemu_rdma_fill(r->rdma, VAR_1, VAR_3, 0);

    if (r->len) {

        return r->len;

    }



    







    VAR_4 = qemu_rdma_exchange_recv(rdma, &head, RDMA_CONTROL_QEMU_FILE);



    if (VAR_4 < 0) {

        rdma->error_state = VAR_4;

        return VAR_4;

    }



    





    return qemu_rdma_fill(r->rdma, VAR_1, VAR_3, 0);

}

static int FUNC_0(void *VAR_0, uint8_t *VAR_1,
int64_t VAR_2, int VAR_3)
{ QEMUFileRDMA *r = VAR_0; RDMAContext *rdma = r->rdma; RDMAControlHeader head; int VAR_4 = 0; CHECK_ERROR_STATE(); r->len = qemu_rdma_fill(r->rdma, VAR_1, VAR_3, 0); if (r->len) { return r->len; } VAR_4 = qemu_rdma_exchange_recv(rdma, &head, RDMA_CONTROL_QEMU_FILE); if (VAR_4 < 0) { rdma->error_state = VAR_4; return VAR_4; } return qemu_rdma_fill(r->rdma, VAR_1, VAR_3, 0); }