From: Michael Tokarev <mjt@tls.msk.ru>
To: Arthur Gautier <baloo@gandi.net>, qemu-devel@nongnu.org
Cc: qemu-trivial@nongnu.org
Subject: Re: [Qemu-trivial] [PATCH] vmdk: Fix cylinders number during convert
Date: Thu, 23 Oct 2014 10:55:18 +0400 [thread overview]
Message-ID: <5448A656.6030204@msgid.tls.msk.ru> (raw)
In-Reply-To: <1413984320-28585-1-git-send-email-baloo@gandi.net>
On 10/22/2014 05:25 PM, Arthur Gautier wrote:
> We can not rely on int cast to get a correct number of cylinders. The
> cylinders information was wrong in 49.9999% of cases.
>
> This ensures the cylinders always gets the ceiling value.
Good thing, especially the good probability :), and also a good patch
which comes with a test.
But I wonder if anything can break this way? Migration, windows guest
being unable to find its partitions, something else?
And more. What-if our drive size in cylinders will be larger than
the size in bytes? The proposed div_round_up() will increase number
of cylinders, so size in CHS will be larger than size in bytes. Maybe
there was a reason why originally the size in cylinders was calculated
by truncating extra fractional part? What-if guest will try to access
the very last CHS which is incomplete?
Thanks,
/mjt
> Reviewed-by: William Dauchy <william@gandi.net>
> Signed-off-by: Arthur Gautier <baloo@gandi.net>
> ---
> block/vmdk.c | 4 +--
> tests/qemu-iotests/106 | 67 ++++++++++++++++++++++++++++++++++++++++++++++
> tests/qemu-iotests/106.out | 5 ++++
> tests/qemu-iotests/group | 1 +
> 4 files changed, 75 insertions(+), 2 deletions(-)
> create mode 100755 tests/qemu-iotests/106
> create mode 100644 tests/qemu-iotests/106.out
>
> diff --git a/block/vmdk.c b/block/vmdk.c
> index 4ae6c75..c22a6c6 100644
> --- a/block/vmdk.c
> +++ b/block/vmdk.c
> @@ -1928,8 +1928,8 @@ static int vmdk_create(const char *filename, QemuOpts *opts, Error **errp)
> parent_desc_line,
> ext_desc_lines->str,
> (flags & BLOCK_FLAG_COMPAT6 ? 6 : 4),
> - total_size /
> - (int64_t)(63 * number_heads * BDRV_SECTOR_SIZE),
> + DIV_ROUND_UP(total_size,
> + (int64_t)(63 * number_heads * BDRV_SECTOR_SIZE)),
> number_heads,
> adapter_type);
> desc_len = strlen(desc);
[]
WARNING: multiple messages have this Message-ID (diff)
From: Michael Tokarev <mjt@tls.msk.ru>
To: Arthur Gautier <baloo@gandi.net>, qemu-devel@nongnu.org
Cc: qemu-trivial@nongnu.org
Subject: Re: [Qemu-devel] [Qemu-trivial] [PATCH] vmdk: Fix cylinders number during convert
Date: Thu, 23 Oct 2014 10:55:18 +0400 [thread overview]
Message-ID: <5448A656.6030204@msgid.tls.msk.ru> (raw)
In-Reply-To: <1413984320-28585-1-git-send-email-baloo@gandi.net>
On 10/22/2014 05:25 PM, Arthur Gautier wrote:
> We can not rely on int cast to get a correct number of cylinders. The
> cylinders information was wrong in 49.9999% of cases.
>
> This ensures the cylinders always gets the ceiling value.
Good thing, especially the good probability :), and also a good patch
which comes with a test.
But I wonder if anything can break this way? Migration, windows guest
being unable to find its partitions, something else?
And more. What-if our drive size in cylinders will be larger than
the size in bytes? The proposed div_round_up() will increase number
of cylinders, so size in CHS will be larger than size in bytes. Maybe
there was a reason why originally the size in cylinders was calculated
by truncating extra fractional part? What-if guest will try to access
the very last CHS which is incomplete?
Thanks,
/mjt
> Reviewed-by: William Dauchy <william@gandi.net>
> Signed-off-by: Arthur Gautier <baloo@gandi.net>
> ---
> block/vmdk.c | 4 +--
> tests/qemu-iotests/106 | 67 ++++++++++++++++++++++++++++++++++++++++++++++
> tests/qemu-iotests/106.out | 5 ++++
> tests/qemu-iotests/group | 1 +
> 4 files changed, 75 insertions(+), 2 deletions(-)
> create mode 100755 tests/qemu-iotests/106
> create mode 100644 tests/qemu-iotests/106.out
>
> diff --git a/block/vmdk.c b/block/vmdk.c
> index 4ae6c75..c22a6c6 100644
> --- a/block/vmdk.c
> +++ b/block/vmdk.c
> @@ -1928,8 +1928,8 @@ static int vmdk_create(const char *filename, QemuOpts *opts, Error **errp)
> parent_desc_line,
> ext_desc_lines->str,
> (flags & BLOCK_FLAG_COMPAT6 ? 6 : 4),
> - total_size /
> - (int64_t)(63 * number_heads * BDRV_SECTOR_SIZE),
> + DIV_ROUND_UP(total_size,
> + (int64_t)(63 * number_heads * BDRV_SECTOR_SIZE)),
> number_heads,
> adapter_type);
> desc_len = strlen(desc);
[]
next prev parent reply other threads:[~2014-10-23 6:55 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-22 13:25 [Qemu-trivial] [PATCH] vmdk: Fix cylinders number during convert Arthur Gautier
2014-10-22 13:25 ` [Qemu-devel] " Arthur Gautier
2014-10-23 6:55 ` Michael Tokarev [this message]
2014-10-23 6:55 ` [Qemu-devel] [Qemu-trivial] " Michael Tokarev
2014-10-23 8:03 ` [Qemu-trivial] [Qemu-devel] " Markus Armbruster
2014-10-23 8:03 ` [Qemu-devel] [Qemu-trivial] " Markus Armbruster
2014-10-28 16:00 ` [Qemu-trivial] [Qemu-devel] " Stefan Hajnoczi
2014-10-28 16:00 ` [Qemu-devel] [Qemu-trivial] " Stefan Hajnoczi
2014-10-29 1:28 ` [Qemu-trivial] [Qemu-devel] " Fam Zheng
2014-10-29 1:28 ` [Qemu-devel] [Qemu-trivial] " Fam Zheng
2014-10-30 9:09 ` [Qemu-trivial] [Qemu-devel] " Arthur Gautier
2014-10-30 9:09 ` [Qemu-devel] [Qemu-trivial] " Arthur Gautier
2014-10-30 10:27 ` [Qemu-trivial] [Qemu-devel] " Fam Zheng
2014-10-30 10:27 ` [Qemu-devel] [Qemu-trivial] " Fam Zheng
2014-10-30 14:28 ` [Qemu-trivial] [Qemu-devel] " Arthur Gautier
2014-10-30 14:28 ` [Qemu-devel] [Qemu-trivial] " Arthur Gautier
2014-10-31 2:52 ` [Qemu-trivial] [Qemu-devel] " Fam Zheng
2014-10-31 2:52 ` [Qemu-devel] [Qemu-trivial] " Fam Zheng
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=5448A656.6030204@msgid.tls.msk.ru \
--to=mjt@tls.msk.ru \
--cc=baloo@gandi.net \
--cc=qemu-devel@nongnu.org \
--cc=qemu-trivial@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.