static void blockdev_mirror_common(BlockDriverState *bs,

                                   BlockDriverState *target,

                                   bool has_replaces, const char *replaces,

                                   enum MirrorSyncMode sync,

                                   bool has_speed, int64_t speed,

                                   bool has_granularity, uint32_t granularity,

                                   bool has_buf_size, int64_t buf_size,

                                   bool has_on_source_error,

                                   BlockdevOnError on_source_error,

                                   bool has_on_target_error,

                                   BlockdevOnError on_target_error,

                                   bool has_unmap, bool unmap,

                                   Error **errp)

{



    if (!has_speed) {

        speed = 0;

    }

    if (!has_on_source_error) {

        on_source_error = BLOCKDEV_ON_ERROR_REPORT;

    }

    if (!has_on_target_error) {

        on_target_error = BLOCKDEV_ON_ERROR_REPORT;

    }

    if (!has_granularity) {

        granularity = 0;

    }

    if (!has_buf_size) {

        buf_size = 0;

    }

    if (!has_unmap) {

        unmap = true;

    }



    if (granularity != 0 && (granularity < 512 || granularity > 1048576 * 64)) {

        error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "granularity",

                   "a value in range [512B, 64MB]");

        return;

    }

    if (granularity & (granularity - 1)) {

        error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "granularity",

                   "power of 2");

        return;

    }



    if (bdrv_op_is_blocked(bs, BLOCK_OP_TYPE_MIRROR_SOURCE, errp)) {

        return;

    }

    if (bdrv_op_is_blocked(target, BLOCK_OP_TYPE_MIRROR_TARGET, errp)) {

        return;

    }

    if (target->blk) {

        error_setg(errp, "Cannot mirror to an attached block device");

        return;

    }



    if (!bs->backing && sync == MIRROR_SYNC_MODE_TOP) {

        sync = MIRROR_SYNC_MODE_FULL;

    }



    /* pass the node name to replace to mirror start since it's loose coupling

     * and will allow to check whether the node still exist at mirror completion

     */

    mirror_start(bs, target,

                 has_replaces ? replaces : NULL,

                 speed, granularity, buf_size, sync,

                 on_source_error, on_target_error, unmap,

                 block_job_cb, bs, errp);

}

static void blockdev_mirror_common(BlockDriverState *bs,

                                   BlockDriverState *target,

                                   bool has_replaces, const char *replaces,

                                   enum MirrorSyncMode sync,

                                   bool has_speed, int64_t speed,

                                   bool has_granularity, uint32_t granularity,

                                   bool has_buf_size, int64_t buf_size,

                                   bool has_on_source_error,

                                   BlockdevOnError on_source_error,

                                   bool has_on_target_error,

                                   BlockdevOnError on_target_error,

                                   bool has_unmap, bool unmap,

                                   Error **errp)

{



    if (!has_speed) {

        speed = 0;

    }

    if (!has_on_source_error) {

        on_source_error = BLOCKDEV_ON_ERROR_REPORT;

    }

    if (!has_on_target_error) {

        on_target_error = BLOCKDEV_ON_ERROR_REPORT;

    }

    if (!has_granularity) {

        granularity = 0;

    }

    if (!has_buf_size) {

        buf_size = 0;

    }

    if (!has_unmap) {

        unmap = true;

    }



    if (granularity != 0 && (granularity < 512 || granularity > 1048576 * 64)) {

        error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "granularity",

                   "a value in range [512B, 64MB]");

        return;

    }

    if (granularity & (granularity - 1)) {

        error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "granularity",

                   "power of 2");

        return;

    }



    if (bdrv_op_is_blocked(bs, BLOCK_OP_TYPE_MIRROR_SOURCE, errp)) {

        return;

    }

    if (bdrv_op_is_blocked(target, BLOCK_OP_TYPE_MIRROR_TARGET, errp)) {

        return;

    }

    if (target->blk) {

        error_setg(errp, "Cannot mirror to an attached block device");

        return;

    }



    if (!bs->backing && sync == MIRROR_SYNC_MODE_TOP) {

        sync = MIRROR_SYNC_MODE_FULL;

    }



    





    mirror_start(bs, target,

                 has_replaces ? replaces : NULL,

                 speed, granularity, buf_size, sync,

                 on_source_error, on_target_error, unmap,

                 block_job_cb, bs, errp);

}

static void FUNC_0(BlockDriverState *VAR_0,

                                   BlockDriverState *VAR_1,

                                   bool VAR_2, const char *VAR_3,

                                   enum MirrorSyncMode VAR_4,

                                   bool VAR_5, int64_t VAR_6,

                                   bool VAR_7, uint32_t VAR_8,

                                   bool VAR_9, int64_t VAR_10,

                                   bool VAR_11,

                                   BlockdevOnError VAR_12,

                                   bool VAR_13,

                                   BlockdevOnError VAR_14,

                                   bool VAR_15, bool VAR_16,

                                   Error **VAR_17)

{



    if (!VAR_5) {

        VAR_6 = 0;

    }

    if (!VAR_11) {

        VAR_12 = BLOCKDEV_ON_ERROR_REPORT;

    }

    if (!VAR_13) {

        VAR_14 = BLOCKDEV_ON_ERROR_REPORT;

    }

    if (!VAR_7) {

        VAR_8 = 0;

    }

    if (!VAR_9) {

        VAR_10 = 0;

    }

    if (!VAR_15) {

        VAR_16 = true;

    }



    if (VAR_8 != 0 && (VAR_8 < 512 || VAR_8 > 1048576 * 64)) {

        error_setg(VAR_17, QERR_INVALID_PARAMETER_VALUE, "VAR_8",

                   "a value in range [512B, 64MB]");

        return;

    }

    if (VAR_8 & (VAR_8 - 1)) {

        error_setg(VAR_17, QERR_INVALID_PARAMETER_VALUE, "VAR_8",

                   "power of 2");

        return;

    }



    if (bdrv_op_is_blocked(VAR_0, BLOCK_OP_TYPE_MIRROR_SOURCE, VAR_17)) {

        return;

    }

    if (bdrv_op_is_blocked(VAR_1, BLOCK_OP_TYPE_MIRROR_TARGET, VAR_17)) {

        return;

    }

    if (VAR_1->blk) {

        error_setg(VAR_17, "Cannot mirror to an attached block device");

        return;

    }



    if (!VAR_0->backing && VAR_4 == MIRROR_SYNC_MODE_TOP) {

        VAR_4 = MIRROR_SYNC_MODE_FULL;

    }



    





    mirror_start(VAR_0, VAR_1,

                 VAR_2 ? VAR_3 : NULL,

                 VAR_6, VAR_8, VAR_10, VAR_4,

                 VAR_12, VAR_14, VAR_16,

                 block_job_cb, VAR_0, VAR_17);

}

static void FUNC_0(BlockDriverState *VAR_0,
BlockDriverState *VAR_1,
bool VAR_2, const char *VAR_3,
enum MirrorSyncMode VAR_4,
bool VAR_5, int64_t VAR_6,
bool VAR_7, uint32_t VAR_8,
bool VAR_9, int64_t VAR_10,
bool VAR_11,
BlockdevOnError VAR_12,
bool VAR_13,
BlockdevOnError VAR_14,
bool VAR_15, bool VAR_16,
Error **VAR_17)
{ if (!VAR_5) { VAR_6 = 0; } if (!VAR_11) { VAR_12 = BLOCKDEV_ON_ERROR_REPORT; } if (!VAR_13) { VAR_14 = BLOCKDEV_ON_ERROR_REPORT; } if (!VAR_7) { VAR_8 = 0; } if (!VAR_9) { VAR_10 = 0; } if (!VAR_15) { VAR_16 = true; } if (VAR_8 != 0 && (VAR_8 < 512 || VAR_8 > 1048576 * 64)) { error_setg(VAR_17, QERR_INVALID_PARAMETER_VALUE, "VAR_8",
"a value in range [512B, 64MB]"); return; } if (VAR_8 & (VAR_8 - 1)) { error_setg(VAR_17, QERR_INVALID_PARAMETER_VALUE, "VAR_8",
"power of 2"); return; } if (bdrv_op_is_blocked(VAR_0, BLOCK_OP_TYPE_MIRROR_SOURCE, VAR_17)) { return; } if (bdrv_op_is_blocked(VAR_1, BLOCK_OP_TYPE_MIRROR_TARGET, VAR_17)) { return; } if (VAR_1->blk) { error_setg(VAR_17, "Cannot mirror to an attached block device"); return; } if (!VAR_0->backing && VAR_4 == MIRROR_SYNC_MODE_TOP) { VAR_4 = MIRROR_SYNC_MODE_FULL; } mirror_start(VAR_0, VAR_1,
VAR_2 ? VAR_3 : NULL,
VAR_6, VAR_8, VAR_10, VAR_4,
VAR_12, VAR_14, VAR_16,
block_job_cb, VAR_0, VAR_17); }