static int qemu_rdma_put_buffer(void *opaque, const uint8_t *buf,

                                int64_t pos, int size)

{

    QEMUFileRDMA *r = opaque;

    QEMUFile *f = r->file;

    RDMAContext *rdma = r->rdma;

    size_t remaining = size;

    uint8_t * data = (void *) buf;

    int ret;



    CHECK_ERROR_STATE();



    /*

     * Push out any writes that

     * we're queued up for VM's ram.

     */

    ret = qemu_rdma_write_flush(f, rdma);

    if (ret < 0) {

        rdma->error_state = ret;

        return ret;

    }



    while (remaining) {

        RDMAControlHeader head;



        r->len = MIN(remaining, RDMA_SEND_INCREMENT);

        remaining -= r->len;



        head.len = r->len;

        head.type = RDMA_CONTROL_QEMU_FILE;



        ret = qemu_rdma_exchange_send(rdma, &head, data, NULL, NULL, NULL);



        if (ret < 0) {

            rdma->error_state = ret;

            return ret;

        }



        data += r->len;

    }



    return size;

}

static int qemu_rdma_put_buffer(void *opaque, const uint8_t *buf,

                                int64_t pos, int size)

{

    QEMUFileRDMA *r = opaque;

    QEMUFile *f = r->file;

    RDMAContext *rdma = r->rdma;

    size_t remaining = size;

    uint8_t * data = (void *) buf;

    int ret;



    CHECK_ERROR_STATE();



    







    ret = qemu_rdma_write_flush(f, rdma);

    if (ret < 0) {

        rdma->error_state = ret;

        return ret;

    }



    while (remaining) {

        RDMAControlHeader head;



        r->len = MIN(remaining, RDMA_SEND_INCREMENT);

        remaining -= r->len;



        head.len = r->len;

        head.type = RDMA_CONTROL_QEMU_FILE;



        ret = qemu_rdma_exchange_send(rdma, &head, data, NULL, NULL, NULL);



        if (ret < 0) {

            rdma->error_state = ret;

            return ret;

        }



        data += r->len;

    }



    return size;

}

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

                                int64_t VAR_2, int VAR_3)

{

    QEMUFileRDMA *r = VAR_0;

    QEMUFile *f = r->file;

    RDMAContext *rdma = r->rdma;

    size_t remaining = VAR_3;

    uint8_t * data = (void *) VAR_1;

    int VAR_4;



    CHECK_ERROR_STATE();



    







    VAR_4 = qemu_rdma_write_flush(f, rdma);

    if (VAR_4 < 0) {

        rdma->error_state = VAR_4;

        return VAR_4;

    }



    while (remaining) {

        RDMAControlHeader head;



        r->len = MIN(remaining, RDMA_SEND_INCREMENT);

        remaining -= r->len;



        head.len = r->len;

        head.type = RDMA_CONTROL_QEMU_FILE;



        VAR_4 = qemu_rdma_exchange_send(rdma, &head, data, NULL, NULL, NULL);



        if (VAR_4 < 0) {

            rdma->error_state = VAR_4;

            return VAR_4;

        }



        data += r->len;

    }



    return VAR_3;

}

static int FUNC_0(void *VAR_0, const uint8_t *VAR_1,
int64_t VAR_2, int VAR_3)
{ QEMUFileRDMA *r = VAR_0; QEMUFile *f = r->file; RDMAContext *rdma = r->rdma; size_t remaining = VAR_3; uint8_t * data = (void *) VAR_1; int VAR_4; CHECK_ERROR_STATE(); VAR_4 = qemu_rdma_write_flush(f, rdma); if (VAR_4 < 0) { rdma->error_state = VAR_4; return VAR_4; } while (remaining) { RDMAControlHeader head; r->len = MIN(remaining, RDMA_SEND_INCREMENT); remaining -= r->len; head.len = r->len; head.type = RDMA_CONTROL_QEMU_FILE; VAR_4 = qemu_rdma_exchange_send(rdma, &head, data, NULL, NULL, NULL); if (VAR_4 < 0) { rdma->error_state = VAR_4; return VAR_4; } data += r->len; } return VAR_3; }