block/vpc: choose size calculation method based on creator_app field
commitc540d53ac849f385521acb7552ade4f6d3f55ca6
authorJeff Cody <jcody@redhat.com>
Thu, 25 Feb 2016 17:27:27 +0000 (25 12:27 -0500)
committerKevin Wolf <kwolf@redhat.com>
Mon, 14 Mar 2016 15:46:42 +0000 (14 16:46 +0100)
tree9ea32123150e33798746254206fe995c3488f059
parentc21cc6ca989ebbeaed3e601ae4e521afbff5df54
block/vpc: choose size calculation method based on creator_app field

The VHD file format is used by both Virtual PC, and Hyper-V.  However,
how the virtual disk size is calculated varies between the two.

Virtual PC uses the CHS drive parameters to determine the drive size.
Hyper-V, on the other hand, uses the current_size field in the footer
when determining image size.

This is problematic for a few reasons:

* VHD images from Hyper-V, using CHS calculations, will likely be
  trunctated.

* If we just rely always on current_size, then QEMU may have data
  compatibility issues with Virtual PC (we may write too much data
  into a VHD file to be used by Virtual PC, for instance).

* Existing VHD images created by QEMU have used the CHS calculations,
  except for images exceeding the 127GB limit.  We want to remain
  compatible with our own generated images.

Luckily, the VHD specification defines a 'Creator App' field, that is
used to indicate what software created the VHD file.

This patch does two things:

    1. Uses the 'Creator App' field to help determine how to calculate
       size, and

    2. Adds a VPC format option 'force_size_calc', so that the user can
       override the 'Creator App' auto-detection, in case there exist
       VHD images with unknown or contradictory 'Creator App' entries.

N.B.: We currently use the maximum CHS value as an indication to use the
current_size field.  This patch does not change that, even with the
'force_size_calc' option.

Signed-off-by: Jeff Cody <jcody@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block/vpc.c