- Timestamp:
- Aug 25, 2010 11:00:38 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/FTM.cpp
r31938 r31953 35 35 #include <iprt/mem.h> 36 36 #include <iprt/tcp.h> 37 #include <iprt/socket.h> 37 38 #include <iprt/semaphore.h> 38 39 #include <iprt/asm.h> … … 211 212 * @param pszNAckMsg Optional NACK message. 212 213 */ 213 static int ftmR3TcpReadACK(PVM pVM, const char *pszWhich, const char *pszNAckMsg /*= NULL*/)214 static int ftmR3TcpReadACK(PVM pVM, const char *pszWhich, const char *pszNAckMsg = NULL) 214 215 { 215 216 char szMsg[256]; … … 256 257 } 257 258 return VERR_INTERNAL_ERROR_3; 259 } 260 261 /** 262 * Submitts a command to the destination and waits for the ACK. 263 * 264 * @returns VBox status code. 265 * 266 * @param pVM The VM to operate on. 267 * @param pszCommand The command. 268 * @param fWaitForAck Whether to wait for the ACK. 269 */ 270 static int ftmR3TcpSubmitCommand(PVM pVM, const char *pszCommand, bool fWaitForAck = true) 271 { 272 int rc = RTTcpSgWriteL(pVM->ftm.s.hSocket, 2, pszCommand, strlen(pszCommand), "\n", sizeof("\n") - 1); 273 if (RT_FAILURE(rc)) 274 return rc; 275 if (!fWaitForAck) 276 return VINF_SUCCESS; 277 return ftmR3TcpReadACK(pVM, pszCommand); 258 278 } 259 279 … … 540 560 { 541 561 case FTMSYNCSTATE_FULL: 562 { 563 bool fSuspended = false; 564 565 rc = ftmR3TcpSubmitCommand(pVM, "full-sync"); 566 AssertRC(rc); 567 568 rc = VMR3Save(pVM, NULL /* pszFilename */, &g_ftmR3TcpOps, pVM, true /* fContinueAfterwards */, NULL, NULL, &fSuspended); 569 AssertRC(rc); 570 571 rc = ftmR3TcpReadACK(pVM, "full-sync-complete"); 572 AssertRC(rc); 542 573 break; 574 } 543 575 544 576 case FTMSYNCSTATE_DELTA_VM: … … 733 765 char szCmd[128]; 734 766 rc = ftmR3TcpReadLine(pVM, szCmd, sizeof(szCmd)); 767 AssertRC(rc); 735 768 if (RT_FAILURE(rc)) 736 769 break; … … 747 780 { 748 781 } 749 if (RT_FAILURE(rc)) 750 break; 782 else 783 if (!strcmp(szCmd, "full-sync")) 784 { 785 rc = ftmR3TcpWriteACK(pVM); 786 AssertRC(rc); 787 if (RT_FAILURE(rc)) 788 continue; 789 790 RTSocketRetain(pVM->ftm.s.hSocket); /* For concurrent access by I/O thread and EMT. */ 791 pVM->ftm.s.syncstate.uOffStream = 0; 792 793 rc = VMR3LoadFromStream(pVM, &g_ftmR3TcpOps, pVM, NULL, NULL); 794 RTSocketRelease(pVM->ftm.s.hSocket); 795 AssertRC(rc); 796 if (RT_FAILURE(rc)) 797 { 798 LogRel(("FTSync: VMR3LoadFromStream -> %Rrc\n", rc)); 799 ftmR3TcpWriteNACK(pVM, rc); 800 continue; 801 } 802 803 /* The EOS might not have been read, make sure it is. */ 804 pVM->ftm.s.syncstate.fStopReading = false; 805 size_t cbRead; 806 rc = ftmR3TcpOpRead(pVM, pVM->ftm.s.syncstate.uOffStream, szCmd, 1, &cbRead); 807 if (rc != VERR_EOF) 808 { 809 LogRel(("FTSync: Draining teleporterTcpOpRead -> %Rrc\n", rc)); 810 ftmR3TcpWriteNACK(pVM, rc); 811 continue; 812 } 813 814 rc = ftmR3TcpWriteACK(pVM); 815 AssertRC(rc); 816 } 751 817 } 752 818 LogFlowFunc(("returns mRc=%Rrc\n", rc)); … … 867 933 pVM->ftm.s.syncstate.fEndOfStream = false; 868 934 869 /* Sync state + changed memory . */935 /* Sync state + changed memory with the standby node. */ 870 936 rc = VMR3ReqCallWait(pVM, VMCPUID_ANY, (PFNRT)ftmR3PerformSync, 2, pVM, FTMSYNCSTATE_DELTA_VM); 871 937 AssertRC(rc);
Note:
See TracChangeset
for help on using the changeset viewer.