qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] block: Use backing format driver during image creation
@ 2011-01-24  9:32 Stefan Hajnoczi
  2011-01-24  9:53 ` [Qemu-devel] " Jes Sorensen
  2011-01-24 10:31 ` Kevin Wolf
  0 siblings, 2 replies; 3+ messages in thread
From: Stefan Hajnoczi @ 2011-01-24  9:32 UTC (permalink / raw)
  To: qemu-devel; +Cc: Kevin Wolf, Jes Sorensen, xudong, 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.

Also print the backing filename if there is an error opening the backing
file instead of the image filename.

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
---
 block.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/block.c b/block.c
index ff2795b..7ad3ddf 100644
--- a/block.c
+++ b/block.c
@@ -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);
-- 
1.7.2.3

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [Qemu-devel] Re: [PATCH] block: Use backing format driver during image creation
  2011-01-24  9:32 [Qemu-devel] [PATCH] block: Use backing format driver during image creation Stefan Hajnoczi
@ 2011-01-24  9:53 ` Jes Sorensen
  2011-01-24 10:31 ` Kevin Wolf
  1 sibling, 0 replies; 3+ messages in thread
From: Jes Sorensen @ 2011-01-24  9:53 UTC (permalink / raw)
  To: Stefan Hajnoczi; +Cc: Kevin Wolf, qemu-devel, xudong

On 01/24/11 10:32, Stefan Hajnoczi wrote:
> 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 <stefanha@linux.vnet.ibm.com>
> ---
>  block.c |    8 +++++---
>  1 files changed, 5 insertions(+), 3 deletions(-)
> 

Looks good!

Acked-by: Jes Sorensen <Jes.Sorensen@redhat.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Qemu-devel] Re: [PATCH] block: Use backing format driver during image creation
  2011-01-24  9:32 [Qemu-devel] [PATCH] block: Use backing format driver during image creation Stefan Hajnoczi
  2011-01-24  9:53 ` [Qemu-devel] " Jes Sorensen
@ 2011-01-24 10:31 ` Kevin Wolf
  1 sibling, 0 replies; 3+ messages in thread
From: Kevin Wolf @ 2011-01-24 10:31 UTC (permalink / raw)
  To: Stefan Hajnoczi; +Cc: Jes Sorensen, qemu-devel, xudong

Am 24.01.2011 10:32, schrieb 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.
> 
> Also print the backing filename if there is an error opening the backing
> file instead of the image filename.
> 
> Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>

Thanks, applied to the block branch.

I think we'll want to have a qemu-iotests case for this kind of regressions.

Kevin

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-01-24 10:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-01-24  9:32 [Qemu-devel] [PATCH] block: Use backing format driver during image creation Stefan Hajnoczi
2011-01-24  9:53 ` [Qemu-devel] " Jes Sorensen
2011-01-24 10:31 ` Kevin Wolf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).