Skip to content

Commit

Permalink
vpc: Don't round up already aligned BAT sizes
Browse files Browse the repository at this point in the history
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>
Message-Id: <20200402093603.2369-1-kwolf@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
(cherry picked from commit 3f6de65)
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
  • Loading branch information
kevmw authored and mdroth committed Jun 22, 2020
1 parent 9c2e242 commit ecdb0d5
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion block/vpc.c
Expand Up @@ -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) {
Expand Down

0 comments on commit ecdb0d5

Please sign in to comment.