Changeset 32001 in vbox for trunk/src/VBox/VMM
- Timestamp:
- Aug 26, 2010 2:13:09 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/FTM.cpp
r31953 r32001 58 58 uint32_t cb; 59 59 } FTMTCPHDR; 60 /** Magic value for TELEPORTERTCPHDR::u32Magic. (Egberto Gismonti Amin) */60 /** Magic value for FTMTCPHDR::u32Magic. (Egberto Gismonti Amin) */ 61 61 #define FTMTCPHDR_MAGIC UINT32_C(0x19471205) 62 62 /** The max block size. */ 63 63 #define FTMTCPHDR_MAX_SIZE UINT32_C(0x00fffff8) 64 65 /** 66 * TCP stream header. 67 * 68 * This is an extra layer for fixing the problem with figuring out when the SSM 69 * stream ends. 70 */ 71 typedef struct FTMTCPHDRMEM 72 { 73 /** Magic value. */ 74 uint32_t u32Magic; 75 /** Size (Uncompressed) of the pages following the header. */ 76 uint32_t cbPageRange; 77 /** GC Physical address of the page(s) to sync. */ 78 RTGCPHYS GCPhys; 79 /** The size of the data block following this header. 80 * 0 indicates the end of the stream, while UINT32_MAX indicates 81 * cancelation. */ 82 uint32_t cb; 83 } FTMTCPHDRMEM; 64 84 65 85 /******************************************************************************* … … 603 623 static DECLCALLBACK(int) ftmR3SyncDirtyPage(PVM pVM, RTGCPHYS GCPhys, uint8_t *pRange, unsigned cbRange, void *pvUser) 604 624 { 625 FTMTCPHDRMEM Hdr; 626 Hdr.u32Magic = FTMTCPHDR_MAGIC; 627 Hdr.GCPhys = GCPhys; 628 Hdr.cbPageRange = cbRange; 629 Hdr.cb = cbRange; 630 /** @todo compress page(s). */ 631 int rc = RTTcpSgWriteL(pVM->ftm.s.hSocket, 2, &Hdr, sizeof(Hdr), pRange, (size_t)Hdr.cb); 632 if (RT_FAILURE(rc)) 633 { 634 LogRel(("FTSync/TCP: Write error (ftmR3SyncDirtyPage): %Rrc (cb=%#x)\n", rc, Hdr.cb)); 635 return rc; 636 } 605 637 return VINF_SUCCESS; 606 638 } … … 682 714 AssertMsg(rc == VINF_SUCCESS, ("%Rrc\n", rc)); 683 715 716 rc = ftmR3TcpSubmitCommand(pVM, "mem-sync"); 717 AssertRC(rc); 718 684 719 /* sync the changed memory with the standby node. */ 685 720 rc = VMR3ReqCallWait(pVM, VMCPUID_ANY, (PFNRT)ftmR3PerformSync, 2, pVM, FTMSYNCSTATE_DELTA_MEMORY); 686 721 AssertRC(rc); 687 722 723 /* Enumerate all dirty pages and send them to the standby VM. */ 688 724 rc = PGMR3PhysEnumDirtyFTPages(pVM, ftmR3SyncDirtyPage, NULL /* pvUser */); 725 AssertRC(rc); 726 727 /* Send last memory header to signal the end. */ 728 FTMTCPHDRMEM Hdr; 729 Hdr.u32Magic = FTMTCPHDR_MAGIC; 730 Hdr.GCPhys = 0; 731 Hdr.cbPageRange = 0; 732 Hdr.cb = 0; 733 int rc = RTTcpSgWriteL(pVM->ftm.s.hSocket, 1, &Hdr, sizeof(Hdr)); 734 if (RT_FAILURE(rc)) 735 LogRel(("FTSync/TCP: Write error (ftmR3MasterThread): %Rrc (cb=%#x)\n", rc, Hdr.cb)); 736 737 rc = ftmR3TcpReadACK(pVM, "mem-sync-complete"); 689 738 AssertRC(rc); 690 739 … … 771 820 if (!strcmp(szCmd, "mem-sync")) 772 821 { 822 rc = ftmR3TcpWriteACK(pVM); 823 AssertRC(rc); 824 if (RT_FAILURE(rc)) 825 continue; 826 827 while (true) 828 { 829 FTMTCPHDRMEM Hdr; 830 void *pPage; 831 832 /* Read memory header. */ 833 rc = RTTcpRead(pVM->ftm.s.hSocket, &Hdr, sizeof(Hdr), NULL); 834 if (RT_FAILURE(rc)) 835 { 836 Log(("RTTcpRead failed with %Rrc\n", rc)); 837 break; 838 } 839 840 if (Hdr.cb == 0) 841 break; /* end of sync. */ 842 843 Assert(Hdr.cb == Hdr.cbPageRange); /** @todo uncompress */ 844 845 /* Allocate memory to hold the page(s). */ 846 pPage = RTMemAlloc(Hdr.cbPageRange); 847 AssertBreak(pPage); 848 849 /* Fetch the page(s). */ 850 rc = RTTcpRead(pVM->ftm.s.hSocket, pPage, Hdr.cb, NULL); 851 if (RT_FAILURE(rc)) 852 { 853 Log(("RTTcpRead page data (%d bytes) failed with %Rrc\n", Hdr.cb, rc)); 854 break; 855 } 856 857 /* Update the guest memory of the standby VM. */ 858 rc = PGMPhysWrite(pVM, Hdr.GCPhys, pPage, Hdr.cbPageRange); 859 AssertRC(rc); 860 861 RTMemFree(pPage); 862 } 863 864 rc = ftmR3TcpWriteACK(pVM); 865 AssertRC(rc); 773 866 } 774 867 else
Note:
See TracChangeset
for help on using the changeset viewer.