VirtualBox

Changeset 21927 in vbox


Ignore:
Timestamp:
Aug 2, 2009 5:19:29 PM (16 years ago)
Author:
vboxsync
Message:

SSM,VBox/err.h: SSMR3SkipToEndOfUnit and more error codes.

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/err.h

    r21653 r21927  
    489489/** The specified data unit wasn't owned by caller. */
    490490#define VERR_SSM_UNIT_NOT_OWNER                 (-1802)
     491
    491492/** General saved state file integrity error. */
    492493#define VERR_SSM_INTEGRITY                      (-1810)
     
    497498/** The saved state file size didn't match the one in the header. */
    498499#define VERR_SSM_INTEGRITY_SIZE                 (-1813)
    499 /** The CRC of the saved state file did match. */
     500/** The CRC of the saved state file did not match. */
    500501#define VERR_SSM_INTEGRITY_CRC                  (-1814)
    501 /** The current virtual machine id didn't match the virtual machine id. */
     502/** The machine uuid field wasn't null. */
    502503#define VERR_SMM_INTEGRITY_MACHINE              (-1815)
     504/** Saved state header integrity error. */
     505#define VERR_SSM_INTEGRITY_HEADER               (-1816)
     506/** Unit header integrity error. */
     507#define VERR_SSM_INTEGRITY_UNIT                 (-1817)
    503508/** Invalid unit magic (internal data tag). */
    504 #define VERR_SSM_INTEGRITY_UNIT_MAGIC           (-1816)
     509#define VERR_SSM_INTEGRITY_UNIT_MAGIC           (-1818)
    505510/** The file contained a data unit which no-one wants. */
    506 #define VERR_SSM_INTEGRITY_UNIT_NOT_FOUND       (-1817)
    507 /** Incorrect type sizes in the header. */
    508 #define VERR_SSM_INTEGRITY_SIZES                (-1818)
     511#define VERR_SSM_INTEGRITY_UNIT_NOT_FOUND       (-1819)
    509512/** Incorrect version numbers in the header. */
    510 #define VERR_SSM_INTEGRITY_VBOX_VERSION         (-1819)
     513#define VERR_SSM_INTEGRITY_VBOX_VERSION         (-1820)
     514/** Footer integrity error. */
     515#define VERR_SSM_INTEGRITY_FOOTER               (-1821)
     516/** Record header integrity error. */
     517#define VERR_SSM_INTEGRITY_REC_HDR              (-1822)
     518/** Termination record integrity error. */
     519#define VERR_SSM_INTEGRITY_REC_TERM             (-1823)
     520/** Termination record CRC mismatch. */
     521#define VERR_SSM_INTEGRITY_REC_TERM_CRC         (-1824)
     522/** Decompression interity error.  */
     523#define VERR_SSM_INTEGRITY_DECOMPRESSION        (-1825)
     524/** Saved state directory iintegrity error.  */
     525#define VERR_SSM_INTEGRITY_DIR                  (-1826)
     526/** The saved state directory magic is wrong. */
     527#define VERR_SSM_INTEGRITY_DIR_MAGIC            (-1827)
     528
    511529/** A data unit in the saved state file was defined but didn't any
    512530 * routine for processing it. */
    513 #define VERR_SSM_NO_LOAD_EXEC                   (-1820)
     531#define VERR_SSM_NO_LOAD_EXEC                   (-1830)
    514532/** A restore routine attempted to load more data then the unit contained. */
    515 #define VERR_SSM_LOADED_TOO_MUCH                (-1821)
     533#define VERR_SSM_LOADED_TOO_MUCH                (-1831)
    516534/** Not in the correct state for the attempted operation. */
    517 #define VERR_SSM_INVALID_STATE                  (-1822)
     535#define VERR_SSM_INVALID_STATE                  (-1832)
     536/** Not in the correct state for the attempted operation. */
     537#define VERR_SSM_LOADED_TOO_LITTLE              (-1833)
    518538
    519539/** Unsupported data unit version.
    520540 * A SSM user returns this if it doesn't know the u32Version. */
    521 #define VERR_SSM_UNSUPPORTED_DATA_UNIT_VERSION  (-1823)
     541#define VERR_SSM_UNSUPPORTED_DATA_UNIT_VERSION  (-1840)
    522542/** The format of a data unit has changed.
    523543 * A SSM user returns this if it's not able to read the format for
    524544 * other reasons than u32Version. */
    525 #define VERR_SSM_DATA_UNIT_FORMAT_CHANGED       (-1824)
     545#define VERR_SSM_DATA_UNIT_FORMAT_CHANGED       (-1841)
    526546/** The CPUID instruction returns different information when loading than when saved.
    527547 * Normally caused by hardware changes on the host, but could also be caused by
    528548 * changes in the BIOS setup. */
    529 #define VERR_SSM_LOAD_CPUID_MISMATCH            (-1825)
     549#define VERR_SSM_LOAD_CPUID_MISMATCH            (-1842)
    530550/** The RAM size differes between the saved state and the VM config. */
    531 #define VERR_SSM_LOAD_MEMORY_SIZE_MISMATCH      (-1826)
     551#define VERR_SSM_LOAD_MEMORY_SIZE_MISMATCH      (-1843)
    532552/** The state doesn't match the VM configuration in one or another way.
    533553 * (There are certain PCI reconfiguration which the OS could potentially
    534554 * do which can cause this problem. Check this out when it happens.) */
    535 #define VERR_SSM_LOAD_CONFIG_MISMATCH           (-1827)
     555#define VERR_SSM_LOAD_CONFIG_MISMATCH           (-1844)
    536556/** The virtual clock freqency differs too much.
    537557 * The clock source for the virtual time isn't reliable or the code have changed. */
    538 #define VERR_SSM_VIRTUAL_CLOCK_HZ               (-1828)
     558#define VERR_SSM_VIRTUAL_CLOCK_HZ               (-1845)
    539559/** A timeout occured while waiting for async IDE operations to finish. */
    540 #define VERR_SSM_IDE_ASYNC_TIMEOUT              (-1829)
     560#define VERR_SSM_IDE_ASYNC_TIMEOUT              (-1846)
    541561/** One of the structure magics was wrong. */
    542 #define VERR_SSM_STRUCTURE_MAGIC                (-1830)
     562#define VERR_SSM_STRUCTURE_MAGIC                (-1847)
    543563/** The data in the saved state doesn't confirm to expectations. */
    544 #define VERR_SSM_UNEXPECTED_DATA                (-1831)
     564#define VERR_SSM_UNEXPECTED_DATA                (-1848)
    545565/** Trying to read a 64-bit guest physical address into a 32-bit variable. */
    546 #define VERR_SSM_GCPHYS_OVERFLOW                (-1832)
     566#define VERR_SSM_GCPHYS_OVERFLOW                (-1849)
    547567/** Trying to read a 64-bit guest virtual address into a 32-bit variable. */
    548 #define VERR_SSM_GCPTR_OVERFLOW                 (-1833)
     568#define VERR_SSM_GCPTR_OVERFLOW                 (-1850)
    549569/** @} */
    550570
  • trunk/include/VBox/ssm.h

    r21795 r21927  
    513513VMMR3DECL(int) SSMR3GetTimer(PSSMHANDLE pSSM, PTMTIMER pTimer);
    514514VMMR3DECL(int) SSMR3Skip(PSSMHANDLE pSSM, size_t cb);
     515VMMR3DECL(int) SSMR3SkipToEndOfUnit(PSSMHANDLE pSSM);
    515516
    516517/** @} */
  • trunk/src/VBox/VMM/SSM-new.cpp

    r21926 r21927  
    28322832                }
    28332833            }
    2834             LogRel(("SSM: Failed to finalize state file! rc=%Rrc\n", rc));
     2834            if (RT_FAILURE(rc))
     2835                LogRel(("SSM: Failed to finalize state file! rc=%Rrc\n", rc));
    28352836        }
    28362837
     
    29942995        {
    29952996            LogRel(("SSM: Incorrect cHostBits value: %u\n", pSSM->u.Read.cHostBits));
    2996             return VERR_SSM_INTEGRITY_SIZES;
     2997            return VERR_SSM_INTEGRITY_HEADER;
    29972998        }
    29982999    }
    29993000    else
    3000         AssertLogRelReturn(pSSM->u.Read.cHostBits == 0, VERR_SSM_INTEGRITY_SIZES);
     3001        AssertLogRelReturn(pSSM->u.Read.cHostBits == 0, VERR_SSM_INTEGRITY_HEADER);
    30013002
    30023003    if (    pSSM->u.Read.cbGCPhys != sizeof(uint32_t)
     
    30043005    {
    30053006        LogRel(("SSM: Incorrect cbGCPhys value: %d\n", pSSM->u.Read.cbGCPhys));
    3006         return VERR_SSM_INTEGRITY_SIZES;
     3007        return VERR_SSM_INTEGRITY_HEADER;
    30073008    }
    30083009    if (    pSSM->u.Read.cbGCPtr != sizeof(uint32_t)
     
    30103011    {
    30113012        LogRel(("SSM: Incorrect cbGCPtr value: %d\n", pSSM->u.Read.cbGCPtr));
    3012         return VERR_SSM_INTEGRITY_SIZES;
     3013        return VERR_SSM_INTEGRITY_HEADER;
    30133014    }
    30143015
     
    31483149            {
    31493150                LogRel(("SSM: Bad footer magic: %.*Rhxs\n", sizeof(Footer.szMagic), &Footer.szMagic[0]));
    3150                 return VERR_SSM_INTEGRITY;
     3151                return VERR_SSM_INTEGRITY_FOOTER;
    31513152            }
    31523153            SSM_CHECK_CRC32_RET(&Footer, sizeof(Footer), ("Footer CRC mismatch: %08x, correct is %08x\n", u32CRC, u32ActualCRC));
     
    31543155            {
    31553156                LogRel(("SSM: SSMFILEFTR::offStream is wrong: %llx, expected %llx\n", Footer.offStream, offFooter));
    3156                 return VERR_SSM_INTEGRITY;
     3157                return VERR_SSM_INTEGRITY_FOOTER;
    31573158            }
    31583159            if (Footer.u32Reserved)
    31593160            {
    31603161                LogRel(("SSM: Reserved footer field isn't zero: %08x\n", Footer.u32Reserved));
    3161                 return VERR_SSM_INTEGRITY;
     3162                return VERR_SSM_INTEGRITY_FOOTER;
    31623163            }
    31633164            if (    !fChecksummed
     
    31653166            {
    31663167                LogRel(("SSM: u32StreamCRC field isn't zero, but header says stream checksumming is disabled.\n"));
    3167                 return VERR_SSM_INTEGRITY;
     3168                return VERR_SSM_INTEGRITY_FOOTER;
    31683169            }
    31693170
     
    34643465                    {
    34653466                        LogRel(("SSM: Unit name '%.*s' was not properly terminated.\n", UnitHdr.cchName, pszName));
    3466                         rc = VERR_SSM_INTEGRITY;
     3467                        rc = VERR_SSM_INTEGRITY_UNIT;
    34673468                        break;
    34683469                    }
     
    35303531                            {
    35313532                                LogRel(("SSM: Unit '%s' read %lld bytes too much!\n", pszName, i64Diff));
    3532                                 VMSetError(pVM, rc, RT_SRC_POS, N_("Unit '%s' read %lld bytes too much"), pszName, i64Diff);
    3533                                 rc = VERR_SSM_INTEGRITY;
     3533                                rc = VMSetError(pVM, VERR_SSM_LOADED_TOO_MUCH, RT_SRC_POS,
     3534                                                N_("Unit '%s' read %lld bytes too much"), pszName, i64Diff);
    35343535                                break;
    35353536                            }
     
    35433544                            VMSetError(pVM, rc, RT_SRC_POS, N_("Load exec failed for '%s' instance #%u (version %u)"),
    35443545                                       pszName, UnitHdr.u32Instance, UnitHdr.u32Version);
    3545                             rc = VERR_SSM_INTEGRITY;
    35463546                            break;
    35473547                        }
     
    36103610        if (UnitHdr.cbName)
    36113611        {
    3612             if (RT_UNLIKELY(UnitHdr.cbName > sizeof(UnitHdr.szName)))
    3613             {
    3614                 LogRel(("SSM: Unit at %#llx (%lld): UnitHdr.cbName=%u > %u\n",
    3615                         offUnit, offUnit, UnitHdr.cbName, sizeof(UnitHdr.szName)));
    3616                 return VERR_SSM_INTEGRITY;
    3617             }
     3612            AssertLogRelMsgReturn(UnitHdr.cbName <= sizeof(UnitHdr.szName),
     3613                                  ("Unit at %#llx (%lld): UnitHdr.cbName=%u > %u\n",
     3614                                   offUnit, offUnit, UnitHdr.cbName, sizeof(UnitHdr.szName)),
     3615                                  VERR_SSM_INTEGRITY_UNIT);
    36183616            rc = ssmR3StrmRead(&pSSM->Strm, &UnitHdr.szName[0], UnitHdr.cbName);
    36193617            if (RT_FAILURE(rc))
    36203618                return rc;
    3621             if (RT_UNLIKELY(UnitHdr.szName[UnitHdr.cbName - 1]))
    3622             {
    3623                 LogRel(("SSM: Unit at %#llx (%lld): Name %.*Rhxs was not properly terminated.\n",
    3624                         offUnit, offUnit, UnitHdr.cbName, UnitHdr.szName));
    3625                 return VERR_SSM_INTEGRITY;
    3626             }
     3619            AssertLogRelMsgReturn(!UnitHdr.szName[UnitHdr.cbName - 1],
     3620                                  ("Unit at %#llx (%lld): Name %.*Rhxs was not properly terminated.\n",
     3621                                   offUnit, offUnit, UnitHdr.cbName, UnitHdr.szName),
     3622                                  VERR_SSM_INTEGRITY_UNIT);
    36273623        }
    36283624        SSM_CHECK_CRC32_RET(&UnitHdr, RT_OFFSETOF(SSMFILEUNITHDR, szName[UnitHdr.cbName]),
    36293625                            ("Unit at %#llx (%lld): CRC mismatch: %08x, correct is %08x\n", offUnit, offUnit, u32CRC, u32ActualCRC));
    3630         if (RT_UNLIKELY(UnitHdr.offStream != offUnit))
    3631         {
    3632             LogRel(("SSM: Unit at %#llx (%lld): offStream=%#llx, expected %#llx\n", offUnit, offUnit, UnitHdr.offStream, offUnit));
    3633             return VERR_SSM_INTEGRITY;
    3634         }
     3626        AssertLogRelMsgReturn(UnitHdr.offStream == offUnit,
     3627                              ("Unit at %#llx (%lld): offStream=%#llx, expected %#llx\n", offUnit, offUnit, UnitHdr.offStream, offUnit),
     3628                              VERR_SSM_INTEGRITY_UNIT);
    36353629        AssertLogRelMsgReturn(UnitHdr.u32CurStreamCRC == u32CurStreamCRC || !pSSM->Strm.fChecksummed,
    3636                               ("Unit at %#llx (%lld): Stream CRC mismatch: %08x, correct is %08x\n", offUnit, offUnit, UnitHdr.u32CurStreamCRC, u32CurStreamCRC), VERR_SSM_INTEGRITY);
    3637         AssertLogRelMsgReturn(!UnitHdr.fFlags, ("Unit at %#llx (%lld): fFlags=%08x\n", offUnit, offUnit, UnitHdr.fFlags), VERR_SSM_INTEGRITY);
     3630                              ("Unit at %#llx (%lld): Stream CRC mismatch: %08x, correct is %08x\n", offUnit, offUnit, UnitHdr.u32CurStreamCRC, u32CurStreamCRC),
     3631                              VERR_SSM_INTEGRITY_UNIT);
     3632        AssertLogRelMsgReturn(!UnitHdr.fFlags, ("Unit at %#llx (%lld): fFlags=%08x\n", offUnit, offUnit, UnitHdr.fFlags),
     3633                              VERR_SSM_INTEGRITY_UNIT);
    36383634        if (!memcmp(&UnitHdr.szMagic[0], SSMFILEUNITHDR_END,   sizeof(UnitHdr.szMagic)))
    36393635        {
     
    36433639                                  && UnitHdr.u32Phase     == SSM_PHASE_FINAL,
    36443640                                  ("Unit at %#llx (%lld): Malformed END unit\n", offUnit, offUnit),
    3645                                   VERR_SSM_INTEGRITY);
     3641                                  VERR_SSM_INTEGRITY_UNIT);
    36463642
    36473643            /*
     
    37043700             */
    37053701            LogRel(("SSM: Found no handler for unit '%s' instance #%u!\n", UnitHdr.szName, UnitHdr.u32Instance));
    3706             //if (pSSM->enmAfter != SSMAFTER_DEBUG_IT)
     3702            if (pSSM->enmAfter != SSMAFTER_DEBUG_IT)
    37073703                return VMSetError(pVM, VERR_SSM_INTEGRITY_UNIT_NOT_FOUND, RT_SRC_POS,
    37083704                                  N_("Found no handler for unit '%s' instance #%u"), UnitHdr.szName, UnitHdr.u32Instance);
    3709             /** @todo Read data unit to /dev/null. */
     3705            SSMR3SkipToEndOfUnit(pSSM);
     3706            ssmR3DataReadFinishV2(pSSM);
    37103707        }
    37113708    }
     
    40404037                AssertLogRelMsgReturn(!szName[UnitHdr.cchName - 1],
    40414038                                      (" Unit name '%.*s' was not properly terminated.\n", cbUnitNm, szName),
    4042                                       VERR_SSM_INTEGRITY);
     4039                                      VERR_SSM_INTEGRITY_UNIT);
    40434040
    40444041                /*
     
    40884085    int rc = ssmR3StrmPeekAt(&pSSM->Strm, offDir, pDir, cbDir, NULL);
    40894086    AssertLogRelRCReturn(rc, rc);
    4090     AssertLogRelReturn(!memcmp(pDir->szMagic, SSMFILEDIR_MAGIC, sizeof(pDir->szMagic)), VERR_SSM_INTEGRITY);
     4087    AssertLogRelReturn(!memcmp(pDir->szMagic, SSMFILEDIR_MAGIC, sizeof(pDir->szMagic)), VERR_SSM_INTEGRITY_DIR_MAGIC);
    40914088    SSM_CHECK_CRC32_RET(pDir, cbDir, ("Bad directory CRC: %08x, actual %08x\n", u32CRC, u32ActualCRC));
    40924089    AssertLogRelMsgReturn(pDir->cEntries == cDirEntries,
    40934090                          ("Bad directory entry count: %#x, expected %#x (from the footer)\n", pDir->cEntries, cDirEntries),
    4094                           VERR_SSM_INTEGRITY);
     4091                           VERR_SSM_INTEGRITY_DIR);
    40954092    for (uint32_t i = 0; i < cDirEntries; i++)
    40964093        AssertLogRelMsgReturn(pDir->aEntries[i].off < offDir,
    40974094                              ("i=%u off=%lld offDir=%lld\n", i, pDir->aEntries[i].off, offDir),
    4098                               VERR_SSM_INTEGRITY);
     4095                              VERR_SSM_INTEGRITY_DIR);
    40994096
    41004097    /*
     
    41234120            AssertLogRelMsgReturn(!memcmp(UnitHdr.szMagic, SSMFILEUNITHDR_MAGIC, sizeof(UnitHdr.szMagic)),
    41244121                                  ("Bad unit header or dictionary offset: i=%u off=%lld\n", i, pDir->aEntries[i].off),
    4125                                   VERR_SSM_INTEGRITY);
     4122                                  VERR_SSM_INTEGRITY_UNIT);
    41264123            AssertLogRelMsgReturn(UnitHdr.offStream == pDir->aEntries[i].off,
    41274124                                  ("Bad unit header: i=%d off=%lld offStream=%lld\n", i, pDir->aEntries[i].off, UnitHdr.offStream),
    4128                                   VERR_SSM_INTEGRITY);
     4125                                  VERR_SSM_INTEGRITY_UNIT);
    41294126            AssertLogRelMsgReturn(UnitHdr.u32Instance == pDir->aEntries[i].u32Instance,
    41304127                                  ("Bad unit header: i=%d off=%lld u32Instance=%u Dir.u32Instance=%u\n",
    41314128                                   i, pDir->aEntries[i].off, UnitHdr.u32Instance, pDir->aEntries[i].u32Instance),
    4132                                   VERR_SSM_INTEGRITY);
     4129                                  VERR_SSM_INTEGRITY_UNIT);
    41334130            uint32_t cbUnitHdr = RT_UOFFSETOF(SSMFILEUNITHDR, szName[UnitHdr.cbName]);
    41344131            AssertLogRelMsgReturn(   UnitHdr.cbName > 0
     
    41364133                                  && cbUnitHdr <= cbToRead,
    41374134                                  ("Bad unit header: i=%u off=%lld cbName=%#x cbToRead=%#x\n", i, pDir->aEntries[i].off, UnitHdr.cbName, cbToRead),
    4138                                   VERR_SSM_INTEGRITY);
     4135                                  VERR_SSM_INTEGRITY_UNIT);
    41394136            SSM_CHECK_CRC32_RET(&UnitHdr, RT_OFFSETOF(SSMFILEUNITHDR, szName[UnitHdr.cbName]),
    41404137                                ("Bad unit header CRC: i=%u off=%lld u32CRC=%#x u32ActualCRC=%#x\n",
     
    50415038    }
    50425039
    5043     /** @todo weed out lazy saving */
    50445040    if (pSSM->enmAfter != SSMAFTER_DEBUG_IT)
    50455041        AssertMsgFailed(("SSM: attempted reading more than the unit!\n"));
     
    51215117        if (    RT_SUCCESS(rc)
    51225118            &&  !pSSM->u.Read.fEndOfData)
    5123             rc = VERR_SSM_LOADED_TOO_MUCH; /** @todo More error codes! */
     5119        {
     5120            rc = VERR_SSM_LOADED_TOO_LITTLE;
     5121            AssertFailed();
     5122        }
    51245123        pSSM->rc = rc;
    51255124    }
     
    51675166                          && pSSM->u.Read.cbRecLeft <= RT_SIZEOFMEMB(SSMHANDLE, u.Read.abComprBuffer) + 2,
    51685167                          ("%#x\n", pSSM->u.Read.cbRecLeft),
    5169                           VERR_SSM_INTEGRITY);
    5170 
    5171 /** @todo this isn't very efficient, we know we have to read it all, so both
    5172  *        reading the first byte separately.  */
     5168                          VERR_SSM_INTEGRITY_DECOMPRESSION);
     5169
    51735170    uint8_t cKB;
    51745171    int rc = ssmR3DataReadV2Raw(pSSM, &cKB, 1);
     
    51815178                          && cbDecompr <= RT_SIZEOFMEMB(SSMHANDLE, u.Read.abDataBuffer),
    51825179                          ("%#x\n", cbDecompr),
    5183                           VERR_SSM_INTEGRITY);
     5180                          VERR_SSM_INTEGRITY_DECOMPRESSION);
    51845181
    51855182    *pcbDecompr = cbDecompr;
     
    52295226    if (RT_SUCCESS(rc))
    52305227    {
    5231         AssertLogRelMsgReturn(cbDstActual == cbDecompr, ("%#x %#x\n", cbDstActual, cbDecompr), VERR_SSM_INTEGRITY);
     5228        AssertLogRelMsgReturn(cbDstActual == cbDecompr, ("%#x %#x\n", cbDstActual, cbDecompr), VERR_SSM_INTEGRITY_DECOMPRESSION);
    52325229        return VINF_SUCCESS;
    52335230    }
    5234     return rc;
     5231
     5232    AssertLogRelMsgFailed(("cbCompr=%#x cbDecompr=%#x rc=%Rrc\n", cbCompr, cbDecompr, rc));
     5233    return VERR_SSM_INTEGRITY_DECOMPRESSION;
    52355234}
    52365235
     
    52635262     */
    52645263    pSSM->u.Read.u8TypeAndFlags = abHdr[0];
    5265     AssertLogRelMsgReturn(SSM_REC_ARE_TYPE_AND_FLAGS_VALID(abHdr[0]), ("%#x %#x\n", abHdr[0], abHdr[1]), VERR_SSM_INTEGRITY);
     5264    AssertLogRelMsgReturn(SSM_REC_ARE_TYPE_AND_FLAGS_VALID(abHdr[0]), ("%#x %#x\n", abHdr[0], abHdr[1]), VERR_SSM_INTEGRITY_REC_HDR);
    52665265    if ((abHdr[0] & SSM_REC_TYPE_MASK) == SSM_REC_TYPE_TERM)
    52675266    {
    52685267        pSSM->u.Read.cbRecLeft = 0;
    52695268        pSSM->u.Read.fEndOfData = true;
    5270         AssertLogRelMsgReturn(abHdr[1] == sizeof(SSMRECTERM) - 2, ("%#x\n", abHdr[1]), VERR_SSM_INTEGRITY);
    5271         AssertLogRelMsgReturn(abHdr[0] & SSM_REC_FLAGS_IMPORTANT, ("%#x\n", abHdr[0]), VERR_SSM_INTEGRITY);
     5269        AssertLogRelMsgReturn(abHdr[1] == sizeof(SSMRECTERM) - 2, ("%#x\n", abHdr[1]), VERR_SSM_INTEGRITY_REC_TERM);
     5270        AssertLogRelMsgReturn(abHdr[0] & SSM_REC_FLAGS_IMPORTANT, ("%#x\n", abHdr[0]), VERR_SSM_INTEGRITY_REC_TERM);
    52725271
    52735272        /* get the rest */
     
    52815280        AssertLogRelMsgReturn(TermRec.cbUnit == pSSM->offUnit,
    52825281                              ("cbUnit=%#llx offUnit=%#llx\n", TermRec.cbUnit, pSSM->offUnit),
    5283                               VERR_SSM_INTEGRITY);
    5284         AssertLogRelMsgReturn(!(TermRec.fFlags & ~SSMRECTERM_FLAGS_CRC32), ("%#x\n", TermRec.fFlags), VERR_SSM_INTEGRITY);
     5282                              VERR_SSM_INTEGRITY_REC_TERM);
     5283        AssertLogRelMsgReturn(!(TermRec.fFlags & ~SSMRECTERM_FLAGS_CRC32), ("%#x\n", TermRec.fFlags), VERR_SSM_INTEGRITY_REC_TERM);
    52855284        if (!(TermRec.fFlags & SSMRECTERM_FLAGS_CRC32))
    5286             AssertLogRelMsgReturn(TermRec.u32StreamCRC == 0, ("%#x\n", TermRec.u32StreamCRC), VERR_SSM_INTEGRITY);
     5285            AssertLogRelMsgReturn(TermRec.u32StreamCRC == 0, ("%#x\n", TermRec.u32StreamCRC), VERR_SSM_INTEGRITY_REC_TERM);
    52875286        else if (pSSM->Strm.fChecksummed)
    5288             AssertLogRelMsgReturn(TermRec.u32StreamCRC == u32StreamCRC, ("%#x, %#x\n", TermRec.u32StreamCRC, u32StreamCRC), VERR_SSM_INTEGRITY_CRC);
     5287            AssertLogRelMsgReturn(TermRec.u32StreamCRC == u32StreamCRC, ("%#x, %#x\n", TermRec.u32StreamCRC, u32StreamCRC),
     5288                                  VERR_SSM_INTEGRITY_REC_TERM_CRC);
    52895289
    52905290        Log3(("ssmR3DataReadRecHdrV2: %08llx|%08llx: TERM\n", ssmR3StrmTell(&pSSM->Strm) - sizeof(SSMRECTERM), pSSM->offUnit));
     
    53165316            cb = 6;
    53175317        else
    5318             AssertLogRelMsgFailedReturn(("Invalid record size byte: %#x\n", cb), VERR_SSM_INTEGRITY);
     5318            AssertLogRelMsgFailedReturn(("Invalid record size byte: %#x\n", cb), VERR_SSM_INTEGRITY_REC_HDR);
    53195319        cbHdr = cb + 1;
    53205320
     
    53295329        {
    53305330            case 6:
    5331                 AssertLogRelMsgReturn((abHdr[6] & 0xc0) == 0x80, ("6/%u: %.*Rhxs\n", cb, cb + 1, &abHdr[0]), VERR_SSM_INTEGRITY);
     5331                AssertLogRelMsgReturn((abHdr[6] & 0xc0) == 0x80, ("6/%u: %.*Rhxs\n", cb, cb + 1, &abHdr[0]), VERR_SSM_INTEGRITY_REC_HDR);
    53325332            case 5:
    5333                 AssertLogRelMsgReturn((abHdr[5] & 0xc0) == 0x80, ("5/%u: %.*Rhxs\n", cb, cb + 1, &abHdr[0]), VERR_SSM_INTEGRITY);
     5333                AssertLogRelMsgReturn((abHdr[5] & 0xc0) == 0x80, ("5/%u: %.*Rhxs\n", cb, cb + 1, &abHdr[0]), VERR_SSM_INTEGRITY_REC_HDR);
    53345334            case 4:
    5335                 AssertLogRelMsgReturn((abHdr[4] & 0xc0) == 0x80, ("4/%u: %.*Rhxs\n", cb, cb + 1, &abHdr[0]), VERR_SSM_INTEGRITY);
     5335                AssertLogRelMsgReturn((abHdr[4] & 0xc0) == 0x80, ("4/%u: %.*Rhxs\n", cb, cb + 1, &abHdr[0]), VERR_SSM_INTEGRITY_REC_HDR);
    53365336            case 3:
    5337                 AssertLogRelMsgReturn((abHdr[3] & 0xc0) == 0x80, ("3/%u: %.*Rhxs\n", cb, cb + 1, &abHdr[0]), VERR_SSM_INTEGRITY);
     5337                AssertLogRelMsgReturn((abHdr[3] & 0xc0) == 0x80, ("3/%u: %.*Rhxs\n", cb, cb + 1, &abHdr[0]), VERR_SSM_INTEGRITY_REC_HDR);
    53385338            case 2:
    5339                 AssertLogRelMsgReturn((abHdr[2] & 0xc0) == 0x80, ("2/%u: %.*Rhxs\n", cb, cb + 1, &abHdr[0]), VERR_SSM_INTEGRITY);
     5339                AssertLogRelMsgReturn((abHdr[2] & 0xc0) == 0x80, ("2/%u: %.*Rhxs\n", cb, cb + 1, &abHdr[0]), VERR_SSM_INTEGRITY_REC_HDR);
    53405340                break;
    53415341            default:
     
    53555355                    | ((uint32_t)(abHdr[2] & 0x3f) << 24)
    53565356                    | ((uint32_t)(abHdr[1] & 0x01) << 30);
    5357                 AssertLogRelMsgReturn(cb >= 0x04000000 && cb <= 0x7fffffff, ("cb=%#x\n", cb), VERR_SSM_INTEGRITY);
     5357                AssertLogRelMsgReturn(cb >= 0x04000000 && cb <= 0x7fffffff, ("cb=%#x\n", cb), VERR_SSM_INTEGRITY_REC_HDR);
    53585358                break;
    53595359            case 5:
     
    53635363                    | ((uint32_t)(abHdr[2] & 0x3f) << 18)
    53645364                    | ((uint32_t)(abHdr[1] & 0x03) << 24);
    5365                 AssertLogRelMsgReturn(cb >= 0x00200000 && cb <= 0x03ffffff, ("cb=%#x\n", cb), VERR_SSM_INTEGRITY);
     5365                AssertLogRelMsgReturn(cb >= 0x00200000 && cb <= 0x03ffffff, ("cb=%#x\n", cb), VERR_SSM_INTEGRITY_REC_HDR);
    53665366                break;
    53675367            case 4:
     
    53705370                    | ((uint32_t)(abHdr[2] & 0x3f) << 12)
    53715371                    | ((uint32_t)(abHdr[1] & 0x07) << 18);
    5372                 AssertLogRelMsgReturn(cb >= 0x00010000 && cb <= 0x001fffff, ("cb=%#x\n", cb), VERR_SSM_INTEGRITY);
     5372                AssertLogRelMsgReturn(cb >= 0x00010000 && cb <= 0x001fffff, ("cb=%#x\n", cb), VERR_SSM_INTEGRITY_REC_HDR);
    53735373                break;
    53745374            case 3:
     
    53775377                    | ((uint32_t)(abHdr[1] & 0x0f) << 12);
    53785378#if 0  /* disabled to optimize buffering */
    5379                 AssertLogRelMsgReturn(cb >= 0x00000800 && cb <= 0x0000ffff, ("cb=%#x\n", cb), VERR_SSM_INTEGRITY);
     5379                AssertLogRelMsgReturn(cb >= 0x00000800 && cb <= 0x0000ffff, ("cb=%#x\n", cb), VERR_SSM_INTEGRITY_REC_HDR);
    53805380#endif
    53815381                break;
     
    53845384                    | ((uint32_t)(abHdr[1] & 0x1f) << 6);
    53855385#if 0  /* disabled to optimize buffering */
    5386                 AssertLogRelMsgReturn(cb >= 0x00000080 && cb <= 0x000007ff, ("cb=%#x\n", cb), VERR_SSM_INTEGRITY);
     5386                AssertLogRelMsgReturn(cb >= 0x00000080 && cb <= 0x000007ff, ("cb=%#x\n", cb), VERR_SSM_INTEGRITY_REC_HDR);
    53875387#endif
    53885388                break;
     
    62386238
    62396239/**
     6240 * Skips to the end of the current data unit.
     6241 *
     6242 * Since version 2 of the format, the load exec callback have to explicitly call
     6243 * this API if it wish to be lazy for some reason.  This is because there seldom
     6244 * is a good reason to not read your entire data unit and it was hiding bugs.
     6245 *
     6246 * @returns VBox status code.
     6247 * @param   pSSM                The saved state handle.
     6248 */
     6249VMMR3DECL(int) SSMR3SkipToEndOfUnit(PSSMHANDLE pSSM)
     6250{
     6251    AssertMsgReturn(   pSSM->enmOp == SSMSTATE_LOAD_EXEC
     6252                    || pSSM->enmOp == SSMSTATE_OPEN_READ,
     6253                    ("Invalid state %d\n", pSSM->enmOp),
     6254                     VERR_SSM_INVALID_STATE);
     6255    if (pSSM->u.Read.uFmtVerMajor >= 2)
     6256    {
     6257        /*
     6258         * Read until we the end of data condition is raised.
     6259         */
     6260        pSSM->u.Read.cbDataBuffer  = 0;
     6261        pSSM->u.Read.offDataBuffer = 0;
     6262        if (!pSSM->u.Read.fEndOfData)
     6263        {
     6264            do
     6265            {
     6266                /* read the rest of the current record */
     6267                while (pSSM->u.Read.cbRecLeft)
     6268                {
     6269                    uint8_t abBuf[8192];
     6270                    size_t  cbToRead = RT_MIN(sizeof(pSSM->u.Read.cbRecLeft), sizeof(abBuf));
     6271                    int rc = ssmR3DataReadV2Raw(pSSM, abBuf, cbToRead);
     6272                    if (RT_FAILURE(rc))
     6273                        return pSSM->rc = rc;
     6274                    pSSM->u.Read.cbRecLeft -= cbToRead;
     6275                }
     6276
     6277                /* read the next header. */
     6278                int rc = ssmR3DataReadRecHdrV2(pSSM);
     6279                if (RT_FAILURE(rc))
     6280                    return pSSM->rc = rc;
     6281            } while (!pSSM->u.Read.fEndOfData);
     6282        }
     6283    }
     6284    /* else: Doesn't matter for the version 1 loading. */
     6285
     6286    return VINF_SUCCESS;
     6287}
     6288
     6289
     6290/**
    62406291 * Query what the VBox status code of the operation is.
    62416292 *
  • trunk/src/VBox/VMM/SSM.cpp

    r21799 r21927  
    15071507        {
    15081508            LogRel(("SSM: Incorrect cHostBits value: %d\n", pHdr->cHostBits));
    1509             return VERR_SSM_INTEGRITY_SIZES;
     1509            return VERR_SSM_INTEGRITY_HEADER;
    15101510        }
    15111511        if (    pHdr->cbGCPhys != sizeof(uint32_t)
     
    15131513        {
    15141514            LogRel(("SSM: Incorrect cbGCPhys value: %d\n", pHdr->cbGCPhys));
    1515             return VERR_SSM_INTEGRITY_SIZES;
     1515            return VERR_SSM_INTEGRITY_HEADER;
    15161516        }
    15171517        if (    pHdr->cbGCPtr != sizeof(uint32_t)
     
    15191519        {
    15201520            LogRel(("SSM: Incorrect cbGCPtr value: %d\n", pHdr->cbGCPtr));
    1521             return VERR_SSM_INTEGRITY_SIZES;
     1521            return VERR_SSM_INTEGRITY_HEADER;
    15221522        }
    15231523    }
     
    35023502
    35033503/**
     3504 * Skips to the end of the current data unit.
     3505 *
     3506 * Since version 2 of the format, the load exec callback have to explicitly call
     3507 * this API if it wish to be lazy for some reason.  This is because there seldom
     3508 * is a good reason to not read your entire data unit and it was hiding bugs.
     3509 *
     3510 * @returns VBox status code.
     3511 * @param   pSSM                The saved state handle.
     3512 */
     3513VMMR3DECL(int) SSMR3SkipToEndOfUnit(PSSMHANDLE pSSM)
     3514{
     3515    /* nothing to do here.  */
     3516    return VINF_SUCCESS;
     3517}
     3518
     3519
     3520/**
    35043521 * Query what the VBox status code of the operation is.
    35053522 *
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