qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 3/3] block: Fix the use of protocols in backing file


From: Stefan Hajnoczi
Subject: [Qemu-devel] [PATCH 3/3] block: Fix the use of protocols in backing files
Date: Tue, 30 Nov 2010 15:14:16 +0000

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 <address@hidden>.

Signed-off-by: Stefan Hajnoczi <address@hidden>
---
 block.c |   15 +++++++++++----
 1 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/block.c b/block.c
index 59b69e4..c9a6720 100644
--- a/block.c
+++ b/block.c
@@ -611,10 +611,17 @@ 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')
-            back_drv = bdrv_find_format(bs->backing_format);
+        if (path_has_protocol(bs->backing_file)) {
+            back_drv = bdrv_find_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 =
-- 
1.7.2.3




reply via email to

[Prev in Thread] Current Thread [Next in Thread]