Index: trunk/src/VBox/Main/idl/VirtualBox.xidl
===================================================================
--- trunk/src/VBox/Main/idl/VirtualBox.xidl	(revision 44970)
+++ trunk/src/VBox/Main/idl/VirtualBox.xidl	(revision 45010)
@@ -8969,5 +8969,6 @@
     >
     <desc>
-      Guest session statuses.
+      Guest session status. This enumeration represents possible values of
+      the <link to="IGuestSession::status"/> attribute.
     </desc>
     <const name="Undefined"               value="0">
@@ -9000,4 +9001,73 @@
   </enum>
 
+  <enum
+    name="GuestSessionWaitForFlag"
+    uuid="bb7a372a-f635-4e11-a81a-e707f3a52ef5"
+    >
+    <desc>
+      Guest session waiting flags. Multiple flags can be combined.
+    </desc>
+
+    <const name="None"                    value="0">
+      <desc>No waiting flags specified. Do not use this.</desc>
+    </const>
+    <const name="Start"                   value="1">
+      <desc>Wait for the guest session being started.</desc>
+    </const>
+    <const name="Terminate"               value="2">
+      <desc>Wait for the guest session being terminated.</desc>
+    </const>
+    <const name="Status"                  value="4">
+      <desc>Wait for the next guest session status change.</desc>
+    </const>
+  </enum>
+  
+  <enum
+    name="GuestSessionWaitResult"
+    uuid="c0f6a8a5-fdb6-42bf-a582-56c6f82bcd2d"
+    >
+    <desc>
+      Guest session waiting results. Depending on the session waiting flags (for
+      more information see <link to="GuestSessionWaitForFlag"/>) the waiting result
+      can vary based on the session's current status.
+
+      To wait for a guest session to terminate after it has been
+      created by <link to="IGuest::createSession"/> one would specify 
+      GuestSessionWaitResult_Terminate.
+    </desc>
+
+    <const name="None"                    value="0">
+      <desc>No result was returned. Not being used.</desc>
+    </const>
+    <const name="Start"                   value="1">
+      <desc>The guest session has been started.</desc>
+    </const>
+    <const name="Terminate"               value="2">
+      <desc>The guest session has been terminated.</desc>
+    </const>
+    <const name="Status"                  value="3">
+      <desc>
+        The guest session has changed its status. The status then can
+        be retrieved via <link to="IGuestSession::status"/>.
+      </desc>
+    </const>
+    <const name="Error"                   value="4">
+      <desc>Error while executing the process.</desc>
+    </const>
+    <const name="Timeout"                 value="5">
+      <desc>
+        The waiting operation timed out. This also will happen
+        when no event has been occured matching the
+        current waiting flags in a <link to="IGuestSession::waitFor"/> call.
+      </desc>
+    </const>
+    <const name="WaitFlagNotSupported"    value="6">
+      <desc>
+        A waiting flag specified in the <link to="IGuestSession::waitFor"/> call
+        is not supported by the guest.
+      </desc>
+    </const>
+  </enum>
+  
   <enum
     name="FileSeekType"
@@ -9084,5 +9154,5 @@
       can vary based on the processes' current status.
 
-      To wait for a gust process to terminate after it has been
+      To wait for a guest process to terminate after it has been
       created by <link to="IGuestSession::processCreate"/> or <link to="IGuestSession::processCreateEx"/>
       one would specify ProcessWaitResult_Terminate.
@@ -9425,5 +9495,5 @@
   <interface
     name="IGuestSession" extends="$unknown"
-    uuid="8490516f-9c2c-49e9-b283-35f3ce463f69"
+    uuid="56f551a2-f924-43ab-8a69-a954109db878"
     wsmap="managed"
     >
@@ -10225,4 +10295,53 @@
       <param name="file" type="wstring" dir="in">
         <desc>Symbolic link to remove.</desc>
+      </param>
+    </method>
+    
+    <method name="waitFor">
+      <desc>
+        Waits for one more events to happen.
+      </desc>
+      <param name="waitFor" type="unsigned long" dir="in">
+        <desc>
+          Specifies what to wait for;
+          see <link to="GuestSessionWaitForFlag"/> for more information.
+        </desc>
+      </param>
+      <param name="timeoutMS" type="unsigned long" dir="in">
+        <desc>
+          Timeout (in ms) to wait for the operation to complete.
+          Pass 0 for an infinite timeout.
+        </desc>
+      </param>
+      <param name="reason" type="GuestSessionWaitResult" dir="return">
+        <desc>
+          The overall wait result;
+          see <link to="GuestSessionWaitResult"/> for more information.
+        </desc>
+      </param>
+    </method>
+
+    <method name="waitForArray">
+      <desc>
+        Waits for one more events to happen.
+        Scriptable version of <link to="#waitFor" />.
+      </desc>
+      <param name="waitFor" type="GuestSessionWaitForFlag" dir="in" safearray="yes">
+        <desc>
+          Specifies what to wait for;
+          see <link to="GuestSessionWaitForFlag"/> for more information.
+        </desc>
+      </param>
+      <param name="timeoutMS" type="unsigned long" dir="in">
+        <desc>
+          Timeout (in ms) to wait for the operation to complete.
+          Pass 0 for an infinite timeout.
+        </desc>
+      </param>
+      <param name="reason" type="GuestSessionWaitResult" dir="return">
+        <desc>
+          The overall wait result;
+          see <link to="GuestSessionWaitResult"/> for more information.
+        </desc>
       </param>
     </method>
Index: trunk/src/VBox/Main/include/GuestCtrlImplPrivate.h
===================================================================
--- trunk/src/VBox/Main/include/GuestCtrlImplPrivate.h	(revision 44970)
+++ trunk/src/VBox/Main/include/GuestCtrlImplPrivate.h	(revision 45010)
@@ -205,4 +205,42 @@
     /** Structure containing the overall result. */
     ProcessWaitResult_T         mResult;
+};
+
+
+/*
+ * Class representing a guest control session waiting
+ * event.
+ */
+class GuestSessionWaitEvent : public GuestCtrlEvent
+{
+public:
+
+    GuestSessionWaitEvent(void);
+
+    GuestSessionWaitEvent(uint32_t uWaitFlags);
+
+    virtual ~GuestSessionWaitEvent(void);
+
+public:
+
+    void Destroy(void);
+
+    int Init(uint32_t uWaitFlags);
+
+    uint32_t GetWaitFlags(void) { return ASMAtomicReadU32(&mFlags); }
+
+    GuestSessionWaitResult_T GetWaitResult(void) { return mResult; }
+
+    int GetWaitRc(void) { return mRC; }
+
+    int Signal(GuestSessionWaitResult_T enmResult, int rc = VINF_SUCCESS);
+
+protected:
+
+    /** The waiting flag(s). The specifies what to
+     *  wait for. See GuestSessionWaitFlag_T. */
+    uint32_t                    mFlags;
+    /** Structure containing the overall result. */
+    GuestSessionWaitResult_T    mResult;
 };
 
Index: trunk/src/VBox/Main/include/GuestProcessImpl.h
===================================================================
--- trunk/src/VBox/Main/include/GuestProcessImpl.h	(revision 44970)
+++ trunk/src/VBox/Main/include/GuestProcessImpl.h	(revision 45010)
@@ -113,7 +113,7 @@
         /** The current process status. */
         ProcessStatus_T          mStatus;
+        /** The last returned process status
+         *  returned from the guest side. */
         int                      mRC;
-        /** The mutex for protecting the waiter(s). */
-        RTSEMMUTEX               mWaitMutex;
         /** How many waiters? At the moment there can only
          *  be one. */
Index: trunk/src/VBox/Main/include/GuestSessionImpl.h
===================================================================
--- trunk/src/VBox/Main/include/GuestSessionImpl.h	(revision 44970)
+++ trunk/src/VBox/Main/include/GuestSessionImpl.h	(revision 45010)
@@ -311,4 +311,6 @@
     STDMETHOD(SymlinkRemoveDirectory)(IN_BSTR aPath);
     STDMETHOD(SymlinkRemoveFile)(IN_BSTR aFile);
+    STDMETHOD(WaitFor)(ULONG aWaitFlags, ULONG aTimeoutMS, GuestSessionWaitResult_T *aReason);
+    STDMETHOD(WaitForArray)(ComSafeArrayIn(GuestSessionWaitForFlag_T, aFlags), ULONG aTimeoutMS, GuestSessionWaitResult_T *aReason);
     /** @}  */
 
@@ -347,8 +349,8 @@
     static Utf8Str          guestErrorToString(int guestRc);
     int                     onSessionStatusChange(PVBOXGUESTCTRLHOSTCBCTX pCbCtx, GuestCtrlCallback *pCallback, PVBOXGUESTCTRLHOSTCALLBACK pSvcCbData);
-    int                     openSession(int *pGuestRc);
-    int                     openSessionAsync(void);
+    int                     startSessionIntenal(int *pGuestRc);
+    int                     startSessionAsync(void);
     static DECLCALLBACK(int)
-                            openSessionThread(RTTHREAD Thread, void *pvUser);
+                            startSessionThread(RTTHREAD Thread, void *pvUser);
     Guest                  *getParent(void) { return mData.mParent; }
     uint32_t                getProtocolVersion(void) { return mData.mProtocolVersion; }
@@ -361,4 +363,5 @@
     int                     startTaskAsync(const Utf8Str &strTaskDesc, GuestSessionTask *pTask, ComObjPtr<Progress> &pProgress);
     int                     queryInfo(void);
+    int                     waitFor(uint32_t fWaitFlags, ULONG uTimeoutMS, GuestSessionWaitResult_T &waitResult, int *pGuestRc);
     /** @}  */
 
@@ -396,4 +399,13 @@
          *  files, ...). */
         uint32_t                    mNumObjects;
+        /** The last returned session status
+         *  returned from the guest side. */
+        int                         mRC;
+        /** How many waiters? At the moment there can only
+         *  be one. */
+        uint32_t                    mWaitCount;
+        /** The actual session event for doing the waits.
+         *  At the moment we only support one wait a time. */
+        GuestSessionWaitEvent      *mWaitEvent;
     } mData;
 };
Index: trunk/src/VBox/Main/src-client/GuestCtrlImpl.cpp
===================================================================
--- trunk/src/VBox/Main/src-client/GuestCtrlImpl.cpp	(revision 44970)
+++ trunk/src/VBox/Main/src-client/GuestCtrlImpl.cpp	(revision 45010)
@@ -174,5 +174,5 @@
         Assert(!pSession.isNull());
         int guestRc;
-        rc = pSession->openSession(&guestRc);
+        rc = pSession->startSessionIntenal(&guestRc);
         if (RT_FAILURE(rc))
         {
@@ -467,6 +467,6 @@
          *        the new session.getStatus() API call! */
 
-        /* Open (fork) the session on the guest. */
-        rc = pSession->openSession(&guestRc);
+        /* Start (fork) the session on the guest. */
+        rc = pSession->startSessionIntenal(&guestRc);
         if (RT_SUCCESS(rc))
         {
Index: trunk/src/VBox/Main/src-client/GuestCtrlPrivate.cpp
===================================================================
--- trunk/src/VBox/Main/src-client/GuestCtrlPrivate.cpp	(revision 44970)
+++ trunk/src/VBox/Main/src-client/GuestCtrlPrivate.cpp	(revision 45010)
@@ -437,4 +437,38 @@
 
 int GuestProcessWaitEvent::Signal(ProcessWaitResult_T enmResult, int rc /*= VINF_SUCCESS*/)
+{
+    mResult = enmResult;
+
+    return GuestCtrlEvent::Signal(rc);
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+GuestSessionWaitEvent::GuestSessionWaitEvent(void)
+    : mFlags(0),
+      mResult(GuestSessionWaitResult_None)
+{
+}
+
+GuestSessionWaitEvent::GuestSessionWaitEvent(uint32_t uWaitFlags)
+    : mFlags(uWaitFlags)
+{
+    int rc = GuestCtrlEvent::Init();
+    AssertRC(rc);
+}
+
+GuestSessionWaitEvent::~GuestSessionWaitEvent(void)
+{
+    Destroy();
+}
+
+void GuestSessionWaitEvent::Destroy(void)
+{
+    GuestCtrlEvent::Destroy();
+
+    mFlags = GuestSessionWaitForFlag_None;
+}
+
+int GuestSessionWaitEvent::Signal(GuestSessionWaitResult_T enmResult, int rc /*= VINF_SUCCESS*/)
 {
     mResult = enmResult;
Index: trunk/src/VBox/Main/src-client/GuestProcessImpl.cpp
===================================================================
--- trunk/src/VBox/Main/src-client/GuestProcessImpl.cpp	(revision 44970)
+++ trunk/src/VBox/Main/src-client/GuestProcessImpl.cpp	(revision 45010)
@@ -963,5 +963,4 @@
                      mData.mStatus, procStatus, procRc));
 
-#if 0
     if (procStatus == ProcessStatus_Error)
     {
@@ -973,5 +972,4 @@
     else
         AssertMsg(RT_SUCCESS(procRc), ("Guest rc must not be an error (%Rrc)\n", procRc));
-#endif
 
     mData.mStatus = procStatus;
@@ -1160,4 +1158,11 @@
             {
                 int guestRc = pCallbackStart->GetResultCode();
+                if (RT_SUCCESS(guestRc))
+                {
+                    /* Nothing to do here right now. */
+                }
+                else
+                    vrc = VERR_GENERAL_FAILURE; /** @todo Special guest control rc needed! */
+
                 if (pGuestRc)
                     *pGuestRc = guestRc;
Index: trunk/src/VBox/Main/src-client/GuestSessionImpl.cpp
===================================================================
--- trunk/src/VBox/Main/src-client/GuestSessionImpl.cpp	(revision 44970)
+++ trunk/src/VBox/Main/src-client/GuestSessionImpl.cpp	(revision 45010)
@@ -88,4 +88,11 @@
 {
     LogFlowThisFunc(("\n"));
+
+    mData.mRC = VINF_SUCCESS;
+    mData.mStatus = GuestSessionStatus_Undefined;
+
+    mData.mWaitCount = 0;
+    mData.mWaitEvent = NULL;
+
     return BaseFinalConstruct();
 }
@@ -1123,12 +1130,24 @@
             break;
 
-        case GUEST_SESSION_NOTIFYTYPE_OPEN:
-            if (RT_FAILURE(guestRc))
-                mData.mStatus = GuestSessionStatus_Started;
+        case GUEST_SESSION_NOTIFYTYPE_STARTED:
+            mData.mStatus = GuestSessionStatus_Started;
             break;
 
-        case GUEST_SESSION_NOTIFYTYPE_CLOSE:
-            if (RT_FAILURE(guestRc))
-                mData.mStatus = GuestSessionStatus_Terminated;
+        case GUEST_SESSION_NOTIFYTYPE_TEN:
+        case GUEST_SESSION_NOTIFYTYPE_TES:
+        case GUEST_SESSION_NOTIFYTYPE_TEA:
+            mData.mStatus = GuestSessionStatus_Terminated;
+            break;
+
+        case GUEST_SESSION_NOTIFYTYPE_TOK:
+            mData.mStatus = GuestSessionStatus_TimedOutKilled;
+            break;
+
+        case GUEST_SESSION_NOTIFYTYPE_TOA:
+            mData.mStatus = GuestSessionStatus_TimedOutAbnormally;
+            break;
+
+        case GUEST_SESSION_NOTIFYTYPE_DWN:
+            mData.mStatus = GuestSessionStatus_Down;
             break;
 
@@ -1167,5 +1186,5 @@
 }
 
-int GuestSession::openSession(int *pGuestRc)
+int GuestSession::startSessionIntenal(int *pGuestRc)
 {
     AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
@@ -1251,5 +1270,5 @@
 }
 
-int GuestSession::openSessionAsync(void)
+int GuestSession::startSessionAsync(void)
 {
     LogFlowThisFuncEnter();
@@ -1264,8 +1283,8 @@
         AssertReturn(pTask->isOk(), pTask->rc());
 
-        vrc = RTThreadCreate(NULL, GuestSession::openSessionThread,
+        vrc = RTThreadCreate(NULL, GuestSession::startSessionThread,
                              (void *)pTask.get(), 0,
                              RTTHREADTYPE_MAIN_WORKER, 0,
-                             "gctlSesOpen");
+                             "gctlSesStart");
         if (RT_SUCCESS(vrc))
         {
@@ -1284,5 +1303,5 @@
 
 /* static */
-DECLCALLBACK(int) GuestSession::openSessionThread(RTTHREAD Thread, void *pvUser)
+DECLCALLBACK(int) GuestSession::startSessionThread(RTTHREAD Thread, void *pvUser)
 {
     LogFlowFunc(("pvUser=%p\n", pvUser));
@@ -1297,5 +1316,5 @@
     if (FAILED(autoCaller.rc())) return autoCaller.rc();
 
-    int vrc = pSession->openSession(NULL /* Guest rc, ignored */);
+    int vrc = pSession->startSessionIntenal(NULL /* Guest rc, ignored */);
     /* Nothing to do here anymore. */
 
@@ -1603,4 +1622,152 @@
 }
 
+int GuestSession::waitFor(uint32_t fWaitFlags, ULONG uTimeoutMS, GuestSessionWaitResult_T &waitResult, int *pGuestRc)
+{
+    LogFlowThisFuncEnter();
+
+    AssertReturn(fWaitFlags, VERR_INVALID_PARAMETER);
+
+    LogFlowThisFunc(("fWaitFlags=0x%x, uTimeoutMS=%RU32, mStatus=%RU32, mWaitCount=%RU32, mWaitEvent=%p, pGuestRc=%p\n",
+                     fWaitFlags, uTimeoutMS, mData.mStatus, mData.mWaitCount, mData.mWaitEvent, pGuestRc));
+
+    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
+
+    /* Did some error occur before? Then skip waiting and return. */
+    if (mData.mStatus == GuestSessionStatus_Error)
+    {
+        waitResult = GuestSessionWaitResult_Error;
+        AssertMsg(RT_FAILURE(mData.mRC), ("No error rc (%Rrc) set when guest session indicated an error\n", mData.mRC));
+        if (pGuestRc)
+            *pGuestRc = mData.mRC; /* Return last set error. */
+        return VERR_GENERAL_FAILURE; /** @todo Special guest control rc needed! */
+    }
+
+    waitResult = GuestSessionWaitResult_None;
+    if (fWaitFlags & GuestSessionWaitForFlag_Terminate)
+    {
+        switch (mData.mStatus)
+        {
+            case GuestSessionStatus_Terminated:
+            case GuestSessionStatus_Down:
+                waitResult = GuestSessionWaitResult_Terminate;
+                break;
+
+            case GuestSessionStatus_TimedOutKilled:
+            case GuestSessionStatus_TimedOutAbnormally:
+                waitResult = GuestSessionWaitResult_Timeout;
+                break;
+
+            case GuestSessionStatus_Error:
+                /* Handled above. */
+                break;
+
+            case GuestSessionStatus_Started:
+                waitResult = GuestSessionWaitResult_Start;
+                break;
+
+            case GuestSessionStatus_Undefined:
+            case GuestSessionStatus_Starting:
+                /* Do the waiting below. */
+                break;
+
+            default:
+                AssertMsgFailed(("Unhandled session status %ld\n", mData.mStatus));
+                return VERR_NOT_IMPLEMENTED;
+        }
+    }
+    else if (fWaitFlags & GuestSessionWaitForFlag_Start)
+    {
+        switch (mData.mStatus)
+        {
+            case GuestSessionStatus_Started:
+            case GuestSessionStatus_Terminating:
+            case GuestSessionStatus_Terminated:
+            case GuestSessionStatus_Down:
+                waitResult = GuestSessionWaitResult_Start;
+                break;
+
+            case GuestSessionStatus_Error:
+                waitResult = GuestSessionWaitResult_Error;
+                break;
+
+            case GuestSessionStatus_TimedOutKilled:
+            case GuestSessionStatus_TimedOutAbnormally:
+                waitResult = GuestSessionWaitResult_Timeout;
+                break;
+
+            case GuestSessionStatus_Undefined:
+            case GuestSessionStatus_Starting:
+                /* Do the waiting below. */
+                break;
+
+            default:
+                AssertMsgFailed(("Unhandled session status %ld\n", mData.mStatus));
+                return VERR_NOT_IMPLEMENTED;
+        }
+    }
+
+    LogFlowThisFunc(("sessionStatus=%ld, sessionRc=%Rrc, waitResult=%ld\n",
+                     mData.mStatus, mData.mRC, waitResult));
+
+    /* No waiting needed? Return immediately using the last set error. */
+    if (waitResult != GuestSessionWaitResult_None)
+    {
+        if (pGuestRc)
+            *pGuestRc = mData.mRC; /* Return last set error (if any). */
+        return RT_SUCCESS(mData.mRC) ? VINF_SUCCESS : VERR_GENERAL_FAILURE; /** @todo Special guest control rc needed! */
+    }
+
+    if (mData.mWaitCount > 0) /* We only support one waiting caller a time at the moment. */
+        return VERR_ALREADY_EXISTS;
+    mData.mWaitCount++;
+
+    int vrc = VINF_SUCCESS;
+    try
+    {
+        Assert(mData.mWaitEvent == NULL);
+        mData.mWaitEvent = new GuestSessionWaitEvent(fWaitFlags);
+    }
+    catch(std::bad_alloc &)
+    {
+        vrc = VERR_NO_MEMORY;
+    }
+
+    if (RT_SUCCESS(vrc))
+    {
+        GuestSessionWaitEvent *pEvent = mData.mWaitEvent;
+        AssertPtr(pEvent);
+
+        alock.release(); /* Release lock before waiting. */
+
+        vrc = pEvent->Wait(uTimeoutMS);
+        LogFlowThisFunc(("Waiting completed with rc=%Rrc\n", vrc));
+        if (RT_SUCCESS(vrc))
+        {
+            waitResult = pEvent->GetWaitResult();
+            int waitRc = pEvent->GetWaitRc();
+
+            LogFlowThisFunc(("Waiting event returned rc=%Rrc\n", waitRc));
+
+            if (pGuestRc)
+                *pGuestRc = waitRc;
+
+            vrc = RT_SUCCESS(waitRc) ? VINF_SUCCESS : VERR_GENERAL_FAILURE; /** @todo Special guest control rc needed! */
+        }
+
+        alock.acquire(); /* Get the lock again. */
+
+        /* Note: The caller always is responsible of deleting the
+         *       stuff it created before. See close() for more information. */
+        delete mData.mWaitEvent;
+        mData.mWaitEvent = NULL;
+    }
+
+    Assert(mData.mWaitCount);
+    mData.mWaitCount--;
+
+    LogFlowFuncLeaveRC(vrc);
+    return vrc;
+}
+
 // implementation of public methods
 /////////////////////////////////////////////////////////////////////////////
@@ -2664,2 +2831,77 @@
 }
 
+STDMETHODIMP GuestSession::WaitFor(ULONG aWaitFlags, ULONG aTimeoutMS, GuestSessionWaitResult_T *aReason)
+{
+#ifndef VBOX_WITH_GUEST_CONTROL
+    ReturnComNotImplemented();
+#else
+    LogFlowThisFuncEnter();
+
+    CheckComArgOutPointerValid(aReason);
+
+    AutoCaller autoCaller(this);
+    if (FAILED(autoCaller.rc())) return autoCaller.rc();
+
+    /*
+     * Note: Do not hold any locks here while waiting!
+     */
+    HRESULT hr = S_OK;
+
+    int guestRc; GuestSessionWaitResult_T waitResult;
+    int vrc = waitFor(aWaitFlags, aTimeoutMS, waitResult, &guestRc);
+    if (RT_SUCCESS(vrc))
+    {
+        *aReason = waitResult;
+    }
+    else
+    {
+        switch (vrc)
+        {
+            case VERR_GENERAL_FAILURE: /** @todo Special guest control rc needed! */
+                hr = GuestSession::setErrorExternal(this, guestRc);
+                break;
+
+            case VERR_TIMEOUT:
+                *aReason = GuestSessionWaitResult_Timeout;
+                break;
+
+            default:
+            {
+                const char *pszSessionName = mData.mSession.mName.c_str();
+                hr = setError(VBOX_E_IPRT_ERROR,
+                              tr("Waiting for guest session \"%s\" failed: %Rrc"),
+                                 pszSessionName ? pszSessionName : tr("Unnamed"), vrc);
+                break;
+            }
+        }
+    }
+
+    LogFlowFuncLeaveRC(vrc);
+    return hr;
+#endif /* VBOX_WITH_GUEST_CONTROL */
+}
+
+STDMETHODIMP GuestSession::WaitForArray(ComSafeArrayIn(GuestSessionWaitForFlag_T, aFlags), ULONG aTimeoutMS, GuestSessionWaitResult_T *aReason)
+{
+#ifndef VBOX_WITH_GUEST_CONTROL
+    ReturnComNotImplemented();
+#else
+    LogFlowThisFuncEnter();
+
+    CheckComArgOutPointerValid(aReason);
+
+    AutoCaller autoCaller(this);
+    if (FAILED(autoCaller.rc())) return autoCaller.rc();
+
+    /*
+     * Note: Do not hold any locks here while waiting!
+     */
+    uint32_t fWaitFor = GuestSessionWaitForFlag_None;
+    com::SafeArray<GuestSessionWaitForFlag_T> flags(ComSafeArrayInArg(aFlags));
+    for (size_t i = 0; i < flags.size(); i++)
+        fWaitFor |= flags[i];
+
+    return WaitFor(fWaitFor, aTimeoutMS, aReason);
+#endif /* VBOX_WITH_GUEST_CONTROL */
+}
+
Index: trunk/src/VBox/Main/src-client/GuestSessionImplTasks.cpp
===================================================================
--- trunk/src/VBox/Main/src-client/GuestSessionImplTasks.cpp	(revision 44970)
+++ trunk/src/VBox/Main/src-client/GuestSessionImplTasks.cpp	(revision 45010)
@@ -186,5 +186,5 @@
     if (FAILED(autoCaller.rc())) return autoCaller.rc();
 
-    int vrc = pSession->openSession(pGuestRc);
+    int vrc = pSession->startSessionIntenal(pGuestRc);
     /* Nothing to do here anymore. */
 
