[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 09/15] vpc: Round up image size during fixed image c
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PATCH 09/15] vpc: Round up image size during fixed image creation |
Date: |
Fri, 10 Feb 2012 13:47:38 +0100 |
The geometry calculation algorithm from the VHD spec rounds the image
size down if it doesn't exactly match a geometry. During image
conversion, this causes the image to be truncated. For dynamic images,
we already have code in place to round up instead, let's do the same for
fixed images.
Signed-off-by: Kevin Wolf <address@hidden>
---
block/vpc.c | 23 ++++++++++-------------
1 files changed, 10 insertions(+), 13 deletions(-)
diff --git a/block/vpc.c b/block/vpc.c
index db6b14b..6b4816f 100644
--- a/block/vpc.c
+++ b/block/vpc.c
@@ -685,24 +685,21 @@ static int vpc_create(const char *filename,
QEMUOptionParameter *options)
return -EIO;
}
+ /*
+ * Calculate matching total_size and geometry. Increase the number of
+ * sectors requested until we get enough (or fail). This ensures that
+ * qemu-img convert doesn't truncate images, but rather rounds up.
+ */
total_sectors = total_size / BDRV_SECTOR_SIZE;
- if (disk_type == VHD_DYNAMIC) {
- /* Calculate matching total_size and geometry. Increase the number of
- sectors requested until we get enough (or fail). */
- for (i = 0; total_sectors > (int64_t)cyls * heads * secs_per_cyl;
- i++) {
- if (calculate_geometry(total_sectors + i,
- &cyls, &heads, &secs_per_cyl)) {
- ret = -EFBIG;
- goto fail;
- }
- }
- } else {
- if (calculate_geometry(total_sectors, &cyls, &heads, &secs_per_cyl)) {
+ for (i = 0; total_sectors > (int64_t)cyls * heads * secs_per_cyl; i++) {
+ if (calculate_geometry(total_sectors + i, &cyls, &heads,
+ &secs_per_cyl))
+ {
ret = -EFBIG;
goto fail;
}
}
+
total_sectors = (int64_t) cyls * heads * secs_per_cyl;
/* Prepare the Hard Disk Footer */
--
1.7.6.5
- [Qemu-devel] [PULL 00/15] Block patches, Kevin Wolf, 2012/02/10
- [Qemu-devel] [PATCH 01/15] cutils: extract buffer_is_zero() from qemu-img.c, Kevin Wolf, 2012/02/10
- [Qemu-devel] [PATCH 02/15] block: add .bdrv_co_write_zeroes() interface, Kevin Wolf, 2012/02/10
- [Qemu-devel] [PATCH 03/15] block: perform zero-detection during copy-on-read, Kevin Wolf, 2012/02/10
- [Qemu-devel] [PATCH 04/15] qed: replace is_write with flags field, Kevin Wolf, 2012/02/10
- [Qemu-devel] [PATCH 05/15] qed: add .bdrv_co_write_zeroes() support, Kevin Wolf, 2012/02/10
- [Qemu-devel] [PATCH 06/15] qemu-io: add write -z option for bdrv_co_write_zeroes, Kevin Wolf, 2012/02/10
- [Qemu-devel] [PATCH 14/15] sheepdog: fix co_recv coroutine context, Kevin Wolf, 2012/02/10
- [Qemu-devel] [PATCH 15/15] AHCI: Masking of IRQs actually masks them, Kevin Wolf, 2012/02/10
- [Qemu-devel] [PATCH 09/15] vpc: Round up image size during fixed image creation,
Kevin Wolf <=
- [Qemu-devel] [PATCH 11/15] qcow2: Keep unknown header extension when rewriting header, Kevin Wolf, 2012/02/10
- [Qemu-devel] [PATCH 12/15] rewrite QEMU_BUILD_BUG_ON, Kevin Wolf, 2012/02/10
- [Qemu-devel] [PATCH 10/15] qcow2: Update whole header at once, Kevin Wolf, 2012/02/10
- [Qemu-devel] [PATCH 08/15] vpc: Add support for Fixed Disk type, Kevin Wolf, 2012/02/10
- [Qemu-devel] [PATCH 13/15] AHCI: Fix port reset race, Kevin Wolf, 2012/02/10
- [Qemu-devel] [PATCH 07/15] iSCSI: add configuration variables for iSCSI, Kevin Wolf, 2012/02/10
- Re: [Qemu-devel] [PULL 00/15] Block patches, Kevin Wolf, 2012/02/15
- Re: [Qemu-devel] [PULL 00/15] Block patches, Anthony Liguori, 2012/02/15