block: Use backing format driver during image creation
PATCH 1/1 block: Use backing format driver during image creation
The backing format should be honored during image creation. For some reason we currently use the image format to open the backing file. This fails when the backing file has a different format than the image being created. Keep the image and backing format drivers completely separate.
Also print the backing filename if there is an error opening the backing file instead of the image filename.
--- block.c | 8 +++++--- 1 files changed, 5 insertions(+), 3 deletions(-)
block.c +5 -3
@@ -2778,6 +2778,7 @@ int bdrv_img_create(const char *filename, const char *fmt,QEMUOptionParameter *backing_fmt, *backing_file;BlockDriverState *bs =NULL ;BlockDriver *drv, *proto_drv; +BlockDriver *backing_drv =NULL ;int ret =0 ;/* Find driver and parse its options */
@@ -2846,7 +2847,8 @@ int bdrv_img_create(const char *filename, const char *fmt, backing_fmt =get_option_parameter (param,BLOCK_OPT_BACKING_FMT );if (backing_fmt && backing_fmt->value.s) { -if (!bdrv_find_format (backing_fmt->value.s)) { + backing_drv =bdrv_find_format (backing_fmt->value.s); +if (!backing_drv) {error_report ("Unknown backing file format '%s'" , backing_fmt->value.s); ret = -EINVAL ;
@@ -2863,9 +2865,9 @@ int bdrv_img_create(const char *filename, const char *fmt, bs =bdrv_new ("" ); - ret =bdrv_open (bs, backing_file->value.s, flags, drv); + ret =bdrv_open (bs, backing_file->value.s, flags, backing_drv);if (ret <0 ) { -error_report ("Could not open '%s'" , filename); +error_report ("Could not open '%s'" , backing_file->value.s); goto out; }bdrv_get_geometry (bs, &size);
Signature · 1 line
1.7.2.3
Quoted 5 lines · Stefan Hajnoczi
The backing format should be honored during image creation. For some reason we currently use the image format to open the backing file. This fails when the backing file has a different format than the image being created. Keep the image and backing format drivers completely separate.
Quoted 8 lines
Also print the backing filename if there is an error opening the backing file instead of the image filename.
Signed-off-by Stefan Hajnoczi <[email protected]>--- block.c | 8 +++++--- 1 files changed, 5 insertions(+), 3 deletions(-)
Looks good!
Kevin Wolf
AppliedAm 24.01.2011 10:32, schrieb Stefan Hajnoczi:
Quoted 9 lines
The backing format should be honored during image creation. For some reason we currently use the image format to open the backing file. This fails when the backing file has a different format than the image being created. Keep the image and backing format drivers completely separate.
Also print the backing filename if there is an error opening the backing file instead of the image filename.
Signed-off-by Stefan Hajnoczi <[email protected]>
Thanks, applied to the block branch.
I think we'll want to have a qemu-iotests case for this kind of regressions.
Kevin