Received: from eggs.gnu.org ([2001:4830:134:3::10]:59165) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bFz22-0005Vy-OH for qemu-devel@nongnu.org; Thu, 23 Jun 2016 03:26:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bFz1x-00018e-Mp for qemu-devel@nongnu.org; Thu, 23 Jun 2016 03:26:34 -0400 Received: from indium.canonical.com ([91.189.90.7]:38574) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bFz1x-00018X-Gl for qemu-devel@nongnu.org; Thu, 23 Jun 2016 03:26:29 -0400 Received: from loganberry.canonical.com ([91.189.90.37]) by indium.canonical.com with esmtp (Exim 4.76 #1 (Debian)) id 1bFz1w-0003rv-L8 for ; Thu, 23 Jun 2016 07:26:28 +0000 Received: from loganberry.canonical.com (localhost [127.0.0.1]) by loganberry.canonical.com (Postfix) with ESMTP id 93DED2E80C8 for ; Thu, 23 Jun 2016 07:26:28 +0000 (UTC) MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Date: Thu, 23 Jun 2016 07:17:09 -0000 From: "T. Huth" <1105670@bugs.launchpad.net> Reply-To: Bug 1105670 <1105670@bugs.launchpad.net> Sender: bounces@canonical.com References: <20130126032127.27241.69274.malonedeb@gac.canonical.com> Message-Id: <20160623071709.26218.12808.malone@gac.canonical.com> Errors-To: bounces@canonical.com Subject: [Qemu-devel] [Bug 1105670] Re: Converting vpc image to raw results in an image that is smaller than it should be. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Looks like the fix for this problem has been included here: http://git.qemu.org/?p=3Dqemu.git;a=3Dcommitdiff;h=3Df880defbb06708d30a38ce ... so I think it should be OK now to close this ticket. ** Changed in: qemu Status: New =3D> Fix Released -- = You received this bug notification because you are a member of qemu- devel-ml, which is subscribed to QEMU. https://bugs.launchpad.net/bugs/1105670 Title: Converting vpc image to raw results in an image that is smaller than it should be. Status in QEMU: Fix Released Bug description: When using qemu-img to convert a 3GB dynamic vhd image to raw, the resultant image was smaller than what I was expecting. I was expecting a new raw image of size 3221225472bytes but the size generated was 3220955136bytes. I had similar results when I used a fixed vhd image and explicitly specified the format as vpc. Details about my configuration OS: Centos 5.4, 64bit Qemu used 1.1.1-1, but also saw the same behavior on 1.3.3 and the develo= pment build. Command used for dynamic vhd image file: qemu-img convert -O raw inputDynamic.vhd outputFromDynamic.raw Command used for fixed vhd image file: qemu-img convert f vpc -O raw inputFixed.vhd outputFromFixed.raw Both images were first created on hyperv running on windows 2008 r2 using the hyperv manager interface. I think I tried their diskpart utility and had the same results. Output from the following commands (I saw this on Bug#893956) $ hexdump -C -n 512 image.VHD 00000000 63 6f 6e 65 63 74 69 78 00 00 00 02 00 01 00 00 |conectix....= ....| 00000010 00 00 00 00 00 00 02 00 18 25 da 57 77 69 6e 20 |.........%.W= win | 00000020 00 06 00 01 57 69 32 6b 00 00 00 00 c0 00 00 00 |....Wi2k....= ....| 00000030 00 00 00 00 c0 00 00 00 18 61 10 3f 00 00 00 03 |.........a.?= ....| 00000040 ff ff ee b1 83 34 83 78 26 0a 13 4f 99 9c 9e e9 |.....4.x&..O= ....| 00000050 dc 93 21 d1 00 00 00 00 00 00 00 00 00 00 00 00 |..!.........= ....| 00000060 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |............= ....| * 00000200 $ hexdump -C -n 512 -s $(($(ls -l image.VHD | awk '{ print $5 }') - 512))= image.VHD 56057e00 63 6f 6e 65 63 74 69 78 00 00 00 02 00 01 00 00 |conectix....= ....| 56057e10 00 00 00 00 00 00 02 00 18 25 da 57 77 69 6e 20 |.........%.W= win | 56057e20 00 06 00 01 57 69 32 6b 00 00 00 00 c0 00 00 00 |....Wi2k....= ....| 56057e30 00 00 00 00 c0 00 00 00 18 61 10 3f 00 00 00 03 |.........a.?= ....| 56057e40 ff ff ee b1 83 34 83 78 26 0a 13 4f 99 9c 9e e9 |.....4.x&..O= ....| 56057e50 dc 93 21 d1 00 00 00 00 00 00 00 00 00 00 00 00 |..!.........= ....| 56057e60 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |............= ....| * 56058000 ----- When I investigated this a bit further I found that the disk geometry cal= culations needed to be one cylinder more than the information stored in the= footer size information. The disk size information in the file was 322122= 5472 bytes, and the disk geometry was cylinders 6241, heads 10, sectors per= cylinder 63. Multiplying that together and with a sector size of 512 give= s 3220955136bytes...the size qemu made the image as, but the new image is = now smaller than the original image. When I added one to the cylinder size I got a size larger than I was expecting, but large enough to hold all of the data from the original image. My suggested fix for this is to add one to the cylinder size when reading a vhd image file. And subtracting one when writing out to a vhd file. I've attached a patch with the suggested fix. Please let me know if you need additional information. To manage notifications about this bug go to: https://bugs.launchpad.net/qemu/+bug/1105670/+subscriptions