VirtualBox

Changeset 31895 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Aug 24, 2010 9:00:14 AM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
65105
Message:

FT updates

Location:
trunk/src/VBox
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VBoxBFE/VMControl.cpp

    r28800 r31895  
    132132    startProgressInfo("Saving");
    133133    rc = VMR3ReqCallWait(gpVM, VMCPUID_ANY,
    134                          (PFNRT)VMR3Save, 5, gpVM, g_pszStateFile, false /*fContinueAftewards*/, &callProgressInfo, (uintptr_t)NULL);
     134                         (PFNRT)VMR3Save, 7, gpVM, g_pszStateFile,
     135                         NULL /* pStreamOps */,
     136                         NULL /* pvStreamOpsUser */,
     137                         false /*fContinueAftewards*/, &callProgressInfo, (uintptr_t)NULL);
    135138    AssertRC(rc);
    136139    endProgressInfo();
  • trunk/src/VBox/Main/ConsoleImpl.cpp

    r31841 r31895  
    78037803            int vrc = VMR3Save(that->mpVM,
    78047804                               strSavedStateFile.c_str(),
     7805                               NULL /* pStreamOps */,
     7806                               NULL /* pvStreamOpsUser */,
    78057807                               true /*fContinueAfterwards*/,
    78067808                               Console::stateProgressCallback,
     
    80628064    int vrc = VMR3Save(that->mpVM,
    80638065                       task->mSavedStateFile.c_str(),
     8066                        NULL /* pStreamOps */,
     8067                        NULL /* pvStreamOpsUser */,
    80648068                       false, /*fContinueAfterwards*/
    80658069                       Console::stateProgressCallback,
  • trunk/src/VBox/VMM/FTM.cpp

    r31809 r31895  
    521521
    522522/**
     523 * Sync the VM state partially or fully
     524 *
     525 * @returns VBox status code.
     526 * @param   pVM         The VM handle.
     527 * @param   enmState    Which state to sync
     528 */
     529static DECLCALLBACK(void) ftmR3PerformSync(PVM pVM, FTMSYNCSTATE enmState)
     530{
     531    int rc;
     532
     533    if (enmState != FTMSYNCSTATE_DELTA_MEMORY)
     534    {
     535        rc = VMR3Suspend(pVM);
     536        AssertReturnVoid(RT_SUCCESS(rc));
     537    }
     538
     539    switch (enmState)
     540    {
     541    case FTMSYNCSTATE_FULL:
     542        break;
     543
     544    case FTMSYNCSTATE_DELTA_VM:
     545        break;
     546
     547    case FTMSYNCSTATE_DELTA_MEMORY:
     548        break;
     549    }
     550    /* Write protect all memory. */
     551    rc = PGMR3PhysWriteProtectRAM(pVM);
     552    AssertRC(rc);
     553
     554    if (enmState != FTMSYNCSTATE_DELTA_MEMORY)
     555    {
     556        rc = VMR3Resume(pVM);
     557        AssertRC(rc);
     558    }
     559}
     560
     561/**
    523562 * Thread function which starts syncing process for this master VM
    524563 *
     
    527566 * @return  VINF_SUCCESS (ignored).
    528567 *
    529  * @note Locks the Console object for writing.
    530568 */
    531569static DECLCALLBACK(int) ftmR3MasterThread(RTTHREAD Thread, void *pvUser)
     
    579617     */
    580618
     619    /* First sync all memory and write protect everything so
     620     * we can send changed pages later on.
     621     */
     622
     623    rc = VMR3ReqCallWait(pVM, VMCPUID_ANY, (PFNRT)ftmR3PerformSync, 2, pVM, FTMSYNCSTATE_FULL);
     624    AssertRC(rc);
     625
    581626    for (;;)
    582627    {
  • trunk/src/VBox/VMM/FTMInternal.h

    r31833 r31895  
    2929 * @{
    3030 */
     31
     32typedef enum
     33{
     34    /* Sync the changed memory pages. */
     35    FTMSYNCSTATE_DELTA_MEMORY,
     36    /* Sync the changed state (memory + vm/device internal state) */
     37    FTMSYNCSTATE_DELTA_VM,
     38    /* Sync the entire VM state. */
     39    FTMSYNCSTATE_FULL
     40} FTMSYNCSTATE;
    3141
    3242
  • trunk/src/VBox/VMM/PGMInternal.h

    r31851 r31895  
    37893789void            pgmR3PoolClearAll(PVM pVM, bool fFlushRemTlb);
    37903790DECLCALLBACK(VBOXSTRICTRC) pgmR3PoolClearAllRendezvous(PVM pVM, PVMCPU pVCpu, void *fpvFlushRemTbl);
     3791void            pgmR3PoolWriteProtectPages(PVM pVM);
    37913792
    37923793#endif /* IN_RING3 */
  • trunk/src/VBox/VMM/PGMPhys.cpp

    r31630 r31895  
    956956    return VERR_NOT_IMPLEMENTED;
    957957#endif
     958}
     959
     960/**
     961 * Rendezvous callback used by PGMR3WriteProtectRAM that write protects all physical RAM
     962 *
     963 * This is only called on one of the EMTs while the other ones are waiting for
     964 * it to complete this function.
     965 *
     966 * @returns VINF_SUCCESS (VBox strict status code).
     967 * @param   pVM         The VM handle.
     968 * @param   pVCpu       The VMCPU for the EMT we're being called on. Unused.
     969 * @param   pvUser      User parameter
     970 */
     971static DECLCALLBACK(VBOXSTRICTRC) pgmR3PhysWriteProtectRAMRendezvous(PVM pVM, PVMCPU pVCpu, void *pvUser)
     972{
     973    int rc = VINF_SUCCESS;
     974
     975    pgmLock(pVM);
     976#ifdef PGMPOOL_WITH_OPTIMIZED_DIRTY_PT
     977    pgmPoolResetDirtyPages(pVM);
     978#endif
     979
     980    /** @todo pointless to write protect the physical page pointed to by RSP. */
     981
     982    /*
     983     * Clear all the GCPhys links and rebuild the phys ext free list.
     984     */
     985    for (PPGMRAMRANGE pRam = pVM->pgm.s.CTX_SUFF(pRamRanges);
     986         pRam;
     987         pRam = pRam->CTX_SUFF(pNext))
     988    {
     989        if (!PGM_RAM_RANGE_IS_AD_HOC(pRam))
     990        {
     991            unsigned iPage = pRam->cb >> PAGE_SHIFT;
     992            while (iPage-- > 0)
     993            {
     994                PPGMPAGE pPage = &pRam->aPages[iPage];
     995                if (RT_LIKELY(PGM_PAGE_GET_TYPE(pPage) == PGMPAGETYPE_RAM))
     996                {
     997                    /*
     998                     * A RAM page.
     999                     */
     1000                    switch (PGM_PAGE_GET_STATE(pPage))
     1001                    {
     1002                    case PGM_PAGE_STATE_ALLOCATED:                   
     1003                        /** @todo Optimize this: Don't always re-enable write
     1004                            * monitoring if the page is known to be very busy. */
     1005                        if (PGM_PAGE_IS_WRITTEN_TO(pPage))
     1006                            PGM_PAGE_CLEAR_WRITTEN_TO(pPage);
     1007
     1008                        PGM_PAGE_SET_STATE(pPage, PGM_PAGE_STATE_WRITE_MONITORED);
     1009                        break;
     1010
     1011                    case PGM_PAGE_STATE_SHARED:
     1012                        AssertFailed();
     1013                        break;
     1014
     1015                    case PGM_PAGE_STATE_WRITE_MONITORED:    /* nothing to change. */
     1016                    default:
     1017                        break;
     1018                    }
     1019                }
     1020            }
     1021        }
     1022    }
     1023    pgmR3PoolWriteProtectPages(pVM);
     1024    PGM_INVL_ALL_VCPU_TLBS(pVM);
     1025    for (VMCPUID idCpu = 0; idCpu < pVM->cCpus; idCpu++)
     1026        CPUMSetChangedFlags(&pVM->aCpus[idCpu], CPUM_CHANGED_GLOBAL_TLB_FLUSH);
     1027
     1028    pgmUnlock(pVM);
     1029    return rc;
     1030}
     1031
     1032/**
     1033 * Protect all physical RAM to monitor writes
     1034 *
     1035 * @returns VBox status code.
     1036 * @param   pVM         The VM handle.
     1037 */
     1038VMMR3DECL(int) PGMR3PhysWriteProtectRAM(PVM pVM)
     1039{
     1040    VM_ASSERT_EMT_RETURN(pVM, VERR_VM_THREAD_NOT_EMT);
     1041
     1042    int rc = VMMR3EmtRendezvous(pVM, VMMEMTRENDEZVOUS_FLAGS_TYPE_ONCE, pgmR3PhysWriteProtectRAMRendezvous, NULL);
     1043    AssertRC(rc);
     1044    return rc;
    9581045}
    9591046
  • trunk/src/VBox/VMM/PGMPool.cpp

    r31775 r31895  
    818818}
    819819
     820/**
     821 * Protect all pgm pool page table entries to monitor writes
     822 *
     823 * @param   pVM         The VM handle.
     824 *
     825 * Remark: assumes the caller will flush all TLBs (!!)
     826 */     
     827void pgmR3PoolWriteProtectPages(PVM pVM)
     828{
     829    Assert(PGMIsLockOwner(pVM));
     830    PPGMPOOL pPool = pVM->pgm.s.CTX_SUFF(pPool);
     831    unsigned cLeft = pPool->cUsedPages;
     832    unsigned iPage = pPool->cCurPages;
     833    while (--iPage >= PGMPOOL_IDX_FIRST)
     834    {
     835        PPGMPOOLPAGE pPage = &pPool->aPages[iPage];
     836        if (    pPage->GCPhys != NIL_RTGCPHYS
     837            &&  pPage->cPresent)
     838        {
     839            union
     840            {
     841                void           *pv;
     842                PX86PT          pPT;
     843                PPGMSHWPTPAE    pPTPae;
     844                PEPTPT          pPTEpt;
     845            } uShw;
     846            uShw.pv = NULL;
     847
     848            switch (pPage->enmKind)
     849            {
     850                /*
     851                 * We only care about shadow page tables.
     852                 */
     853                case PGMPOOLKIND_32BIT_PT_FOR_32BIT_PT:
     854                case PGMPOOLKIND_32BIT_PT_FOR_32BIT_4MB:
     855                case PGMPOOLKIND_32BIT_PT_FOR_PHYS:
     856                    for (unsigned iShw = 0; iShw < RT_ELEMENTS(uShw.pPT); iShw++)
     857                    {
     858                        if (uShw.pPT->a[iShw].n.u1Present)
     859                            uShw.pPT->a[iShw].n.u1Write = 0;
     860                    }
     861                    break;
     862
     863                case PGMPOOLKIND_PAE_PT_FOR_32BIT_PT:
     864                case PGMPOOLKIND_PAE_PT_FOR_32BIT_4MB:
     865                case PGMPOOLKIND_PAE_PT_FOR_PAE_PT:
     866                case PGMPOOLKIND_PAE_PT_FOR_PAE_2MB:
     867                case PGMPOOLKIND_PAE_PT_FOR_PHYS:
     868                    for (unsigned iShw = 0; iShw < RT_ELEMENTS(uShw.pPTPae); iShw++)
     869                    {
     870                        if (uShw.pPTPae->a[iShw].n.u1Present)
     871                            uShw.pPTPae->a[iShw].n.u1Write = 0;
     872                    }
     873                    break;
     874
     875                case PGMPOOLKIND_EPT_PT_FOR_PHYS:
     876                    for (unsigned iShw = 0; iShw < RT_ELEMENTS(uShw.pPTEpt); iShw++)
     877                    {
     878                        if (uShw.pPTEpt->a[iShw].n.u1Present)
     879                            uShw.pPTEpt->a[iShw].n.u1Write = 0;
     880                    }
     881                    break;
     882
     883                default:
     884                    break;
     885            }
     886            if (!--cLeft)
     887                break;
     888        }
     889    }
     890}
    820891
    821892#ifdef VBOX_WITH_DEBUGGER
  • trunk/src/VBox/VMM/SSM.cpp

    r31847 r31895  
    48864886 *
    48874887 * @param   pVM             The VM handle.
    4888  * @param   pszFilename     Name of the file to save the state in.
     4888 * @param   pszFilename     Name of the file to save the state in. NULL if pStreamOps is used.
     4889 * @param   pStreamOps      The stream method table. NULL if pszFilename is
     4890 *                          used.
     4891 * @param   pvStreamOpsUser The user argument to the stream methods.
    48894892 * @param   enmAfter        What is planned after a successful save operation.
    48904893 * @param   pfnProgress     Progress callback. Optional.
     
    48934896 * @thread  EMT
    48944897 */
    4895 VMMR3DECL(int) SSMR3Save(PVM pVM, const char *pszFilename, SSMAFTER enmAfter, PFNVMPROGRESS pfnProgress, void *pvUser)
     4898VMMR3DECL(int) SSMR3Save(PVM pVM, const char *pszFilename, PCSSMSTRMOPS pStreamOps, void *pvStreamOpsUser,
     4899                         SSMAFTER enmAfter, PFNVMPROGRESS pfnProgress, void *pvUser)
    48964900{
    48974901    LogFlow(("SSMR3Save: pszFilename=%p:{%s} enmAfter=%d pfnProgress=%p pvUser=%p\n", pszFilename, pszFilename, enmAfter, pfnProgress, pvUser));
     
    49064910                    VERR_INVALID_PARAMETER);
    49074911
     4912    AssertReturn(!pszFilename != !pStreamOps, VERR_INVALID_PARAMETER);
     4913    if (pStreamOps)
     4914    {
     4915        AssertReturn(pStreamOps->u32Version == SSMSTRMOPS_VERSION, VERR_INVALID_MAGIC);
     4916        AssertReturn(pStreamOps->u32EndVersion == SSMSTRMOPS_VERSION, VERR_INVALID_MAGIC);
     4917        AssertReturn(pStreamOps->pfnWrite, VERR_INVALID_PARAMETER);
     4918        AssertReturn(pStreamOps->pfnRead, VERR_INVALID_PARAMETER);
     4919        AssertReturn(pStreamOps->pfnSeek, VERR_INVALID_PARAMETER);
     4920        AssertReturn(pStreamOps->pfnTell, VERR_INVALID_PARAMETER);
     4921        AssertReturn(pStreamOps->pfnSize, VERR_INVALID_PARAMETER);
     4922        AssertReturn(pStreamOps->pfnClose, VERR_INVALID_PARAMETER);
     4923    }
     4924
    49084925    /*
    49094926     * Create the saved state file and handle.
     
    49134930     */
    49144931    PSSMHANDLE pSSM;
    4915     int rc = ssmR3SaveDoCreateFile(pVM, pszFilename, NULL /*pStreamOps*/, NULL /*pvStreamOpsUser*/,
     4932    int rc = ssmR3SaveDoCreateFile(pVM, pszFilename, pStreamOps, pvStreamOpsUser,
    49164933                                   enmAfter, pfnProgress, pvUser, &pSSM);
    49174934    if (RT_FAILURE(rc))
     
    49204937    pSSM->uPercentPrepare = 20;
    49214938    pSSM->uPercentDone    = 2;
     4939    pSSM->fLiveSave       = false;
    49224940
    49234941    /*
  • trunk/src/VBox/VMM/VM.cpp

    r31854 r31895  
    16411641    if (rc == 1 && enmAfter != SSMAFTER_TELEPORT)
    16421642    {
    1643         Assert(!pStreamOps);
    1644         rc = SSMR3Save(pVM, pszFilename, enmAfter, pfnProgress, pvProgressUser);
     1643        rc = SSMR3Save(pVM, pszFilename, pStreamOps, pvStreamOpsUser, enmAfter, pfnProgress, pvProgressUser);
    16451644        vmR3SetState(pVM, VMSTATE_SUSPENDED, VMSTATE_SAVING);
    16461645    }
     
    17491748 * @param   pVM                 The VM which state should be saved.
    17501749 * @param   pszFilename         The name of the save state file.
     1750 * @param   pStreamOps          The stream methods.
     1751 * @param   pvStreamOpsUser     The user argument to the stream methods.
    17511752 * @param   fContinueAfterwards Whether continue execution afterwards or not.
    17521753 *                              When in doubt, set this to true.
     
    17601761 *              RunningLS+SuspeningLS+SuspendedLS+Saving+Suspended.
    17611762 */
    1762 VMMR3DECL(int) VMR3Save(PVM pVM, const char *pszFilename, bool fContinueAfterwards,
    1763                         PFNVMPROGRESS pfnProgress, void *pvUser, bool *pfSuspended)
     1763VMMR3DECL(int) VMR3Save(PVM pVM, const char *pszFilename, PCSSMSTRMOPS pStreamOps, void *pvStreamOpsUser,
     1764                        bool fContinueAfterwards, PFNVMPROGRESS pfnProgress, void *pvUser, bool *pfSuspended)
    17641765{
    17651766    LogFlow(("VMR3Save: pVM=%p pszFilename=%p:{%s} fContinueAfterwards=%RTbool pfnProgress=%p pvUser=%p pfSuspended=%p\n",
     
    17821783    SSMAFTER enmAfter = fContinueAfterwards ? SSMAFTER_CONTINUE : SSMAFTER_DESTROY;
    17831784    int rc = vmR3SaveTeleport(pVM, 250 /*cMsMaxDowntime*/,
    1784                               pszFilename, NULL /*pStreamOps*/, NULL /*pvStreamOpsUser*/,
     1785                              pszFilename, pStreamOps, pvStreamOpsUser,
    17851786                              enmAfter, pfnProgress, pvUser, pfSuspended);
    17861787    LogFlow(("VMR3Save: returns %Rrc (*pfSuspended=%RTbool)\n", rc, *pfSuspended));
  • trunk/src/VBox/VMM/testcase/tstSSM.cpp

    r28800 r31895  
    745745     */
    746746    uint64_t u64Start = RTTimeNanoTS();
    747     rc = SSMR3Save(pVM, pszFilename, SSMAFTER_DESTROY, NULL, NULL);
     747    rc = SSMR3Save(pVM, pszFilename, NULL, NULL, SSMAFTER_DESTROY, NULL, NULL);
    748748    if (RT_FAILURE(rc))
    749749    {
Note: See TracChangeset for help on using the changeset viewer.

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