VirtualBox

Changeset 31953 in vbox for trunk


Ignore:
Timestamp:
Aug 25, 2010 11:00:38 AM (14 years ago)
Author:
vboxsync
Message:

FT updates

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/FTM.cpp

    r31938 r31953  
    3535#include <iprt/mem.h>
    3636#include <iprt/tcp.h>
     37#include <iprt/socket.h>
    3738#include <iprt/semaphore.h>
    3839#include <iprt/asm.h>
     
    211212 * @param   pszNAckMsg          Optional NACK message.
    212213 */
    213 static int ftmR3TcpReadACK(PVM pVM, const char *pszWhich, const char *pszNAckMsg /*= NULL*/)
     214static int ftmR3TcpReadACK(PVM pVM, const char *pszWhich, const char *pszNAckMsg = NULL)
    214215{
    215216    char szMsg[256];
     
    256257    }
    257258    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 */
     270static 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);
    258278}
    259279
     
    540560    {
    541561    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);
    542573        break;
     574    }
    543575
    544576    case FTMSYNCSTATE_DELTA_VM:
     
    733765        char szCmd[128];
    734766        rc = ftmR3TcpReadLine(pVM, szCmd, sizeof(szCmd));
     767        AssertRC(rc);
    735768        if (RT_FAILURE(rc))
    736769            break;
     
    747780        {
    748781        }
    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        }       
    751817    }
    752818    LogFlowFunc(("returns mRc=%Rrc\n", rc));
     
    867933    pVM->ftm.s.syncstate.fEndOfStream = false;
    868934
    869     /* Sync state + changed memory. */
     935    /* Sync state + changed memory with the standby node. */
    870936    rc = VMR3ReqCallWait(pVM, VMCPUID_ANY, (PFNRT)ftmR3PerformSync, 2, pVM, FTMSYNCSTATE_DELTA_VM);
    871937    AssertRC(rc);
Note: See TracChangeset for help on using the changeset viewer.

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