Bug 491981

Summary: Integer wraparound creating a large disk image in VPC format
Product: [Fedora] Fedora Reporter: Daniel Berrangé <berrange>
Component: qemuAssignee: Glauber Costa <gcosta>
Status: CLOSED NEXTRELEASE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: low    
Version: rawhideCC: dwmw2, gcosta, kwolf, markmc, mfkartoz, virt-maint
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: 0.10.4-4.fc11 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2009-04-19 14:43:53 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Daniel Berrangé 2009-03-24 20:05:40 UTC
Description of problem:
Try and create a 5 TB disk image

# qemu-img create -f vpc foo.cow 5000G
Formatting 'foo.cow', fmt=vpc, size=5242880000 kB

...you don't get a 5 TB image out the other side

# qemu-img info foo.cow 
image: foo.cow
file format: vpc
virtual size: 127G (136899993600 bytes)
disk size: 264K

At least qemu-img doesn't SEGV though, so its better than qcow2 :-)

Version-Release number of selected component (if applicable):
qemu-0.10-0.9.kvm20090310git.fc11.x86_64

How reproducible:
Always

Steps to Reproduce:
1.qemu-img create -f vpc foo.cow 5000G
2.
3.
  
Actual results:
127G disk image

Expected results:
5 TB disk image

Additional info:

Comment 1 Glauber Costa 2009-04-01 17:49:40 UTC
Does chris' patch in the qcow2 bz fixes this too?

Comment 2 Daniel Berrangé 2009-04-01 18:22:10 UTC
I can't see how Chris' patch would help, since its against block-qcow2.c not  block-vpc.c  :-)

Comment 3 Kevin Wolf 2009-04-02 15:14:44 UTC
This is not a wraparound but the maximum value supported by the CHS calculation algorithm in the VHD specification - and I tried to stay close to the spec when implementing VHD write support.

Is it even possible to create that large images with Virtual PC? If so, qemu-img should behave the same, even if this means deviating from the spec.

Comment 4 Daniel Berrangé 2009-04-02 15:24:57 UTC
I'm not sure if Virtual PC / VHD spec allows for disks this big - I was just trying to confuse qemu-img code and see what happened :-)

If we can't support 5 TB disks, then I'm happy for qemu-img to explicitly refuse to create this disk, and give an error message back telling the user their requested disk size is too large.

Comment 5 Kevin Wolf 2009-04-02 15:47:41 UTC
I would really like to know what Virtual PC does. Do you have a Windows machine or VM by any chance where you could try this? Currently I don't have the hardware yet to do that myself.

If Virtual PC behaviour matches the spec and the limitation is going to stay, I agree that an error message is a better solution than silently creating a smaller image.

Comment 6 Michael Kartoz 2009-04-10 07:19:19 UTC
Running Virtual PC 2007 SP1 on Vista x64, and creating a "dynamically expanding" virtual hard disk, Virtual PC states that the maximum virtual hard disk size is "130,557 MB".  I tried entering 500000 MB anyhow and it comes back with a message, "Please enter a size value between 3 MB and 130,557 MB."

Interestingly, when I try to create a "fixed-size" virtual hard disk instead, the maximum claims to be 375,493 MB.  I think that is being limited by the free space on the disk at the time I run the utility since I currently have 366 GB free on that partition.  I don't have a larger partition to play with.

Comment 7 Kevin Wolf 2009-04-14 07:32:13 UTC
Thanks for trying it out. This confirms what I found on the internet. I have already sent a patch to qemu-devel last week which aborts with an error message when you want create too large VHD images. It doesn't seem to be applied yet, though.

Please note that the qemu VPC format is only used for dynamic disks. For fixed size disks you would use the raw driver.

Comment 8 Kevin Wolf 2009-04-15 15:04:59 UTC
The patch has now been applied in upstream qemu as SVN Rev 7109.

Comment 9 Mark McLoughlin 2009-04-19 14:43:53 UTC
Thanks Kevin, closing this as resolved upstream - no particular need to fix this for F11

Comment 10 Fedora Update System 2009-05-13 11:59:15 UTC
qemu-0.10.4-2.fc11 has been submitted as an update for Fedora 11.
http://admin.fedoraproject.org/updates/qemu-0.10.4-2.fc11

Comment 11 Fedora Update System 2009-05-13 15:07:09 UTC
qemu-0.10.4-3.fc11 has been submitted as an update for Fedora 11.
http://admin.fedoraproject.org/updates/qemu-0.10.4-3.fc11

Comment 12 Fedora Update System 2009-05-14 11:33:53 UTC
qemu-0.10.4-4.fc11 has been submitted as an update for Fedora 11.
http://admin.fedoraproject.org/updates/qemu-0.10.4-4.fc11

Comment 13 Fedora Update System 2009-05-19 03:37:11 UTC
qemu-0.10.4-5.fc11 has been submitted as an update for Fedora 11.
http://admin.fedoraproject.org/updates/qemu-0.10.4-5.fc11

Comment 14 Fedora Update System 2009-05-20 00:52:58 UTC
qemu-0.10.4-4.fc11 has been pushed to the Fedora 11 stable repository.  If problems still persist, please make note of it in this bug report.