[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 09/43] block: vpc support for ~2 TB disks
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PATCH 09/43] block: vpc support for ~2 TB disks |
Date: |
Thu, 13 Dec 2012 16:10:16 +0100 |
From: Charles Arnold <address@hidden>
The VHD specification allows for up to a 2 TB disk size. The current
implementation in qemu emulates EIDE and ATA-2 hardware which only allows
for up to 127 GB. This disk size limitation can be overridden by allowing
up to 255 heads instead of the normal 4 bit limitation of 16. Doing so
allows disk images to be created of up to nearly 2 TB. This change does
not violate the VHD format specification nor does it change how smaller
disks (ie, <=127GB) are defined.
[Charles Arnold also writes: "In analyzing a 160 GB VHD fixed disk image
created on Windows 2008 R2, it appears that MS is also ignoring the CHS
values in the footer geometry field in whatever driver they use for
accessing the image. The CHS values are set at 65535,16,255 which
obviously doesn't represent an image size of 160 GB." -- Stefan]
Signed-off-by: Charles Arnold <address@hidden>
Reviewed-by: Paolo Bonzini <address@hidden>
Signed-off-by: Stefan Hajnoczi <address@hidden>
---
block/vpc.c | 17 +++++++++++++----
1 files changed, 13 insertions(+), 4 deletions(-)
diff --git a/block/vpc.c b/block/vpc.c
index f14c6ae..566e9a3 100644
--- a/block/vpc.c
+++ b/block/vpc.c
@@ -201,7 +201,8 @@ static int vpc_open(BlockDriverState *bs, int flags)
bs->total_sectors = (int64_t)
be16_to_cpu(footer->cyls) * footer->heads * footer->secs_per_cyl;
- if (bs->total_sectors >= 65535 * 16 * 255) {
+ /* Allow a maximum disk size of approximately 2 TB */
+ if (bs->total_sectors >= 65535LL * 255 * 255) {
err = -EFBIG;
goto fail;
}
@@ -527,19 +528,27 @@ static coroutine_fn int vpc_co_write(BlockDriverState
*bs, int64_t sector_num,
* Note that the geometry doesn't always exactly match total_sectors but
* may round it down.
*
- * Returns 0 on success, -EFBIG if the size is larger than 127 GB
+ * Returns 0 on success, -EFBIG if the size is larger than ~2 TB. Override
+ * the hardware EIDE and ATA-2 limit of 16 heads (max disk size of 127 GB)
+ * and instead allow up to 255 heads.
*/
static int calculate_geometry(int64_t total_sectors, uint16_t* cyls,
uint8_t* heads, uint8_t* secs_per_cyl)
{
uint32_t cyls_times_heads;
- if (total_sectors > 65535 * 16 * 255)
+ /* Allow a maximum disk size of approximately 2 TB */
+ if (total_sectors > 65535LL * 255 * 255) {
return -EFBIG;
+ }
if (total_sectors > 65535 * 16 * 63) {
*secs_per_cyl = 255;
- *heads = 16;
+ if (total_sectors > 65535 * 16 * 255) {
+ *heads = 255;
+ } else {
+ *heads = 16;
+ }
cyls_times_heads = total_sectors / *secs_per_cyl;
} else {
*secs_per_cyl = 17;
--
1.7.6.5
- [Qemu-devel] [PULL 00/43] Block patches, Kevin Wolf, 2012/12/13
- [Qemu-devel] [PATCH 01/43] tests: use aio_poll() instead of aio_flush() in test-aio.c, Kevin Wolf, 2012/12/13
- [Qemu-devel] [PATCH 04/43] aio: Get rid of qemu_aio_flush(), Kevin Wolf, 2012/12/13
- [Qemu-devel] [PATCH 03/43] block: Improve bdrv_aio_co_cancel_em, Kevin Wolf, 2012/12/13
- [Qemu-devel] [PATCH 02/43] tests: avoid qemu_aio_flush() in test-thread-pool.c, Kevin Wolf, 2012/12/13
- [Qemu-devel] [PATCH 06/43] block: Avoid second open for format probing, Kevin Wolf, 2012/12/13
- [Qemu-devel] [PATCH 09/43] block: vpc support for ~2 TB disks,
Kevin Wolf <=
- [Qemu-devel] [PATCH 12/43] block: simplify default_drive, Kevin Wolf, 2012/12/13
- [Qemu-devel] [PATCH 07/43] virtio-blk: Remove duplicate property definition, Kevin Wolf, 2012/12/13
- [Qemu-devel] [PATCH 05/43] block: Factor out bdrv_open_flags, Kevin Wolf, 2012/12/13
- [Qemu-devel] [PATCH 10/43] raw-posix: inline paio_ioctl into hdev_aio_ioctl, Kevin Wolf, 2012/12/13
- [Qemu-devel] [PATCH 16/43] qmp: qmp_transaction(): pass Error object to bdrv_img_create(), Kevin Wolf, 2012/12/13
- [Qemu-devel] [PATCH 13/43] block: bdrv_img_create(): add Error ** argument, Kevin Wolf, 2012/12/13
- [Qemu-devel] [PATCH 14/43] qemu-img: img_create(): pass Error object to bdrv_img_create(), Kevin Wolf, 2012/12/13
- [Qemu-devel] [PATCH 08/43] block: vpc initialize the uuid footer field, Kevin Wolf, 2012/12/13
- [Qemu-devel] [PATCH 17/43] qmp: qmp_drive_mirror(): pass Error object to bdrv_img_create(), Kevin Wolf, 2012/12/13
- [Qemu-devel] [PATCH 11/43] Support default block interfaces per QEMUMachine, Kevin Wolf, 2012/12/13