VirtualBox

Changeset 124 in vbox for trunk/src/VBox/Devices/Storage


Ignore:
Timestamp:
Jan 17, 2007 5:38:24 PM (18 years ago)
Author:
vboxsync
Message:

LogRel() on VDI failure, make them visible on vditool.

Location:
trunk/src/VBox/Devices/Storage
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Storage/VBoxHDD.cpp

    r1 r124  
    711711
    712712            if (pHeader->u.v1.cbHeader < sizeof(VDIHEADER1))
     713            {
     714                LogRel(("VDI: v1 header size wrong (%d < %d)\n",
     715                       pHeader->u.v1.cbHeader, sizeof(VDIHEADER1)));
    713716                return VERR_VDI_INVALID_HEADER;
     717            }
    714718
    715719            if (getImageBlocksOffset(pHeader) < (sizeof(VDIPREHEADER) + sizeof(VDIHEADER1)))
     720            {
     721                LogRel(("VDI: v1 blocks offset wrong (%d < %d)\n",
     722                       getImageBlocksOffset(pHeader), sizeof(VDIPREHEADER) + sizeof(VDIHEADER1)));
    716723                return VERR_VDI_INVALID_HEADER;
     724            }
    717725
    718726            if (getImageDataOffset(pHeader) < (getImageBlocksOffset(pHeader) + getImageBlocks(pHeader) * sizeof(VDIIMAGEBLOCKPOINTER)))
     727            {
     728                LogRel(("VDI: v1 image data offset wrong (%d < %d)\n",
     729                       getImageDataOffset(pHeader), getImageBlocksOffset(pHeader) + getImageBlocks(pHeader) * sizeof(VDIIMAGEBLOCKPOINTER)));
    719730                return VERR_VDI_INVALID_HEADER;
     731            }
    720732
    721733            if (    getImageType(pHeader) == VDI_IMAGE_TYPE_UNDO
     
    723735            {
    724736                if (RTUuidIsNull(getImageParentUUID(pHeader)))
     737                {
     738                    LogRel(("VDI: v1 uuid of parent is 0)\n"));
    725739                    return VERR_VDI_INVALID_HEADER;
     740                }
    726741                if (RTUuidIsNull(getImageParentModificationUUID(pHeader)))
     742                {
     743                    LogRel(("VDI: v1 uuid of parent modification is 0\n"));
    727744                    return VERR_VDI_INVALID_HEADER;
     745                }
    728746            }
    729747
     
    745763
    746764    if ((getImageGeometry(pHeader))->cbSector != VDI_GEOMETRY_SECTOR_SIZE)
     765    {
     766        LogRel(("VDI: wrong section size (%d != %d)\n",
     767               (getImageGeometry(pHeader))->cbSector, VDI_GEOMETRY_SECTOR_SIZE));
    747768        return VERR_VDI_INVALID_HEADER;
     769    }
    748770
    749771    if (    getImageDiskSize(pHeader) == 0
    750772        ||  getImageBlockSize(pHeader) == 0
    751773        ||  getImageBlocks(pHeader) == 0
    752         ||  getPowerOfTwo(getImageBlockSize(pHeader)) == 0
    753         ||  getImageBlocksAllocated(pHeader) > getImageBlocks(pHeader))
     774        ||  getPowerOfTwo(getImageBlockSize(pHeader)) == 0)
     775    {
     776        LogRel(("VDI: wrong size (%lld, %d, %d, %d)\n",
     777              getImageDiskSize(pHeader), getImageBlockSize(pHeader),
     778              getImageBlocks(pHeader), getPowerOfTwo(getImageBlockSize(pHeader))));
    754779        return VERR_VDI_INVALID_HEADER;
     780    }
     781
     782    if (getImageBlocksAllocated(pHeader) > getImageBlocks(pHeader))
     783    {
     784        LogRel(("VDI: too many blocks allocated (%d > %d)\n"
     785                "     blocksize=%d disksize=%lld\n",
     786              getImageBlocksAllocated(pHeader), getImageBlocks(pHeader),
     787              getImageBlockSize(pHeader), getImageDiskSize(pHeader)));
     788        return VERR_VDI_INVALID_HEADER;
     789    }
    755790
    756791    if (    getImageExtraBlockSize(pHeader) != 0
    757792        &&  getPowerOfTwo(getImageExtraBlockSize(pHeader)) == 0)
     793    {
     794        LogRel(("VDI: wrong extra size (%d, %d)\n",
     795               getImageExtraBlockSize(pHeader), getPowerOfTwo(getImageExtraBlockSize(pHeader))));
    758796        return VERR_VDI_INVALID_HEADER;
     797    }
    759798
    760799    if ( (uint64_t)getImageBlockSize(pHeader) * getImageBlocks(pHeader) < getImageDiskSize(pHeader))
     800    {
     801        LogRel(("VDI: wrong disk size (%d, %d, %lld)\n",
     802               getImageBlockSize(pHeader),
     803               getImageBlocks(pHeader),
     804               getImageDiskSize(pHeader)));
    761805        return VERR_VDI_INVALID_HEADER;
     806    }
    762807
    763808    if (RTUuidIsNull(getImageCreationUUID(pHeader)))
     809    {
     810        LogRel(("VDI: uuid of creator is 0\n"));
    764811        return VERR_VDI_INVALID_HEADER;
     812    }
    765813    if (RTUuidIsNull(getImageModificationUUID(pHeader)))
     814    {
     815        LogRel(("VDI: uuid of modificator is 0\n"));
    766816        return VERR_VDI_INVALID_HEADER;
     817    }
    767818
    768819    return VINF_SUCCESS;
  • trunk/src/VBox/Devices/Storage/testcase/vhddtool.cpp

    r1 r124  
    7474        RTPrintf("The operation completed successfully! (rc=%Rrc)\n", rc);
    7575    else
    76         RTPrintf("failure: %Rrf (%Rrc)\n", rc, rc);
     76        RTPrintf("FAILURE: %Rrf (%Rrc)\n", rc, rc);
    7777    return rc;
    7878}
     
    8080static int NewImage(const char *pszFilename, uint32_t cMBs)
    8181{
    82     RTPrintf("creating VDI: file=\"%s\" size=%u MB...\n",
     82    RTPrintf("Creating VDI: file=\"%s\" size=%u MB...\n",
    8383             pszFilename, cMBs);
    8484    int rc = VDICreateBaseImage(pszFilename,
     
    9191static int ConvertDDImage(const char *pszFilename, const char *pszDDFilename)
    9292{
    93     RTPrintf("converting VDI: from DD image file=\"%s\" to file=\"%s\"...\n",
     93    RTPrintf("Converting VDI: from DD image file=\"%s\" to file=\"%s\"...\n",
    9494             pszDDFilename, pszFilename);
    9595
     
    108108    if (VBOX_SUCCESS(rc))
    109109    {
    110         RTPrintf("creating fixed image with size %u Bytes...\n", (unsigned)cbFile);
     110        RTPrintf("Creating fixed image with size %u Bytes...\n", (unsigned)cbFile);
    111111        rc = VDICreateBaseImage(pszFilename,
    112112                                VDI_IMAGE_TYPE_FIXED,
     
    116116        if (VBOX_SUCCESS(rc))
    117117        {
    118             RTPrintf("writing data...\n");
     118            RTPrintf("Writing data...\n");
    119119            PVDIDISK pVdi = VDIDiskCreate();
    120120            rc = VDIDiskOpenImage(pVdi, pszFilename, VDI_OPEN_FLAGS_NORMAL);
     
    177177static int ConvertOldImage(const char *pszFilename)
    178178{
    179     RTPrintf("converting VDI image file=\"%s\" to a new format...\n"
     179    RTPrintf("Converting VDI image file=\"%s\" to a new format...\n"
    180180             "progress: 0%%",
    181181             pszFilename);
     
    188188static int DumpImage(const char *pszFilename)
    189189{
    190     RTPrintf("dumping VDI image file=\"%s\" into the log file...\n", pszFilename);
     190    RTPrintf("Dumping VDI image file=\"%s\" into the log file...\n", pszFilename);
    191191    PVDIDISK pVdi = VDIDiskCreate();
    192192    int rc = VDIDiskOpenImage(pVdi, pszFilename, VDI_OPEN_FLAGS_READONLY);
     
    201201static int ResetImageGeometry(const char *pszFilename)
    202202{
    203     RTPrintf("resetting geometry info of VDI image file=\"%s\"\n", pszFilename);
     203    RTPrintf("Resetting geometry info of VDI image file=\"%s\"\n", pszFilename);
    204204    PVDIDISK pVdi = VDIDiskCreate();
    205205    int rc = VDIDiskOpenImage(pVdi, pszFilename, VDI_OPEN_FLAGS_NORMAL);
     
    216216static int CopyImage(const char *pszDstFile, const char *pszSrcFile)
    217217{
    218     RTPrintf("copying VDI image file=\"%s\" to image file=\"%s\"...\n"
     218    RTPrintf("Copying VDI image file=\"%s\" to image file=\"%s\"...\n"
    219219             "progress: 0%%",
    220220             pszSrcFile, pszDstFile);
     
    227227static int CopyToDD(const char *pszDstFile, const char *pszSrcFile)
    228228{
    229     RTPrintf("copying VDI image file=\"%s\" to DD file=\"%s\"...\n",
     229    RTPrintf("Copying VDI image file=\"%s\" to DD file=\"%s\"...\n",
    230230             pszSrcFile, pszDstFile);
    231231    PVDIDISK pVdi = VDIDiskCreate();
     
    264264static int ShrinkImage(const char *pszFilename)
    265265{
    266     RTPrintf("shrinking VDI image file=\"%s\"...\n"
     266    RTPrintf("Shrinking VDI image file=\"%s\"...\n"
    267267             "progress: 0%%",
    268268             pszFilename);
     
    290290    ascii2upper(szCmd);
    291291
    292     int rc;
     292    PRTLOGGER pLogger;
     293    static const char * const s_apszGroups[] = VBOX_LOGGROUP_NAMES;
     294    int rc = RTLogCreate(&pLogger, 0, "all",
     295                         NULL, ELEMENTS(s_apszGroups), s_apszGroups,
     296                          RTLOGDEST_STDOUT, NULL);
     297    RTLogRelSetDefaultInstance(pLogger);
     298
    293299    if (strcmp(szCmd, "NEW") == 0)
    294300    {
     
    355361        return SyntaxError("Invalid command!");
    356362
     363    RTLogFlush(NULL);
    357364    return !VBOX_SUCCESS(rc);
    358365}
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette