From: Lucian Petrut <petrutlucian94@gmail.com>
To: qemu-devel@nongnu.org
Cc: kwolf@redhat.com, Lucian Petrut <lpetrut@cloudbasesolutions.com>
Subject: [Qemu-devel] block/vpc: Fix vhd extra sectors issue
Date: Fri, 13 Nov 2015 17:32:04 +0200 [thread overview]
Message-ID: <1447428724-28116-1-git-send-email-lpetrut@cloudbasesolutions.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 597 bytes --]
At the moment, qemu-img extends new image virtual sizes based
on the CHS algorithm provided by the VHD specs in order to
ensure that the disk geometry (and payload as seen by some
guests which use the CHS value) can fit in the requested disk.
This patch drops this behavior, as it breaks compatibility with
Azure, which requires the MB alignment to be preserved.
Signed-off-by: Lucian Petrut <lpetrut@cloudbasesolutions.com>
---
Proposed fix for https://bugs.launchpad.net/qemu/+bug/1490611
block/vpc.c | 32 ++++++++------------------------
1 file changed, 8 insertions(+), 24 deletions(-)
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-block-vpc-Fix-vhd-extra-sectors-issue.patch --]
[-- Type: text/x-patch; name="0001-block-vpc-Fix-vhd-extra-sectors-issue.patch", Size: 1978 bytes --]
diff --git a/block/vpc.c b/block/vpc.c
index 299d373..77c0a28 100644
--- a/block/vpc.c
+++ b/block/vpc.c
@@ -762,7 +762,6 @@ static int vpc_create(const char *filename, QemuOpts *opts, Error **errp)
uint8_t buf[1024];
VHDFooter *footer = (VHDFooter *) buf;
char *disk_type_param;
- int i;
uint16_t cyls = 0;
uint8_t heads = 0;
uint8_t secs_per_cyl = 0;
@@ -802,31 +801,16 @@ static int vpc_create(const char *filename, QemuOpts *opts, Error **errp)
goto out;
}
- /*
- * 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.
- *
- * If the image size can't be represented by a spec conform CHS geometry,
- * we set the geometry to 65535 x 16 x 255 (CxHxS) sectors and use
- * the image size from the VHD footer to calculate total_sectors.
- */
- total_sectors = MIN(VHD_MAX_GEOMETRY, total_size / BDRV_SECTOR_SIZE);
- for (i = 0; total_sectors > (int64_t)cyls * heads * secs_per_cyl; i++) {
- calculate_geometry(total_sectors + i, &cyls, &heads, &secs_per_cyl);
- }
-
- if ((int64_t)cyls * heads * secs_per_cyl == VHD_MAX_GEOMETRY) {
- total_sectors = total_size / BDRV_SECTOR_SIZE;
+ total_sectors = total_size / BDRV_SECTOR_SIZE;
+ if (total_sectors > VHD_MAX_SECTORS) {
/* Allow a maximum disk size of approximately 2 TB */
- if (total_sectors > VHD_MAX_SECTORS) {
- ret = -EFBIG;
- goto out;
- }
- } else {
- total_sectors = (int64_t)cyls * heads * secs_per_cyl;
- total_size = total_sectors * BDRV_SECTOR_SIZE;
+ ret = -EFBIG;
+ goto out;
}
+ /*
+ * Calculate geometry.
+ */
+ calculate_geometry(total_sectors, &cyls, &heads, &secs_per_cyl);
/* Prepare the Hard Disk Footer */
memset(buf, 0, 1024);
next reply other threads:[~2015-11-13 15:32 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-13 15:32 Lucian Petrut [this message]
2015-11-16 9:17 ` [Qemu-devel] block/vpc: Fix vhd extra sectors issue Kevin Wolf
2015-11-16 12:22 ` Jeff Cody
2015-11-16 12:48 ` Peter Lieven
2015-11-16 20:58 ` Max Reitz
2015-11-16 21:08 ` Max Reitz
2015-11-17 18:46 ` Eric Blake
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1447428724-28116-1-git-send-email-lpetrut@cloudbasesolutions.com \
--to=petrutlucian94@gmail.com \
--cc=kwolf@redhat.com \
--cc=lpetrut@cloudbasesolutions.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).