Changeset 32294 in vbox
- Timestamp:
- Sep 7, 2010 3:26:36 PM (14 years ago)
- Location:
- trunk/src/VBox/VMM
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/FTM.cpp
r32291 r32294 115 115 pVM->ftm.s.fIsStandbyNode = false; 116 116 pVM->ftm.s.standby.hServer = NIL_RTTCPSERVER; 117 pVM->ftm.s. master.hShutdownEvent= NIL_RTSEMEVENT;117 pVM->ftm.s.hShutdownEvent = NIL_RTSEMEVENT; 118 118 pVM->ftm.s.hSocket = NIL_RTSOCKET; 119 119 … … 153 153 VMMR3DECL(int) FTMR3Term(PVM pVM) 154 154 { 155 if (pVM->ftm.s. master.hShutdownEvent != NIL_RTSEMEVENT)156 { 157 RTSemEventDestroy(pVM->ftm.s. master.hShutdownEvent);158 pVM->ftm.s. master.hShutdownEvent = NIL_RTSEMEVENT;155 if (pVM->ftm.s.hShutdownEvent != NIL_RTSEMEVENT) 156 { 157 RTSemEventDestroy(pVM->ftm.s.hShutdownEvent); 158 pVM->ftm.s.hShutdownEvent = NIL_RTSEMEVENT; 159 159 } 160 160 if (pVM->ftm.s.hSocket != NIL_RTSOCKET) … … 742 742 return VINF_SUCCESS; 743 743 } 744 rc = RTSemEventWait(pVM->ftm.s. master.hShutdownEvent, 1000 /* 1 second */);744 rc = RTSemEventWait(pVM->ftm.s.hShutdownEvent, 1000 /* 1 second */); 745 745 if (rc != VERR_TIMEOUT) 746 746 return VINF_SUCCESS; /* told to quit */ … … 759 759 for (;;) 760 760 { 761 rc = RTSemEventWait(pVM->ftm.s. master.hShutdownEvent, pVM->ftm.s.uInterval);761 rc = RTSemEventWait(pVM->ftm.s.hShutdownEvent, pVM->ftm.s.uInterval); 762 762 if (rc != VERR_TIMEOUT) 763 763 break; /* told to quit */ … … 890 890 } 891 891 892 /** 893 * Thread function which monitors the health of the master VM 894 * 895 * @param Thread The thread id. 896 * @param pvUser Not used 897 * @return VINF_SUCCESS (ignored). 898 * 899 */ 900 static DECLCALLBACK(int) ftmR3StandbyThread(RTTHREAD Thread, void *pvUser) 901 { 902 PVM pVM = (PVM)pvUser; 903 904 for (;;) 905 { 906 uint64_t u64TimeNow; 907 908 int rc = RTSemEventWait(pVM->ftm.s.hShutdownEvent, pVM->ftm.s.uInterval); 909 if (rc != VERR_TIMEOUT) 910 break; /* told to quit */ 911 912 if (pVM->ftm.s.standby.u64LastHeartbeat) 913 { 914 u64TimeNow = RTTimeMilliTS(); 915 916 if (u64TimeNow > pVM->ftm.s.standby.u64LastHeartbeat + pVM->ftm.s.uInterval * 4) 917 { 918 /* Timeout; prepare to fallover. */ 919 LogRel(("FTM: TIMEOUT (%RX64 vs %RX64): activate standby VM!\n", u64TimeNow, pVM->ftm.s.standby.u64LastHeartbeat + pVM->ftm.s.uInterval * 2)); 920 921 pVM->ftm.s.fActivateStandby = true; 922 /** todo: prevent split-brain. */ 923 break; 924 } 925 } 926 } 927 928 return VINF_SUCCESS; 929 } 930 892 931 893 932 /** … … 969 1008 break; 970 1009 1010 pVM->ftm.s.standby.u64LastHeartbeat = RTTimeMilliTS(); 971 1011 if (!strcmp(szCmd, "mem-sync")) 972 1012 { … … 1074 1114 if (pszPassword) 1075 1115 pVM->ftm.s.pszPassword = RTStrDup(pszPassword); 1116 1117 rc = RTSemEventCreate(&pVM->ftm.s.hShutdownEvent); 1118 if (RT_FAILURE(rc)) 1119 return rc; 1120 1076 1121 if (fMaster) 1077 1122 { 1078 rc = RTSemEventCreate(&pVM->ftm.s.master.hShutdownEvent);1079 if (RT_FAILURE(rc))1080 return rc;1081 1082 1123 rc = RTThreadCreate(NULL, ftmR3MasterThread, pVM, 1083 1124 0, RTTHREADTYPE_IO /* higher than normal priority */, 0, "ftmMaster"); … … 1099 1140 { 1100 1141 /* standby */ 1142 rc = RTThreadCreate(NULL, ftmR3StandbyThread, pVM, 1143 0, RTTHREADTYPE_DEFAULT, 0, "ftmStandby"); 1144 if (RT_FAILURE(rc)) 1145 return rc; 1146 1101 1147 rc = RTTcpServerCreateEx(pszAddress, uPort, &pVM->ftm.s.standby.hServer); 1102 1148 if (RT_FAILURE(rc)) … … 1106 1152 rc = RTTcpServerListen(pVM->ftm.s.standby.hServer, ftmR3StandbyServeConnection, pVM); 1107 1153 /** @todo deal with the exit code to check if we should activate this standby VM. */ 1154 if (pVM->ftm.s.fActivateStandby) 1155 { 1156 /** @todo fallover. */ 1157 } 1108 1158 1109 1159 if (pVM->ftm.s.standby.hServer) -
trunk/src/VBox/VMM/FTMInternal.h
r32289 r32294 61 61 /** Set when VM save/restore should only include changed pages. */ 62 62 bool fDeltaLoadSaveActive; 63 bool fAlignment[5]; 63 /** Fallover to the standby VM. */ 64 bool fActivateStandby; 65 bool fAlignment[4]; 64 66 65 67 /** Current active socket. */ … … 81 83 R3PTRTYPE(PRTTCPSERVER) hServer; 82 84 R3PTRTYPE(AVLGCPHYSTREE) pPhysPageTree; 85 uint64_t u64LastHeartbeat; 83 86 } standby; 84 87 88 /* 85 89 struct 86 90 { 87 RTSEMEVENT hShutdownEvent;88 91 } master; 92 */ 93 94 RTSEMEVENT hShutdownEvent; 89 95 90 96 /** FTM critical section.
Note:
See TracChangeset
for help on using the changeset viewer.