Commit 7c96d46ec245d73fd76726588409f9abe4bd5dc1
1 parent
a145ea51
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
Showing
1 changed file
with
13 additions
and
1 deletions
block.c
| ... | ... | @@ -338,6 +338,7 @@ int bdrv_open2(BlockDriverState *bs, const char *filename, int flags, |
| 338 | 338 | if (flags & BDRV_O_SNAPSHOT) { |
| 339 | 339 | BlockDriverState *bs1; |
| 340 | 340 | int64_t total_size; |
| 341 | + int is_protocol = 0; | |
| 341 | 342 | |
| 342 | 343 | /* if snapshot, we create a temporary backing file and open it |
| 343 | 344 | instead of opening 'filename' directly */ |
| ... | ... | @@ -352,10 +353,21 @@ int bdrv_open2(BlockDriverState *bs, const char *filename, int flags, |
| 352 | 353 | return -1; |
| 353 | 354 | } |
| 354 | 355 | total_size = bdrv_getlength(bs1) >> SECTOR_BITS; |
| 356 | + | |
| 357 | + if (bs1->drv && bs1->drv->protocol_name) | |
| 358 | + is_protocol = 1; | |
| 359 | + | |
| 355 | 360 | bdrv_delete(bs1); |
| 356 | 361 | |
| 357 | 362 | get_tmp_filename(tmp_filename, sizeof(tmp_filename)); |
| 358 | - realpath(filename, backing_filename); | |
| 363 | + | |
| 364 | + /* Real path is meaningless for protocols */ | |
| 365 | + if (is_protocol) | |
| 366 | + snprintf(backing_filename, sizeof(backing_filename), | |
| 367 | + "%s", filename); | |
| 368 | + else | |
| 369 | + realpath(filename, backing_filename); | |
| 370 | + | |
| 359 | 371 | if (bdrv_create(&bdrv_qcow2, tmp_filename, |
| 360 | 372 | total_size, backing_filename, 0) < 0) { |
| 361 | 373 | return -1; | ... | ... |