[vbox-dev] VDCopy() fix for VHD

Huihong Luo huisinro at yahoo.com
Wed Oct 7 19:36:57 GMT 2009


after the fix, VHD->VMDk seems to be working fine, but VHD->VDI still not working, the generated vdi disk throws invalid header error.

--- On Wed, 10/7/09, Huihong Luo <huisinro at yahoo.com> wrote:


From: Huihong Luo <huisinro at yahoo.com>
Subject: [vbox-dev] VDCopy() fix for VHD
To: vbox-dev at virtualbox.org
Date: Wednesday, October 7, 2009, 12:30 AM







Can you guys add the following code to function VDCopy() in VBoxHDD.cpp? right before VDCreateBase() is called. 
 
It resets the geometry if cSectors > 63, VHD disk somehow has more than 63 sectors.
 
 
    /* vmlite, fix converting error from VHD */
    if (PCHSGeometryFrom.cHeads > 16 || PCHSGeometryFrom.cSectors > 63)
    {
     Assert(RT_MIN(cbSize / 512 / 16 / 63, 16383) -
        (unsigned int)RT_MIN(cbSize / 512 / 16 / 63, 16383) == 0);  
     PCHSGeometryFrom.cCylinders = (unsigned int)RT_MIN(cbSize / 512 / 16 / 63, 16383);
     PCHSGeometryFrom.cHeads = 16;
     PCHSGeometryFrom.cSectors = 63;
    }
    /* vmlite */
                rc = VDCreateBase(pDiskTo, pszBackend, pszFilename, cbSize,
                                  uImageFlags, szComment,
                                  &PCHSGeometryFrom, &LCHSGeometryFrom,
                                  NULL, uOpenFlagsFrom & ~VD_OPEN_FLAGS_READONLY, NULL, NULL);
                if (RT_SUCCESS(rc) && !RTUuidIsNull(&ImageUuid))
                     pDiskTo->pLast->Backend->pfnSetUuid(pDiskTo->pLast->pvBackendData, &ImageUuid);
                if (RT_SUCCESS(rc) && !RTUuidIsNull(&ParentUuid))
                     pDiskTo->pLast->Backend->pfnSetParentUuid(pDiskTo->pLast->pvBackendData, &ParentUuid);
 
 
- Huihong
-----Inline Attachment Follows-----


_______________________________________________
vbox-dev mailing list
vbox-dev at virtualbox.org
http://vbox.innotek.de/mailman/listinfo/vbox-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.virtualbox.org/pipermail/vbox-dev/attachments/20091007/698fe934/attachment.html>


More information about the vbox-dev mailing list