mirror of https://github.com/xemu-project/xemu.git
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
This commit is contained in:
parent
a946592212
commit
d15a771da1
12
block.c
12
block.c
|
@ -296,7 +296,7 @@ int bdrv_open2(BlockDriverState *bs, const char *filename, int flags,
|
||||||
bdrv_delete(bs1);
|
bdrv_delete(bs1);
|
||||||
|
|
||||||
get_tmp_filename(tmp_filename, sizeof(tmp_filename));
|
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) {
|
total_size, filename, 0) < 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -335,7 +335,9 @@ int bdrv_open2(BlockDriverState *bs, const char *filename, int flags,
|
||||||
qemu_free(bs->opaque);
|
qemu_free(bs->opaque);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
if (drv->bdrv_getlength) {
|
||||||
|
bs->total_sectors = bdrv_getlength(bs) >> SECTOR_BITS;
|
||||||
|
}
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
if (bs->is_temporary) {
|
if (bs->is_temporary) {
|
||||||
unlink(filename);
|
unlink(filename);
|
||||||
|
@ -647,11 +649,7 @@ int64_t bdrv_getlength(BlockDriverState *bs)
|
||||||
|
|
||||||
void bdrv_get_geometry(BlockDriverState *bs, int64_t *nb_sectors_ptr)
|
void bdrv_get_geometry(BlockDriverState *bs, int64_t *nb_sectors_ptr)
|
||||||
{
|
{
|
||||||
int64_t size;
|
*nb_sectors_ptr = bs->total_sectors;
|
||||||
size = bdrv_getlength(bs);
|
|
||||||
if (size < 0)
|
|
||||||
size = 0;
|
|
||||||
*nb_sectors_ptr = size >> SECTOR_BITS;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* force a given boot sector. */
|
/* force a given boot sector. */
|
||||||
|
|
|
@ -73,7 +73,8 @@ struct BlockDriver {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct BlockDriverState {
|
struct BlockDriverState {
|
||||||
int64_t total_sectors; /* XXX: will be suppressed */
|
int64_t total_sectors; /* if we are reading a disk image, give its
|
||||||
|
size in sectors */
|
||||||
int read_only; /* if true, the media is read only */
|
int read_only; /* if true, the media is read only */
|
||||||
int inserted; /* if true, the media is present */
|
int inserted; /* if true, the media is present */
|
||||||
int removable; /* if true, the media can be removed */
|
int removable; /* if true, the media can be removed */
|
||||||
|
|
Loading…
Reference in New Issue