void commit_start(BlockDriverState *bs, BlockDriverState *base,

                  BlockDriverState *top, int64_t speed,

                  BlockdevOnError on_error, BlockDriverCompletionFunc *cb,

                  void *opaque, Error **errp)

{

    CommitBlockJob *s;

    BlockReopenQueue *reopen_queue = NULL;

    int orig_overlay_flags;

    int orig_base_flags;

    BlockDriverState *overlay_bs;

    Error *local_err = NULL;



    if ((on_error == BLOCKDEV_ON_ERROR_STOP ||

         on_error == BLOCKDEV_ON_ERROR_ENOSPC) &&

        !bdrv_iostatus_is_enabled(bs)) {

        error_set(errp, QERR_INVALID_PARAMETER_COMBINATION);

        return;

    }



    /* Once we support top == active layer, remove this check */

    if (top == bs) {

        error_setg(errp,

                   "Top image as the active layer is currently unsupported");

        return;

    }



    if (top == base) {

        error_setg(errp, "Invalid files for merge: top and base are the same");

        return;

    }



    overlay_bs = bdrv_find_overlay(bs, top);



    if (overlay_bs == NULL) {

        error_setg(errp, "Could not find overlay image for %s:", top->filename);

        return;

    }



    orig_base_flags    = bdrv_get_flags(base);

    orig_overlay_flags = bdrv_get_flags(overlay_bs);



    /* convert base & overlay_bs to r/w, if necessary */

    if (!(orig_base_flags & BDRV_O_RDWR)) {

        reopen_queue = bdrv_reopen_queue(reopen_queue, base,

                                         orig_base_flags | BDRV_O_RDWR);

    }

    if (!(orig_overlay_flags & BDRV_O_RDWR)) {

        reopen_queue = bdrv_reopen_queue(reopen_queue, overlay_bs,

                                         orig_overlay_flags | BDRV_O_RDWR);

    }

    if (reopen_queue) {

        bdrv_reopen_multiple(reopen_queue, &local_err);

        if (local_err != NULL) {

            error_propagate(errp, local_err);

            return;

        }

    }





    s = block_job_create(&commit_job_driver, bs, speed, cb, opaque, errp);

    if (!s) {

        return;

    }



    s->base   = base;

    s->top    = top;

    s->active = bs;



    s->base_flags          = orig_base_flags;

    s->orig_overlay_flags  = orig_overlay_flags;



    s->on_error = on_error;

    s->common.co = qemu_coroutine_create(commit_run);



    trace_commit_start(bs, base, top, s, s->common.co, opaque);

    qemu_coroutine_enter(s->common.co, s);

}

void commit_start(BlockDriverState *bs, BlockDriverState *base,

                  BlockDriverState *top, int64_t speed,

                  BlockdevOnError on_error, BlockDriverCompletionFunc *cb,

                  void *opaque, Error **errp)

{

    CommitBlockJob *s;

    BlockReopenQueue *reopen_queue = NULL;

    int orig_overlay_flags;

    int orig_base_flags;

    BlockDriverState *overlay_bs;

    Error *local_err = NULL;



    if ((on_error == BLOCKDEV_ON_ERROR_STOP ||

         on_error == BLOCKDEV_ON_ERROR_ENOSPC) &&

        !bdrv_iostatus_is_enabled(bs)) {

        error_set(errp, QERR_INVALID_PARAMETER_COMBINATION);

        return;

    }



    

    if (top == bs) {

        error_setg(errp,

                   "Top image as the active layer is currently unsupported");

        return;

    }



    if (top == base) {

        error_setg(errp, "Invalid files for merge: top and base are the same");

        return;

    }



    overlay_bs = bdrv_find_overlay(bs, top);



    if (overlay_bs == NULL) {

        error_setg(errp, "Could not find overlay image for %s:", top->filename);

        return;

    }



    orig_base_flags    = bdrv_get_flags(base);

    orig_overlay_flags = bdrv_get_flags(overlay_bs);



    

    if (!(orig_base_flags & BDRV_O_RDWR)) {

        reopen_queue = bdrv_reopen_queue(reopen_queue, base,

                                         orig_base_flags | BDRV_O_RDWR);

    }

    if (!(orig_overlay_flags & BDRV_O_RDWR)) {

        reopen_queue = bdrv_reopen_queue(reopen_queue, overlay_bs,

                                         orig_overlay_flags | BDRV_O_RDWR);

    }

    if (reopen_queue) {

        bdrv_reopen_multiple(reopen_queue, &local_err);

        if (local_err != NULL) {

            error_propagate(errp, local_err);

            return;

        }

    }





    s = block_job_create(&commit_job_driver, bs, speed, cb, opaque, errp);

    if (!s) {

        return;

    }



    s->base   = base;

    s->top    = top;

    s->active = bs;



    s->base_flags          = orig_base_flags;

    s->orig_overlay_flags  = orig_overlay_flags;



    s->on_error = on_error;

    s->common.co = qemu_coroutine_create(commit_run);



    trace_commit_start(bs, base, top, s, s->common.co, opaque);

    qemu_coroutine_enter(s->common.co, s);

}

void FUNC_0(BlockDriverState *VAR_0, BlockDriverState *VAR_1,

                  BlockDriverState *VAR_2, int64_t VAR_3,

                  BlockdevOnError VAR_4, BlockDriverCompletionFunc *VAR_5,

                  void *VAR_6, Error **VAR_7)

{

    CommitBlockJob *s;

    BlockReopenQueue *reopen_queue = NULL;

    int VAR_8;

    int VAR_9;

    BlockDriverState *overlay_bs;

    Error *local_err = NULL;



    if ((VAR_4 == BLOCKDEV_ON_ERROR_STOP ||

         VAR_4 == BLOCKDEV_ON_ERROR_ENOSPC) &&

        !bdrv_iostatus_is_enabled(VAR_0)) {

        error_set(VAR_7, QERR_INVALID_PARAMETER_COMBINATION);

        return;

    }



    

    if (VAR_2 == VAR_0) {

        error_setg(VAR_7,

                   "Top image as the active layer is currently unsupported");

        return;

    }



    if (VAR_2 == VAR_1) {

        error_setg(VAR_7, "Invalid files for merge: VAR_2 and VAR_1 are the same");

        return;

    }



    overlay_bs = bdrv_find_overlay(VAR_0, VAR_2);



    if (overlay_bs == NULL) {

        error_setg(VAR_7, "Could not find overlay image for %s:", VAR_2->filename);

        return;

    }



    VAR_9    = bdrv_get_flags(VAR_1);

    VAR_8 = bdrv_get_flags(overlay_bs);



    

    if (!(VAR_9 & BDRV_O_RDWR)) {

        reopen_queue = bdrv_reopen_queue(reopen_queue, VAR_1,

                                         VAR_9 | BDRV_O_RDWR);

    }

    if (!(VAR_8 & BDRV_O_RDWR)) {

        reopen_queue = bdrv_reopen_queue(reopen_queue, overlay_bs,

                                         VAR_8 | BDRV_O_RDWR);

    }

    if (reopen_queue) {

        bdrv_reopen_multiple(reopen_queue, &local_err);

        if (local_err != NULL) {

            error_propagate(VAR_7, local_err);

            return;

        }

    }





    s = block_job_create(&commit_job_driver, VAR_0, VAR_3, VAR_5, VAR_6, VAR_7);

    if (!s) {

        return;

    }



    s->VAR_1   = VAR_1;

    s->VAR_2    = VAR_2;

    s->active = VAR_0;



    s->base_flags          = VAR_9;

    s->VAR_8  = VAR_8;



    s->VAR_4 = VAR_4;

    s->common.co = qemu_coroutine_create(commit_run);



    trace_commit_start(VAR_0, VAR_1, VAR_2, s, s->common.co, VAR_6);

    qemu_coroutine_enter(s->common.co, s);

}

void FUNC_0(BlockDriverState *VAR_0, BlockDriverState *VAR_1,
BlockDriverState *VAR_2, int64_t VAR_3,
BlockdevOnError VAR_4, BlockDriverCompletionFunc *VAR_5,
void *VAR_6, Error **VAR_7)
{ CommitBlockJob *s; BlockReopenQueue *reopen_queue = NULL; int VAR_8; int VAR_9; BlockDriverState *overlay_bs; Error *local_err = NULL; if ((VAR_4 == BLOCKDEV_ON_ERROR_STOP ||
VAR_4 == BLOCKDEV_ON_ERROR_ENOSPC) &&
!bdrv_iostatus_is_enabled(VAR_0)) { error_set(VAR_7, QERR_INVALID_PARAMETER_COMBINATION); return; } if (VAR_2 == VAR_0) { error_setg(VAR_7,
"Top image as the active layer is currently unsupported"); return; } if (VAR_2 == VAR_1) { error_setg(VAR_7, "Invalid files for merge: VAR_2 and VAR_1 are the same"); return; } overlay_bs = bdrv_find_overlay(VAR_0, VAR_2); if (overlay_bs == NULL) { error_setg(VAR_7, "Could not find overlay image for %s:", VAR_2->filename); return; } VAR_9    = bdrv_get_flags(VAR_1); VAR_8 = bdrv_get_flags(overlay_bs); if (!(VAR_9 & BDRV_O_RDWR)) { reopen_queue = bdrv_reopen_queue(reopen_queue, VAR_1,
VAR_9 | BDRV_O_RDWR); } if (!(VAR_8 & BDRV_O_RDWR)) { reopen_queue = bdrv_reopen_queue(reopen_queue, overlay_bs,
VAR_8 | BDRV_O_RDWR); } if (reopen_queue) { bdrv_reopen_multiple(reopen_queue, &local_err); if (local_err != NULL) { error_propagate(VAR_7, local_err); return; } } s = block_job_create(&commit_job_driver, VAR_0, VAR_3, VAR_5, VAR_6, VAR_7); if (!s) { return; } s->VAR_1   = VAR_1; s->VAR_2    = VAR_2; s->active = VAR_0; s->base_flags          = VAR_9; s->VAR_8  = VAR_8; s->VAR_4 = VAR_4; s->common.co = qemu_coroutine_create(commit_run); trace_commit_start(VAR_0, VAR_1, VAR_2, s, s->common.co, VAR_6); qemu_coroutine_enter(s->common.co, s); }