Skip to contentSkip to conversation

block: Fix the use of protocols in backing files

PATCH Applied Stefan Hajnoczi 2 participants 2 messages Dec 2, 2010

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 block: Fix the use of protocols in backing files

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 <[email protected]>.

---
 block.c |   14 +++++++++++---
 1 files changed, 11 insertions(+), 3 deletions(-)

v2:
* Make backing_format + protocol work

block.c +11 -3
index 59b69e4..de13d1f 100644
@@ -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 =
Signature · 1 line
1.7.2.3
Applied
#1 lore raw

Am 02.12.2010 17:54, schrieb Stefan Hajnoczi:

Quoted 7 lines

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 <[email protected]>.

Thanks, applied to the block branch.

Kevin