Changeset 102614 in vbox for trunk/src/VBox/Main/src-client
- Timestamp:
- Dec 15, 2023 4:10:30 PM (12 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-client/GuestSessionImpl.cpp
r102533 r102614 221 221 * Initialize our data members from the input. 222 222 */ 223 mParent = pGuest; 223 mParent = pGuest; 224 mConsole = pGuest->i_getConsole(); 224 225 225 226 /* Copy over startup info. */ … … 1440 1441 alock.release(); 1441 1442 1442 Console *pConsole = mParent->i_getConsole(); 1443 AssertPtr(pConsole); 1444 1445 vrc = pDirectory->init(pConsole, this /* Parent */, idObject, openInfo); 1443 vrc = pDirectory->init(mConsole, this /* Parent */, idObject, openInfo); 1446 1444 if (RT_SUCCESS(vrc)) 1447 1445 vrc = pDirectory->i_open(pvrcGuest); … … 1923 1921 } 1924 1922 1925 Console *pConsole = mParent->i_getConsole(); 1926 AssertPtr(pConsole); 1927 1928 vrc = pFile->init(pConsole, this /* GuestSession */, idObject, openInfo); 1923 vrc = pFile->init(mConsole, this /* GuestSession */, idObject, openInfo); 1929 1924 if (RT_FAILURE(vrc)) 1930 1925 return vrc; … … 2308 2303 2309 2304 /** 2310 * Checks if this session is ready state where it can handle2305 * Checks if this session is in a ready state where it can handle 2311 2306 * all session-bound actions (like guest processes, guest files). 2312 * Only used by official API methods. Will set an external 2313 * error when not ready. 2307 * 2308 * Only used by official API methods. 2309 * Takes the read lock. 2310 * 2311 * @returns S_OK if ready, E_FAIL if not. 2312 * @note Will set an external error when not ready. 2314 2313 */ 2315 2314 HRESULT GuestSession::i_isStartedExternal(void) … … 2317 2316 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 2318 2317 2319 /** @todo Be a bit more informative. */2320 2318 if (!i_isStarted()) 2321 return setError(E_ UNEXPECTED, tr("Session is not in started state"));2322 2319 return setError(E_FAIL, tr("Session is not in started state (state is '%s')", 2320 Global::stringifyGuestSessionStatus(mData.mStatus))); 2323 2321 return S_OK; 2322 } 2323 2324 /** 2325 * Returns if this session is in a ready-to-use state or not. 2326 * 2327 * @returns \c true if ready, or \c false if not. 2328 */ 2329 bool GuestSession::i_isReady(void) 2330 { 2331 /* Check if the VM has the right machine state we can operate with. Also make sure that 2332 * the VM is in an online *and* non-transient state while at it. 2333 * 2334 * This for instance is required if we want to close a guest session while the VM state is being saved or 2335 * is doing some other lenghtly operations we can't operate with the guest. 2336 */ 2337 MachineState_T enmMachineState = MachineState_Null; 2338 HRESULT hrc = mConsole->COMGETTER(State)(&enmMachineState); 2339 ComAssertComRCRet(hrc, false); 2340 if ( !Global::IsOnline(enmMachineState) 2341 || Global::IsTransient(enmMachineState)) 2342 return false; 2343 2344 return true; 2324 2345 } 2325 2346 … … 3277 3298 } 3278 3299 3279 vrc = pProcess->init(m Parent->i_getConsole() /* Console */, this /* Session */, idObject, procInfo, mData.mpBaseEnvironment);3300 vrc = pProcess->init(mConsole, this /* Session */, idObject, procInfo, mData.mpBaseEnvironment); 3280 3301 if (RT_FAILURE(vrc)) 3281 3302 return vrc; … … 3363 3384 * 3364 3385 * @returns VBox status code. 3386 * @retval VERR_VM_INVALID_VM_STATE if the VM is in a state where can't send message to the guest (anymore). 3365 3387 * @param uMessage Message ID to send. 3366 3388 * @param uParms Number of parameters in \a paParms to send. … … 3374 3396 3375 3397 #ifndef VBOX_GUESTCTRL_TEST_CASE 3376 AutoCaller autoCallerParent(mParent); 3377 if (FAILED(autoCallerParent.hrc())) 3378 return VERR_STATE_CHANGED; 3379 3380 ComObjPtr<Console> pConsole = mParent->i_getConsole(); 3381 Assert(!pConsole.isNull()); 3398 VMMDev *pVMMDev = mConsole->i_getVMMDev(); 3399 AssertPtrReturn(pVMMDev, VERR_VM_INVALID_VM_STATE); 3382 3400 3383 3401 /* Forward the information to the VMM device. */ 3384 VMMDev *pVMMDev = pConsole->i_getVMMDev();3385 if (!pVMMDev)3386 return VERR_STATE_CHANGED;3387 3388 3402 LogFlowThisFunc(("uMessage=%RU32 (%s), uParms=%RU32\n", uMessage, GstCtrlHostMsgtoStr((guestControl::eHostMsg)uMessage), uParms)); 3389 3403 … … 3493 3507 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 3494 3508 3495 AssertPtrReturn(mParent, VERR_INVALID_POINTER);3496 3509 if (!(mParent->i_getGuestControlFeatures0() & VBOX_GUESTCTRL_GF_0_SHUTDOWN)) 3497 3510 return VERR_NOT_SUPPORTED; … … 3861 3874 LogFlowThisFuncEnter(); 3862 3875 3876 HRESULT hrc = i_isStartedExternal(); 3877 if (FAILED(hrc)) 3878 return hrc; 3879 3880 int vrc = VINF_SUCCESS; /* Shut up MSVC. */ 3881 3882 /* If the guest session is not in an unsable state (anymore), do the cleanup stuff ourselves. */ 3883 if (!i_isReady()) 3884 { 3885 i_onRemove(); 3886 return S_OK; 3887 } 3888 3863 3889 /* Note: Don't check if the session is ready via i_isStartedExternal() here; 3864 3890 * the session (already) could be in a stopped / aborted state. */ 3865 3891 3866 int vrc = VINF_SUCCESS; /* Shut up MSVC. */3867 3892 int vrcGuest = VINF_SUCCESS; 3868 3893 … … 3889 3914 /* We have to make sure that our parent (IGuest) still is alive and in a working shapee. 3890 3915 * If not, skip removing the session from it. */ 3891 AutoCaller autoCallerParent(mParent); 3892 if (SUCCEEDED(autoCallerParent.hrc())) 3893 { 3894 LogFlowThisFunc(("Removing session '%s' from parent ...", mData.mSession.mName.c_str())); 3895 3896 /* Remove ourselves from the session list. */ 3897 AssertPtr(mParent); 3898 int vrc2 = mParent->i_sessionRemove(mData.mSession.mID); 3899 if (vrc2 == VERR_NOT_FOUND) /* Not finding the session anymore isn't critical. */ 3900 vrc2 = VINF_SUCCESS; 3901 3902 if (RT_SUCCESS(vrc)) 3903 vrc = vrc2; 3904 } 3905 else /* Do the session remove stuff ourselves. */ 3906 vrc = i_onRemove(); 3916 LogFlowThisFunc(("Removing session '%s' from parent ...", mData.mSession.mName.c_str())); 3917 3918 /* Remove ourselves from the session list. */ 3919 int vrc2 = mParent->i_sessionRemove(mData.mSession.mID); 3920 if (vrc2 == VERR_NOT_FOUND) /* Not finding the session anymore isn't critical. */ 3921 vrc2 = VINF_SUCCESS; 3922 3923 if (RT_SUCCESS(vrc)) 3924 vrc = vrc2; 3907 3925 3908 3926 LogFlowThisFunc(("Returning vrc=%Rrc, vrcGuest=%Rrc\n", vrc, vrcGuest));
Note:
See TracChangeset
for help on using the changeset viewer.