Conflicts: block.h
Signed-off-by: Devin Nakamura <devin...@gmail.com> --- block.c | 32 ++++++++++++++++++++++++++++++++ block.h | 4 ++++ 2 files changed, 36 insertions(+), 0 deletions(-) diff --git a/block.c b/block.c index 4503b7b..9530577 100644 --- a/block.c +++ b/block.c @@ -3038,6 +3038,38 @@ out: return ret; } +int bdrv_open_conversion_target(BlockDriverState **bs, BlockDriverState *file, + BlockConversionOptions *drv_options, + QEMUOptionParameter *usr_options, + const char *target_fmt) +{ + BlockDriver *drv; + BlockDriverState *bss; + + drv = bdrv_find_format(target_fmt); + if (!drv) { + return -ENOENT; + } + + if (!drv->bdrv_open_conversion_target) { + return -ENOTSUP; + } + + *bs = bdrv_new(""); + bss = *bs; + bss->file = file; + bss->total_sectors = drv_options->image_size >> BDRV_SECTOR_BITS; + bss->encrypted = 0; + bss->valid_key = 0; + bss->open_flags = 0; + /* buffer_alignment defaulted to 512, drivers can change this value */ + bss->buffer_alignment = 512; + bss->opaque = qemu_mallocz(drv->instance_size); + bss->drv = drv; + return drv->bdrv_open_conversion_target(bss, drv_options, usr_options); + +} + int bdrv_get_conversion_options(BlockDriverState *bs, BlockConversionOptions *options) { diff --git a/block.h b/block.h index ad7e5ea..662bae7 100644 --- a/block.h +++ b/block.h @@ -255,6 +255,10 @@ typedef struct BlockConversionOptions BlockConversionOptions; int bdrv_get_conversion_options(BlockDriverState *bs, BlockConversionOptions *options); +int bdrv_open_conversion_target(BlockDriverState **bs, BlockDriverState *file, + BlockConversionOptions *drv_options, + QEMUOptionParameter *usr_options, + const char *target_fmt); typedef enum { BLKDBG_L1_UPDATE, -- 1.7.6.rc1