Commit 7c96d46ec245d73fd76726588409f9abe4bd5dc1

Authored by aliguori
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
@@ -338,6 +338,7 @@ int bdrv_open2(BlockDriverState *bs, const char *filename, int flags, @@ -338,6 +338,7 @@ int bdrv_open2(BlockDriverState *bs, const char *filename, int flags,
338 if (flags & BDRV_O_SNAPSHOT) { 338 if (flags & BDRV_O_SNAPSHOT) {
339 BlockDriverState *bs1; 339 BlockDriverState *bs1;
340 int64_t total_size; 340 int64_t total_size;
  341 + int is_protocol = 0;
341 342
342 /* if snapshot, we create a temporary backing file and open it 343 /* if snapshot, we create a temporary backing file and open it
343 instead of opening 'filename' directly */ 344 instead of opening 'filename' directly */
@@ -352,10 +353,21 @@ int bdrv_open2(BlockDriverState *bs, const char *filename, int flags, @@ -352,10 +353,21 @@ int bdrv_open2(BlockDriverState *bs, const char *filename, int flags,
352 return -1; 353 return -1;
353 } 354 }
354 total_size = bdrv_getlength(bs1) >> SECTOR_BITS; 355 total_size = bdrv_getlength(bs1) >> SECTOR_BITS;
  356 +
  357 + if (bs1->drv && bs1->drv->protocol_name)
  358 + is_protocol = 1;
  359 +
355 bdrv_delete(bs1); 360 bdrv_delete(bs1);
356 361
357 get_tmp_filename(tmp_filename, sizeof(tmp_filename)); 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 if (bdrv_create(&bdrv_qcow2, tmp_filename, 371 if (bdrv_create(&bdrv_qcow2, tmp_filename,
360 total_size, backing_filename, 0) < 0) { 372 total_size, backing_filename, 0) < 0) {
361 return -1; 373 return -1;