Revert "block/vpc: Fix size calculation"
This reverts commit f880defbb06708d30a38ce9f2667067626acdd38. Jeff Cody's testing revealed that the interpretation of size differs even between VirtualPC and HyperV. Revert this so there is time to consider the impact of any backwards incompatible behavior this change creates. Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
parent
da888d37b0
commit
33ccf6675f
14
block/vpc.c
14
block/vpc.c
@ -34,8 +34,6 @@
|
|||||||
|
|
||||||
#define HEADER_SIZE 512
|
#define HEADER_SIZE 512
|
||||||
|
|
||||||
#define VHD_SECTOR_SIZE 512
|
|
||||||
|
|
||||||
//#define CACHE
|
//#define CACHE
|
||||||
|
|
||||||
enum vhd_type {
|
enum vhd_type {
|
||||||
@ -206,13 +204,11 @@ static int vpc_open(BlockDriverState *bs, int flags)
|
|||||||
/* Write 'checksum' back to footer, or else will leave it with zero. */
|
/* Write 'checksum' back to footer, or else will leave it with zero. */
|
||||||
footer->checksum = be32_to_cpu(checksum);
|
footer->checksum = be32_to_cpu(checksum);
|
||||||
|
|
||||||
/* The visible size of a image in Virtual PC depends on the guest:
|
// The visible size of a image in Virtual PC depends on the geometry
|
||||||
* QEMU and other emulators report the real size (here in sectors).
|
// rather than on the size stored in the footer (the size in the footer
|
||||||
* All modern operating systems use this real size.
|
// is too large usually)
|
||||||
* Very old operating systems use CHS values to calculate the total size.
|
bs->total_sectors = (int64_t)
|
||||||
* This calculated size is usually smaller than the real size.
|
be16_to_cpu(footer->cyls) * footer->heads * footer->secs_per_cyl;
|
||||||
*/
|
|
||||||
bs->total_sectors = be64_to_cpu(footer->size) / VHD_SECTOR_SIZE;
|
|
||||||
|
|
||||||
/* Allow a maximum disk size of approximately 2 TB */
|
/* Allow a maximum disk size of approximately 2 TB */
|
||||||
if (bs->total_sectors >= 65535LL * 255 * 255) {
|
if (bs->total_sectors >= 65535LL * 255 * 255) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user