VirtualBox

Changeset 29957 in vbox


Ignore:
Timestamp:
Jun 1, 2010 3:21:28 PM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
62239
Message:

Console*: Fixed power off on failure issue again (should be correct now). Fixed missing socket retaining on the source side that would occasionally cause teleporterTcpOpIsOk to fail. Attempt at fixing the error propagation on the target side.

Location:
trunk/src/VBox/Main
Files:
3 edited

Legend:

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

    r29927 r29957  
    74077407                {
    74087408                    /* -> ConsoleImplTeleporter.cpp */
    7409                     vrc = console->teleporterTrg(pVM, pMachine, task->mStartPaused, task->mProgress);
    7410                     if (RT_FAILURE(vrc) && !task->mErrorMsg.length())
    7411                         rc = E_FAIL;    /* Avoid the "Missing error message..." assertion. */
     7409                    bool fPowerOffOnFailure;
     7410                    rc = console->teleporterTrg(pVM, pMachine, &task->mErrorMsg, task->mStartPaused,
     7411                                                task->mProgress, &fPowerOffOnFailure);
     7412                    if (FAILED(rc) && fPowerOffOnFailure)
     7413                    {
     7414                        ErrorInfoKeeper eik;
     7415                        int vrc2 = VMR3PowerOff(pVM);
     7416                        AssertRC(vrc2);
     7417                    }
    74127418                }
    74137419                else if (task->mStartPaused)
  • trunk/src/VBox/Main/ConsoleImplTeleporter.cpp

    r29927 r29957  
    664664        return hrc;
    665665
     666    RTSocketRetain(pState->mhSocket);
    666667    void *pvUser = static_cast<void *>(static_cast<TeleporterState *>(pState));
    667668    vrc = VMR3Teleport(pState->mpVM, pState->mcMsMaxDowntime,
     
    669670                       teleporterProgressCallback, pvUser,
    670671                       &pState->mfSuspendedByUs);
     672    RTSocketRelease(pState->mhSocket);
    671673    if (RT_FAILURE(vrc))
    672674        return setError(E_FAIL, tr("VMR3Teleport -> %Rrc"), vrc);
     
    979981 * @param   pVM                 The VM handle
    980982 * @param   pMachine            The IMachine for the virtual machine.
     983 * @param   pErrorMsg           Pointer to the error string for VMSetError.
    981984 * @param   fStartPaused        Whether to start it in the Paused (true) or
    982985 *                              Running (false) state,
    983986 * @param   pProgress           Pointer to the progress object.
     987 * @param   pfPowerOffOnFailure Whether the caller should power off
     988 *                              the VM on failure.
    984989 *
    985990 * @remarks The caller expects error information to be set on failure.
    986991 * @todo    Check that all the possible failure paths sets error info...
    987992 */
    988 int
    989 Console::teleporterTrg(PVM pVM, IMachine *pMachine, bool fStartPaused, Progress *pProgress)
     993HRESULT
     994Console::teleporterTrg(PVM pVM, IMachine *pMachine, Utf8Str *pErrorMsg, bool fStartPaused,
     995                       Progress *pProgress, bool *pfPowerOffOnFailure)
    990996{
    991997    LogThisFunc(("pVM=%p pMachine=%p fStartPaused=%RTbool pProgress=%p\n", pVM, pMachine, fStartPaused, pProgress));
     998
     999    *pfPowerOffOnFailure = true;
    9921000
    9931001    /*
     
    9971005    HRESULT hrc = pMachine->COMGETTER(TeleporterPort)(&uPort);
    9981006    if (FAILED(hrc))
    999         return VERR_GENERAL_FAILURE;
     1007        return hrc;
    10001008    ULONG const uPortOrg = uPort;
    10011009
     
    10031011    hrc = pMachine->COMGETTER(TeleporterAddress)(bstrAddress.asOutParam());
    10041012    if (FAILED(hrc))
    1005         return VERR_GENERAL_FAILURE;
     1013        return hrc;
    10061014    Utf8Str strAddress(bstrAddress);
    10071015    const char *pszAddress = strAddress.isEmpty() ? NULL : strAddress.c_str();
     
    10101018    hrc = pMachine->COMGETTER(TeleporterPassword)(bstrPassword.asOutParam());
    10111019    if (FAILED(hrc))
    1012         return VERR_GENERAL_FAILURE;
     1020        return hrc;
    10131021    Utf8Str strPassword(bstrPassword);
    10141022    strPassword.append('\n');           /* To simplify password checking. */
     
    10361044            {
    10371045                RTTcpServerDestroy(hServer);
    1038                 return VERR_GENERAL_FAILURE;
     1046                return hrc;
    10391047            }
    10401048        }
    10411049    }
    10421050    if (RT_FAILURE(vrc))
    1043         return vrc;
     1051        return setError(E_FAIL, tr("RTTcpServerCreateEx failed with status %Rrc"), vrc);
    10441052
    10451053    /*
     
    10601068            theState.mhServer          = hServer;
    10611069
    1062             bool fPowerOff = true;
    10631070            void *pvUser = static_cast<void *>(static_cast<TeleporterState *>(&theState));
    10641071            if (pProgress->setCancelCallback(teleporterProgressCancelCallback, pvUser))
     
    10761083                        /* Power off the VM on failure unless the state callback
    10771084                           already did that. */
    1078                         fPowerOff = false;
    1079                         if (RT_FAILURE(vrc))
     1085                        *pfPowerOffOnFailure = false;
     1086                        if (RT_SUCCESS(vrc))
     1087                            hrc = S_OK;
     1088                        else
    10801089                        {
    10811090                            VMSTATE enmVMState = VMR3GetState(pVM);
    10821091                            if (    enmVMState != VMSTATE_OFF
    10831092                                &&  enmVMState != VMSTATE_POWERING_OFF)
    1084                                 fPowerOff = true;
     1093                                *pfPowerOffOnFailure = true;
     1094
     1095                            /* Set error. */
     1096                            if (pErrorMsg->length())
     1097                                hrc = setError(E_FAIL, "%s", pErrorMsg->c_str());
     1098                            else
     1099                                hrc = setError(E_FAIL, tr("Teleporation failed (%Rrc)"), vrc);
    10851100                        }
    10861101                    }
     
    10901105                        hrc = pProgress->COMGETTER(Canceled)(&fCancelled);
    10911106                        if (FAILED(hrc) || fCancelled)
    1092                         {
    1093                             setError(E_FAIL, tr("Teleporting canceled"));
    1094                             vrc = VERR_SSM_CANCELLED;
    1095                         }
     1107                            hrc = setError(E_FAIL, tr("Teleporting canceled"));
    10961108                        else
    1097                         {
    1098                             setError(E_FAIL, tr("Teleporter timed out waiting for incoming connection"));
    1099                             vrc = VERR_TIMEOUT;
    1100                         }
     1109                            hrc = setError(E_FAIL, tr("Teleporter timed out waiting for incoming connection"));
    11011110                        LogRel(("Teleporter: RTTcpServerListen aborted - %Rrc\n", vrc));
    11021111                    }
    11031112                    else
    11041113                    {
     1114                        hrc = setError(E_FAIL, tr("Unexpected RTTcpServerListen status code %Rrc"), vrc);
    11051115                        LogRel(("Teleporter: Unexpected RTTcpServerListen rc: %Rrc\n", vrc));
    1106                         vrc = VERR_IPE_UNEXPECTED_STATUS;
    11071116                    }
    11081117                }
    11091118                else
    1110                 {
    11111119                    LogThisFunc(("SetNextOperation failed, %Rhrc\n", hrc));
    1112                     vrc = Global::vboxStatusCodeFromCOM(hrc);
    1113                 }
    11141120            }
    11151121            else
    11161122            {
    11171123                LogThisFunc(("Canceled - check point #1\n"));
    1118                 vrc = VERR_SSM_CANCELLED;
    1119             }
    1120 
    1121             if (fPowerOff)
    1122             {
    1123                 int vrc2 = VMR3PowerOff(pVM);
    1124                 AssertRC(vrc2);
    1125             }
    1126         }
     1124                hrc = setError(E_FAIL, tr("Teleporting canceled"));
     1125            }
     1126        }
     1127        else
     1128            hrc = setError(E_FAIL, "RTTimerLRStart -> %Rrc", vrc);
    11271129
    11281130        RTTimerLRDestroy(hTimerLR);
    11291131    }
     1132    else
     1133        hrc = setError(E_FAIL, "RTTimerLRCreate -> %Rrc", vrc);
    11301134    RTTcpServerDestroy(hServer);
    11311135
     
    11351139     */
    11361140    if (uPortOrg != uPort)
     1141    {
     1142        ErrorInfoKeeper Eik;
    11371143        pMachine->COMSETTER(TeleporterPort)(uPortOrg);
    1138 
    1139     return vrc;
     1144    }
     1145
     1146    return hrc;
    11401147}
    11411148
  • trunk/src/VBox/Main/include/ConsoleImpl.h

    r29580 r29957  
    573573    HRESULT                     teleporterSrcReadACK(TeleporterStateSrc *pState, const char *pszWhich, const char *pszNAckMsg = NULL);
    574574    HRESULT                     teleporterSrcSubmitCommand(TeleporterStateSrc *pState, const char *pszCommand, bool fWaitForAck = true);
    575     int                         teleporterTrg(PVM pVM, IMachine *pMachine, bool fStartPaused, Progress *pProgress);
     575    HRESULT                     teleporterTrg(PVM pVM, IMachine *pMachine, Utf8Str *pErrorMsg, bool fStartPaused,
     576                                              Progress *pProgress, bool *pfPowerOffOnFailure);
    576577    static DECLCALLBACK(int)    teleporterTrgServeConnection(RTSOCKET Sock, void *pvUser);
    577578    /** @} */
Note: See TracChangeset for help on using the changeset viewer.

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