VirtualBox

Changeset 23904 in vbox


Ignore:
Timestamp:
Oct 20, 2009 3:01:56 PM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
53705
Message:

VMM,Main: Fixed bugs related to teleporting a paused VM.

Location:
trunk/src/VBox
Files:
2 edited

Legend:

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

    r23841 r23904  
    9292    Utf8Str             mstrHostname;
    9393    uint32_t            muPort;
    94 
    95     TeleporterStateSrc(Console *pConsole, PVM pVM, Progress *pProgress)
     94    MachineState_T      menmOldMachineState;
     95
     96    TeleporterStateSrc(Console *pConsole, PVM pVM, Progress *pProgress, MachineState_T enmOldMachineState)
    9697        : TeleporterState(pConsole, pVM, pProgress, true /*fIsSource*/)
    9798        , muPort(UINT32_MAX)
     99        , menmOldMachineState(enmOldMachineState)
    98100    {
    99101    }
     
    110112    PRTTCPSERVER        mhServer;
    111113    PRTTIMERLR          mphTimerLR;
     114    bool                mfStartPaused;
    112115    int                 mRc;
    113116
    114117    TeleporterStateTrg(Console *pConsole, PVM pVM, Progress *pProgress,
    115                        IMachine *pMachine, PRTTIMERLR phTimerLR)
     118                       IMachine *pMachine, PRTTIMERLR phTimerLR, bool fStartPaused)
    116119        : TeleporterState(pConsole, pVM, pProgress, false /*fIsSource*/)
    117120        , mpMachine(pMachine)
    118121        , mhServer(NULL)
    119122        , mphTimerLR(phTimerLR)
     123        , mfStartPaused(false)
    120124        , mRc(VINF_SUCCESS)
    121125    {
     
    617621    void *pvUser = static_cast<void *>(static_cast<TeleporterState *>(pState));
    618622    vrc = VMR3Teleport(pState->mpVM, &g_teleporterTcpOps, pvUser, teleporterProgressCallback, pvUser);
    619     if (vrc)
     623    if (RT_FAILURE(vrc))
    620624        return setError(E_FAIL, tr("VMR3Teleport -> %Rrc"), vrc);
    621625
     
    623627    if (FAILED(hrc))
    624628        return hrc;
     629
     630    /*
     631     * If we're paused, mention this to the target side.
     632     *
     633     * Note: This means you have to resume the target manually if you pause it
     634     *       during the teleportation.
     635     */
     636    if (    vrc == VINF_SSM_LIVE_SUSPENDED
     637        ||  pState->menmOldMachineState == MachineState_Paused)
     638    {
     639        hrc = teleporterSrcSubmitCommand(pState, "pause");
     640        if (FAILED(hrc))
     641            return hrc;
     642    }
    625643
    626644    /*
     
    686704                case VMSTATE_RESETTING:
    687705                case VMSTATE_RESETTING_LS:
    688                     pState->mptrConsole->setMachineState(MachineState_Running);
     706                    if (pState->menmOldMachineState == MachineState_Running)
     707                        pState->mptrConsole->setMachineState(MachineState_Running);
     708                    else
     709                        pState->mptrConsole->setMachineState(MachineState_Paused);
    689710                    break;
    690711                case VMSTATE_GURU_MEDITATION:
     
    777798    CheckComRCReturnRC(hrc);
    778799
    779     TeleporterStateSrc *pState = new TeleporterStateSrc(this, mpVM, ptrProgress);
     800    TeleporterStateSrc *pState = new TeleporterStateSrc(this, mpVM, ptrProgress, mMachineState);
    780801    pState->mstrPassword = aPassword;
    781802    pState->mstrHostname = aHostname;
     
    888909             * Do the job, when it returns we're done.
    889910             */
    890             TeleporterStateTrg State(this, pVM, pProgress, pMachine, &hTimerLR);
     911            TeleporterStateTrg State(this, pVM, pProgress, pMachine, &hTimerLR, fStartPaused);
    891912            State.mstrPassword      = strPassword;
    892913            State.mhServer          = hServer;
     
    904925                    if (RT_SUCCESS(vrc))
    905926                    {
    906                         if (fStartPaused)
     927                        if (State.mfStartPaused)
    907928                            setMachineState(MachineState_Paused);
    908929                        else
     
    10851106
    10861107            vrc = teleporterTcpWriteACK(pState);
    1087             if (RT_FAILURE(vrc))
    1088                 break;
    10891108        }
    10901109        /** @todo implement config verification and hardware compatability checks. Or
     
    10961115            LogRel(("Teleporter: Received cancel command.\n"));
    10971116            vrc = VERR_SSM_CANCELLED;
     1117        }
     1118        else if (!strcmp(szCmd, "pause"))
     1119        {
     1120            pState->mfStartPaused = true;
     1121            vrc = teleporterTcpWriteACK(pState);
    10981122        }
    10991123        else if (!strcmp(szCmd, "done"))
     
    11181142            break;
    11191143        }
     1144
     1145        if (RT_FAILURE(vrc))
     1146            break;
    11201147    }
    11211148
  • trunk/src/VBox/VMM/VM.cpp

    r23826 r23904  
    15331533     */
    15341534    int rc = VINF_SUCCESS;
    1535     if (VMR3GetState(pVM) == VMSTATE_SUSPENDED_LS)
     1535    VMSTATE enmVMState = VMR3GetState(pVM);
     1536    if (enmVMState == VMSTATE_SUSPENDED_LS)
    15361537        vmR3SetState(pVM, VMSTATE_SAVING, VMSTATE_SUSPENDED_LS);
    15371538    else
    15381539    {
    1539         vmR3SetState(pVM, VMSTATE_SAVING, VMSTATE_SUSPENDED_EXT_LS);
     1540        if (enmVMState != VMSTATE_SAVING)
     1541            vmR3SetState(pVM, VMSTATE_SAVING, VMSTATE_SUSPENDED_EXT_LS);
    15401542        rc = VINF_SSM_LIVE_SUSPENDED;
    15411543    }
     
    16021604                             VMSTATE_SAVING,     VMSTATE_SUSPENDED,
    16031605                             VMSTATE_RUNNING_LS, VMSTATE_RUNNING);
    1604     if (rc == 1)
    1605     {
     1606    if (rc == 1 && enmAfter != SSMAFTER_TELEPORT)
     1607    {
     1608        Assert(!pStreamOps);
    16061609        rc = SSMR3Save(pVM, pszFilename, enmAfter, pfnProgress, pvProgressUser);
    16071610        vmR3SetState(pVM, VMSTATE_SUSPENDED, VMSTATE_SAVING);
    16081611    }
    1609     else if (rc == 2)
     1612    else if (rc == 2 || enmAfter == SSMAFTER_TELEPORT)
    16101613    {
    16111614        rc = SSMR3LiveSave(pVM, pszFilename, pStreamOps, pvStreamOpsUser,
     
    16561659        if (RT_SUCCESS(rc))
    16571660        {
    1658             for (;;)
    1659             {
    1660                 /* Try suspend the VM. */
    1661                 rc = VMMR3EmtRendezvous(pVM, VMMEMTRENDEZVOUS_FLAGS_TYPE_DESCENDING | VMMEMTRENDEZVOUS_FLAGS_STOP_ON_ERROR,
    1662                                         vmR3LiveDoSuspend, NULL);
    1663                 if (rc != VERR_TRY_AGAIN)
    1664                     break;
    1665 
    1666                 /* Wait for the state to change. */
    1667                 RTThreadSleep(250); /** @todo LS: fix this polling wait by some smart use of multiple release event  semaphores.. */
    1668             }
     1661            if (VMR3GetState(pVM) != VMSTATE_SAVING)
     1662                for (;;)
     1663                {
     1664                    /* Try suspend the VM. */
     1665                    rc = VMMR3EmtRendezvous(pVM, VMMEMTRENDEZVOUS_FLAGS_TYPE_DESCENDING | VMMEMTRENDEZVOUS_FLAGS_STOP_ON_ERROR,
     1666                                            vmR3LiveDoSuspend, NULL);
     1667                    if (rc != VERR_TRY_AGAIN)
     1668                        break;
     1669
     1670                    /* Wait for the state to change. */
     1671                    RTThreadSleep(250); /** @todo LS: fix this polling wait by some smart use of multiple release event  semaphores.. */
     1672                }
    16691673            if (RT_SUCCESS(rc))
    16701674                rc = VMR3ReqCallWaitU(pVM->pUVM, 0 /*idDstCpu*/, (PFNRT)vmR3LiveDoStep2, 2, pVM, pSSM);
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