void qmp_block_commit(const char *device,

                      bool has_base, const char *base, const char *top,

                      bool has_speed, int64_t speed,

                      Error **errp)

{

    BlockDriverState *bs;

    BlockDriverState *base_bs, *top_bs;

    Error *local_err = NULL;

    /* This will be part of the QMP command, if/when the

     * BlockdevOnError change for blkmirror makes it in

     */

    BlockdevOnError on_error = BLOCKDEV_ON_ERROR_REPORT;



    /* drain all i/o before commits */

    bdrv_drain_all();



    bs = bdrv_find(device);

    if (!bs) {

        error_set(errp, QERR_DEVICE_NOT_FOUND, device);

        return;

    }

    if (base && has_base) {

        base_bs = bdrv_find_backing_image(bs, base);

    } else {

        base_bs = bdrv_find_base(bs);

    }



    if (base_bs == NULL) {

        error_set(errp, QERR_BASE_NOT_FOUND, base ? base : "NULL");

        return;

    }



    /* default top_bs is the active layer */

    top_bs = bs;



    if (top) {

        if (strcmp(bs->filename, top) != 0) {

            top_bs = bdrv_find_backing_image(bs, top);

        }

    }



    if (top_bs == NULL) {

        error_setg(errp, "Top image file %s not found", top ? top : "NULL");

        return;

    }



    commit_start(bs, base_bs, top_bs, speed, on_error, block_job_cb, bs,

                &local_err);

    if (local_err != NULL) {

        error_propagate(errp, local_err);

        return;

    }

    /* Grab a reference so hotplug does not delete the BlockDriverState from

     * underneath us.

     */

    drive_get_ref(drive_get_by_blockdev(bs));

}

void qmp_block_commit(const char *device,

                      bool has_base, const char *base, const char *top,

                      bool has_speed, int64_t speed,

                      Error **errp)

{

    BlockDriverState *bs;

    BlockDriverState *base_bs, *top_bs;

    Error *local_err = NULL;

    





    BlockdevOnError on_error = BLOCKDEV_ON_ERROR_REPORT;



    

    bdrv_drain_all();



    bs = bdrv_find(device);

    if (!bs) {

        error_set(errp, QERR_DEVICE_NOT_FOUND, device);

        return;

    }

    if (base && has_base) {

        base_bs = bdrv_find_backing_image(bs, base);

    } else {

        base_bs = bdrv_find_base(bs);

    }



    if (base_bs == NULL) {

        error_set(errp, QERR_BASE_NOT_FOUND, base ? base : "NULL");

        return;

    }



    

    top_bs = bs;



    if (top) {

        if (strcmp(bs->filename, top) != 0) {

            top_bs = bdrv_find_backing_image(bs, top);

        }

    }



    if (top_bs == NULL) {

        error_setg(errp, "Top image file %s not found", top ? top : "NULL");

        return;

    }



    commit_start(bs, base_bs, top_bs, speed, on_error, block_job_cb, bs,

                &local_err);

    if (local_err != NULL) {

        error_propagate(errp, local_err);

        return;

    }

    





    drive_get_ref(drive_get_by_blockdev(bs));

}

    if (base && has_base) {         base_bs = bdrv_find_backing_image(bs, base);     } else {         base_bs = bdrv_find_base(bs);     if (base_bs == NULL) {         error_set(errp, QERR_BASE_NOT_FOUND, base ? base : "NULL");
void FUNC_0(const char *VAR_0,

                      bool VAR_1, const char *VAR_2, const char *VAR_3,

                      bool VAR_4, int64_t VAR_5,

                      Error **VAR_6)

{

    BlockDriverState *bs;

    BlockDriverState *base_bs, *top_bs;

    Error *local_err = NULL;

    





    BlockdevOnError on_error = BLOCKDEV_ON_ERROR_REPORT;



    

    bdrv_drain_all();



    bs = bdrv_find(VAR_0);

    if (!bs) {

        error_set(VAR_6, QERR_DEVICE_NOT_FOUND, VAR_0);

        return;

    }

    if (VAR_2 && VAR_1) {

        base_bs = bdrv_find_backing_image(bs, VAR_2);

    } else {

        base_bs = bdrv_find_base(bs);

    }



    if (base_bs == NULL) {

        error_set(VAR_6, QERR_BASE_NOT_FOUND, VAR_2 ? VAR_2 : "NULL");

        return;

    }



    

    top_bs = bs;



    if (VAR_3) {

        if (strcmp(bs->filename, VAR_3) != 0) {

            top_bs = bdrv_find_backing_image(bs, VAR_3);

        }

    }



    if (top_bs == NULL) {

        error_setg(VAR_6, "Top image file %s not found", VAR_3 ? VAR_3 : "NULL");

        return;

    }



    commit_start(bs, base_bs, top_bs, VAR_5, on_error, block_job_cb, bs,

                &local_err);

    if (local_err != NULL) {

        error_propagate(VAR_6, local_err);

        return;

    }

    





    drive_get_ref(drive_get_by_blockdev(bs));

}

void FUNC_0(const char *VAR_0,
bool VAR_1, const char *VAR_2, const char *VAR_3,
bool VAR_4, int64_t VAR_5,
Error **VAR_6)
{ BlockDriverState *bs; BlockDriverState *base_bs, *top_bs; Error *local_err = NULL; BlockdevOnError on_error = BLOCKDEV_ON_ERROR_REPORT; bdrv_drain_all(); bs = bdrv_find(VAR_0); if (!bs) { error_set(VAR_6, QERR_DEVICE_NOT_FOUND, VAR_0); return; } if (VAR_2 && VAR_1) { base_bs = bdrv_find_backing_image(bs, VAR_2); } else { base_bs = bdrv_find_base(bs); } if (base_bs == NULL) { error_set(VAR_6, QERR_BASE_NOT_FOUND, VAR_2 ? VAR_2 : "NULL"); return; } top_bs = bs; if (VAR_3) { if (strcmp(bs->filename, VAR_3) != 0) { top_bs = bdrv_find_backing_image(bs, VAR_3); } } if (top_bs == NULL) { error_setg(VAR_6, "Top image file %s not found", VAR_3 ? VAR_3 : "NULL"); return; } commit_start(bs, base_bs, top_bs, VAR_5, on_error, block_job_cb, bs,
&local_err); if (local_err != NULL) { error_propagate(VAR_6, local_err); return; } drive_get_ref(drive_get_by_blockdev(bs)); }