static int qemu_rdma_reg_whole_ram_blocks(RDMAContext *rdma)

{

    int i;

    RDMALocalBlocks *local = &rdma->local_ram_blocks;



    for (i = 0; i < local->nb_blocks; i++) {

        local->block[i].mr =

            ibv_reg_mr(rdma->pd,

                    local->block[i].local_host_addr,

                    local->block[i].length,

                    IBV_ACCESS_LOCAL_WRITE |

                    IBV_ACCESS_REMOTE_WRITE

                    );

        if (!local->block[i].mr) {

            perror("Failed to register local dest ram block!\n");

            break;

        }

        rdma->total_registrations++;

    }



    if (i >= local->nb_blocks) {

        return 0;

    }



    for (i--; i >= 0; i--) {

        ibv_dereg_mr(local->block[i].mr);

        rdma->total_registrations--;

    }



    return -1;



}

static int qemu_rdma_reg_whole_ram_blocks(RDMAContext *rdma)

{

    int i;

    RDMALocalBlocks *local = &rdma->local_ram_blocks;



    for (i = 0; i < local->nb_blocks; i++) {

        local->block[i].mr =

            ibv_reg_mr(rdma->pd,

                    local->block[i].local_host_addr,

                    local->block[i].length,

                    IBV_ACCESS_LOCAL_WRITE |

                    IBV_ACCESS_REMOTE_WRITE

                    );

        if (!local->block[i].mr) {

            perror("Failed to register local dest ram block!\n");

            break;

        }

        rdma->total_registrations++;

    }



    if (i >= local->nb_blocks) {

        return 0;

    }



    for (i--; i >= 0; i--) {

        ibv_dereg_mr(local->block[i].mr);

        rdma->total_registrations--;

    }



    return -1;



}

static int FUNC_0(RDMAContext *VAR_0)

{

    int VAR_1;

    RDMALocalBlocks *local = &VAR_0->local_ram_blocks;



    for (VAR_1 = 0; VAR_1 < local->nb_blocks; VAR_1++) {

        local->block[VAR_1].mr =

            ibv_reg_mr(VAR_0->pd,

                    local->block[VAR_1].local_host_addr,

                    local->block[VAR_1].length,

                    IBV_ACCESS_LOCAL_WRITE |

                    IBV_ACCESS_REMOTE_WRITE

                    );

        if (!local->block[VAR_1].mr) {

            perror("Failed to register local dest ram block!\n");

            break;

        }

        VAR_0->total_registrations++;

    }



    if (VAR_1 >= local->nb_blocks) {

        return 0;

    }



    for (VAR_1--; VAR_1 >= 0; VAR_1--) {

        ibv_dereg_mr(local->block[VAR_1].mr);

        VAR_0->total_registrations--;

    }



    return -1;



}

static int FUNC_0(RDMAContext *VAR_0)
{ int VAR_1; RDMALocalBlocks *local = &VAR_0->local_ram_blocks; for (VAR_1 = 0; VAR_1 < local->nb_blocks; VAR_1++) { local->block[VAR_1].mr =
ibv_reg_mr(VAR_0->pd,
local->block[VAR_1].local_host_addr,
local->block[VAR_1].length,
IBV_ACCESS_LOCAL_WRITE |
IBV_ACCESS_REMOTE_WRITE
); if (!local->block[VAR_1].mr) { perror("Failed to register local dest ram block!\n"); break; } VAR_0->total_registrations++; } if (VAR_1 >= local->nb_blocks) { return 0; } for (VAR_1--; VAR_1 >= 0; VAR_1--) { ibv_dereg_mr(local->block[VAR_1].mr); VAR_0->total_registrations--; } return -1; }