* [PATCH for-5.0] vpc: Don't round up already aligned BAT sizes
@ 2020-04-02 9:36 Kevin Wolf
2020-04-02 10:45 ` Philippe Mathieu-Daudé
2020-04-03 8:55 ` Max Reitz
0 siblings, 2 replies; 5+ messages in thread
From: Kevin Wolf @ 2020-04-02 9:36 UTC (permalink / raw)
To: qemu-block; +Cc: kwolf, qemu-devel, mreitz
As reported on Launchpad, Azure apparently doesn't accept images for
upload that are not both aligned to 1 MB blocks and have a BAT size that
matches the image size exactly.
As far as I can tell, there is no real reason why we create a BAT that
is one entry longer than necessary for aligned image sizes, so change
that.
(Even though the condition is only mentioned as "should" in the spec and
previous products accepted larger BATs - but we'll try to maintain
compatibility with as many of Microsoft's ever-changing interpretations
of the VHD spec as possible.)
Fixes: https://bugs.launchpad.net/bugs/1870098
Reported-by: Tobias Witek
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
block/vpc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/block/vpc.c b/block/vpc.c
index 6df75e22dc..d8141b52da 100644
--- a/block/vpc.c
+++ b/block/vpc.c
@@ -835,7 +835,7 @@ static int create_dynamic_disk(BlockBackend *blk, uint8_t *buf,
/* Write the footer (twice: at the beginning and at the end) */
block_size = 0x200000;
- num_bat_entries = (total_sectors + block_size / 512) / (block_size / 512);
+ num_bat_entries = DIV_ROUND_UP(total_sectors, block_size / 512);
ret = blk_pwrite(blk, offset, buf, HEADER_SIZE, 0);
if (ret < 0) {
--
2.20.1
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH for-5.0] vpc: Don't round up already aligned BAT sizes
2020-04-02 9:36 [PATCH for-5.0] vpc: Don't round up already aligned BAT sizes Kevin Wolf
@ 2020-04-02 10:45 ` Philippe Mathieu-Daudé
2020-04-03 8:55 ` Max Reitz
1 sibling, 0 replies; 5+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-04-02 10:45 UTC (permalink / raw)
To: Kevin Wolf, qemu-block; +Cc: qemu-devel, mreitz
On 4/2/20 11:36 AM, Kevin Wolf wrote:
> As reported on Launchpad, Azure apparently doesn't accept images for
> upload that are not both aligned to 1 MB blocks and have a BAT size that
> matches the image size exactly.
>
> As far as I can tell, there is no real reason why we create a BAT that
> is one entry longer than necessary for aligned image sizes, so change
> that.
>
> (Even though the condition is only mentioned as "should" in the spec and
> previous products accepted larger BATs - but we'll try to maintain
> compatibility with as many of Microsoft's ever-changing interpretations
> of the VHD spec as possible.)
>
> Fixes: https://bugs.launchpad.net/bugs/1870098
> Reported-by: Tobias Witek
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---
> block/vpc.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/block/vpc.c b/block/vpc.c
> index 6df75e22dc..d8141b52da 100644
> --- a/block/vpc.c
> +++ b/block/vpc.c
> @@ -835,7 +835,7 @@ static int create_dynamic_disk(BlockBackend *blk, uint8_t *buf,
>
> /* Write the footer (twice: at the beginning and at the end) */
> block_size = 0x200000;
> - num_bat_entries = (total_sectors + block_size / 512) / (block_size / 512);
> + num_bat_entries = DIV_ROUND_UP(total_sectors, block_size / 512);
>
> ret = blk_pwrite(blk, offset, buf, HEADER_SIZE, 0);
> if (ret < 0) {
>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH for-5.0] vpc: Don't round up already aligned BAT sizes
2020-04-02 9:36 [PATCH for-5.0] vpc: Don't round up already aligned BAT sizes Kevin Wolf
2020-04-02 10:45 ` Philippe Mathieu-Daudé
@ 2020-04-03 8:55 ` Max Reitz
2020-04-03 12:04 ` Kevin Wolf
1 sibling, 1 reply; 5+ messages in thread
From: Max Reitz @ 2020-04-03 8:55 UTC (permalink / raw)
To: Kevin Wolf, qemu-block; +Cc: qemu-devel
[-- Attachment #1.1: Type: text/plain, Size: 1737 bytes --]
On 02.04.20 11:36, Kevin Wolf wrote:
> As reported on Launchpad, Azure apparently doesn't accept images for
> upload that are not both aligned to 1 MB blocks and have a BAT size that
> matches the image size exactly.
>
> As far as I can tell, there is no real reason why we create a BAT that
> is one entry longer than necessary for aligned image sizes, so change
> that.
>
> (Even though the condition is only mentioned as "should" in the spec and
> previous products accepted larger BATs - but we'll try to maintain
> compatibility with as many of Microsoft's ever-changing interpretations
> of the VHD spec as possible.)
So as far as I can tell we still don’t ensure that the image is aligned
to 1 MB blocks?
Well, as long as it’s at least possible for the user to create valid
images, that’s better.
> Fixes: https://bugs.launchpad.net/bugs/1870098
> Reported-by: Tobias Witek
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---
> block/vpc.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/block/vpc.c b/block/vpc.c
> index 6df75e22dc..d8141b52da 100644
> --- a/block/vpc.c
> +++ b/block/vpc.c
> @@ -835,7 +835,7 @@ static int create_dynamic_disk(BlockBackend *blk, uint8_t *buf,
>
> /* Write the footer (twice: at the beginning and at the end) */
> block_size = 0x200000;
> - num_bat_entries = (total_sectors + block_size / 512) / (block_size / 512);
> + num_bat_entries = DIV_ROUND_UP(total_sectors, block_size / 512);
And the old code just looks like a wrong DIV_ROUND_UP() attempt. So:
Reviewed-by: Max Reitz <mreitz@redhat.com>
>
> ret = blk_pwrite(blk, offset, buf, HEADER_SIZE, 0);
> if (ret < 0) {
>
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH for-5.0] vpc: Don't round up already aligned BAT sizes
2020-04-03 8:55 ` Max Reitz
@ 2020-04-03 12:04 ` Kevin Wolf
2020-04-03 13:09 ` Max Reitz
0 siblings, 1 reply; 5+ messages in thread
From: Kevin Wolf @ 2020-04-03 12:04 UTC (permalink / raw)
To: Max Reitz; +Cc: qemu-devel, qemu-block
[-- Attachment #1: Type: text/plain, Size: 1302 bytes --]
Am 03.04.2020 um 10:55 hat Max Reitz geschrieben:
> On 02.04.20 11:36, Kevin Wolf wrote:
> > As reported on Launchpad, Azure apparently doesn't accept images for
> > upload that are not both aligned to 1 MB blocks and have a BAT size that
> > matches the image size exactly.
> >
> > As far as I can tell, there is no real reason why we create a BAT that
> > is one entry longer than necessary for aligned image sizes, so change
> > that.
> >
> > (Even though the condition is only mentioned as "should" in the spec and
> > previous products accepted larger BATs - but we'll try to maintain
> > compatibility with as many of Microsoft's ever-changing interpretations
> > of the VHD spec as possible.)
>
> So as far as I can tell we still don’t ensure that the image is aligned
> to 1 MB blocks?
>
> Well, as long as it’s at least possible for the user to create valid
> images, that’s better.
Yes, we still allow other image sizes because Azure is not the only
product using VHD images, but it is the only one (to my knowledge) that
makes this requirement.
We're trying to stay compatible with at least three different Microsoft
products (VirtualPC, HyperV, Azure) that all have their own
interpretation of the spec and are inconsistent with each other.
Kevin
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 801 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH for-5.0] vpc: Don't round up already aligned BAT sizes
2020-04-03 12:04 ` Kevin Wolf
@ 2020-04-03 13:09 ` Max Reitz
0 siblings, 0 replies; 5+ messages in thread
From: Max Reitz @ 2020-04-03 13:09 UTC (permalink / raw)
To: Kevin Wolf; +Cc: qemu-devel, qemu-block
[-- Attachment #1.1: Type: text/plain, Size: 1403 bytes --]
On 03.04.20 14:04, Kevin Wolf wrote:
> Am 03.04.2020 um 10:55 hat Max Reitz geschrieben:
>> On 02.04.20 11:36, Kevin Wolf wrote:
>>> As reported on Launchpad, Azure apparently doesn't accept images for
>>> upload that are not both aligned to 1 MB blocks and have a BAT size that
>>> matches the image size exactly.
>>>
>>> As far as I can tell, there is no real reason why we create a BAT that
>>> is one entry longer than necessary for aligned image sizes, so change
>>> that.
>>>
>>> (Even though the condition is only mentioned as "should" in the spec and
>>> previous products accepted larger BATs - but we'll try to maintain
>>> compatibility with as many of Microsoft's ever-changing interpretations
>>> of the VHD spec as possible.)
>>
>> So as far as I can tell we still don’t ensure that the image is aligned
>> to 1 MB blocks?
>>
>> Well, as long as it’s at least possible for the user to create valid
>> images, that’s better.
>
> Yes, we still allow other image sizes because Azure is not the only
> product using VHD images, but it is the only one (to my knowledge) that
> makes this requirement.
>
> We're trying to stay compatible with at least three different Microsoft
> products (VirtualPC, HyperV, Azure) that all have their own
> interpretation of the spec and are inconsistent with each other.
OK, nice. Thanks for the explanation!
Max
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-04-03 13:11 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-04-02 9:36 [PATCH for-5.0] vpc: Don't round up already aligned BAT sizes Kevin Wolf
2020-04-02 10:45 ` Philippe Mathieu-Daudé
2020-04-03 8:55 ` Max Reitz
2020-04-03 12:04 ` Kevin Wolf
2020-04-03 13:09 ` Max Reitz
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).