VirtualBox

Changeset 24614 in vbox for trunk/src


Ignore:
Timestamp:
Nov 12, 2009 5:09:46 PM (15 years ago)
Author:
vboxsync
Message:

ConsoleImplTeleporter.cpp: changed to VM hand over and TCP disconnecting point.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/ConsoleImplTeleporter.cpp

    r24558 r24614  
    117117    PRTTCPSERVER                mhServer;
    118118    PRTTIMERLR                  mphTimerLR;
    119     bool                        mfStartPaused;
    120119    bool                        mfLockedMedia;
    121120    int                         mRc;
     
    129128        , mhServer(NULL)
    130129        , mphTimerLR(phTimerLR)
    131         , mfStartPaused(false)
    132130        , mfLockedMedia(false)
    133131        , mRc(VINF_SUCCESS)
     
    637635
    638636    /*
    639      * If we're paused, mention this to the target side.
    640      *
    641      * Note: This means you have to resume the target manually if you pause it
    642      *       during the teleportation.
    643      */
    644     if (    vrc == VINF_SSM_LIVE_SUSPENDED
    645         ||  pState->menmOldMachineState == MachineState_Paused)
    646     {
    647         hrc = teleporterSrcSubmitCommand(pState, "pause");
    648         if (FAILED(hrc))
    649             return hrc;
    650     }
    651 
    652     /*
    653637     * We're at the point of no return.
    654638     */
     
    660644
    661645    /*
    662      * The last thing we do is to hand over any media we might have locked.
     646     * Hand over any media which we might be sharing.
     647     *
     648     * Note! This is only important on localhost teleportations.
    663649     */
    664650    /** @todo Maybe we should only do this if it's a local teleportation... */
     
    672658        return hrc;
    673659
    674     hrc = teleporterSrcSubmitCommand(pState, "done");
     660    /*
     661     * The FINAL step is giving the target instructions how to proceed with the VM.
     662     */
     663    if (    vrc == VINF_SSM_LIVE_SUSPENDED
     664        ||  pState->menmOldMachineState == MachineState_Paused)
     665        hrc = teleporterSrcSubmitCommand(pState, "hand-over-paused");
     666    else
     667        hrc = teleporterSrcSubmitCommand(pState, "hand-over-resume");
    675668    if (FAILED(hrc))
    676669        return hrc;
     
    705698    if (SUCCEEDED(hrc))
    706699        hrc = pState->mptrConsole->teleporterSrc(pState);
     700
     701    /* Close the connection ASAP on so that the other side can complete. */
     702    if (pState->mhSocket != NIL_RTSOCKET)
     703    {
     704        RTTcpClientClose(pState->mhSocket);
     705        pState->mhSocket = NIL_RTSOCKET;
     706    }
    707707
    708708    /* Aaarg! setMachineState trashes error info on Windows, so we have to
     
    714714    pState->mptrProgress->setCancelCallback(NULL, NULL);
    715715
    716     /* Write lock the console before resetting mptrCancelableProgress and fixing the state.  */
     716    /*
     717     * Write lock the console before resetting mptrCancelableProgress and
     718     * fixing the state.
     719     */
    717720    AutoWriteLock autoLock(pState->mptrConsole);
    718721    pState->mptrConsole->mptrCancelableProgress.setNull();
     
    825828     * Cleanup.
    826829     */
    827     if (pState->mhSocket != NIL_RTSOCKET)
    828     {
    829         RTTcpClientClose(pState->mhSocket);
    830         pState->mhSocket = NIL_RTSOCKET;
    831     }
     830    Assert(pState->mhSocket == NIL_RTSOCKET);
    832831    delete pState;
    833832
     
    10201019                {
    10211020                    vrc = State.mRc;
    1022                     if (RT_SUCCESS(vrc))
    1023                     {
    1024                         if (State.mfStartPaused)
    1025                             setMachineState(MachineState_Paused);
    1026                         else
    1027                             vrc = VMR3Resume(pVM);
    1028                     }
    10291021                    /* Power off the VM on failure unless the state callback
    10301022                       already did that. */
    1031                     else
     1023                    if (RT_FAILURE(vrc))
    10321024                    {
    10331025                        VMSTATE enmVMState = VMR3GetState(pVM);
     
    11031095
    11041096
    1105 static int teleporterTcpWriteACK(TeleporterStateTrg *pState)
     1097static int teleporterTcpWriteACK(TeleporterStateTrg *pState, bool fAutomaticUnlock = true)
    11061098{
    11071099    int rc = RTTcpWrite(pState->mhSocket, "ACK\n", sizeof("ACK\n") - 1);
     
    11091101    {
    11101102        LogRel(("Teleporter: RTTcpWrite(,ACK,) -> %Rrc\n", rc));
    1111         teleporterTrgUnlockMedia(pState);
     1103        if (fAutomaticUnlock)
     1104            teleporterTrgUnlockMedia(pState);
    11121105    }
    11131106    RTTcpFlush(pState->mhSocket);
     
    12371230            vrc = VERR_SSM_CANCELLED;
    12381231        }
    1239         else if (!strcmp(szCmd, "pause"))
    1240         {
    1241             pState->mfStartPaused = true;
    1242             vrc = teleporterTcpWriteACK(pState);
    1243         }
    12441232        else if (!strcmp(szCmd, "lock-media"))
    12451233        {
     
    12561244            }
    12571245        }
    1258         else if (!strcmp(szCmd, "done"))
     1246        else if (   !strcmp(szCmd, "hand-over-resume")
     1247                 || !strcmp(szCmd, "hand-over-paused"))
    12591248        {
    12601249            /*
    1261              * The ACK is the point of no return.
     1250             * Point of no return.
     1251             *
     1252             * Note! Since we cannot tell whether a VMR3Resume failure is
     1253             *       destructive for the source or not, we have little choice
     1254             *       but to ACK it first and take any failures locally.
     1255             *
     1256             *       Ideally, we should try resume it first and then ACK (or
     1257             *       NACK) the request since this would reduce latency and
     1258             *       make it possible to recover from some VMR3Resume failures.
    12621259             */
    12631260            if (   pState->mptrProgress->notifyPointOfNoReturn()
    12641261                && pState->mfLockedMedia)
     1262            {
    12651263                vrc = teleporterTcpWriteACK(pState);
     1264                if (RT_SUCCESS(vrc))
     1265                {
     1266                    if (!strcmp(szCmd, "hand-over-resume"))
     1267                        vrc = VMR3Resume(pState->mpVM);
     1268                    else
     1269                        pState->mptrConsole->setMachineState(MachineState_Paused);
     1270                    fDone = true;
     1271                    break;
     1272                }
     1273            }
    12661274            else
    12671275            {
     
    12691277                teleporterTcpWriteNACK(pState, vrc);
    12701278            }
    1271             fDone = true;
    1272             break;
    12731279        }
    12741280        else
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