Bug 857616 - qemu-img does not convert qcow2 correctly into VHD
qemu-img does not convert qcow2 correctly into VHD
Status: CLOSED NOTABUG
Product: Fedora
Classification: Fedora
Component: qemu (Show other bugs)
16
x86_64 Linux
unspecified Severity low
: ---
: ---
Assigned To: Fedora Virtualization Maintainers
Fedora Extras Quality Assurance
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2012-09-15 04:10 EDT by Joachim Metz
Modified: 2013-01-09 07:08 EST (History)
10 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2012-09-26 04:37:52 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:


Attachments (Terms of Use)

  None (edit)
Description Joachim Metz 2012-09-15 04:10:23 EDT
Description of problem:
* create qcow2 image
* convert into VHD with qemu-img
* data size of resulting VHD image is incorrect

Version-Release number of selected component (if applicable):
qemu-img-0.15.1-7.fc16.x86_64

qemu-img version 0.15.1, Copyright (c) 2004-2008 Fabrice Bellard

How reproducible:
tested on single image with consistent results.

Steps to Reproduce:
1. create a 16384 M (17179869184 bytes) qcow2 image
2. convert to VHD using:
qemu-img convert -f qcow2 -O vpc image.qcow2 image.vhd


Actual results:
Data size qcow2 image: 17179869184
Data size VHD image:   17180319744

450560 additional bytes in the VHD image

Expected results:
Data size qcow2 image: 17179869184
Data size VHD image:   17179869184

Additional info:
Comment 1 Paolo Bonzini 2012-09-26 04:37:52 EDT
Virtual PC images require the file size to contain an exact number of cylinders.

The size of a disk is 512 * heads * cylinders/head * sectors/cylinder, and there are limitations on the values:

- sectors/cylinder must be 17, 31, or 63

- cylinders/head must be less than 1024 unless sectors/cylinder is 63

- heads must be between 4 and 16 for sectors/cylinder = 17, otherwise always 16

In your case, sectors/cylinder must be 63 (because smaller values only work up to roughly 256MB disks) and heads must be 16.  Thus, the size of the disk must be a multiple of 63*16*512 = 516096.

In fact, the VHD image you get is exactly 512 * 16 heads * 33289 cylinders/head * 63 sectors/cylinder.
Comment 2 Joachim Metz 2012-09-27 02:05:54 EDT
Thanks for the explanation. According to the MS VHD specification this only applies to ATA disks. I'm not sure if MS still uses this restriction in the format, since VHD files can be larger than the 127 GB ATA media limit.

Maybe it's useful that the qemu-img will print a notification if it's changing the characteristics of the disk image.
Comment 3 Paolo Bonzini 2012-09-27 06:54:27 EDT
My reading of the specification is that anything above 127GB will specify 65535/16/255 as the geometry, but your disk is smaller than that so it should be rounded.

> Maybe it's useful that the qemu-img will print a notification if it's changing 
> the characteristics of the disk image.

Yes, that would be useful.

Note You need to log in before you can comment on or make changes to this bug.