static void mirror_start_job(BlockDriverState *bs, BlockDriverState *target,

                             const char *replaces,

                             int64_t speed, int64_t granularity,

                             int64_t buf_size,

                             BlockdevOnError on_source_error,

                             BlockdevOnError on_target_error,

                             BlockCompletionFunc *cb,

                             void *opaque, Error **errp,

                             const BlockJobDriver *driver,

                             bool is_none_mode, BlockDriverState *base)

{

    MirrorBlockJob *s;



    if (granularity == 0) {

        /* Choose the default granularity based on the target file's cluster

         * size, clamped between 4k and 64k.  */

        BlockDriverInfo bdi;

        if (bdrv_get_info(target, &bdi) >= 0 && bdi.cluster_size != 0) {

            granularity = MAX(4096, bdi.cluster_size);

            granularity = MIN(65536, granularity);

        } else {

            granularity = 65536;

        }

    }



    assert ((granularity & (granularity - 1)) == 0);



    if ((on_source_error == BLOCKDEV_ON_ERROR_STOP ||

         on_source_error == BLOCKDEV_ON_ERROR_ENOSPC) &&

        !bdrv_iostatus_is_enabled(bs)) {

        error_set(errp, QERR_INVALID_PARAMETER, "on-source-error");

        return;

    }





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

    if (!s) {

        return;

    }



    s->replaces = g_strdup(replaces);

    s->on_source_error = on_source_error;

    s->on_target_error = on_target_error;

    s->target = target;

    s->is_none_mode = is_none_mode;

    s->base = base;

    s->granularity = granularity;

    s->buf_size = MAX(buf_size, granularity);



    s->dirty_bitmap = bdrv_create_dirty_bitmap(bs, granularity, errp);

    if (!s->dirty_bitmap) {

        return;

    }

    bdrv_set_enable_write_cache(s->target, true);

    bdrv_set_on_error(s->target, on_target_error, on_target_error);

    bdrv_iostatus_enable(s->target);

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

    trace_mirror_start(bs, s, s->common.co, opaque);

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

}

static void mirror_start_job(BlockDriverState *bs, BlockDriverState *target,

                             const char *replaces,

                             int64_t speed, int64_t granularity,

                             int64_t buf_size,

                             BlockdevOnError on_source_error,

                             BlockdevOnError on_target_error,

                             BlockCompletionFunc *cb,

                             void *opaque, Error **errp,

                             const BlockJobDriver *driver,

                             bool is_none_mode, BlockDriverState *base)

{

    MirrorBlockJob *s;



    if (granularity == 0) {

        



        BlockDriverInfo bdi;

        if (bdrv_get_info(target, &bdi) >= 0 && bdi.cluster_size != 0) {

            granularity = MAX(4096, bdi.cluster_size);

            granularity = MIN(65536, granularity);

        } else {

            granularity = 65536;

        }

    }



    assert ((granularity & (granularity - 1)) == 0);



    if ((on_source_error == BLOCKDEV_ON_ERROR_STOP ||

         on_source_error == BLOCKDEV_ON_ERROR_ENOSPC) &&

        !bdrv_iostatus_is_enabled(bs)) {

        error_set(errp, QERR_INVALID_PARAMETER, "on-source-error");

        return;

    }





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

    if (!s) {

        return;

    }



    s->replaces = g_strdup(replaces);

    s->on_source_error = on_source_error;

    s->on_target_error = on_target_error;

    s->target = target;

    s->is_none_mode = is_none_mode;

    s->base = base;

    s->granularity = granularity;

    s->buf_size = MAX(buf_size, granularity);



    s->dirty_bitmap = bdrv_create_dirty_bitmap(bs, granularity, errp);

    if (!s->dirty_bitmap) {

        return;

    }

    bdrv_set_enable_write_cache(s->target, true);

    bdrv_set_on_error(s->target, on_target_error, on_target_error);

    bdrv_iostatus_enable(s->target);

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

    trace_mirror_start(bs, s, s->common.co, opaque);

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

}

static void FUNC_0(BlockDriverState *VAR_0, BlockDriverState *VAR_1,

                             const char *VAR_2,

                             int64_t VAR_3, int64_t VAR_4,

                             int64_t VAR_5,

                             BlockdevOnError VAR_6,

                             BlockdevOnError VAR_7,

                             BlockCompletionFunc *VAR_8,

                             void *VAR_9, Error **VAR_10,

                             const BlockJobDriver *VAR_11,

                             bool VAR_12, BlockDriverState *VAR_13)

{

    MirrorBlockJob *s;



    if (VAR_4 == 0) {

        



        BlockDriverInfo bdi;

        if (bdrv_get_info(VAR_1, &bdi) >= 0 && bdi.cluster_size != 0) {

            VAR_4 = MAX(4096, bdi.cluster_size);

            VAR_4 = MIN(65536, VAR_4);

        } else {

            VAR_4 = 65536;

        }

    }



    assert ((VAR_4 & (VAR_4 - 1)) == 0);



    if ((VAR_6 == BLOCKDEV_ON_ERROR_STOP ||

         VAR_6 == BLOCKDEV_ON_ERROR_ENOSPC) &&

        !bdrv_iostatus_is_enabled(VAR_0)) {

        error_set(VAR_10, QERR_INVALID_PARAMETER, "on-source-error");

        return;

    }





    s = block_job_create(VAR_11, VAR_0, VAR_3, VAR_8, VAR_9, VAR_10);

    if (!s) {

        return;

    }



    s->VAR_2 = g_strdup(VAR_2);

    s->VAR_6 = VAR_6;

    s->VAR_7 = VAR_7;

    s->VAR_1 = VAR_1;

    s->VAR_12 = VAR_12;

    s->VAR_13 = VAR_13;

    s->VAR_4 = VAR_4;

    s->VAR_5 = MAX(VAR_5, VAR_4);



    s->dirty_bitmap = bdrv_create_dirty_bitmap(VAR_0, VAR_4, VAR_10);

    if (!s->dirty_bitmap) {

        return;

    }

    bdrv_set_enable_write_cache(s->VAR_1, true);

    bdrv_set_on_error(s->VAR_1, VAR_7, VAR_7);

    bdrv_iostatus_enable(s->VAR_1);

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

    trace_mirror_start(VAR_0, s, s->common.co, VAR_9);

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

}

static void FUNC_0(BlockDriverState *VAR_0, BlockDriverState *VAR_1,
const char *VAR_2,
int64_t VAR_3, int64_t VAR_4,
int64_t VAR_5,
BlockdevOnError VAR_6,
BlockdevOnError VAR_7,
BlockCompletionFunc *VAR_8,
void *VAR_9, Error **VAR_10,
const BlockJobDriver *VAR_11,
bool VAR_12, BlockDriverState *VAR_13)
{ MirrorBlockJob *s; if (VAR_4 == 0) { BlockDriverInfo bdi; if (bdrv_get_info(VAR_1, &bdi) >= 0 && bdi.cluster_size != 0) { VAR_4 = MAX(4096, bdi.cluster_size); VAR_4 = MIN(65536, VAR_4); } else { VAR_4 = 65536; } } assert ((VAR_4 & (VAR_4 - 1)) == 0); if ((VAR_6 == BLOCKDEV_ON_ERROR_STOP ||
VAR_6 == BLOCKDEV_ON_ERROR_ENOSPC) &&
!bdrv_iostatus_is_enabled(VAR_0)) { error_set(VAR_10, QERR_INVALID_PARAMETER, "on-source-error"); return; } s = block_job_create(VAR_11, VAR_0, VAR_3, VAR_8, VAR_9, VAR_10); if (!s) { return; } s->VAR_2 = g_strdup(VAR_2); s->VAR_6 = VAR_6; s->VAR_7 = VAR_7; s->VAR_1 = VAR_1; s->VAR_12 = VAR_12; s->VAR_13 = VAR_13; s->VAR_4 = VAR_4; s->VAR_5 = MAX(VAR_5, VAR_4); s->dirty_bitmap = bdrv_create_dirty_bitmap(VAR_0, VAR_4, VAR_10); if (!s->dirty_bitmap) { return; } bdrv_set_enable_write_cache(s->VAR_1, true); bdrv_set_on_error(s->VAR_1, VAR_7, VAR_7); bdrv_iostatus_enable(s->VAR_1); s->common.co = qemu_coroutine_create(mirror_run); trace_mirror_start(VAR_0, s, s->common.co, VAR_9); qemu_coroutine_enter(s->common.co, s); }