aboutsummaryrefslogtreecommitdiff
path: root/block.c
diff options
context:
space:
mode:
authoraliguori <aliguori@c046a42c-6fe2-441c-8c8c-71466251a162>2008-09-12 17:54:13 +0000
committeraliguori <aliguori@c046a42c-6fe2-441c-8c8c-71466251a162>2008-09-12 17:54:13 +0000
commit7c96d46ec245d73fd76726588409f9abe4bd5dc1 (patch)
tree37937dfeeb7b4836b51684e6380f623a6dc98e96 /block.c
parenta145ea512061fb87f492605cad3f26dbb8293c99 (diff)
downloadqemu-7c96d46ec245d73fd76726588409f9abe4bd5dc1.zip
qemu-7c96d46ec245d73fd76726588409f9abe4bd5dc1.tar.gz
qemu-7c96d46ec245d73fd76726588409f9abe4bd5dc1.tar.bz2
Let snapshot work with protocols
realpath will horribly mangle a protocol so avoid calling it if the backing file is a protocol. git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5200 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'block.c')
-rw-r--r--block.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/block.c b/block.c
index e81df0a..52c8f37 100644
--- a/block.c
+++ b/block.c
@@ -338,6 +338,7 @@ int bdrv_open2(BlockDriverState *bs, const char *filename, int flags,
if (flags & BDRV_O_SNAPSHOT) {
BlockDriverState *bs1;
int64_t total_size;
+ int is_protocol = 0;
/* if snapshot, we create a temporary backing file and open it
instead of opening 'filename' directly */
@@ -352,10 +353,21 @@ int bdrv_open2(BlockDriverState *bs, const char *filename, int flags,
return -1;
}
total_size = bdrv_getlength(bs1) >> SECTOR_BITS;
+
+ if (bs1->drv && bs1->drv->protocol_name)
+ is_protocol = 1;
+
bdrv_delete(bs1);
get_tmp_filename(tmp_filename, sizeof(tmp_filename));
- realpath(filename, backing_filename);
+
+ /* Real path is meaningless for protocols */
+ if (is_protocol)
+ snprintf(backing_filename, sizeof(backing_filename),
+ "%s", filename);
+ else
+ realpath(filename, backing_filename);
+
if (bdrv_create(&bdrv_qcow2, tmp_filename,
total_size, backing_filename, 0) < 0) {
return -1;