Patchwork [v2] block: Fix the use of protocols in backing files

login
register
mail settings
Submitter Stefan Hajnoczi
Date Dec. 2, 2010, 4:54 p.m.
Message ID <1291308853-11011-1-git-send-email-stefanha@linux.vnet.ibm.com>
Download mbox | patch
Permalink /patch/73999/
State New
Headers show

Comments

Stefan Hajnoczi - Dec. 2, 2010, 4:54 p.m.
Backing filenames may contain a protocol.  The code currently doesn't
consider this case and produces filenames that embed "<protocol>:".
Don't combine filenames if the backing filename contains a protocol.

Based on an earlier patch by Anthony Liguori <aliguori@us.ibm.com>.

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

v2:
 * Make backing_format + protocol work
Kevin Wolf - Dec. 2, 2010, 5:06 p.m.
Am 02.12.2010 17:54, schrieb Stefan Hajnoczi:
> Backing filenames may contain a protocol.  The code currently doesn't
> consider this case and produces filenames that embed "<protocol>:".
> Don't combine filenames if the backing filename contains a protocol.
> 
> Based on an earlier patch by Anthony Liguori <aliguori@us.ibm.com>.
> 
> Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>

Thanks, applied to the block branch.

Kevin

Patch

diff --git a/block.c b/block.c
index 59b69e4..de13d1f 100644
--- a/block.c
+++ b/block.c
@@ -611,10 +611,18 @@  int bdrv_open(BlockDriverState *bs, const char *filename, int flags,
         BlockDriver *back_drv = NULL;
 
         bs->backing_hd = bdrv_new("");
-        path_combine(backing_filename, sizeof(backing_filename),
-                     filename, bs->backing_file);
-        if (bs->backing_format[0] != '\0')
+
+        if (path_has_protocol(bs->backing_file)) {
+            pstrcpy(backing_filename, sizeof(backing_filename),
+                    bs->backing_file);
+        } else {
+            path_combine(backing_filename, sizeof(backing_filename),
+                         filename, bs->backing_file);
+        }
+
+        if (bs->backing_format[0] != '\0') {
             back_drv = bdrv_find_format(bs->backing_format);
+        }
 
         /* backing files always opened read-only */
         back_flags =