VirtualBox

Changeset 21927 in vbox for trunk/src/VBox


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

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

Location:
trunk/src/VBox/VMM
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • 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