void qmp_blockdev_mirror(const char *device, const char *target,

                         bool has_replaces, const char *replaces,

                         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,

                         Error **errp)

{

    BlockDriverState *bs;

    BlockBackend *blk;

    BlockDriverState *target_bs;

    AioContext *aio_context;

    BlockMirrorBackingMode backing_mode = MIRROR_LEAVE_BACKING_CHAIN;

    Error *local_err = NULL;



    blk = blk_by_name(device);

    if (!blk) {

        error_setg(errp, "Device '%s' not found", device);

        return;

    }

    bs = blk_bs(blk);



    if (!bs) {

        error_setg(errp, "Device '%s' has no media", device);

        return;

    }



    target_bs = bdrv_lookup_bs(target, target, errp);

    if (!target_bs) {

        return;

    }



    aio_context = bdrv_get_aio_context(bs);

    aio_context_acquire(aio_context);



    bdrv_set_aio_context(target_bs, aio_context);



    blockdev_mirror_common(bs, target_bs,

                           has_replaces, replaces, sync, backing_mode,

                           has_speed, speed,

                           has_granularity, granularity,

                           has_buf_size, buf_size,

                           has_on_source_error, on_source_error,

                           has_on_target_error, on_target_error,

                           true, true,

                           &local_err);

    if (local_err) {

        error_propagate(errp, local_err);

    }



    aio_context_release(aio_context);

}

void qmp_blockdev_mirror(const char *device, const char *target,

                         bool has_replaces, const char *replaces,

                         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,

                         Error **errp)

{

    BlockDriverState *bs;

    BlockBackend *blk;

    BlockDriverState *target_bs;

    AioContext *aio_context;

    BlockMirrorBackingMode backing_mode = MIRROR_LEAVE_BACKING_CHAIN;

    Error *local_err = NULL;



    blk = blk_by_name(device);

    if (!blk) {

        error_setg(errp, "Device '%s' not found", device);

        return;

    }

    bs = blk_bs(blk);



    if (!bs) {

        error_setg(errp, "Device '%s' has no media", device);

        return;

    }



    target_bs = bdrv_lookup_bs(target, target, errp);

    if (!target_bs) {

        return;

    }



    aio_context = bdrv_get_aio_context(bs);

    aio_context_acquire(aio_context);



    bdrv_set_aio_context(target_bs, aio_context);



    blockdev_mirror_common(bs, target_bs,

                           has_replaces, replaces, sync, backing_mode,

                           has_speed, speed,

                           has_granularity, granularity,

                           has_buf_size, buf_size,

                           has_on_source_error, on_source_error,

                           has_on_target_error, on_target_error,

                           true, true,

                           &local_err);

    if (local_err) {

        error_propagate(errp, local_err);

    }



    aio_context_release(aio_context);

}

void FUNC_0(const char *VAR_0, const char *VAR_1,

                         bool VAR_2, const char *VAR_3,

                         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,

                         Error **VAR_15)

{

    BlockDriverState *bs;

    BlockBackend *blk;

    BlockDriverState *target_bs;

    AioContext *aio_context;

    BlockMirrorBackingMode backing_mode = MIRROR_LEAVE_BACKING_CHAIN;

    Error *local_err = NULL;



    blk = blk_by_name(VAR_0);

    if (!blk) {

        error_setg(VAR_15, "Device '%s' not found", VAR_0);

        return;

    }

    bs = blk_bs(blk);



    if (!bs) {

        error_setg(VAR_15, "Device '%s' has no media", VAR_0);

        return;

    }



    target_bs = bdrv_lookup_bs(VAR_1, VAR_1, VAR_15);

    if (!target_bs) {

        return;

    }



    aio_context = bdrv_get_aio_context(bs);

    aio_context_acquire(aio_context);



    bdrv_set_aio_context(target_bs, aio_context);



    blockdev_mirror_common(bs, target_bs,

                           VAR_2, VAR_3, VAR_4, backing_mode,

                           VAR_5, VAR_6,

                           VAR_7, VAR_8,

                           VAR_9, VAR_10,

                           VAR_11, VAR_12,

                           VAR_13, VAR_14,

                           true, true,

                           &local_err);

    if (local_err) {

        error_propagate(VAR_15, local_err);

    }



    aio_context_release(aio_context);

}

void FUNC_0(const char *VAR_0, const char *VAR_1,
bool VAR_2, const char *VAR_3,
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,
Error **VAR_15)
{ BlockDriverState *bs; BlockBackend *blk; BlockDriverState *target_bs; AioContext *aio_context; BlockMirrorBackingMode backing_mode = MIRROR_LEAVE_BACKING_CHAIN; Error *local_err = NULL; blk = blk_by_name(VAR_0); if (!blk) { error_setg(VAR_15, "Device '%s' not found", VAR_0); return; } bs = blk_bs(blk); if (!bs) { error_setg(VAR_15, "Device '%s' has no media", VAR_0); return; } target_bs = bdrv_lookup_bs(VAR_1, VAR_1, VAR_15); if (!target_bs) { return; } aio_context = bdrv_get_aio_context(bs); aio_context_acquire(aio_context); bdrv_set_aio_context(target_bs, aio_context); blockdev_mirror_common(bs, target_bs,
VAR_2, VAR_3, VAR_4, backing_mode,
VAR_5, VAR_6,
VAR_7, VAR_8,
VAR_9, VAR_10,
VAR_11, VAR_12,
VAR_13, VAR_14,
true, true,
&local_err); if (local_err) { error_propagate(VAR_15, local_err); } aio_context_release(aio_context); }