Fix VHD parsing - Take 2. #364
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Back in the Microsoft Virtual PC days, a VHD file's size was based on "Disk Geometry" instead of simple byte count. However, this method restricts the sizes that the disk can be. So, Hyper-V just ignores the "Disk Geometry" fields and uses the VHD's "Current Size" field instead. Unfortunately,
qemu-img
still by default outputs VHDs using "Disk Geometry". This generally means it has to round up the size. To make matters worse, the new disk size is almost never a multiple of 1 MiB, which can prevent this disk from being uploaded to Azure.When Image Customizer uses
qemu-img
, it knows to pass an option that tellsqemu-img
to use "Current Size" instead of "Disk Geometry". Specifically,-o force_size=on
. But if a user manually callsqemu-img
, they might not know they need to do this.This change adds logic to reject input VHDs that use "Disk Geometry" instead of "Current Size". This will make it easier to catch problematic disks earlier, instead of Image Customizer being blamed for the incorrect disk size.
Checklist