Changeset 31895 in vbox for trunk/src/VBox
- Timestamp:
- Aug 24, 2010 9:00:14 AM (15 years ago)
- svn:sync-xref-src-repo-rev:
- 65105
- Location:
- trunk/src/VBox
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxBFE/VMControl.cpp
r28800 r31895 132 132 startProgressInfo("Saving"); 133 133 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); 135 138 AssertRC(rc); 136 139 endProgressInfo(); -
trunk/src/VBox/Main/ConsoleImpl.cpp
r31841 r31895 7803 7803 int vrc = VMR3Save(that->mpVM, 7804 7804 strSavedStateFile.c_str(), 7805 NULL /* pStreamOps */, 7806 NULL /* pvStreamOpsUser */, 7805 7807 true /*fContinueAfterwards*/, 7806 7808 Console::stateProgressCallback, … … 8062 8064 int vrc = VMR3Save(that->mpVM, 8063 8065 task->mSavedStateFile.c_str(), 8066 NULL /* pStreamOps */, 8067 NULL /* pvStreamOpsUser */, 8064 8068 false, /*fContinueAfterwards*/ 8065 8069 Console::stateProgressCallback, -
trunk/src/VBox/VMM/FTM.cpp
r31809 r31895 521 521 522 522 /** 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 */ 529 static 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 /** 523 562 * Thread function which starts syncing process for this master VM 524 563 * … … 527 566 * @return VINF_SUCCESS (ignored). 528 567 * 529 * @note Locks the Console object for writing.530 568 */ 531 569 static DECLCALLBACK(int) ftmR3MasterThread(RTTHREAD Thread, void *pvUser) … … 579 617 */ 580 618 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 581 626 for (;;) 582 627 { -
trunk/src/VBox/VMM/FTMInternal.h
r31833 r31895 29 29 * @{ 30 30 */ 31 32 typedef 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; 31 41 32 42 -
trunk/src/VBox/VMM/PGMInternal.h
r31851 r31895 3789 3789 void pgmR3PoolClearAll(PVM pVM, bool fFlushRemTlb); 3790 3790 DECLCALLBACK(VBOXSTRICTRC) pgmR3PoolClearAllRendezvous(PVM pVM, PVMCPU pVCpu, void *fpvFlushRemTbl); 3791 void pgmR3PoolWriteProtectPages(PVM pVM); 3791 3792 3792 3793 #endif /* IN_RING3 */ -
trunk/src/VBox/VMM/PGMPhys.cpp
r31630 r31895 956 956 return VERR_NOT_IMPLEMENTED; 957 957 #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 */ 971 static 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 */ 1038 VMMR3DECL(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; 958 1045 } 959 1046 -
trunk/src/VBox/VMM/PGMPool.cpp
r31775 r31895 818 818 } 819 819 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 */ 827 void 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 } 820 891 821 892 #ifdef VBOX_WITH_DEBUGGER -
trunk/src/VBox/VMM/SSM.cpp
r31847 r31895 4886 4886 * 4887 4887 * @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. 4889 4892 * @param enmAfter What is planned after a successful save operation. 4890 4893 * @param pfnProgress Progress callback. Optional. … … 4893 4896 * @thread EMT 4894 4897 */ 4895 VMMR3DECL(int) SSMR3Save(PVM pVM, const char *pszFilename, SSMAFTER enmAfter, PFNVMPROGRESS pfnProgress, void *pvUser) 4898 VMMR3DECL(int) SSMR3Save(PVM pVM, const char *pszFilename, PCSSMSTRMOPS pStreamOps, void *pvStreamOpsUser, 4899 SSMAFTER enmAfter, PFNVMPROGRESS pfnProgress, void *pvUser) 4896 4900 { 4897 4901 LogFlow(("SSMR3Save: pszFilename=%p:{%s} enmAfter=%d pfnProgress=%p pvUser=%p\n", pszFilename, pszFilename, enmAfter, pfnProgress, pvUser)); … … 4906 4910 VERR_INVALID_PARAMETER); 4907 4911 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 4908 4925 /* 4909 4926 * Create the saved state file and handle. … … 4913 4930 */ 4914 4931 PSSMHANDLE pSSM; 4915 int rc = ssmR3SaveDoCreateFile(pVM, pszFilename, NULL /*pStreamOps*/, NULL /*pvStreamOpsUser*/,4932 int rc = ssmR3SaveDoCreateFile(pVM, pszFilename, pStreamOps, pvStreamOpsUser, 4916 4933 enmAfter, pfnProgress, pvUser, &pSSM); 4917 4934 if (RT_FAILURE(rc)) … … 4920 4937 pSSM->uPercentPrepare = 20; 4921 4938 pSSM->uPercentDone = 2; 4939 pSSM->fLiveSave = false; 4922 4940 4923 4941 /* -
trunk/src/VBox/VMM/VM.cpp
r31854 r31895 1641 1641 if (rc == 1 && enmAfter != SSMAFTER_TELEPORT) 1642 1642 { 1643 Assert(!pStreamOps); 1644 rc = SSMR3Save(pVM, pszFilename, enmAfter, pfnProgress, pvProgressUser); 1643 rc = SSMR3Save(pVM, pszFilename, pStreamOps, pvStreamOpsUser, enmAfter, pfnProgress, pvProgressUser); 1645 1644 vmR3SetState(pVM, VMSTATE_SUSPENDED, VMSTATE_SAVING); 1646 1645 } … … 1749 1748 * @param pVM The VM which state should be saved. 1750 1749 * @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. 1751 1752 * @param fContinueAfterwards Whether continue execution afterwards or not. 1752 1753 * When in doubt, set this to true. … … 1760 1761 * RunningLS+SuspeningLS+SuspendedLS+Saving+Suspended. 1761 1762 */ 1762 VMMR3DECL(int) VMR3Save(PVM pVM, const char *pszFilename, bool fContinueAfterwards,1763 PFNVMPROGRESS pfnProgress, void *pvUser, bool *pfSuspended)1763 VMMR3DECL(int) VMR3Save(PVM pVM, const char *pszFilename, PCSSMSTRMOPS pStreamOps, void *pvStreamOpsUser, 1764 bool fContinueAfterwards, PFNVMPROGRESS pfnProgress, void *pvUser, bool *pfSuspended) 1764 1765 { 1765 1766 LogFlow(("VMR3Save: pVM=%p pszFilename=%p:{%s} fContinueAfterwards=%RTbool pfnProgress=%p pvUser=%p pfSuspended=%p\n", … … 1782 1783 SSMAFTER enmAfter = fContinueAfterwards ? SSMAFTER_CONTINUE : SSMAFTER_DESTROY; 1783 1784 int rc = vmR3SaveTeleport(pVM, 250 /*cMsMaxDowntime*/, 1784 pszFilename, NULL /*pStreamOps*/, NULL /*pvStreamOpsUser*/,1785 pszFilename, pStreamOps, pvStreamOpsUser, 1785 1786 enmAfter, pfnProgress, pvUser, pfSuspended); 1786 1787 LogFlow(("VMR3Save: returns %Rrc (*pfSuspended=%RTbool)\n", rc, *pfSuspended)); -
trunk/src/VBox/VMM/testcase/tstSSM.cpp
r28800 r31895 745 745 */ 746 746 uint64_t u64Start = RTTimeNanoTS(); 747 rc = SSMR3Save(pVM, pszFilename, SSMAFTER_DESTROY, NULL, NULL);747 rc = SSMR3Save(pVM, pszFilename, NULL, NULL, SSMAFTER_DESTROY, NULL, NULL); 748 748 if (RT_FAILURE(rc)) 749 749 {
Note:
See TracChangeset
for help on using the changeset viewer.