static int qemu_rdma_post_send_control(RDMAContext *rdma, uint8_t *buf,

                                       RDMAControlHeader *head)

{

    int ret = 0;

    RDMAWorkRequestData *wr = &rdma->wr_data[RDMA_WRID_CONTROL];

    struct ibv_send_wr *bad_wr;

    struct ibv_sge sge = {

                           .addr = (uint64_t)(wr->control),

                           .length = head->len + sizeof(RDMAControlHeader),

                           .lkey = wr->control_mr->lkey,

                         };

    struct ibv_send_wr send_wr = {

                                   .wr_id = RDMA_WRID_SEND_CONTROL,

                                   .opcode = IBV_WR_SEND,

                                   .send_flags = IBV_SEND_SIGNALED,

                                   .sg_list = &sge,

                                   .num_sge = 1,

                                };



    DDDPRINTF("CONTROL: sending %s..\n", control_desc[head->type]);



    /*

     * We don't actually need to do a memcpy() in here if we used

     * the "sge" properly, but since we're only sending control messages

     * (not RAM in a performance-critical path), then its OK for now.

     *

     * The copy makes the RDMAControlHeader simpler to manipulate

     * for the time being.

     */

    assert(head->len <= RDMA_CONTROL_MAX_BUFFER - sizeof(*head));

    memcpy(wr->control, head, sizeof(RDMAControlHeader));

    control_to_network((void *) wr->control);



    if (buf) {

        memcpy(wr->control + sizeof(RDMAControlHeader), buf, head->len);

    }





    if (ibv_post_send(rdma->qp, &send_wr, &bad_wr)) {

        return -1;

    }



    if (ret < 0) {

        fprintf(stderr, "Failed to use post IB SEND for control!\n");

        return ret;

    }



    ret = qemu_rdma_block_for_wrid(rdma, RDMA_WRID_SEND_CONTROL);

    if (ret < 0) {

        fprintf(stderr, "rdma migration: send polling control error!\n");

    }



    return ret;

}

static int qemu_rdma_post_send_control(RDMAContext *rdma, uint8_t *buf,

                                       RDMAControlHeader *head)

{

    int ret = 0;

    RDMAWorkRequestData *wr = &rdma->wr_data[RDMA_WRID_CONTROL];

    struct ibv_send_wr *bad_wr;

    struct ibv_sge sge = {

                           .addr = (uint64_t)(wr->control),

                           .length = head->len + sizeof(RDMAControlHeader),

                           .lkey = wr->control_mr->lkey,

                         };

    struct ibv_send_wr send_wr = {

                                   .wr_id = RDMA_WRID_SEND_CONTROL,

                                   .opcode = IBV_WR_SEND,

                                   .send_flags = IBV_SEND_SIGNALED,

                                   .sg_list = &sge,

                                   .num_sge = 1,

                                };



    DDDPRINTF("CONTROL: sending %s..\n", control_desc[head->type]);



    















    assert(head->len <= RDMA_CONTROL_MAX_BUFFER - sizeof(*head));

    memcpy(wr->control, head, sizeof(RDMAControlHeader));

    control_to_network((void *) wr->control);



    if (buf) {

        memcpy(wr->control + sizeof(RDMAControlHeader), buf, head->len);

    }





    if (ibv_post_send(rdma->qp, &send_wr, &bad_wr)) {

        return -1;

    }



    if (ret < 0) {

        fprintf(stderr, "Failed to use post IB SEND for control!\n");

        return ret;

    }



    ret = qemu_rdma_block_for_wrid(rdma, RDMA_WRID_SEND_CONTROL);

    if (ret < 0) {

        fprintf(stderr, "rdma migration: send polling control error!\n");

    }



    return ret;

}

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

                                       RDMAControlHeader *VAR_2)

{

    int VAR_3 = 0;

    RDMAWorkRequestData *wr = &VAR_0->wr_data[RDMA_WRID_CONTROL];

    struct ibv_send_wr *VAR_4;

    struct ibv_sge VAR_5 = {

                           .addr = (uint64_t)(wr->control),

                           .length = VAR_2->len + sizeof(RDMAControlHeader),

                           .lkey = wr->control_mr->lkey,

                         };

    struct ibv_send_wr VAR_6 = {

                                   .wr_id = RDMA_WRID_SEND_CONTROL,

                                   .opcode = IBV_WR_SEND,

                                   .send_flags = IBV_SEND_SIGNALED,

                                   .sg_list = &VAR_5,

                                   .num_sge = 1,

                                };



    DDDPRINTF("CONTROL: sending %s..\n", control_desc[VAR_2->type]);



    















    assert(VAR_2->len <= RDMA_CONTROL_MAX_BUFFER - sizeof(*VAR_2));

    memcpy(wr->control, VAR_2, sizeof(RDMAControlHeader));

    control_to_network((void *) wr->control);



    if (VAR_1) {

        memcpy(wr->control + sizeof(RDMAControlHeader), VAR_1, VAR_2->len);

    }





    if (ibv_post_send(VAR_0->qp, &VAR_6, &VAR_4)) {

        return -1;

    }



    if (VAR_3 < 0) {

        fprintf(stderr, "Failed to use post IB SEND for control!\n");

        return VAR_3;

    }



    VAR_3 = qemu_rdma_block_for_wrid(VAR_0, RDMA_WRID_SEND_CONTROL);

    if (VAR_3 < 0) {

        fprintf(stderr, "VAR_0 migration: send polling control error!\n");

    }



    return VAR_3;

}

static int FUNC_0(RDMAContext *VAR_0, uint8_t *VAR_1,
RDMAControlHeader *VAR_2)
{ int VAR_3 = 0; RDMAWorkRequestData *wr = &VAR_0->wr_data[RDMA_WRID_CONTROL]; struct ibv_send_wr *VAR_4; struct ibv_sge VAR_5 = { .addr = (uint64_t)(wr->control),
.length = VAR_2->len + sizeof(RDMAControlHeader),
.lkey = wr->control_mr->lkey,
}; struct ibv_send_wr VAR_6 = { .wr_id = RDMA_WRID_SEND_CONTROL,
.opcode = IBV_WR_SEND,
.send_flags = IBV_SEND_SIGNALED,
.sg_list = &VAR_5,
.num_sge = 1,
}; DDDPRINTF("CONTROL: sending %s..\n", control_desc[VAR_2->type]); assert(VAR_2->len <= RDMA_CONTROL_MAX_BUFFER - sizeof(*VAR_2)); memcpy(wr->control, VAR_2, sizeof(RDMAControlHeader)); control_to_network((void *) wr->control); if (VAR_1) { memcpy(wr->control + sizeof(RDMAControlHeader), VAR_1, VAR_2->len); } if (ibv_post_send(VAR_0->qp, &VAR_6, &VAR_4)) { return -1; } if (VAR_3 < 0) { fprintf(stderr, "Failed to use post IB SEND for control!\n"); return VAR_3; } VAR_3 = qemu_rdma_block_for_wrid(VAR_0, RDMA_WRID_SEND_CONTROL); if (VAR_3 < 0) { fprintf(stderr, "VAR_0 migration: send polling control error!\n"); } return VAR_3; }