summaryrefslogtreecommitdiff
path: root/block.c
diff options
context:
space:
mode:
authorbellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162>2006-08-06 13:35:09 +0000
committerbellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162>2006-08-06 13:35:09 +0000
commitd15a771da15513560371443bd361abbcf51f70b8 (patch)
treefab5d442d7f396b46603e577c980674a2d123d85 /block.c
parenta946592212874f1e214e0db365c29e8de1179847 (diff)
downloadqemu-d15a771da15513560371443bd361abbcf51f70b8.tar.gz
qcow2 is now used for '-snapshot' - keep BlockDriverState.total_sectors
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@2094 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'block.c')
-rw-r--r--block.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/block.c b/block.c
index 529dd4e250..dacee2f7fb 100644
--- a/block.c
+++ b/block.c
@@ -296,7 +296,7 @@ int bdrv_open2(BlockDriverState *bs, const char *filename, int flags,
bdrv_delete(bs1);
get_tmp_filename(tmp_filename, sizeof(tmp_filename));
- if (bdrv_create(&bdrv_qcow, tmp_filename,
+ if (bdrv_create(&bdrv_qcow2, tmp_filename,
total_size, filename, 0) < 0) {
return -1;
}
@@ -335,7 +335,9 @@ int bdrv_open2(BlockDriverState *bs, const char *filename, int flags,
qemu_free(bs->opaque);
return ret;
}
-
+ if (drv->bdrv_getlength) {
+ bs->total_sectors = bdrv_getlength(bs) >> SECTOR_BITS;
+ }
#ifndef _WIN32
if (bs->is_temporary) {
unlink(filename);
@@ -647,11 +649,7 @@ int64_t bdrv_getlength(BlockDriverState *bs)
void bdrv_get_geometry(BlockDriverState *bs, int64_t *nb_sectors_ptr)
{
- int64_t size;
- size = bdrv_getlength(bs);
- if (size < 0)
- size = 0;
- *nb_sectors_ptr = size >> SECTOR_BITS;
+ *nb_sectors_ptr = bs->total_sectors;
}
/* force a given boot sector. */