VirtualBox

Changeset 22480 in vbox for trunk/src/VBox/VMM


Ignore:
Timestamp:
Aug 26, 2009 5:14:13 PM (15 years ago)
Author:
vboxsync
Message:

SSM,VMM,Devices,Main,VBoxBFE: Live snapshot/migration SSM API adjustments.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/CPUM.cpp

    r22070 r22480  
    100100static int cpumR3CpuIdInit(PVM pVM);
    101101static DECLCALLBACK(int)  cpumR3Save(PVM pVM, PSSMHANDLE pSSM);
    102 static DECLCALLBACK(int)  cpumR3Load(PVM pVM, PSSMHANDLE pSSM, uint32_t u32Version);
     102static DECLCALLBACK(int)  cpumR3Load(PVM pVM, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPhase);
    103103static DECLCALLBACK(void) cpumR3InfoAll(PVM pVM, PCDBGFINFOHLP pHlp, const char *pszArgs);
    104104static DECLCALLBACK(void) cpumR3InfoGuest(PVM pVM, PCDBGFINFOHLP pHlp, const char *pszArgs);
     
    199199     */
    200200    int rc = SSMR3RegisterInternal(pVM, "cpum", 1, CPUM_SAVED_STATE_VERSION, sizeof(CPUM),
     201                                   NULL, NULL, NULL,
    201202                                   NULL, cpumR3Save, NULL,
    202203                                   NULL, cpumR3Load, NULL);
     
    990991 * @param   pVM             VM Handle.
    991992 * @param   pSSM            SSM operation handle.
    992  * @param   u32Version      Data layout version.
    993  */
    994 static DECLCALLBACK(int) cpumR3Load(PVM pVM, PSSMHANDLE pSSM, uint32_t u32Version)
    995 {
     993 * @param   uVersion        Data layout version.
     994 */
     995static DECLCALLBACK(int) cpumR3Load(PVM pVM, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPhase)
     996{
     997    Assert(uPhase == SSM_PHASE_FINAL); NOREF(uPhase);
     998
    996999    /*
    9971000     * Validate version.
    9981001     */
    999     if (    u32Version != CPUM_SAVED_STATE_VERSION
    1000         &&  u32Version != CPUM_SAVED_STATE_VERSION_VER2_1_NOMSR
    1001         &&  u32Version != CPUM_SAVED_STATE_VERSION_VER2_0
    1002         &&  u32Version != CPUM_SAVED_STATE_VERSION_VER1_6)
    1003     {
    1004         AssertMsgFailed(("cpuR3Load: Invalid version u32Version=%d!\n", u32Version));
     1002    if (    uVersion != CPUM_SAVED_STATE_VERSION
     1003        &&  uVersion != CPUM_SAVED_STATE_VERSION_VER2_1_NOMSR
     1004        &&  uVersion != CPUM_SAVED_STATE_VERSION_VER2_0
     1005        &&  uVersion != CPUM_SAVED_STATE_VERSION_VER1_6)
     1006    {
     1007        AssertMsgFailed(("cpuR3Load: Invalid version uVersion=%d!\n", uVersion));
    10051008        return VERR_SSM_UNSUPPORTED_DATA_UNIT_VERSION;
    10061009    }
    10071010
    10081011    /* Set the size of RTGCPTR for SSMR3GetGCPtr. */
    1009     if (u32Version == CPUM_SAVED_STATE_VERSION_VER1_6)
     1012    if (uVersion == CPUM_SAVED_STATE_VERSION_VER1_6)
    10101013        SSMR3SetGCPtrSize(pSSM, sizeof(RTGCPTR32));
    1011     else if (u32Version <= CPUM_SAVED_STATE_VERSION)
     1014    else if (uVersion <= CPUM_SAVED_STATE_VERSION)
    10121015        SSMR3SetGCPtrSize(pSSM, HC_ARCH_BITS == 32 ? sizeof(RTGCPTR32) : sizeof(RTGCPTR));
    10131016
     
    10151018     * Restore.
    10161019     */
    1017     for (unsigned i=0;i<pVM->cCPUs;i++)
     1020    for (VMCPUID i = 0; i < pVM->cCPUs; i++)
    10181021    {
    10191022        PVMCPU   pVCpu = &pVM->aCpus[i];
     
    10261029    }
    10271030
    1028     if (u32Version == CPUM_SAVED_STATE_VERSION_VER1_6)
     1031    if (uVersion == CPUM_SAVED_STATE_VERSION_VER1_6)
    10291032    {
    10301033        CPUMCTX_VER1_6 cpumctx16;
     
    10401043    else
    10411044    {
    1042         if (u32Version >= CPUM_SAVED_STATE_VERSION_VER2_1_NOMSR)
     1045        if (uVersion >= CPUM_SAVED_STATE_VERSION_VER2_1_NOMSR)
    10431046        {
    10441047            int rc = SSMR3GetU32(pSSM, &pVM->cCPUs);
     
    10481051        if (    !pVM->cCPUs
    10491052            ||  pVM->cCPUs > VMM_MAX_CPU_COUNT
    1050             ||  (   u32Version == CPUM_SAVED_STATE_VERSION_VER2_0
     1053            ||  (   uVersion == CPUM_SAVED_STATE_VERSION_VER2_0
    10511054                 && pVM->cCPUs != 1))
    10521055        {
     
    10551058        }
    10561059
    1057         for (unsigned i=0;i<pVM->cCPUs;i++)
     1060        for (VMCPUID i = 0; i < pVM->cCPUs; i++)
    10581061        {
    10591062            SSMR3GetMem(pSSM, &pVM->aCpus[i].cpum.s.Guest, sizeof(pVM->aCpus[i].cpum.s.Guest));
    10601063            SSMR3GetU32(pSSM, &pVM->aCpus[i].cpum.s.fUseFlags);
    10611064            SSMR3GetU32(pSSM, &pVM->aCpus[i].cpum.s.fChanged);
    1062             if (u32Version == CPUM_SAVED_STATE_VERSION)
     1065            if (uVersion == CPUM_SAVED_STATE_VERSION)
    10631066                SSMR3GetMem(pSSM, &pVM->aCpus[i].cpum.s.GuestMsr, sizeof(pVM->aCpus[i].cpum.s.GuestMsr));
    10641067        }
  • trunk/src/VBox/VMM/EM.cpp

    r21403 r22480  
    8484*******************************************************************************/
    8585static DECLCALLBACK(int) emR3Save(PVM pVM, PSSMHANDLE pSSM);
    86 static DECLCALLBACK(int) emR3Load(PVM pVM, PSSMHANDLE pSSM, uint32_t u32Version);
     86static DECLCALLBACK(int) emR3Load(PVM pVM, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPhase);
    8787static int emR3Debug(PVM pVM, PVMCPU pVCpu, int rc);
    8888static int emR3RemStep(PVM pVM, PVMCPU pVCpu);
     
    131131     */
    132132    rc = SSMR3RegisterInternal(pVM, "em", 0, EM_SAVED_STATE_VERSION, 16,
     133                               NULL, NULL, NULL,
    133134                               NULL, emR3Save, NULL,
    134135                               NULL, emR3Load, NULL);
     
    516517 * @param   pVM             VM Handle.
    517518 * @param   pSSM            SSM operation handle.
    518  * @param   u32Version      Data layout version.
    519  */
    520 static DECLCALLBACK(int) emR3Load(PVM pVM, PSSMHANDLE pSSM, uint32_t u32Version)
     519 * @param   uVersion        Data layout version.
     520 * @param   uPhase          The data phase.
     521 */
     522static DECLCALLBACK(int) emR3Load(PVM pVM, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPhase)
    521523{
    522     int rc = VINF_SUCCESS;
    523 
    524524    /*
    525525     * Validate version.
    526526     */
    527     if (    u32Version != EM_SAVED_STATE_VERSION
    528         &&  u32Version != EM_SAVED_STATE_VERSION_PRE_SMP)
    529     {
    530         AssertMsgFailed(("emR3Load: Invalid version u32Version=%d (current %d)!\n", u32Version, EM_SAVED_STATE_VERSION));
     527    if (    uVersion != EM_SAVED_STATE_VERSION
     528        &&  uVersion != EM_SAVED_STATE_VERSION_PRE_SMP)
     529    {
     530        AssertMsgFailed(("emR3Load: Invalid version uVersion=%d (current %d)!\n", uVersion, EM_SAVED_STATE_VERSION));
    531531        return VERR_SSM_UNSUPPORTED_DATA_UNIT_VERSION;
    532532    }
     
    539539        PVMCPU pVCpu = &pVM->aCpus[i];
    540540
    541         rc = SSMR3GetBool(pSSM, &pVCpu->em.s.fForceRAW);
     541        int rc = SSMR3GetBool(pSSM, &pVCpu->em.s.fForceRAW);
    542542        if (RT_FAILURE(rc))
    543543            pVCpu->em.s.fForceRAW = false;
    544 
    545         if (u32Version > EM_SAVED_STATE_VERSION_PRE_SMP)
     544        AssertRCReturn(rc, rc);
     545
     546        if (uVersion > EM_SAVED_STATE_VERSION_PRE_SMP)
    546547        {
    547548            AssertCompile(sizeof(pVCpu->em.s.enmPrevState) == sizeof(uint32_t));
     
    554555        Assert(!pVCpu->em.s.pCliStatTree);
    555556    }
    556     return rc;
     557    return VINF_SUCCESS;
    557558}
    558559
  • trunk/src/VBox/VMM/HWACCM.cpp

    r22290 r22480  
    270270*******************************************************************************/
    271271static DECLCALLBACK(int) hwaccmR3Save(PVM pVM, PSSMHANDLE pSSM);
    272 static DECLCALLBACK(int) hwaccmR3Load(PVM pVM, PSSMHANDLE pSSM, uint32_t u32Version);
     272static DECLCALLBACK(int) hwaccmR3Load(PVM pVM, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPhase);
    273273
    274274
     
    308308     */
    309309    int rc = SSMR3RegisterInternal(pVM, "HWACCM", 0, HWACCM_SSM_VERSION, sizeof(HWACCM),
     310                                   NULL, NULL, NULL,
    310311                                   NULL, hwaccmR3Save, NULL,
    311312                                   NULL, hwaccmR3Load, NULL);
     
    327328     * Check CFGM options.
    328329     */
    329     PCFGMNODE pRoot      = CFGMR3GetRoot(pVM); 
     330    PCFGMNODE pRoot      = CFGMR3GetRoot(pVM);
    330331    PCFGMNODE pHWVirtExt = CFGMR3GetChild(pRoot, "HWVirtExt/");
    331332    /* Nested paging: disabled by default. */
     
    409410    STAM_REG(pVM, &pVM->hwaccm.s.StatTPRReplaceSuccess, STAMTYPE_COUNTER, "/HWACCM/TPR/Replace/Success", STAMUNIT_OCCURENCES, "Number of times an instruction was successfully patched.");
    410411    STAM_REG(pVM, &pVM->hwaccm.s.StatTPRReplaceFailure, STAMTYPE_COUNTER, "/HWACCM/TPR/Replace/Failed",  STAMUNIT_OCCURENCES, "Number of unsuccessful patch attempts.");
    411    
     412
    412413    /*
    413414     * Statistics.
     
    512513        HWACCM_REG_COUNTER(&pVCpu->hwaccm.s.StatTSCIntercept,           "/HWACCM/CPU%d/TSC/Intercept");
    513514        HWACCM_REG_COUNTER(&pVCpu->hwaccm.s.StatTSCInterceptOverFlow,   "/HWACCM/CPU%d/TSC/InterceptOverflow");
    514        
     515
    515516        HWACCM_REG_COUNTER(&pVCpu->hwaccm.s.StatDRxArmed,               "/HWACCM/CPU%d/Debug/Armed");
    516517        HWACCM_REG_COUNTER(&pVCpu->hwaccm.s.StatDRxContextSwitch,       "/HWACCM/CPU%d/Debug/ContextSwitch");
     
    14191420 * @returns VBox status code.
    14201421 * @param   pVM     The VM handle.
    1421  * @param   pVCpu   The VMCPU for the EMT we're being called on. 
     1422 * @param   pVCpu   The VMCPU for the EMT we're being called on.
    14221423 * @param   pvUser  Unused
    14231424 *
     
    15601561 * @returns VBox status code.
    15611562 * @param   pVM     The VM handle.
    1562  * @param   pVCpu   The VMCPU for the EMT we're being called on. 
     1563 * @param   pVCpu   The VMCPU for the EMT we're being called on.
    15631564 * @param   pvUser  User specified CPU context
    15641565 *
     
    17171718 * @returns VBox status code.
    17181719 * @param   pVM     The VM handle.
    1719  * @param   pVCpu   The VMCPU for the EMT we're being called on. 
     1720 * @param   pVCpu   The VMCPU for the EMT we're being called on.
    17201721 * @param   pvUser  User specified CPU context
    17211722 *
     
    22432244        uint32_t u32Val  = 0;
    22442245
    2245         rc = IOMIOPortRead(pVM, pVCpu->hwaccm.s.PendingIO.s.Port.uPort, 
    2246                            &u32Val, 
     2246        rc = IOMIOPortRead(pVM, pVCpu->hwaccm.s.PendingIO.s.Port.uPort,
     2247                           &u32Val,
    22472248                           pVCpu->hwaccm.s.PendingIO.s.Port.cbSize);
    22482249        if (IOM_SUCCESS(rc))
     
    22562257
    22572258    case HWACCMPENDINGIO_PORT_WRITE:
    2258         rc = IOMIOPortWrite(pVM, pVCpu->hwaccm.s.PendingIO.s.Port.uPort, 
    2259                             pCtx->eax & pVCpu->hwaccm.s.PendingIO.s.Port.uAndVal, 
     2259        rc = IOMIOPortWrite(pVM, pVCpu->hwaccm.s.PendingIO.s.Port.uPort,
     2260                            pCtx->eax & pVCpu->hwaccm.s.PendingIO.s.Port.uAndVal,
    22602261                            pVCpu->hwaccm.s.PendingIO.s.Port.cbSize);
    22612262        if (IOM_SUCCESS(rc))
     
    24172418 * @param   pVM             VM Handle.
    24182419 * @param   pSSM            SSM operation handle.
    2419  * @param   u32Version      Data layout version.
    2420  */
    2421 static DECLCALLBACK(int) hwaccmR3Load(PVM pVM, PSSMHANDLE pSSM, uint32_t u32Version)
     2420 * @param   uVersion        Data layout version.
     2421 * @param   uPhase          The data phase.
     2422 */
     2423static DECLCALLBACK(int) hwaccmR3Load(PVM pVM, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPhase)
    24222424{
    24232425    int rc;
    24242426
    24252427    Log(("hwaccmR3Load:\n"));
     2428    Assert(uPhase == SSM_PHASE_FINAL); NOREF(uPhase);
    24262429
    24272430    /*
    24282431     * Validate version.
    24292432     */
    2430     if (   u32Version != HWACCM_SSM_VERSION
    2431         && u32Version != HWACCM_SSM_VERSION_NO_PATCHING
    2432         && u32Version != HWACCM_SSM_VERSION_2_0_X)
    2433     {
    2434         AssertMsgFailed(("hwaccmR3Load: Invalid version u32Version=%d!\n", u32Version));
     2433    if (   uVersion != HWACCM_SSM_VERSION
     2434        && uVersion != HWACCM_SSM_VERSION_NO_PATCHING
     2435        && uVersion != HWACCM_SSM_VERSION_2_0_X)
     2436    {
     2437        AssertMsgFailed(("hwaccmR3Load: Invalid version uVersion=%d!\n", uVersion));
    24352438        return VERR_SSM_UNSUPPORTED_DATA_UNIT_VERSION;
    24362439    }
    2437     for (unsigned i=0;i<pVM->cCPUs;i++)
     2440    for (VMCPUID i = 0; i < pVM->cCPUs; i++)
    24382441    {
    24392442        rc = SSMR3GetU32(pSSM, &pVM->aCpus[i].hwaccm.s.Event.fPending);
     
    24442447        AssertRCReturn(rc, rc);
    24452448
    2446         if (u32Version >= HWACCM_SSM_VERSION_NO_PATCHING)
     2449        if (uVersion >= HWACCM_SSM_VERSION_NO_PATCHING)
    24472450        {
    24482451            uint32_t val;
     
    24622465    }
    24632466#ifdef VBOX_HWACCM_WITH_GUEST_PATCHING
    2464     if (u32Version > HWACCM_SSM_VERSION_NO_PATCHING)
     2467    if (uVersion > HWACCM_SSM_VERSION_NO_PATCHING)
    24652468    {
    24662469        rc = SSMR3GetGCPtr(pSSM, &pVM->hwaccm.s.pGuestPatchMem);
     
    25082511            rc = SSMR3GetU32(pSSM, &pPatch->pJumpTarget);
    25092512            AssertRCReturn(rc, rc);
    2510            
     2513
    25112514            rc = RTAvloU32Insert(&pVM->hwaccm.s.svm.PatchTree, &pPatch->Core);
    25122515            AssertRC(rc);
  • trunk/src/VBox/VMM/MM.cpp

    r19663 r22480  
    177177*******************************************************************************/
    178178static DECLCALLBACK(int) mmR3Save(PVM pVM, PSSMHANDLE pSSM);
    179 static DECLCALLBACK(int) mmR3Load(PVM pVM, PSSMHANDLE pSSM, uint32_t u32Version);
     179static DECLCALLBACK(int) mmR3Load(PVM pVM, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPhase);
    180180
    181181
     
    266266             */
    267267            rc = SSMR3RegisterInternal(pVM, "mm", 1, MM_SAVED_STATE_VERSION, sizeof(uint32_t) * 2,
     268                                       NULL, NULL, NULL,
    268269                                       NULL, mmR3Save, NULL,
    269270                                       NULL, mmR3Load, NULL);
     
    528529 * @param   pVM             VM Handle.
    529530 * @param   pSSM            SSM operation handle.
    530  * @param   u32Version      Data layout version.
    531  */
    532 static DECLCALLBACK(int) mmR3Load(PVM pVM, PSSMHANDLE pSSM, uint32_t u32Version)
     531 * @param   uVersion       Data layout version.
     532 * @param   uPhase          The data phase.
     533 */
     534static DECLCALLBACK(int) mmR3Load(PVM pVM, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPhase)
    533535{
    534536    LogFlow(("mmR3Load:\n"));
     537    Assert(uPhase == SSM_PHASE_FINAL); NOREF(uPhase);
    535538
    536539    /*
    537540     * Validate version.
    538541     */
    539     if (    SSM_VERSION_MAJOR_CHANGED(u32Version, MM_SAVED_STATE_VERSION)
    540         ||  !u32Version)
    541     {
    542         AssertMsgFailed(("mmR3Load: Invalid version u32Version=%d!\n", u32Version));
     542    if (    SSM_VERSION_MAJOR_CHANGED(uVersion, MM_SAVED_STATE_VERSION)
     543        ||  !uVersion)
     544    {
     545        AssertMsgFailed(("mmR3Load: Invalid version uVersion=%d!\n", uVersion));
    543546        return VERR_SSM_UNSUPPORTED_DATA_UNIT_VERSION;
    544547    }
     
    552555    /* cBasePages (ignored) */
    553556    uint64_t cPages;
    554     if (u32Version >= 2)
     557    if (uVersion >= 2)
    555558        rc = SSMR3GetU64(pSSM, &cPages);
    556559    else
     
    564567    /* cbRamBase */
    565568    uint64_t cb;
    566     if (u32Version != 1)
     569    if (uVersion != 1)
    567570        rc = SSMR3GetU64(pSSM, &cb);
    568571    else
  • trunk/src/VBox/VMM/PATM/CSAM.cpp

    r21876 r22480  
    7070*******************************************************************************/
    7171static DECLCALLBACK(int) csamr3Save(PVM pVM, PSSMHANDLE pSSM);
    72 static DECLCALLBACK(int) csamr3Load(PVM pVM, PSSMHANDLE pSSM, uint32_t u32Version);
     72static DECLCALLBACK(int) csamr3Load(PVM pVM, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPhase);
    7373static DECLCALLBACK(int) CSAMCodePageWriteHandler(PVM pVM, RTGCPTR GCPtr, void *pvPtr, void *pvBuf, size_t cbBuf, PGMACCESSTYPE enmAccessType, void *pvUser);
    7474static DECLCALLBACK(int) CSAMCodePageInvalidate(PVM pVM, RTGCPTR GCPtr);
     
    130130     */
    131131    rc = SSMR3RegisterInternal(pVM, "CSAM", 0, CSAM_SSM_VERSION, sizeof(pVM->csam.s) + PAGE_SIZE*16,
     132                               NULL, NULL, NULL,
    132133                               NULL, csamr3Save, NULL,
    133134                               NULL, csamr3Load, NULL);
     
    440441 * @param   pVM             VM Handle.
    441442 * @param   pSSM            SSM operation handle.
    442  * @param   u32Version      Data layout version.
    443  */
    444 static DECLCALLBACK(int) csamr3Load(PVM pVM, PSSMHANDLE pSSM, uint32_t u32Version)
     443 * @param   uVersion        Data layout version.
     444 * @param   uPhase          The data phase.
     445 */
     446static DECLCALLBACK(int) csamr3Load(PVM pVM, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPhase)
    445447{
    446448    int  rc;
    447449    CSAM csamInfo;
    448450
    449     if (u32Version != CSAM_SSM_VERSION)
    450     {
    451         AssertMsgFailed(("csamR3Load: Invalid version u32Version=%d!\n", u32Version));
     451    Assert(uPhase == SSM_PHASE_FINAL); NOREF(uPhase);
     452    if (uVersion != CSAM_SSM_VERSION)
     453    {
     454        AssertMsgFailed(("csamR3Load: Invalid version uVersion=%d!\n", uVersion));
    452455        return VERR_SSM_UNSUPPORTED_DATA_UNIT_VERSION;
    453456    }
  • trunk/src/VBox/VMM/PATM/PATM.cpp

    r22147 r22480  
    177177     */
    178178    rc = SSMR3RegisterInternal(pVM, "PATM", 0, PATM_SSM_VERSION, sizeof(pVM->patm.s) + PATCH_MEMORY_SIZE  + PAGE_SIZE + PATM_STACK_TOTAL_SIZE + PAGE_SIZE,
    179                                NULL, patmr3Save, NULL,
    180                                NULL, patmr3Load, NULL);
    181     if (RT_FAILURE(rc))
    182     {
    183         AssertRC(rc);
    184         return rc;
    185     }
     179                               NULL, NULL, NULL,
     180                               NULL, patmR3Save, NULL,
     181                               NULL, patmR3Load, NULL);
     182    AssertRCReturn(rc, rc);
    186183
    187184#ifdef VBOX_WITH_DEBUGGER
  • trunk/src/VBox/VMM/PATM/PATMInternal.h

    r20374 r22480  
    524524
    525525
    526 /**
    527  * Execute state save operation.
    528  *
    529  * @returns VBox status code.
    530  * @param   pVM             VM Handle.
    531  * @param   pSSM            SSM operation handle.
    532  */
    533 DECLCALLBACK(int) patmr3Save(PVM pVM, PSSMHANDLE pSSM);
    534526
    535527DECLCALLBACK(int) patmVirtPageHandler(PVM pVM, RTGCPTR GCPtr, void *pvPtr, void *pvBuf, size_t cbBuf, PGMACCESSTYPE enmAccessType, void *pvUser);
    536528
    537 /**
    538  * Execute state load operation.
    539  *
    540  * @returns VBox status code.
    541  * @param   pVM             VM Handle.
    542  * @param   pSSM            SSM operation handle.
    543  * @param   u32Version      Data layout version.
    544  */
    545 DECLCALLBACK(int) patmr3Load(PVM pVM, PSSMHANDLE pSSM, uint32_t u32Version);
     529DECLCALLBACK(int) patmR3Save(PVM pVM, PSSMHANDLE pSSM);
     530DECLCALLBACK(int) patmR3Load(PVM pVM, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPhase);
    546531
    547532#ifdef IN_RING3
  • trunk/src/VBox/VMM/PATM/PATMSSM.cpp

    r19144 r22480  
    153153        if (*pFixup == pVM->pVMRC + RT_OFFSETOF(VM, aCpus[0].fLocalForcedActions))
    154154            rec.Core.Key = (AVLPVKEY)PATM_FIXUP_CPU_FF_ACTION;
    155         else 
     155        else
    156156        if (*pFixup == CPUMR3GetGuestCpuIdDefRCPtr(pVM))
    157157            rec.Core.Key = (AVLPVKEY)PATM_FIXUP_CPUID_DEFAULT;
    158         else 
     158        else
    159159        if (*pFixup == CPUMR3GetGuestCpuIdStdRCPtr(pVM))
    160160            rec.Core.Key = (AVLPVKEY)PATM_FIXUP_CPUID_STANDARD;
    161         else 
     161        else
    162162        if (*pFixup == CPUMR3GetGuestCpuIdExtRCPtr(pVM))
    163163            rec.Core.Key = (AVLPVKEY)PATM_FIXUP_CPUID_EXTENDED;
    164         else 
     164        else
    165165        if (*pFixup == CPUMR3GetGuestCpuIdCentaurRCPtr(pVM))
    166166            rec.Core.Key = (AVLPVKEY)PATM_FIXUP_CPUID_CENTAUR;
     
    236236 * @param   pSSM            SSM operation handle.
    237237 */
    238 DECLCALLBACK(int) patmr3Save(PVM pVM, PSSMHANDLE pSSM)
     238DECLCALLBACK(int) patmR3Save(PVM pVM, PSSMHANDLE pSSM)
    239239{
    240240    PATM patmInfo = pVM->patm.s;
     
    299299 * @param   pVM             VM Handle.
    300300 * @param   pSSM            SSM operation handle.
    301  * @param   u32Version      Data layout version.
     301 * @param   uVersion        Data layout version.
     302 * @param   uPhase          The data phase.
    302303 */
    303 DECLCALLBACK(int) patmr3Load(PVM pVM, PSSMHANDLE pSSM, uint32_t u32Version)
     304DECLCALLBACK(int) patmR3Load(PVM pVM, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPhase)
    304305{
    305306    PATM patmInfo;
    306307    int  rc;
    307308
    308     if (    u32Version != PATM_SSM_VERSION
    309         &&  u32Version != PATM_SSM_VERSION_FIXUP_HACK
    310         &&  u32Version != PATM_SSM_VERSION_VER16
     309    if (    uVersion != PATM_SSM_VERSION
     310        &&  uVersion != PATM_SSM_VERSION_FIXUP_HACK
     311        &&  uVersion != PATM_SSM_VERSION_VER16
    311312#ifdef PATM_WITH_NEW_SSM
    312         &&  u32Version != PATM_SSM_VERSION_GETPUTMEM)
     313        &&  uVersion != PATM_SSM_VERSION_GETPUTMEM)
    313314#else
    314315       )
    315316#endif
    316317    {
    317         AssertMsgFailed(("patmR3Load: Invalid version u32Version=%d!\n", u32Version));
     318        AssertMsgFailed(("patmR3Load: Invalid version uVersion=%d!\n", uVersion));
    318319        return VERR_SSM_UNSUPPORTED_DATA_UNIT_VERSION;
    319320    }
     
    325326     */
    326327#ifdef PATM_WITH_NEW_SSM
    327     if (u32Version == PATM_SSM_VERSION_GETPUTMEM)
     328    if (uVersion == PATM_SSM_VERSION_GETPUTMEM)
    328329    {
    329330#endif
     
    478479     */
    479480#ifdef PATM_WITH_NEW_SSM
    480     if (u32Version == PATM_SSM_VERSION_GETPUTMEM)
     481    if (uVersion == PATM_SSM_VERSION_GETPUTMEM)
    481482    {
    482483#endif
     
    644645                }
    645646
    646                 patmCorrectFixup(pVM, u32Version, patmInfo, &pPatchRec->patch, &rec, offset, pFixup);
     647                patmCorrectFixup(pVM, uVersion, patmInfo, &pPatchRec->patch, &rec, offset, pFixup);
    647648            }
    648649
     
    719720
    720721        /* Correct fixups that refer to PATM structures in the hypervisor region (their addresses might have changed). */
    721         patmCorrectFixup(pVM, u32Version, patmInfo, &pVM->patm.s.pGlobalPatchRec->patch, pRec, offset, pFixup);
     722        patmCorrectFixup(pVM, uVersion, patmInfo, &pVM->patm.s.pGlobalPatchRec->patch, pRec, offset, pFixup);
    722723    }
    723724
  • trunk/src/VBox/VMM/PDM.cpp

    r21144 r22480  
    288288*******************************************************************************/
    289289static DECLCALLBACK(int) pdmR3Save(PVM pVM, PSSMHANDLE pSSM);
    290 static DECLCALLBACK(int) pdmR3Load(PVM pVM, PSSMHANDLE pSSM, uint32_t u32Version);
     290static DECLCALLBACK(int) pdmR3Load(PVM pVM, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPhase);
    291291static DECLCALLBACK(int) pdmR3LoadPrep(PVM pVM, PSSMHANDLE pSSM);
    292292
     
    357357         */
    358358        rc = SSMR3RegisterInternal(pVM, "pdm", 1, PDM_SAVED_STATE_VERSION, 128,
     359                                   NULL, NULL, NULL,
    359360                                   NULL, pdmR3Save, NULL,
    360361                                   pdmR3LoadPrep, pdmR3Load, NULL);
     
    717718 * @param   pVM             VM Handle.
    718719 * @param   pSSM            SSM operation handle.
    719  * @param   u32Version      Data layout version.
    720  */
    721 static DECLCALLBACK(int) pdmR3Load(PVM pVM, PSSMHANDLE pSSM, uint32_t u32Version)
     720 * @param   uVersion        Data layout version.
     721 * @param   uPhase          The data phase.
     722 */
     723static DECLCALLBACK(int) pdmR3Load(PVM pVM, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPhase)
    722724{
    723725    int rc;
    724726
    725727    LogFlow(("pdmR3Load:\n"));
     728    Assert(uPhase == SSM_PHASE_FINAL); NOREF(uPhase);
    726729
    727730    /*
    728731     * Validate version.
    729732     */
    730     if (    u32Version != PDM_SAVED_STATE_VERSION
    731         &&  u32Version != PDM_SAVED_STATE_VERSION_PRE_NMI_FF)
    732     {
    733         AssertMsgFailed(("pdmR3Load: Invalid version u32Version=%d!\n", u32Version));
     733    if (    uVersion != PDM_SAVED_STATE_VERSION
     734        &&  uVersion != PDM_SAVED_STATE_VERSION_PRE_NMI_FF)
     735    {
     736        AssertMsgFailed(("pdmR3Load: Invalid version uVersion=%d!\n", uVersion));
    734737        return VERR_SSM_UNSUPPORTED_DATA_UNIT_VERSION;
    735738    }
     
    738741     * Load the interrupt and DMA states.
    739742     */
    740     for (unsigned idCpu = 0; idCpu < pVM->cCPUs; idCpu++)
     743    for (VMCPUID idCpu = 0; idCpu < pVM->cCPUs; idCpu++)
    741744    {
    742745        PVMCPU pVCpu = &pVM->aCpus[idCpu];
     
    770773            VMCPU_FF_SET(pVCpu, VMCPU_FF_INTERRUPT_PIC);
    771774
    772         if (u32Version > PDM_SAVED_STATE_VERSION_PRE_NMI_FF)
     775        if (uVersion > PDM_SAVED_STATE_VERSION_PRE_NMI_FF)
    773776        {
    774777            /* NMI interrupt */
     
    824827    uint32_t i = 0;
    825828    PPDMDEVINS pDevIns = pVM->pdm.s.pDevInstances;
    826     for (;;pDevIns = pDevIns->Internal.s.pNextR3, i++)
     829    for (;; pDevIns = pDevIns->Internal.s.pNextR3, i++)
    827830    {
    828831        /* Get the separator / terminator. */
  • trunk/src/VBox/VMM/PDMDevHlp.cpp

    r22277 r22480  
    399399
    400400/** @copydoc PDMDEVHLPR3::pfnSSMRegister */
    401 static DECLCALLBACK(int) pdmR3DevHlp_SSMRegister(PPDMDEVINS pDevIns, const char *pszName, uint32_t u32Instance, uint32_t u32Version, size_t cbGuess,
     401static DECLCALLBACK(int) pdmR3DevHlp_SSMRegister(PPDMDEVINS pDevIns, uint32_t uVersion, size_t cbGuess, const char *pszBefore,
     402                                                 PFNSSMDEVLIVEPREP pfnLivePrep, PFNSSMDEVLIVEEXEC pfnLiveExec, PFNSSMDEVLIVEVOTE pfnLiveVote,
    402403                                                 PFNSSMDEVSAVEPREP pfnSavePrep, PFNSSMDEVSAVEEXEC pfnSaveExec, PFNSSMDEVSAVEDONE pfnSaveDone,
    403404                                                 PFNSSMDEVLOADPREP pfnLoadPrep, PFNSSMDEVLOADEXEC pfnLoadExec, PFNSSMDEVLOADDONE pfnLoadDone)
     
    405406    PDMDEV_ASSERT_DEVINS(pDevIns);
    406407    VM_ASSERT_EMT(pDevIns->Internal.s.pVMR3);
    407     LogFlow(("pdmR3DevHlp_SSMRegister: caller='%s'/%d: pszName=%p:{%s} u32Instance=%#x u32Version=#x cbGuess=%#x pfnSavePrep=%p pfnSaveExec=%p pfnSaveDone=%p pszLoadPrep=%p pfnLoadExec=%p pfnLoaddone=%p\n",
    408              pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, pszName, pszName, u32Instance, u32Version, cbGuess, pfnSavePrep, pfnSaveExec, pfnSaveDone, pfnLoadPrep, pfnLoadExec, pfnLoadDone));
    409 
    410     int rc = SSMR3RegisterDevice(pDevIns->Internal.s.pVMR3, pDevIns, pszName, u32Instance, u32Version, cbGuess, NULL,
     408    LogFlow(("pdmR3DevHlp_SSMRegister: caller='%s'/%d: uVersion=#x cbGuess=%#x pszBefore=%p:{%s}\n"
     409             "    pfnLivePrep=%p pfnLiveExec=%p pfnLiveVote=%p pfnSavePrep=%p pfnSaveExec=%p pfnSaveDone=%p pszLoadPrep=%p pfnLoadExec=%p pfnLoadDone=%p\n",
     410             pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, uVersion, cbGuess, pszBefore, pszBefore,
     411             pfnLivePrep, pfnLiveExec, pfnLiveVote,
     412             pfnSavePrep, pfnSaveExec, pfnSaveDone,
     413             pfnLoadPrep, pfnLoadExec, pfnLoadDone));
     414
     415    int rc = SSMR3RegisterDevice(pDevIns->Internal.s.pVMR3, pDevIns, pDevIns->pDevReg->szDeviceName, pDevIns->iInstance,
     416                                 uVersion, cbGuess, pszBefore,
     417                                 pfnLivePrep, pfnLiveExec, pfnLiveVote,
    411418                                 pfnSavePrep, pfnSaveExec, pfnSaveDone,
    412419                                 pfnLoadPrep, pfnLoadExec, pfnLoadDone);
  • trunk/src/VBox/VMM/PDMDriver.cpp

    r22277 r22480  
    278278    AssertMsgReturn(pDrvReg->u32Version == PDM_DRVREG_VERSION, ("%#x\n", pDrvReg->u32Version), VERR_PDM_UNKNOWN_DRVREG_VERSION);
    279279    AssertReturn(pDrvReg->szDriverName[0], VERR_PDM_INVALID_DRIVER_REGISTRATION);
    280     AssertMsgReturn(memchr(pDrvReg->szDriverName, '\0', sizeof(pDrvReg->szDriverName)), 
     280    AssertMsgReturn(memchr(pDrvReg->szDriverName, '\0', sizeof(pDrvReg->szDriverName)),
    281281                    (".*s\n", sizeof(pDrvReg->szDriverName), pDrvReg->szDriverName),
    282282                    VERR_PDM_INVALID_DRIVER_REGISTRATION);
    283283    AssertMsgReturn((pDrvReg->fFlags & PDM_DRVREG_FLAGS_HOST_BITS_MASK) == PDM_DRVREG_FLAGS_HOST_BITS_DEFAULT,
    284                     ("%s: fFlags=%#x\n", pDrvReg->szDriverName, pDrvReg->fFlags), 
     284                    ("%s: fFlags=%#x\n", pDrvReg->szDriverName, pDrvReg->fFlags),
    285285                    VERR_PDM_INVALID_DRIVER_HOST_BITS);
    286286    AssertMsgReturn(pDrvReg->cMaxInstances > 0, ("%s: %#x\n", pDrvReg->szDriverName, pDrvReg->cMaxInstances),
     
    290290    AssertMsgReturn(VALID_PTR(pDrvReg->pfnConstruct), ("%s: %p\n", pDrvReg->szDriverName, pDrvReg->pfnConstruct),
    291291                    VERR_PDM_INVALID_DRIVER_REGISTRATION);
    292     AssertMsgReturn(pDrvReg->pfnSoftReset == NULL, ("%s: %p\n", pDrvReg->szDriverName, pDrvReg->pfnSoftReset), 
     292    AssertMsgReturn(pDrvReg->pfnSoftReset == NULL, ("%s: %p\n", pDrvReg->szDriverName, pDrvReg->pfnSoftReset),
    293293                    VERR_PDM_INVALID_DRIVER_REGISTRATION);
    294     AssertMsgReturn(pDrvReg->u32VersionEnd == PDM_DRVREG_VERSION, ("%s: #x\n", pDrvReg->szDriverName, pDrvReg->u32VersionEnd), 
     294    AssertMsgReturn(pDrvReg->u32VersionEnd == PDM_DRVREG_VERSION, ("%s: #x\n", pDrvReg->szDriverName, pDrvReg->u32VersionEnd),
    295295                    VERR_PDM_INVALID_DRIVER_REGISTRATION);
    296296
     
    393393 *
    394394 * @param   pDrvIns     Pointer to the driver instance to start with.
    395  * @param   fFlags      PDM_TACH_FLAGS_NOT_HOT_PLUG or 0. 
     395 * @param   fFlags      PDM_TACH_FLAGS_NOT_HOT_PLUG or 0.
    396396 */
    397397void pdmR3DrvDestroyChain(PPDMDRVINS pDrvIns, uint32_t fFlags)
     
    855855
    856856/** @copydoc PDMDRVHLP::pfnSSMRegister */
    857 static DECLCALLBACK(int) pdmR3DrvHlp_SSMRegister(PPDMDRVINS pDrvIns, const char *pszName, uint32_t u32Instance, uint32_t u32Version, size_t cbGuess,
     857static DECLCALLBACK(int) pdmR3DrvHlp_SSMRegister(PPDMDRVINS pDrvIns, uint32_t uVersion, size_t cbGuess,
     858                                                 PFNSSMDRVLIVEPREP pfnLivePrep, PFNSSMDRVLIVEEXEC pfnLiveExec, PFNSSMDRVLIVEVOTE pfnLiveVote,
    858859                                                 PFNSSMDRVSAVEPREP pfnSavePrep, PFNSSMDRVSAVEEXEC pfnSaveExec, PFNSSMDRVSAVEDONE pfnSaveDone,
    859860                                                 PFNSSMDRVLOADPREP pfnLoadPrep, PFNSSMDRVLOADEXEC pfnLoadExec, PFNSSMDRVLOADDONE pfnLoadDone)
     
    861862    PDMDRV_ASSERT_DRVINS(pDrvIns);
    862863    VM_ASSERT_EMT(pDrvIns->Internal.s.pVM);
    863     LogFlow(("pdmR3DrvHlp_SSMRegister: caller='%s'/%d: pszName=%p:{%s} u32Instance=%#x u32Version=#x cbGuess=%#x pfnSavePrep=%p pfnSaveExec=%p pfnSaveDone=%p pszLoadPrep=%p pfnLoadExec=%p pfnLoaddone=%p\n",
    864              pDrvIns->pDrvReg->szDriverName, pDrvIns->iInstance, pszName, pszName, u32Instance, u32Version, cbGuess, pfnSavePrep, pfnSaveExec, pfnSaveDone, pfnLoadPrep, pfnLoadExec, pfnLoadDone));
    865 
    866     int rc = SSMR3RegisterDriver(pDrvIns->Internal.s.pVM, pDrvIns, pszName, u32Instance, u32Version, cbGuess,
     864    LogFlow(("pdmR3DrvHlp_SSMRegister: caller='%s'/%d: uVersion=#x cbGuess=%#x \n"
     865             "    pfnLivePrep=%p pfnLiveExec=%p pfnLiveVote=%p  pfnSavePrep=%p pfnSaveExec=%p pfnSaveDone=%p pszLoadPrep=%p pfnLoadExec=%p pfnLoaddone=%p\n",
     866             pDrvIns->pDrvReg->szDriverName, pDrvIns->iInstance, uVersion, cbGuess,
     867             pfnLivePrep, pfnLiveExec, pfnLiveVote,
     868             pfnSavePrep, pfnSaveExec, pfnSaveDone, pfnLoadPrep, pfnLoadExec, pfnLoadDone));
     869
     870    int rc = SSMR3RegisterDriver(pDrvIns->Internal.s.pVM, pDrvIns, pDrvIns->pDrvReg->szDriverName, pDrvIns->iInstance,
     871                                 uVersion, cbGuess,
     872                                 pfnLivePrep, pfnLiveExec, pfnLiveVote,
    867873                                 pfnSavePrep, pfnSaveExec, pfnSaveDone,
    868874                                 pfnLoadPrep, pfnLoadExec, pfnLoadDone);
  • trunk/src/VBox/VMM/PGM.cpp

    r22327 r22480  
    634634#endif
    635635static DECLCALLBACK(int)  pgmR3Save(PVM pVM, PSSMHANDLE pSSM);
    636 static DECLCALLBACK(int)  pgmR3Load(PVM pVM, PSSMHANDLE pSSM, uint32_t u32Version);
     636static DECLCALLBACK(int)  pgmR3Load(PVM pVM, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPhase);
    637637static int                pgmR3ModeDataInit(PVM pVM, bool fResolveGCAndR0);
    638638static void               pgmR3ModeDataSwitch(PVM pVM, PVMCPU pVCpu, PGMMODE enmShw, PGMMODE enmGst);
     
    12831283
    12841284    rc = SSMR3RegisterInternal(pVM, "pgm", 1, PGM_SAVED_STATE_VERSION, (size_t)cbRam + sizeof(PGM),
     1285                               NULL, NULL, NULL,
    12851286                               NULL, pgmR3Save, NULL,
    12861287                               NULL, pgmR3Load, NULL);
     
    26752676 * @param   pVM                 The VM handle.
    26762677 * @param   pSSM                The SSM handle.
    2677  * @param   u32Version          The saved state version.
    2678  */
    2679 static int pgmR3LoadLocked(PVM pVM, PSSMHANDLE pSSM, uint32_t u32Version)
     2678 * @param   uVersion            The saved state version.
     2679 */
     2680static int pgmR3LoadLocked(PVM pVM, PSSMHANDLE pSSM, uint32_t uVersion)
    26802681{
    26812682    PPGM        pPGM = &pVM->pgm.s;
     
    26862687     * Load basic data (required / unaffected by relocation).
    26872688     */
    2688     if (u32Version >= PGM_SAVED_STATE_VERSION)
     2689    if (uVersion >= PGM_SAVED_STATE_VERSION)
    26892690    {
    26902691        rc = SSMR3GetStruct(pSSM, pPGM, &s_aPGMFields[0]);
     
    26972698        }
    26982699    }
    2699     else if (u32Version >= PGM_SAVED_STATE_VERSION_RR_DESC)
     2700    else if (uVersion >= PGM_SAVED_STATE_VERSION_RR_DESC)
    27002701    {
    27012702        AssertRelease(pVM->cCPUs == 1);
     
    28352836        char    szDesc[256];
    28362837        szDesc[0] = '\0';
    2837         if (u32Version >= PGM_SAVED_STATE_VERSION_RR_DESC)
     2838        if (uVersion >= PGM_SAVED_STATE_VERSION_RR_DESC)
    28382839        {
    28392840            rc = SSMR3GetStrZ(pSSM, szDesc, sizeof(szDesc));
     
    28422843            /* Since we've modified the description strings in r45878, only compare
    28432844               them if the saved state is more recent. */
    2844             if (u32Version != PGM_SAVED_STATE_VERSION_RR_DESC)
     2845            if (uVersion != PGM_SAVED_STATE_VERSION_RR_DESC)
    28452846                cchDesc = strlen(szDesc);
    28462847        }
     
    28592860                      && strcmp(szDesc, pRam->pszDesc)) )
    28602861                /* Hack for PDMDevHlpPhysReserve(pDevIns, 0xfff80000, 0x80000, "High ROM Region"); */
    2861             &&  (   u32Version != PGM_SAVED_STATE_VERSION_OLD_PHYS_CODE
     2862            &&  (   uVersion != PGM_SAVED_STATE_VERSION_OLD_PHYS_CODE
    28622863                 || GCPhys     != UINT32_C(0xfff80000)
    28632864                 || GCPhysLast != UINT32_C(0xffffffff)
     
    28842885
    28852886        uint32_t cPages = (GCPhysLast - GCPhys + 1) >> PAGE_SHIFT;
    2886         if (u32Version >= PGM_SAVED_STATE_VERSION_RR_DESC)
     2887        if (uVersion >= PGM_SAVED_STATE_VERSION_RR_DESC)
    28872888        {
    28882889            /*
     
    30293030 * @param   pVM             VM Handle.
    30303031 * @param   pSSM            SSM operation handle.
    3031  * @param   u32Version      Data layout version.
    3032  */
    3033 static DECLCALLBACK(int) pgmR3Load(PVM pVM, PSSMHANDLE pSSM, uint32_t u32Version)
     3032 * @param   uVersion        Data layout version.
     3033 * @param   uPhase          The data phase.
     3034 */
     3035static DECLCALLBACK(int) pgmR3Load(PVM pVM, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPhase)
    30343036{
    30353037    int     rc;
    30363038    PPGM    pPGM = &pVM->pgm.s;
     3039    Assert(uPhase == SSM_PHASE_FINAL); NOREF(uPhase);
    30373040
    30383041    /*
    30393042     * Validate version.
    30403043     */
    3041     if (    u32Version != PGM_SAVED_STATE_VERSION
    3042         &&  u32Version != PGM_SAVED_STATE_VERSION_2_2_2
    3043         &&  u32Version != PGM_SAVED_STATE_VERSION_RR_DESC
    3044         &&  u32Version != PGM_SAVED_STATE_VERSION_OLD_PHYS_CODE)
    3045     {
    3046         AssertMsgFailed(("pgmR3Load: Invalid version u32Version=%d (current %d)!\n", u32Version, PGM_SAVED_STATE_VERSION));
     3044    if (    uVersion != PGM_SAVED_STATE_VERSION
     3045        &&  uVersion != PGM_SAVED_STATE_VERSION_2_2_2
     3046        &&  uVersion != PGM_SAVED_STATE_VERSION_RR_DESC
     3047        &&  uVersion != PGM_SAVED_STATE_VERSION_OLD_PHYS_CODE)
     3048    {
     3049        AssertMsgFailed(("pgmR3Load: Invalid version uVersion=%d (current %d)!\n", uVersion, PGM_SAVED_STATE_VERSION));
    30473050        return VERR_SSM_UNSUPPORTED_DATA_UNIT_VERSION;
    30483051    }
     
    30583061     */
    30593062    pgmLock(pVM);
    3060     rc = pgmR3LoadLocked(pVM, pSSM, u32Version);
     3063    rc = pgmR3LoadLocked(pVM, pSSM, uVersion);
    30613064    pgmUnlock(pVM);
    30623065    if (RT_SUCCESS(rc))
     
    30653068         * We require a full resync now.
    30663069         */
    3067         for (unsigned i=0;i<pVM->cCPUs;i++)
     3070        for (VMCPUID i = 0; i < pVM->cCPUs; i++)
    30683071        {
    30693072            PVMCPU pVCpu = &pVM->aCpus[i];
     
    30763079        pgmR3HandlerPhysicalUpdateAll(pVM);
    30773080
    3078         for (unsigned i=0;i<pVM->cCPUs;i++)
     3081        for (VMCPUID i = 0; i < pVM->cCPUs; i++)
    30793082        {
    30803083            PVMCPU pVCpu = &pVM->aCpus[i];
  • trunk/src/VBox/VMM/SELM.cpp

    r22105 r22480  
    112112*******************************************************************************/
    113113static DECLCALLBACK(int)  selmR3Save(PVM pVM, PSSMHANDLE pSSM);
    114 static DECLCALLBACK(int)  selmR3Load(PVM pVM, PSSMHANDLE pSSM, uint32_t u32Version);
     114static DECLCALLBACK(int)  selmR3Load(PVM pVM, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPhase);
    115115static DECLCALLBACK(int)  selmR3LoadDone(PVM pVM, PSSMHANDLE pSSM);
    116116static DECLCALLBACK(int)  selmR3GuestGDTWriteHandler(PVM pVM, RTGCPTR GCPtr, void *pvPhys, void *pvBuf, size_t cbBuf, PGMACCESSTYPE enmAccessType, void *pvUser);
     
    199199     */
    200200    rc = SSMR3RegisterInternal(pVM, "selm", 1, SELM_SAVED_STATE_VERSION, sizeof(SELM),
     201                               NULL, NULL, NULL,
    201202                               NULL, selmR3Save, NULL,
    202203                               NULL, selmR3Load, selmR3LoadDone);
     
    695696 * @param   pVM             VM Handle.
    696697 * @param   pSSM            SSM operation handle.
    697  * @param   u32Version      Data layout version.
    698  */
    699 static DECLCALLBACK(int) selmR3Load(PVM pVM, PSSMHANDLE pSSM, uint32_t u32Version)
     698 * @param   uVersion        Data layout version.
     699 * @param   uPhase          The data phase.
     700 */
     701static DECLCALLBACK(int) selmR3Load(PVM pVM, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPhase)
    700702{
    701703    LogFlow(("selmR3Load:\n"));
     704    Assert(uPhase == SSM_PHASE_FINAL); NOREF(uPhase);
    702705
    703706    /*
    704707     * Validate version.
    705708     */
    706     if (u32Version != SELM_SAVED_STATE_VERSION)
    707     {
    708         AssertMsgFailed(("selmR3Load: Invalid version u32Version=%d!\n", u32Version));
     709    if (uVersion != SELM_SAVED_STATE_VERSION)
     710    {
     711        AssertMsgFailed(("selmR3Load: Invalid version uVersion=%d!\n", uVersion));
    709712        return VERR_SSM_UNSUPPORTED_DATA_UNIT_VERSION;
    710713    }
  • trunk/src/VBox/VMM/SSM.cpp

    r22255 r22480  
    163163*   Defined Constants And Macros                                               *
    164164*******************************************************************************/
    165 /** The special value for the final phase.  */
    166 #define SSM_PHASE_FINAL                         UINT32_MAX
    167 
    168165/** The max length of a unit name. */
    169166#define SSM_MAX_NAME_SIZE                       48
     
    754751*******************************************************************************/
    755752static int                  ssmR3LazyInit(PVM pVM);
     753static DECLCALLBACK(int)    ssmR3SelfLiveExec(PVM pVM, PSSMHANDLE pSSM, uint32_t uPhase);
    756754static DECLCALLBACK(int)    ssmR3SelfSaveExec(PVM pVM, PSSMHANDLE pSSM);
    757 static DECLCALLBACK(int)    ssmR3SelfLoadExec(PVM pVM, PSSMHANDLE pSSM, uint32_t u32Version);
    758 static int                  ssmR3Register(PVM pVM, const char *pszName, uint32_t u32Instance, uint32_t u32Version, size_t cbGuess, const char *pszBefore, PSSMUNIT *ppUnit);
     755static DECLCALLBACK(int)    ssmR3SelfLoadExec(PVM pVM, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPhase);
     756static int                  ssmR3Register(PVM pVM, const char *pszName, uint32_t uInstance, uint32_t uVersion, size_t cbGuess, const char *pszBefore, PSSMUNIT *ppUnit);
    759757static int                  ssmR3StrmWriteBuffers(PSSMSTRM pStrm);
    760758static int                  ssmR3StrmReadMore(PSSMSTRM pStrm);
    761759static int                  ssmR3CalcChecksum(RTFILE File, uint64_t cbFile, uint32_t *pu32CRC);
    762760static void                 ssmR3Progress(PSSMHANDLE pSSM, uint64_t cbAdvance);
    763 static PSSMUNIT             ssmR3Find(PVM pVM, const char *pszName, uint32_t u32Instance);
     761static PSSMUNIT             ssmR3Find(PVM pVM, const char *pszName, uint32_t uInstance);
    764762static int                  ssmR3DataWriteFinish(PSSMHANDLE pSSM);
    765763static void                 ssmR3DataWriteBegin(PSSMHANDLE pSSM);
     
    787785     */
    788786    pVM->ssm.s.fInitialized = true;
    789     int rc = SSMR3RegisterInternal(pVM, "SSM", 0 /*u32Instance*/, 1/*u32Version*/, 64 /*cbGuess*/,
     787    int rc = SSMR3RegisterInternal(pVM, "SSM", 0 /*uInstance*/, 1 /*uVersion*/, 64 /*cbGuess*/,
     788                                   NULL /*pfnLivePrep*/, ssmR3SelfLiveExec, NULL /*pfnLiveVote*/,
    790789                                   NULL /*pfnSavePrep*/, ssmR3SelfSaveExec, NULL /*pfnSaveDone*/,
    791790                                   NULL /*pfnSavePrep*/, ssmR3SelfLoadExec, NULL /*pfnSaveDone*/);
     
    796795
    797796/**
     797 * Do ssmR3SelfSaveExec in phase 0.
     798 *
     799 * @returns VBox status code.
     800 * @param   pVM             Pointer to the shared VM structure.
     801 * @param   pSSM            The SSM handle.
     802 * @param   uPhase          The data phase number.
     803 */
     804static DECLCALLBACK(int) ssmR3SelfLiveExec(PVM pVM, PSSMHANDLE pSSM, uint32_t uPhase)
     805{
     806    if (uPhase == 0)
     807        return ssmR3SelfSaveExec(pVM, pSSM);
     808    return VINF_SUCCESS;
     809}
     810
     811
     812/**
    798813 * For saving usful things without having to go thru the tedious process of
    799814 * adding it to the header.
     
    826841 * @param   pVM             Pointer to the shared VM structure.
    827842 * @param   pSSM            The SSM handle.
    828  * @param   u32Version      The version (1).
    829  */
    830 static DECLCALLBACK(int) ssmR3SelfLoadExec(PVM pVM, PSSMHANDLE pSSM, uint32_t u32Version)
    831 {
    832     AssertLogRelMsgReturn(u32Version == 1, ("%d", u32Version), VERR_SSM_UNSUPPORTED_DATA_UNIT_VERSION);
     843 * @param   uVersion        The version (1).
     844 * @param   uPhase          The phase.
     845 */
     846static DECLCALLBACK(int) ssmR3SelfLoadExec(PVM pVM, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPhase)
     847{
     848    AssertLogRelMsgReturn(uVersion == 1, ("%d", uVersion), VERR_SSM_UNSUPPORTED_DATA_UNIT_VERSION);
    833849
    834850    /*
     
    860876 * @param   pVM             The VM handle.
    861877 * @param   pszName         Data unit name.
    862  * @param   u32Instance     The instance id.
    863  * @param   u32Version      The data unit version.
     878 * @param   uInstance       The instance id.
     879 * @param   uVersion        The data unit version.
    864880 * @param   cbGuess         The guessed data unit size.
    865881 * @param   pszBefore       Name of data unit to be placed in front of.
     
    868884 *                          Caller must fill in the missing details.
    869885 */
    870 static int ssmR3Register(PVM pVM, const char *pszName, uint32_t u32Instance,
    871                          uint32_t u32Version, size_t cbGuess, const char *pszBefore, PSSMUNIT *ppUnit)
     886static int ssmR3Register(PVM pVM, const char *pszName, uint32_t uInstance,
     887                         uint32_t uVersion, size_t cbGuess, const char *pszBefore, PSSMUNIT *ppUnit)
    872888{
    873889    /*
     
    901917    while (pUnit)
    902918    {
    903         if (    pUnit->u32Instance == u32Instance
     919        if (    pUnit->u32Instance == uInstance
    904920            &&  pUnit->cchName == cchName
    905921            &&  !memcmp(pUnit->szName, pszName, cchName))
     
    931947     * Fill in (some) data. (Stuff is zero'ed.)
    932948     */
    933     pUnit->u32Version   = u32Version;
    934     pUnit->u32Instance  = u32Instance;
     949    pUnit->u32Version   = uVersion;
     950    pUnit->u32Instance  = uInstance;
    935951    pUnit->cbGuess      = cbGuess;
    936952    pUnit->cchName      = cchName;
     
    967983 * @param   pDevIns         Device instance.
    968984 * @param   pszName         Data unit name.
    969  * @param   u32Instance     The instance identifier of the data unit.
     985 * @param   uInstance       The instance identifier of the data unit.
    970986 *                          This must together with the name be unique.
    971  * @param   u32Version      Data layout version number.
     987 * @param   uVersion        Data layout version number.
    972988 * @param   cbGuess         The approximate amount of data in the unit.
    973989 *                          Only for progress indicators.
    974990 * @param   pszBefore       Name of data unit which we should be put in front
    975991 *                          of. Optional (NULL).
     992 *
     993 * @param   pfnLivePrep     Prepare live save callback, optional.
     994 * @param   pfnLiveExec     Execute live save callback, optional.
     995 * @param   pfnLiveVote     Vote live save callback, optional.
     996 *
    976997 * @param   pfnSavePrep     Prepare save callback, optional.
    977998 * @param   pfnSaveExec     Execute save callback, optional.
    978999 * @param   pfnSaveDone     Done save callback, optional.
     1000 *
    9791001 * @param   pfnLoadPrep     Prepare load callback, optional.
    9801002 * @param   pfnLoadExec     Execute load callback, optional.
    9811003 * @param   pfnLoadDone     Done load callback, optional.
    9821004 */
    983 VMMR3DECL(int) SSMR3RegisterDevice(PVM pVM, PPDMDEVINS pDevIns, const char *pszName, uint32_t u32Instance, uint32_t u32Version, size_t cbGuess, const char *pszBefore,
     1005VMMR3DECL(int) SSMR3RegisterDevice(PVM pVM, PPDMDEVINS pDevIns, const char *pszName, uint32_t uInstance, uint32_t uVersion, size_t cbGuess, const char *pszBefore,
     1006    PFNSSMDEVLIVEPREP pfnLivePrep, PFNSSMDEVLIVEEXEC pfnLiveExec, PFNSSMDEVLIVEVOTE pfnLiveVote,
    9841007    PFNSSMDEVSAVEPREP pfnSavePrep, PFNSSMDEVSAVEEXEC pfnSaveExec, PFNSSMDEVSAVEDONE pfnSaveDone,
    9851008    PFNSSMDEVLOADPREP pfnLoadPrep, PFNSSMDEVLOADEXEC pfnLoadExec, PFNSSMDEVLOADDONE pfnLoadDone)
    9861009{
    9871010    PSSMUNIT pUnit;
    988     int rc = ssmR3Register(pVM, pszName, u32Instance, u32Version, cbGuess, pszBefore, &pUnit);
     1011    int rc = ssmR3Register(pVM, pszName, uInstance, uVersion, cbGuess, pszBefore, &pUnit);
    9891012    if (RT_SUCCESS(rc))
    9901013    {
    9911014        pUnit->enmType = SSMUNITTYPE_DEV;
     1015        pUnit->u.Dev.pfnLivePrep = pfnLivePrep;
     1016        pUnit->u.Dev.pfnLiveExec = pfnLiveExec;
     1017        pUnit->u.Dev.pfnLiveVote = pfnLiveVote;
    9921018        pUnit->u.Dev.pfnSavePrep = pfnSavePrep;
    9931019        pUnit->u.Dev.pfnSaveExec = pfnSaveExec;
     
    10101036 * @param   pDrvIns         Driver instance.
    10111037 * @param   pszName         Data unit name.
    1012  * @param   u32Instance     The instance identifier of the data unit.
     1038 * @param   uInstance       The instance identifier of the data unit.
    10131039 *                          This must together with the name be unique.
    1014  * @param   u32Version      Data layout version number.
     1040 * @param   uVersion        Data layout version number.
    10151041 * @param   cbGuess         The approximate amount of data in the unit.
    10161042 *                          Only for progress indicators.
     1043 *
     1044 * @param   pfnLivePrep     Prepare live save callback, optional.
     1045 * @param   pfnLiveExec     Execute live save callback, optional.
     1046 * @param   pfnLiveVote     Vote live save callback, optional.
     1047 *
    10171048 * @param   pfnSavePrep     Prepare save callback, optional.
    10181049 * @param   pfnSaveExec     Execute save callback, optional.
    10191050 * @param   pfnSaveDone     Done save callback, optional.
     1051 *
    10201052 * @param   pfnLoadPrep     Prepare load callback, optional.
    10211053 * @param   pfnLoadExec     Execute load callback, optional.
    10221054 * @param   pfnLoadDone     Done load callback, optional.
    10231055 */
    1024 VMMR3DECL(int) SSMR3RegisterDriver(PVM pVM, PPDMDRVINS pDrvIns, const char *pszName, uint32_t u32Instance, uint32_t u32Version, size_t cbGuess,
     1056VMMR3DECL(int) SSMR3RegisterDriver(PVM pVM, PPDMDRVINS pDrvIns, const char *pszName, uint32_t uInstance, uint32_t uVersion, size_t cbGuess,
     1057    PFNSSMDRVLIVEPREP pfnLivePrep, PFNSSMDRVLIVEEXEC pfnLiveExec, PFNSSMDRVLIVEVOTE pfnLiveVote,
    10251058    PFNSSMDRVSAVEPREP pfnSavePrep, PFNSSMDRVSAVEEXEC pfnSaveExec, PFNSSMDRVSAVEDONE pfnSaveDone,
    10261059    PFNSSMDRVLOADPREP pfnLoadPrep, PFNSSMDRVLOADEXEC pfnLoadExec, PFNSSMDRVLOADDONE pfnLoadDone)
    10271060{
    10281061    PSSMUNIT pUnit;
    1029     int rc = ssmR3Register(pVM, pszName, u32Instance, u32Version, cbGuess, NULL, &pUnit);
     1062    int rc = ssmR3Register(pVM, pszName, uInstance, uVersion, cbGuess, NULL, &pUnit);
    10301063    if (RT_SUCCESS(rc))
    10311064    {
     
    10501083 * @param   pVM             The VM handle.
    10511084 * @param   pszName         Data unit name.
    1052  * @param   u32Instance     The instance identifier of the data unit.
     1085 * @param   uInstance       The instance identifier of the data unit.
    10531086 *                          This must together with the name be unique.
    1054  * @param   u32Version      Data layout version number.
     1087 * @param   uVersion        Data layout version number.
    10551088 * @param   cbGuess         The approximate amount of data in the unit.
    10561089 *                          Only for progress indicators.
     1090 *
     1091 * @param   pfnLivePrep     Prepare live save callback, optional.
     1092 * @param   pfnLiveExec     Execute live save callback, optional.
     1093 * @param   pfnLiveVote     Vote live save callback, optional.
     1094 *
    10571095 * @param   pfnSavePrep     Prepare save callback, optional.
    10581096 * @param   pfnSaveExec     Execute save callback, optional.
    10591097 * @param   pfnSaveDone     Done save callback, optional.
     1098 *
    10601099 * @param   pfnLoadPrep     Prepare load callback, optional.
    10611100 * @param   pfnLoadExec     Execute load callback, optional.
    10621101 * @param   pfnLoadDone     Done load callback, optional.
    10631102 */
    1064 VMMR3DECL(int) SSMR3RegisterInternal(PVM pVM, const char *pszName, uint32_t u32Instance, uint32_t u32Version, size_t cbGuess,
     1103VMMR3DECL(int) SSMR3RegisterInternal(PVM pVM, const char *pszName, uint32_t uInstance, uint32_t uVersion, size_t cbGuess,
     1104    PFNSSMINTLIVEPREP pfnLivePrep, PFNSSMINTLIVEEXEC pfnLiveExec, PFNSSMINTLIVEVOTE pfnLiveVote,
    10651105    PFNSSMINTSAVEPREP pfnSavePrep, PFNSSMINTSAVEEXEC pfnSaveExec, PFNSSMINTSAVEDONE pfnSaveDone,
    10661106    PFNSSMINTLOADPREP pfnLoadPrep, PFNSSMINTLOADEXEC pfnLoadExec, PFNSSMINTLOADDONE pfnLoadDone)
    10671107{
    10681108    PSSMUNIT pUnit;
    1069     int rc = ssmR3Register(pVM, pszName, u32Instance, u32Version, cbGuess, NULL, &pUnit);
     1109    int rc = ssmR3Register(pVM, pszName, uInstance, uVersion, cbGuess, NULL, &pUnit);
    10701110    if (RT_SUCCESS(rc))
    10711111    {
    10721112        pUnit->enmType = SSMUNITTYPE_INTERNAL;
     1113        pUnit->u.Internal.pfnLivePrep = pfnLivePrep;
     1114        pUnit->u.Internal.pfnLiveExec = pfnLiveExec;
     1115        pUnit->u.Internal.pfnLiveVote = pfnLiveVote;
    10731116        pUnit->u.Internal.pfnSavePrep = pfnSavePrep;
    10741117        pUnit->u.Internal.pfnSaveExec = pfnSaveExec;
     
    10891132 * @param   pVM             The VM handle.
    10901133 * @param   pszName         Data unit name.
    1091  * @param   u32Instance     The instance identifier of the data unit.
     1134 * @param   uInstance       The instance identifier of the data unit.
    10921135 *                          This must together with the name be unique.
    1093  * @param   u32Version      Data layout version number.
     1136 * @param   uVersion        Data layout version number.
    10941137 * @param   cbGuess         The approximate amount of data in the unit.
    10951138 *                          Only for progress indicators.
     1139 *
     1140 * @param   pfnLivePrep     Prepare live save callback, optional.
     1141 * @param   pfnLiveExec     Execute live save callback, optional.
     1142 * @param   pfnLiveVote     Vote live save callback, optional.
     1143 *
    10961144 * @param   pfnSavePrep     Prepare save callback, optional.
    10971145 * @param   pfnSaveExec     Execute save callback, optional.
    10981146 * @param   pfnSaveDone     Done save callback, optional.
     1147 *
    10991148 * @param   pfnLoadPrep     Prepare load callback, optional.
    11001149 * @param   pfnLoadExec     Execute load callback, optional.
     
    11021151 * @param   pvUser          User argument.
    11031152 */
    1104 VMMR3DECL(int) SSMR3RegisterExternal(PVM pVM, const char *pszName, uint32_t u32Instance, uint32_t u32Version, size_t cbGuess,
     1153VMMR3DECL(int) SSMR3RegisterExternal(PVM pVM, const char *pszName, uint32_t uInstance, uint32_t uVersion, size_t cbGuess,
     1154    PFNSSMEXTLIVEPREP pfnLivePrep, PFNSSMEXTLIVEEXEC pfnLiveExec, PFNSSMEXTLIVEVOTE pfnLiveVote,
    11051155    PFNSSMEXTSAVEPREP pfnSavePrep, PFNSSMEXTSAVEEXEC pfnSaveExec, PFNSSMEXTSAVEDONE pfnSaveDone,
    11061156    PFNSSMEXTLOADPREP pfnLoadPrep, PFNSSMEXTLOADEXEC pfnLoadExec, PFNSSMEXTLOADDONE pfnLoadDone, void *pvUser)
    11071157{
    11081158    PSSMUNIT pUnit;
    1109     int rc = ssmR3Register(pVM, pszName, u32Instance, u32Version, cbGuess, NULL, &pUnit);
     1159    int rc = ssmR3Register(pVM, pszName, uInstance, uVersion, cbGuess, NULL, &pUnit);
    11101160    if (RT_SUCCESS(rc))
    11111161    {
    11121162        pUnit->enmType = SSMUNITTYPE_EXTERNAL;
     1163        pUnit->u.External.pfnLivePrep = pfnLivePrep;
     1164        pUnit->u.External.pfnLiveExec = pfnLiveExec;
     1165        pUnit->u.External.pfnLiveVote = pfnLiveVote;
    11131166        pUnit->u.External.pfnSavePrep = pfnSavePrep;
    11141167        pUnit->u.External.pfnSaveExec = pfnSaveExec;
     
    11321185 * @param   pszName         Data unit name.
    11331186 *                          Use NULL to deregister all data units for that device instance.
    1134  * @param   u32Instance     The instance identifier of the data unit.
     1187 * @param   uInstance       The instance identifier of the data unit.
    11351188 *                          This must together with the name be unique.
    11361189 * @remark  Only for dynmaic data units and dynamic unloaded modules.
    11371190 */
    1138 VMMR3DECL(int) SSMR3DeregisterDevice(PVM pVM, PPDMDEVINS pDevIns, const char *pszName, uint32_t u32Instance)
     1191VMMR3DECL(int) SSMR3DeregisterDevice(PVM pVM, PPDMDEVINS pDevIns, const char *pszName, uint32_t uInstance)
    11391192{
    11401193    /*
     
    11601213                 || (   pUnit->cchName == cchName
    11611214                     && !memcmp(pUnit->szName, pszName, cchName)))
    1162             &&  pUnit->u32Instance == u32Instance
     1215            &&  pUnit->u32Instance == uInstance
    11631216            )
    11641217        {
     
    12081261 * @param   pszName         Data unit name.
    12091262 *                          Use NULL to deregister all data units for that driver instance.
    1210  * @param   u32Instance     The instance identifier of the data unit.
     1263 * @param   uInstance       The instance identifier of the data unit.
    12111264 *                          This must together with the name be unique. Ignored if pszName is NULL.
    12121265 * @remark  Only for dynmaic data units and dynamic unloaded modules.
    12131266 */
    1214 VMMR3DECL(int) SSMR3DeregisterDriver(PVM pVM, PPDMDRVINS pDrvIns, const char *pszName, uint32_t u32Instance)
     1267VMMR3DECL(int) SSMR3DeregisterDriver(PVM pVM, PPDMDRVINS pDrvIns, const char *pszName, uint32_t uInstance)
    12151268{
    12161269    /*
     
    12361289                 || (   pUnit->cchName == cchName
    12371290                     && !memcmp(pUnit->szName, pszName, cchName)
    1238                      && pUnit->u32Instance == u32Instance))
     1291                     && pUnit->u32Instance == uInstance))
    12391292            )
    12401293        {
     
    33983451 * @param   pVM             VM handle.
    33993452 * @param   pszName         Data unit name.
    3400  * @param   u32Instance     The data unit instance id.
    3401  */
    3402 static PSSMUNIT ssmR3Find(PVM pVM, const char *pszName, uint32_t u32Instance)
     3453 * @param   uInstance       The data unit instance id.
     3454 */
     3455static PSSMUNIT ssmR3Find(PVM pVM, const char *pszName, uint32_t uInstance)
    34033456{
    34043457    size_t   cchName = strlen(pszName);
    34053458    PSSMUNIT pUnit = pVM->ssm.s.pHead;
    34063459    while (     pUnit
    3407            &&   (   pUnit->u32Instance != u32Instance
     3460           &&   (   pUnit->u32Instance != uInstance
    34083461                 || pUnit->cchName != cchName
    34093462                 || memcmp(pUnit->szName, pszName, cchName)))
     
    34983551                        {
    34993552                            case SSMUNITTYPE_DEV:
    3500                                 rc = pUnit->u.Dev.pfnLoadExec(pUnit->u.Dev.pDevIns, pSSM, UnitHdr.u32Version);
     3553                                rc = pUnit->u.Dev.pfnLoadExec(pUnit->u.Dev.pDevIns, pSSM, UnitHdr.u32Version, SSM_PHASE_FINAL);
    35013554                                break;
    35023555                            case SSMUNITTYPE_DRV:
    3503                                 rc = pUnit->u.Drv.pfnLoadExec(pUnit->u.Drv.pDrvIns, pSSM, UnitHdr.u32Version);
     3556                                rc = pUnit->u.Drv.pfnLoadExec(pUnit->u.Drv.pDrvIns, pSSM, UnitHdr.u32Version, SSM_PHASE_FINAL);
    35043557                                break;
    35053558                            case SSMUNITTYPE_INTERNAL:
    3506                                 rc = pUnit->u.Internal.pfnLoadExec(pVM, pSSM, UnitHdr.u32Version);
     3559                                rc = pUnit->u.Internal.pfnLoadExec(pVM, pSSM, UnitHdr.u32Version, SSM_PHASE_FINAL);
    35073560                                break;
    35083561                            case SSMUNITTYPE_EXTERNAL:
    3509                                 rc = pUnit->u.External.pfnLoadExec(pSSM, pUnit->u.External.pvUser, UnitHdr.u32Version);
     3562                                rc = pUnit->u.External.pfnLoadExec(pSSM, pUnit->u.External.pvUser, UnitHdr.u32Version, SSM_PHASE_FINAL);
    35103563                                break;
    35113564                        }
     
    36773730            {
    36783731                case SSMUNITTYPE_DEV:
    3679                     rc = pUnit->u.Dev.pfnLoadExec(pUnit->u.Dev.pDevIns, pSSM, UnitHdr.u32Version);
     3732                    rc = pUnit->u.Dev.pfnLoadExec(pUnit->u.Dev.pDevIns, pSSM, UnitHdr.u32Version, UnitHdr.u32Phase);
    36803733                    break;
    36813734                case SSMUNITTYPE_DRV:
    3682                     rc = pUnit->u.Drv.pfnLoadExec(pUnit->u.Drv.pDrvIns, pSSM, UnitHdr.u32Version);
     3735                    rc = pUnit->u.Drv.pfnLoadExec(pUnit->u.Drv.pDrvIns, pSSM, UnitHdr.u32Version, UnitHdr.u32Phase);
    36833736                    break;
    36843737                case SSMUNITTYPE_INTERNAL:
    3685                     rc = pUnit->u.Internal.pfnLoadExec(pVM, pSSM, UnitHdr.u32Version);
     3738                    rc = pUnit->u.Internal.pfnLoadExec(pVM, pSSM, UnitHdr.u32Version, UnitHdr.u32Phase);
    36863739                    break;
    36873740                case SSMUNITTYPE_EXTERNAL:
    3688                     rc = pUnit->u.External.pfnLoadExec(pSSM, pUnit->u.External.pvUser, UnitHdr.u32Version);
     3741                    rc = pUnit->u.External.pfnLoadExec(pSSM, pUnit->u.External.pvUser, UnitHdr.u32Version, UnitHdr.u32Phase);
    36893742                    break;
    36903743            }
  • trunk/src/VBox/VMM/SSMInternal.h

    r21798 r22480  
    7474        struct
    7575        {
     76            /** Prepare live save. */
     77            PFNSSMDEVLIVEPREP   pfnLivePrep;
     78            /** Execute live save. */
     79            PFNSSMDEVLIVEEXEC   pfnLiveExec;
     80            /** Vote live save complete. */
     81            PFNSSMDEVLIVEVOTE   pfnLiveVote;
    7682            /** Prepare save. */
    7783            PFNSSMDEVSAVEPREP   pfnSavePrep;
     
    9399        struct
    94100        {
     101            /** Prepare live save. */
     102            PFNSSMDRVLIVEPREP   pfnLivePrep;
     103            /** Execute live save. */
     104            PFNSSMDRVLIVEEXEC   pfnLiveExec;
     105            /** Vote live save complete. */
     106            PFNSSMDRVLIVEVOTE   pfnLiveVote;
    95107            /** Prepare save. */
    96108            PFNSSMDRVSAVEPREP   pfnSavePrep;
     
    112124        struct
    113125        {
     126            /** Prepare live save. */
     127            PFNSSMINTLIVEPREP   pfnLivePrep;
     128            /** Execute live save. */
     129            PFNSSMINTLIVEEXEC   pfnLiveExec;
     130            /** Vote live save complete. */
     131            PFNSSMINTLIVEVOTE   pfnLiveVote;
    114132            /** Prepare save. */
    115133            PFNSSMINTSAVEPREP   pfnSavePrep;
     
    129147        struct
    130148        {
     149            /** Prepare live save. */
     150            PFNSSMEXTLIVEPREP   pfnLivePrep;
     151            /** Execute live save. */
     152            PFNSSMEXTLIVEEXEC   pfnLiveExec;
     153            /** Vote live save complete. */
     154            PFNSSMEXTLIVEVOTE   pfnLiveVote;
    131155            /** Prepare save. */
    132156            PFNSSMEXTSAVEPREP   pfnSavePrep;
     
    147171        struct
    148172        {
     173            /** Prepare live save. */
     174            PFNRT               pfnLivePrep;
     175            /** Execute live save. */
     176            PFNRT               pfnLiveExec;
     177            /** Vote live save complete. */
     178            PFNRT               pfnLiveVote;
    149179            /** Prepare save. */
    150180            PFNRT               pfnSavePrep;
     
    178208} SSMUNIT;
    179209
     210AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnLivePrep, u.Dev.pfnLivePrep);
     211AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnLiveExec, u.Dev.pfnLiveExec);
     212AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnLiveVote, u.Dev.pfnLiveVote);
    180213AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnSavePrep, u.Dev.pfnSavePrep);
    181214AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnSaveExec, u.Dev.pfnSaveExec);
     
    186219AssertCompile2MemberOffsets(SSMUNIT, u.Common.pvKey,       u.Dev.pDevIns);
    187220
     221AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnLivePrep, u.Drv.pfnLivePrep);
     222AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnLiveExec, u.Drv.pfnLiveExec);
     223AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnLiveVote, u.Drv.pfnLiveVote);
    188224AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnSavePrep, u.Drv.pfnSavePrep);
    189225AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnSaveExec, u.Drv.pfnSaveExec);
     
    194230AssertCompile2MemberOffsets(SSMUNIT, u.Common.pvKey,       u.Drv.pDrvIns);
    195231
     232AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnLivePrep, u.Internal.pfnLivePrep);
     233AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnLiveExec, u.Internal.pfnLiveExec);
     234AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnLiveVote, u.Internal.pfnLiveVote);
    196235AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnSavePrep, u.Internal.pfnSavePrep);
    197236AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnSaveExec, u.Internal.pfnSaveExec);
     
    201240AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnLoadDone, u.Internal.pfnLoadDone);
    202241
     242AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnLivePrep, u.External.pfnLivePrep);
     243AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnLiveExec, u.External.pfnLiveExec);
     244AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnLiveVote, u.External.pfnLiveVote);
    203245AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnSavePrep, u.External.pfnSavePrep);
    204246AssertCompile2MemberOffsets(SSMUNIT, u.Common.pfnSaveExec, u.External.pfnSaveExec);
  • trunk/src/VBox/VMM/TM.cpp

    r22242 r22480  
    162162static uint64_t             tmR3CalibrateTSC(PVM pVM);
    163163static DECLCALLBACK(int)    tmR3Save(PVM pVM, PSSMHANDLE pSSM);
    164 static DECLCALLBACK(int)    tmR3Load(PVM pVM, PSSMHANDLE pSSM, uint32_t u32Version);
     164static DECLCALLBACK(int)    tmR3Load(PVM pVM, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPhase);
    165165static DECLCALLBACK(void)   tmR3TimerCallback(PRTTIMER pTimer, void *pvUser, uint64_t iTick);
    166166static void                 tmR3TimerQueueRun(PVM pVM, PTMTIMERQUEUE pQueue);
     
    526526     */
    527527    rc = SSMR3RegisterInternal(pVM, "tm", 1, TM_SAVED_STATE_VERSION, sizeof(uint64_t) * 8,
     528                               NULL, NULL, NULL,
    528529                               NULL, tmR3Save, NULL,
    529530                               NULL, tmR3Load, NULL);
     
    10881089 * @param   pVM             VM Handle.
    10891090 * @param   pSSM            SSM operation handle.
    1090  * @param   u32Version      Data layout version.
    1091  */
    1092 static DECLCALLBACK(int) tmR3Load(PVM pVM, PSSMHANDLE pSSM, uint32_t u32Version)
     1091 * @param   uVersion        Data layout version.
     1092 * @param   uPhase          The data phase.
     1093 */
     1094static DECLCALLBACK(int) tmR3Load(PVM pVM, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPhase)
    10931095{
    10941096    LogFlow(("tmR3Load:\n"));
    10951097
     1098    Assert(uPhase == SSM_PHASE_FINAL); NOREF(uPhase);
    10961099#ifdef VBOX_STRICT
    10971100    for (VMCPUID i = 0; i < pVM->cCPUs; i++)
     
    11071110     * Validate version.
    11081111     */
    1109     if (u32Version != TM_SAVED_STATE_VERSION)
    1110     {
    1111         AssertMsgFailed(("tmR3Load: Invalid version u32Version=%d!\n", u32Version));
     1112    if (uVersion != TM_SAVED_STATE_VERSION)
     1113    {
     1114        AssertMsgFailed(("tmR3Load: Invalid version uVersion=%d!\n", uVersion));
    11121115        return VERR_SSM_UNSUPPORTED_DATA_UNIT_VERSION;
    11131116    }
  • trunk/src/VBox/VMM/TRPM.cpp

    r20841 r22480  
    439439*******************************************************************************/
    440440static DECLCALLBACK(int) trpmR3Save(PVM pVM, PSSMHANDLE pSSM);
    441 static DECLCALLBACK(int) trpmR3Load(PVM pVM, PSSMHANDLE pSSM, uint32_t u32Version);
     441static DECLCALLBACK(int) trpmR3Load(PVM pVM, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPhase);
    442442static DECLCALLBACK(int) trpmR3GuestIDTWriteHandler(PVM pVM, RTGCPTR GCPtr, void *pvPtr, void *pvBuf, size_t cbBuf, PGMACCESSTYPE enmAccessType, void *pvUser);
    443443
     
    508508     */
    509509    int rc = SSMR3RegisterInternal(pVM, "trpm", 1, TRPM_SAVED_STATE_VERSION, sizeof(TRPM),
     510                                   NULL, NULL, NULL,
    510511                                   NULL, trpmR3Save, NULL,
    511512                                   NULL, trpmR3Load, NULL);
     
    818819 * @param   pVM             VM Handle.
    819820 * @param   pSSM            SSM operation handle.
    820  * @param   u32Version      Data layout version.
    821  */
    822 static DECLCALLBACK(int) trpmR3Load(PVM pVM, PSSMHANDLE pSSM, uint32_t u32Version)
     821 * @param   uVersion        Data layout version.
     822 * @param   uPhase          The data phase.
     823 */
     824static DECLCALLBACK(int) trpmR3Load(PVM pVM, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPhase)
    823825{
    824826    LogFlow(("trpmR3Load:\n"));
     827    Assert(uPhase == SSM_PHASE_FINAL); NOREF(uPhase);
    825828
    826829    /*
    827830     * Validate version.
    828831     */
    829     if (    u32Version != TRPM_SAVED_STATE_VERSION
    830         &&  u32Version != TRPM_SAVED_STATE_VERSION_UNI)
    831     {
    832         AssertMsgFailed(("trpmR3Load: Invalid version u32Version=%d!\n", u32Version));
     832    if (    uVersion != TRPM_SAVED_STATE_VERSION
     833        &&  uVersion != TRPM_SAVED_STATE_VERSION_UNI)
     834    {
     835        AssertMsgFailed(("trpmR3Load: Invalid version uVersion=%d!\n", uVersion));
    833836        return VERR_SSM_UNSUPPORTED_DATA_UNIT_VERSION;
    834837    }
     
    844847    PTRPM pTrpm = &pVM->trpm.s;
    845848
    846     if (u32Version == TRPM_SAVED_STATE_VERSION)
    847     {
    848         for (unsigned i=0;i<pVM->cCPUs;i++)
     849    if (uVersion == TRPM_SAVED_STATE_VERSION)
     850    {
     851        for (VMCPUID i = 0; i < pVM->cCPUs; i++)
    849852        {
    850853            PTRPMCPU pTrpmCpu = &pVM->aCpus[i].trpm.s;
  • trunk/src/VBox/VMM/VMM.cpp

    r21963 r22480  
    110110static void                 vmmR3InitRegisterStats(PVM pVM);
    111111static DECLCALLBACK(int)    vmmR3Save(PVM pVM, PSSMHANDLE pSSM);
    112 static DECLCALLBACK(int)    vmmR3Load(PVM pVM, PSSMHANDLE pSSM, uint32_t u32Version);
     112static DECLCALLBACK(int)    vmmR3Load(PVM pVM, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPhase);
    113113static DECLCALLBACK(void)   vmmR3YieldEMT(PVM pVM, PTMTIMER pTimer, void *pvUser);
    114114static int                  vmmR3ServiceCallRing3Request(PVM pVM, PVMCPU pVCpu);
     
    169169     */
    170170    rc = SSMR3RegisterInternal(pVM, "vmm", 1, VMM_SAVED_STATE_VERSION, VMM_STACK_SIZE + sizeof(RTGCPTR),
     171                               NULL, NULL, NULL,
    171172                               NULL, vmmR3Save, NULL,
    172173                               NULL, vmmR3Load, NULL);
     
    252253
    253254#ifdef VBOX_STRICT_VMM_STACK
    254         rc = MMR3HyperAllocOnceNoRelEx(pVM, PAGE_SIZE + VMM_STACK_SIZE + PAGE_SIZE, 
     255        rc = MMR3HyperAllocOnceNoRelEx(pVM, PAGE_SIZE + VMM_STACK_SIZE + PAGE_SIZE,
    255256#else
    256         rc = MMR3HyperAllocOnceNoRelEx(pVM, VMM_STACK_SIZE, 
     257        rc = MMR3HyperAllocOnceNoRelEx(pVM, VMM_STACK_SIZE,
    257258#endif
    258259                                       PAGE_SIZE, MM_TAG_VMM, fFlags, (void **)&pVCpu->vmm.s.pbEMTStackR3);
     
    934935 * @param   pVM             VM Handle.
    935936 * @param   pSSM            SSM operation handle.
    936  * @param   u32Version      Data layout version.
    937  */
    938 static DECLCALLBACK(int) vmmR3Load(PVM pVM, PSSMHANDLE pSSM, uint32_t u32Version)
     937 * @param   uVersion        Data layout version.
     938 * @param   uPhase          The data phase.
     939 */
     940static DECLCALLBACK(int) vmmR3Load(PVM pVM, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPhase)
    939941{
    940942    LogFlow(("vmmR3Load:\n"));
     943    Assert(uPhase == SSM_PHASE_FINAL); NOREF(uPhase);
    941944
    942945    /*
    943946     * Validate version.
    944947     */
    945     if (u32Version != VMM_SAVED_STATE_VERSION)
    946     {
    947         AssertMsgFailed(("vmmR3Load: Invalid version u32Version=%d!\n", u32Version));
     948    if (uVersion != VMM_SAVED_STATE_VERSION)
     949    {
     950        AssertMsgFailed(("vmmR3Load: Invalid version uVersion=%d!\n", uVersion));
    948951        return VERR_SSM_UNSUPPORTED_DATA_UNIT_VERSION;
    949952    }
  • trunk/src/VBox/VMM/testcase/tstSSM.cpp

    r22025 r22480  
    186186 * @param   pDevIns         Device instance of the device which registered the data unit.
    187187 * @param   pSSM            SSM operation handle.
    188  */
    189 DECLCALLBACK(int) Item01Load(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t u32Version)
    190 {
    191     if (u32Version != 0)
    192     {
    193         RTPrintf("Item01: u32Version=%#x, expected 0\n", u32Version);
     188 * @param   uVersion        The data layout version.
     189 * @param   uPhase          The data phase.
     190 */
     191DECLCALLBACK(int) Item01Load(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPhase)
     192{
     193    if (uVersion != 0)
     194    {
     195        RTPrintf("Item01: uVersion=%#x, expected 0\n", uVersion);
    194196        return VERR_GENERAL_FAILURE;
    195197    }
     
    340342 * @param   pDevIns         Device instance of the device which registered the data unit.
    341343 * @param   pSSM            SSM operation handle.
    342  */
    343 DECLCALLBACK(int) Item02Load(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t u32Version)
    344 {
    345     if (u32Version != 0)
    346     {
    347         RTPrintf("Item02: u32Version=%#x, expected 0\n", u32Version);
     344 * @param   uVersion        The data layout version.
     345 * @param   uPhase          The data phase.
     346 */
     347DECLCALLBACK(int) Item02Load(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPhase)
     348{
     349    if (uVersion != 0)
     350    {
     351        RTPrintf("Item02: uVersion=%#x, expected 0\n", uVersion);
    348352        return VERR_GENERAL_FAILURE;
    349353    }
     
    452456 * @param   pDevIns         Device instance of the device which registered the data unit.
    453457 * @param   pSSM            SSM operation handle.
    454  */
    455 DECLCALLBACK(int) Item03Load(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t u32Version)
    456 {
    457     if (u32Version != 123)
    458     {
    459         RTPrintf("Item03: u32Version=%#x, expected 123\n", u32Version);
     458 * @param   uVersion        The data layout version.
     459 * @param   uPhase          The data phase.
     460 */
     461DECLCALLBACK(int) Item03Load(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPhase)
     462{
     463    if (uVersion != 123)
     464    {
     465        RTPrintf("Item03: uVersion=%#x, expected 123\n", uVersion);
    460466        return VERR_GENERAL_FAILURE;
    461467    }
     
    556562 * @param   pDevIns         Device instance of the device which registered the data unit.
    557563 * @param   pSSM            SSM operation handle.
    558  */
    559 DECLCALLBACK(int) Item04Load(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t u32Version)
    560 {
    561     if (u32Version != 42)
    562     {
    563         RTPrintf("Item04: u32Version=%#x, expected 42\n", u32Version);
     564 * @param   uVersion        The data layout version.
     565 * @param   uPhase          The data phase.
     566 */
     567DECLCALLBACK(int) Item04Load(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPhase)
     568{
     569    if (uVersion != 42)
     570    {
     571        RTPrintf("Item04: uVersion=%#x, expected 42\n", uVersion);
    564572        return VERR_GENERAL_FAILURE;
    565573    }
     
    698706     */
    699707    rc = SSMR3RegisterDevice(pVM, NULL, "SSM Testcase Data Item no.1 (all types)", 1, 0, 256, NULL,
    700         NULL, Item01Save, NULL,
    701         NULL, Item01Load, NULL);
     708                             NULL, NULL, NULL,
     709                             NULL, Item01Save, NULL,
     710                             NULL, Item01Load, NULL);
    702711    if (RT_FAILURE(rc))
    703712    {
     
    707716
    708717    rc = SSMR3RegisterDevice(pVM, NULL, "SSM Testcase Data Item no.2 (rand mem)", 2, 0, _1M * 8, NULL,
    709         NULL, Item02Save, NULL,
    710         NULL, Item02Load, NULL);
     718                             NULL, NULL, NULL,
     719                             NULL, Item02Save, NULL,
     720                             NULL, Item02Load, NULL);
    711721    if (RT_FAILURE(rc))
    712722    {
     
    716726
    717727    rc = SSMR3RegisterDevice(pVM, NULL, "SSM Testcase Data Item no.3 (big mem)", 0, 123, 512*_1M, NULL,
    718         NULL, Item03Save, NULL,
    719         NULL, Item03Load, NULL);
     728                             NULL, NULL, NULL,
     729                             NULL, Item03Save, NULL,
     730                             NULL, Item03Load, NULL);
    720731    if (RT_FAILURE(rc))
    721732    {
     
    725736
    726737    rc = SSMR3RegisterDevice(pVM, NULL, "SSM Testcase Data Item no.4 (big zero mem)", 0, 42, 512*_1M, NULL,
    727         NULL, Item04Save, NULL,
    728         NULL, Item04Load, NULL);
     738                             NULL, NULL, NULL,
     739                             NULL, Item04Save, NULL,
     740                             NULL, Item04Load, NULL);
    729741    if (RT_FAILURE(rc))
    730742    {
     
    831843        return 1;
    832844    }
    833     uint32_t u32Version = 0xbadc0ded;
    834     rc = SSMR3Seek(pSSM, "SSM Testcase Data Item no.2 (rand mem)", 2, &u32Version);
     845    uint32_t uVersion = 0xbadc0ded;
     846    rc = SSMR3Seek(pSSM, "SSM Testcase Data Item no.2 (rand mem)", 2, &uVersion);
    835847    if (RT_FAILURE(rc))
    836848    {
     
    839851    }
    840852    u64Start = RTTimeNanoTS();
    841     rc = Item02Load(NULL, pSSM, u32Version);
     853    rc = Item02Load(NULL, pSSM, uVersion, SSM_PHASE_FINAL);
    842854    if (RT_FAILURE(rc))
    843855    {
     
    849861
    850862    /* 1st unit */
    851     u32Version = 0xbadc0ded;
    852     rc = SSMR3Seek(pSSM, "SSM Testcase Data Item no.1 (all types)", 1, &u32Version);
     863    uVersion = 0xbadc0ded;
     864    rc = SSMR3Seek(pSSM, "SSM Testcase Data Item no.1 (all types)", 1, &uVersion);
    853865    if (RT_FAILURE(rc))
    854866    {
     
    857869    }
    858870    u64Start = RTTimeNanoTS();
    859     rc = Item01Load(NULL, pSSM, u32Version);
     871    rc = Item01Load(NULL, pSSM, uVersion, SSM_PHASE_FINAL);
    860872    if (RT_FAILURE(rc))
    861873    {
     
    867879
    868880    /* 3st unit */
    869     u32Version = 0xbadc0ded;
    870     rc = SSMR3Seek(pSSM, "SSM Testcase Data Item no.3 (big mem)", 0, &u32Version);
     881    uVersion = 0xbadc0ded;
     882    rc = SSMR3Seek(pSSM, "SSM Testcase Data Item no.3 (big mem)", 0, &uVersion);
    871883    if (RT_FAILURE(rc))
    872884    {
     
    875887    }
    876888    u64Start = RTTimeNanoTS();
    877     rc = Item03Load(NULL, pSSM, u32Version);
     889    rc = Item03Load(NULL, pSSM, uVersion, SSM_PHASE_FINAL);
    878890    if (RT_FAILURE(rc))
    879891    {
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