static int qemu_rdma_exchange_recv(RDMAContext *rdma, RDMAControlHeader *head,

                                int expecting)

{

    RDMAControlHeader ready = {

                                .len = 0,

                                .type = RDMA_CONTROL_READY,

                                .repeat = 1,

                              };

    int ret;



    /*

     * Inform the source that we're ready to receive a message.

     */

    ret = qemu_rdma_post_send_control(rdma, NULL, &ready);



    if (ret < 0) {

        fprintf(stderr, "Failed to send control buffer!\n");

        return ret;

    }



    /*

     * Block and wait for the message.

     */

    ret = qemu_rdma_exchange_get_response(rdma, head,

                                          expecting, RDMA_WRID_READY);



    if (ret < 0) {

        return ret;

    }



    qemu_rdma_move_header(rdma, RDMA_WRID_READY, head);



    /*

     * Post a new RECV work request to replace the one we just consumed.

     */

    ret = qemu_rdma_post_recv_control(rdma, RDMA_WRID_READY);

    if (ret) {

        fprintf(stderr, "rdma migration: error posting second control recv!");

        return ret;

    }



    return 0;

}

static int qemu_rdma_exchange_recv(RDMAContext *rdma, RDMAControlHeader *head,

                                int expecting)

{

    RDMAControlHeader ready = {

                                .len = 0,

                                .type = RDMA_CONTROL_READY,

                                .repeat = 1,

                              };

    int ret;



    





    ret = qemu_rdma_post_send_control(rdma, NULL, &ready);



    if (ret < 0) {

        fprintf(stderr, "Failed to send control buffer!\n");

        return ret;

    }



    





    ret = qemu_rdma_exchange_get_response(rdma, head,

                                          expecting, RDMA_WRID_READY);



    if (ret < 0) {

        return ret;

    }



    qemu_rdma_move_header(rdma, RDMA_WRID_READY, head);



    





    ret = qemu_rdma_post_recv_control(rdma, RDMA_WRID_READY);

    if (ret) {

        fprintf(stderr, "rdma migration: error posting second control recv!");

        return ret;

    }



    return 0;

}

static int FUNC_0(RDMAContext *VAR_0, RDMAControlHeader *VAR_1,

                                int VAR_2)

{

    RDMAControlHeader ready = {

                                .len = 0,

                                .type = RDMA_CONTROL_READY,

                                .repeat = 1,

                              };

    int VAR_3;



    





    VAR_3 = qemu_rdma_post_send_control(VAR_0, NULL, &ready);



    if (VAR_3 < 0) {

        fprintf(stderr, "Failed to send control buffer!\n");

        return VAR_3;

    }



    





    VAR_3 = qemu_rdma_exchange_get_response(VAR_0, VAR_1,

                                          VAR_2, RDMA_WRID_READY);



    if (VAR_3 < 0) {

        return VAR_3;

    }



    qemu_rdma_move_header(VAR_0, RDMA_WRID_READY, VAR_1);



    





    VAR_3 = qemu_rdma_post_recv_control(VAR_0, RDMA_WRID_READY);

    if (VAR_3) {

        fprintf(stderr, "VAR_0 migration: error posting second control recv!");

        return VAR_3;

    }



    return 0;

}

static int FUNC_0(RDMAContext *VAR_0, RDMAControlHeader *VAR_1,
int VAR_2)
{ RDMAControlHeader ready = { .len = 0,
.type = RDMA_CONTROL_READY,
.repeat = 1,
}; int VAR_3; VAR_3 = qemu_rdma_post_send_control(VAR_0, NULL, &ready); if (VAR_3 < 0) { fprintf(stderr, "Failed to send control buffer!\n"); return VAR_3; } VAR_3 = qemu_rdma_exchange_get_response(VAR_0, VAR_1,
VAR_2, RDMA_WRID_READY); if (VAR_3 < 0) { return VAR_3; } qemu_rdma_move_header(VAR_0, RDMA_WRID_READY, VAR_1); VAR_3 = qemu_rdma_post_recv_control(VAR_0, RDMA_WRID_READY); if (VAR_3) { fprintf(stderr, "VAR_0 migration: error posting second control recv!"); return VAR_3; } return 0; }