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.
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 address hidden>
---
block.c | 8 +++++---
1 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/block.c b/block.c create( const char *filename, const char *fmt, Parameter *backing_fmt, *backing_file; rState *bs = NULL;
index ff2795b..7ad3ddf 100644
--- a/block.c
+++ b/block.c
@@ -2778,6 +2778,7 @@ int bdrv_img_
QEMUOption
BlockDrive
BlockDriver *drv, *proto_drv;
+ BlockDriver *backing_drv = NULL;
int ret = 0;
/* Find driver and parse its options */ create( const char *filename, const char *fmt,
@@ -2846,7 +2847,8 @@ int bdrv_img_
backing_fmt = get_option_ parameter( param, BLOCK_OPT_ BACKING_ FMT); fmt->value. s) { find_format( backing_ fmt->value. s)) { format( backing_ fmt->value. s);
error_ report( "Unknown backing file format '%s'",
backing_ fmt->value. s); create( const char *filename, const char *fmt,
if (backing_fmt && backing_
- if (!bdrv_
+ backing_drv = bdrv_find_
+ if (!backing_drv) {
ret = -EINVAL;
@@ -2863,9 +2865,9 @@ int bdrv_img_
bs = bdrv_new("");
- ret = bdrv_open(bs, backing_ file->value. s, flags, drv); file->value. s, flags, backing_drv); file->value. s);
goto out;
bdrv_ get_geometry( bs, &size);
+ ret = bdrv_open(bs, backing_
if (ret < 0) {
- error_report("Could not open '%s'", filename);
+ error_report("Could not open '%s'", backing_
}
--
1.7.2.3