summaryrefslogtreecommitdiff
path: root/block.c
diff options
context:
space:
mode:
authorStefan Hajnoczi <stefanha@linux.vnet.ibm.com>2010-12-02 16:54:13 +0000
committerKevin Wolf <kwolf@redhat.com>2010-12-17 16:10:59 +0100
commit8306dde29c324bf90590caaf9a48194c3d8a18f2 (patch)
treef4351fb996f7b48d89d97202bdc95f4dca5b8953 /block.c
parentfc806aa16862ca4e9a75fbd1e156e01375e4d53f (diff)
downloadqemu-8306dde29c324bf90590caaf9a48194c3d8a18f2.tar.gz
qemu-8306dde29c324bf90590caaf9a48194c3d8a18f2.tar.bz2
qemu-8306dde29c324bf90590caaf9a48194c3d8a18f2.zip
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 <aliguori@us.ibm.com>. Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'block.c')
-rw-r--r--block.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/block.c b/block.c
index 65fce8031a..b4aaf41640 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 =