Changeset 31070 in vbox
- Timestamp:
- Jul 23, 2010 4:00:09 PM (14 years ago)
- Location:
- trunk/src/VBox
- Files:
-
- 28 edited
-
Frontends/VBoxHeadless/VBoxHeadless.cpp (modified) (1 diff)
-
Frontends/VBoxHeadless/testcase/tstHeadless.cpp (modified) (1 diff)
-
Frontends/VBoxManage/VBoxManage.cpp (modified) (1 diff)
-
Frontends/VBoxManage/VBoxManageControlVM.cpp (modified) (1 diff)
-
Frontends/VBoxManage/VBoxManageGuestCtrl.cpp (modified) (1 diff)
-
Frontends/VBoxManage/VBoxManageGuestProp.cpp (modified) (1 diff)
-
Frontends/VBoxManage/VBoxManageInfo.cpp (modified) (1 diff)
-
Frontends/VBoxManage/VBoxManageMisc.cpp (modified) (8 diffs)
-
Frontends/VBoxManage/VBoxManageModifyVM.cpp (modified) (1 diff)
-
Frontends/VBoxManage/VBoxManageSnapshot.cpp (modified) (1 diff)
-
Frontends/VBoxManage/VBoxManageStorageController.cpp (modified) (3 diffs)
-
Frontends/VBoxManage/VBoxManageUSB.cpp (modified) (1 diff)
-
Frontends/VBoxSDL/VBoxSDL.cpp (modified) (1 diff)
-
Frontends/VirtualBox/src/VBoxMediaManagerDlg.cpp (modified) (1 diff)
-
Frontends/VirtualBox/src/runtime/UIMachine.cpp (modified) (1 diff)
-
Frontends/VirtualBox/src/selector/UIVMPreviewWindow.cpp (modified) (2 diffs)
-
Frontends/VirtualBox/src/selector/VBoxSelectorWnd.cpp (modified) (5 diffs)
-
Frontends/VirtualBox/src/selector/VBoxSnapshotsWgt.cpp (modified) (3 diffs)
-
Frontends/VirtualBox/src/wizards/newvm/UINewVMWzd.cpp (modified) (1 diff)
-
Main/ApplianceImplImport.cpp (modified) (5 diffs)
-
Main/MachineImpl.cpp (modified) (5 diffs)
-
Main/SessionImpl.cpp (modified) (7 diffs)
-
Main/cbinding/tstXPCOMCGlue.c (modified) (1 diff)
-
Main/glue/glue-java.xsl (modified) (6 diffs)
-
Main/idl/VirtualBox.xidl (modified) (8 diffs)
-
Main/include/SessionImpl.h (modified) (3 diffs)
-
Main/testcase/tstVBoxAPILinux.cpp (modified) (1 diff)
-
Main/testcase/tstVBoxAPIWin.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxHeadless/VBoxHeadless.cpp
r31023 r31070 1161 1161 */ 1162 1162 Log(("VBoxHeadless: Closing the session...\n")); 1163 session-> Close();1163 session->UnlockMachine(); 1164 1164 } 1165 1165 -
trunk/src/VBox/Frontends/VBoxHeadless/testcase/tstHeadless.cpp
r31019 r31070 201 201 } 202 202 203 RTPrintf ("Closing the session (may fail after power off)...\n");204 CHECK_ERROR (session, Close());203 RTPrintf("Closing the session (may fail after power off)...\n"); 204 CHECK_ERROR(session, UnlockMachine()); 205 205 } 206 206 while (0); -
trunk/src/VBox/Frontends/VBoxManage/VBoxManage.cpp
r28800 r31070 416 416 * Aborted which may have unwanted side effects like killing the saved 417 417 * state file (if the machine was in the Saved state before). */ 418 session-> Close();418 session->UnlockMachine(); 419 419 420 420 EventQueue::getMainEventQueue()->processEventQueue(0); -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageControlVM.cpp
r31019 r31070 881 881 } while (0); 882 882 883 a->session-> Close();883 a->session->UnlockMachine(); 884 884 885 885 return SUCCEEDED(rc) ? 0 : 1; -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageGuestCtrl.cpp
r31019 r31070 520 520 } 521 521 } 522 a->session-> Close();522 a->session->UnlockMachine(); 523 523 } while (0); 524 524 } -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageGuestProp.cpp
r31020 r31070 168 168 CHECK_ERROR(machine, SaveSettings()); 169 169 170 a->session-> Close();170 a->session->UnlockMachine(); 171 171 } 172 172 return SUCCEEDED(rc) ? 0 : 1; -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageInfo.cpp
r31019 r31070 2146 2146 2147 2147 if (console) 2148 a->session-> Close();2148 a->session->UnlockMachine(); 2149 2149 } 2150 2150 -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageMisc.cpp
r31019 r31070 393 393 394 394 /* it's important to always close sessions */ 395 a->session-> Close();395 a->session->UnlockMachine(); 396 396 397 397 return SUCCEEDED(rc) ? 0 : 1; … … 425 425 CHECK_ERROR_BREAK(console, ForgetSavedState(true)); 426 426 } while (0); 427 CHECK_ERROR_BREAK(a->session, Close());427 CHECK_ERROR_BREAK(a->session, UnlockMachine()); 428 428 } while (0); 429 429 } … … 459 459 CHECK_ERROR_BREAK(console, AdoptSavedState(Bstr(a->argv[1]))); 460 460 } while (0); 461 CHECK_ERROR_BREAK(a->session, Close());461 CHECK_ERROR_BREAK(a->session, UnlockMachine()); 462 462 } while (0); 463 463 } … … 735 735 fWritable, fAutoMount)); 736 736 if (console) 737 a->session-> Close();737 a->session->UnlockMachine(); 738 738 } 739 739 else … … 751 751 CHECK_ERROR(machine, SaveSettings()); 752 752 753 a->session-> Close();753 a->session->UnlockMachine(); 754 754 } 755 755 } … … 800 800 801 801 if (console) 802 a->session-> Close();802 a->session->UnlockMachine(); 803 803 } 804 804 else … … 814 814 /* commit and close the session */ 815 815 CHECK_ERROR(machine, SaveSettings()); 816 a->session-> Close();816 a->session->UnlockMachine(); 817 817 } 818 818 } … … 904 904 } 905 905 } 906 a->session-> Close();906 a->session->UnlockMachine(); 907 907 } 908 908 } -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageModifyVM.cpp
r31019 r31070 2048 2048 2049 2049 /* it's important to always close sessions */ 2050 a->session-> Close();2050 a->session->UnlockMachine(); 2051 2051 2052 2052 return SUCCEEDED(rc) ? 0 : 1; -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageSnapshot.cpp
r31019 r31070 499 499 } while (0); 500 500 501 a->session-> Close();501 a->session->UnlockMachine(); 502 502 503 503 return SUCCEEDED(rc) ? 0 : 1; -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageStorageController.cpp
r31019 r31070 636 636 leave: 637 637 /* it's important to always close sessions */ 638 a->session-> Close();638 a->session->UnlockMachine(); 639 639 640 640 return SUCCEEDED(rc) ? 0 : 1; … … 765 765 { 766 766 /* it's important to always close sessions */ 767 a->session-> Close();767 a->session->UnlockMachine(); 768 768 errorSyntax(USAGE_STORAGECONTROLLER, "Storage controller name not specified\n"); 769 769 return 1; … … 954 954 955 955 /* it's important to always close sessions */ 956 a->session-> Close();956 a->session->UnlockMachine(); 957 957 958 958 return SUCCEEDED(rc) ? 0 : 1; -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageUSB.cpp
r31019 r31070 562 562 } 563 563 /* close the session */ 564 a->session-> Close();564 a->session->UnlockMachine(); 565 565 } 566 566 -
trunk/src/VBox/Frontends/VBoxSDL/VBoxSDL.cpp
r31019 r31070 2747 2747 if (sessionOpened) 2748 2748 { 2749 rc = session-> Close();2749 rc = session->UnlockMachine(); 2750 2750 AssertComRC(rc); 2751 2751 } -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxMediaManagerDlg.cpp
r30677 r31070 1263 1263 /* If a new session was opened, we must close it */ 1264 1264 if (!session.isNull()) 1265 session. Close();1265 session.UnlockMachine(); 1266 1266 1267 1267 return success; -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.cpp
r30753 r31070 418 418 delete m_pActionsPool; 419 419 m_pActionsPool = 0; 420 m_session. Close();420 m_session.UnlockMachine(); 421 421 m_session.detach(); 422 422 QApplication::quit(); -
trunk/src/VBox/Frontends/VirtualBox/src/selector/UIVMPreviewWindow.cpp
r31056 r31070 90 90 /* Close any open session */ 91 91 if (m_session.GetState() == KSessionState_Locked) 92 m_session. Close();92 m_session.UnlockMachine(); 93 93 } 94 94 … … 363 363 /* Close any open session */ 364 364 if (m_session.GetState() == KSessionState_Locked) 365 m_session. Close();365 m_session.UnlockMachine(); 366 366 if (!m_machine.isNull()) 367 367 { -
trunk/src/VBox/Frontends/VirtualBox/src/selector/VBoxSelectorWnd.cpp
r31019 r31070 628 628 mVMListView->setFocus(); 629 629 630 session. Close();630 session.UnlockMachine(); 631 631 } 632 632 … … 672 672 else 673 673 ok = true; 674 session. Close();674 session.UnlockMachine(); 675 675 } 676 676 else … … 771 771 vboxProblem().cannotOpenSession(vbox, item->machine(), progress); 772 772 773 session. Close();773 session.UnlockMachine(); 774 774 } 775 775 … … 809 809 vboxProblem().cannotDiscardSavedState (console); 810 810 811 session. Close();811 session.UnlockMachine(); 812 812 } 813 813 … … 841 841 } 842 842 843 session. Close();843 session.UnlockMachine(); 844 844 } 845 845 -
trunk/src/VBox/Frontends/VirtualBox/src/selector/VBoxSnapshotsWgt.cpp
r31008 r31070 544 544 vboxProblem().cannotRestoreSnapshot (progress, snapshot.GetName()); 545 545 546 session. Close();546 session.UnlockMachine(); 547 547 } 548 548 … … 590 590 vboxProblem().cannotDeleteSnapshot (console, snapshot.GetName()); 591 591 592 session. Close();592 session.UnlockMachine(); 593 593 } 594 594 … … 661 661 vboxProblem().cannotTakeSnapshot (console); 662 662 663 session. Close();663 session.UnlockMachine(); 664 664 } 665 665 } -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UINewVMWzd.cpp
r30956 r31070 777 777 } 778 778 779 session. Close();779 session.UnlockMachine(); 780 780 } 781 781 if (!success) -
trunk/src/VBox/Main/ApplianceImplImport.cpp
r31019 r31070 1243 1243 rc2 = sMachine->SaveSettings(); 1244 1244 } 1245 stack.pSession-> Close();1245 stack.pSession->UnlockMachine(); 1246 1246 } 1247 1247 } … … 1850 1850 1851 1851 // only now that we're done with all disks, close the session 1852 rc = stack.pSession-> Close();1852 rc = stack.pSession->UnlockMachine(); 1853 1853 if (FAILED(rc)) DebugBreakThrow(rc); 1854 1854 stack.fSessionOpen = false; … … 1857 1857 { 1858 1858 if (stack.fSessionOpen) 1859 stack.pSession-> Close();1859 stack.pSession->UnlockMachine(); 1860 1860 1861 1861 throw; … … 1942 1942 1943 1943 // only now that we're done with all disks, close the session 1944 rc = stack.pSession-> Close();1944 rc = stack.pSession->UnlockMachine(); 1945 1945 if (FAILED(rc)) DebugBreakThrow(rc); 1946 1946 stack.fSessionOpen = false; … … 1949 1949 { 1950 1950 if (stack.fSessionOpen) 1951 stack.pSession-> Close();1951 stack.pSession->UnlockMachine(); 1952 1952 1953 1953 throw; -
trunk/src/VBox/Main/MachineImpl.cpp
r31063 r31070 2698 2698 tr("The given session is busy")); 2699 2699 2700 / * get the IInternalSessionControl interface */2700 // get the client's IInternalSessionControl interface 2701 2701 ComPtr<IInternalSessionControl> pSessionControl = aSession; 2702 2702 ComAssertMsgRet(!!pSessionControl, ("No IInternalSessionControl interface"), … … 2727 2727 2728 2728 // try again now 2729 if ( mData->mSession.mState == SessionState_Locked2730 || mData->mSession.mState == SessionState_Unlocking2729 if ( (mData->mSession.mState == SessionState_Locked) // machine is write-locked already (i.e. session machine exists) 2730 && (lockType == LockType_Shared) // caller wants a shared link to the existing session that holds the write lock: 2731 2731 ) 2732 2732 { 2733 // If the machine is write-locked already (i.e. SessionMachine exists) and2734 // caller permits sharing, then try to do that now2735 if ( (mData->mSession.mState == SessionState_Locked)2736 && (lockType == LockType_Shared)2737 ) 2738 {2739 ComAssertRet(!mData->mSession.mDirectControl.isNull(), E_FAIL);2740 2741 // copy member variables before leaving lock2742 ComPtr<IInternalSessionControl> pDirectControl = mData->mSession.mDirectControl;2743 ComObjPtr<SessionMachine> pSessionMachine = mData->mSession.mMachine; 2744 AssertReturn(!pSessionMachine.isNull(), E_FAIL);2745 2746 /*2747 * Leave the lock before calling the client process. It's safe here2748 * since the only thing to do after we get the lock again is to add2749 * the remote control to the list (which doesn't directly influence2750 * anything).2751 */ 2752 alock.leave();2753 2754 // get the console from the direct session (this is a remote call)2755 ComPtr<IConsole> pConsole;2756 LogFlowThisFunc(("Calling GetRemoteConsole()...\n"));2757 rc = pDirectControl->GetRemoteConsole(pConsole.asOutParam());2758 LogFlowThisFunc(("GetRemoteConsole() returned %08X\n", rc));2759 if (FAILED(rc))2760 /* The failure may occur w/o any error info (from RPC), so provide one */2761 return setError(VBOX_E_VM_ERROR, 2762 tr("Failed to get a console object from the direct session (%Rrc)"), rc);2763 2764 ComAssertRet(!pConsole.isNull(), E_FAIL);2765 2766 /* attach the remote session to the machine */2767 LogFlowThisFunc(("Calling AssignRemoteMachine()...\n"));2768 rc = pSessionControl->AssignRemoteMachine(pSessionMachine, pConsole); 2769 LogFlowThisFunc(("AssignRemoteMachine() returned %08X\n", rc));2770 2771 /* The failure may occur w/o any error info (from RPC), so provide one */2772 if (FAILED(rc))2773 return setError(VBOX_E_VM_ERROR,2774 tr("Failed to assign the machine to the session (%Rrc)"), 2775 rc);2776 alock.enter();2777 2778 /* need to revalidate the state after entering the lock again */2779 if (mData->mSession.mState != SessionState_Locked)2780 {2781 pSessionControl->Uninitialize();2782 return setError(VBOX_E_INVALID_SESSION_STATE,2783 tr("The machine '%ls' was unlocked unexpectedly while attempting to share its session"), 2784 mUserData->mName.raw());2785 }2786 2787 // add the caller's control to the list2788 mData->mSession.mRemoteControls.push_back(pSessionControl);2789 }2790 else2791 // still unlocking, or caller has not permitted sharing:2792 return setError(VBOX_E_INVALID_OBJECT_STATE,2793 tr("The machine '%ls' is already locked for a session (or being unlocked)"),2794 mUserData->mName.raw());2733 // OK, share the session... we are now dealing with three processes: 2734 // 1) VBoxSVC (where this code runs); 2735 // 2) process C: the caller's client process (who wants a shared session); 2736 // 3) process W: the process which already holds the write lock on the machine (write-locking session) 2737 2738 // copy pointers to W (the write-locking session) before leaving lock (these must not be NULL) 2739 ComPtr<IInternalSessionControl> pSessionW = mData->mSession.mDirectControl; 2740 ComAssertRet(!pSessionW.isNull(), E_FAIL); 2741 ComObjPtr<SessionMachine> pSessionMachine = mData->mSession.mMachine; 2742 AssertReturn(!pSessionMachine.isNull(), E_FAIL); 2743 2744 /* 2745 * Leave the lock before calling the client process. It's safe here 2746 * since the only thing to do after we get the lock again is to add 2747 * the remote control to the list (which doesn't directly influence 2748 * anything). 2749 */ 2750 alock.leave(); 2751 2752 // get the console of the session holding the write lock (this is a remote call) 2753 ComPtr<IConsole> pConsoleW; 2754 LogFlowThisFunc(("Calling GetRemoteConsole()...\n")); 2755 rc = pSessionW->GetRemoteConsole(pConsoleW.asOutParam()); 2756 LogFlowThisFunc(("GetRemoteConsole() returned %08X\n", rc)); 2757 if (FAILED(rc)) 2758 // the failure may occur w/o any error info (from RPC), so provide one 2759 return setError(VBOX_E_VM_ERROR, 2760 tr("Failed to get a console object from the direct session (%Rrc)"), rc); 2761 2762 ComAssertRet(!pConsoleW.isNull(), E_FAIL); 2763 2764 // share the session machine and W's console with the caller's session 2765 LogFlowThisFunc(("Calling AssignRemoteMachine()...\n")); 2766 rc = pSessionControl->AssignRemoteMachine(pSessionMachine, pConsoleW); 2767 LogFlowThisFunc(("AssignRemoteMachine() returned %08X\n", rc)); 2768 2769 if (FAILED(rc)) 2770 // the failure may occur w/o any error info (from RPC), so provide one 2771 return setError(VBOX_E_VM_ERROR, 2772 tr("Failed to assign the machine to the session (%Rrc)"), rc); 2773 alock.enter(); 2774 2775 // need to revalidate the state after entering the lock again 2776 if (mData->mSession.mState != SessionState_Locked) 2777 { 2778 pSessionControl->Uninitialize(); 2779 return setError(VBOX_E_INVALID_SESSION_STATE, 2780 tr("The machine '%ls' was unlocked unexpectedly while attempting to share its session"), 2781 mUserData->mName.raw()); 2782 } 2783 2784 // add the caller's session to the list 2785 mData->mSession.mRemoteControls.push_back(pSessionControl); 2786 } 2787 else if ( mData->mSession.mState == SessionState_Locked 2788 || mData->mSession.mState == SessionState_Unlocking 2789 ) 2790 { 2791 // sharing not permitted, or machine still unlocking: 2792 return setError(VBOX_E_INVALID_OBJECT_STATE, 2793 tr("The machine '%ls' is already locked for a session (or being unlocked)"), 2794 mUserData->mName.raw()); 2795 2795 } 2796 2796 else 2797 2797 { 2798 // no lock exists or sharing not permitted: then create the session machine2799 2800 / * may not be busy */2798 // machine is not locked: then write-lock the machine (create the session machine) 2799 2800 // must not be busy 2801 2801 AssertReturn(!Global::IsOnlineOrTransient(mData->mMachineState), E_FAIL); 2802 2802 … … 2807 2807 Assert(pid != NIL_RTPROCESS); 2808 2808 2809 if (mData->mSession.mState == SessionState_Spawning) 2810 { 2811 /* This machine is awaiting for a spawning session to be opened, so 2812 * reject any other open attempts from processes other than one 2813 * started by #openRemoteSession(). */ 2809 bool fLaunchingVMProcess = (mData->mSession.mState == SessionState_Spawning); 2810 2811 if (fLaunchingVMProcess) 2812 { 2813 // this machine is awaiting for a spawning session to be opened: 2814 // then the calling process must be the one that got started by 2815 // launchVMProcess() 2814 2816 2815 2817 LogFlowThisFunc(("mSession.mPid=%d(0x%x)\n", mData->mSession.mPid, mData->mSession.mPid)); … … 2867 2869 2868 2870 if ( SUCCEEDED(rc) 2869 && origState == SessionState_Spawning2871 && fLaunchingVMProcess 2870 2872 ) 2871 2873 { … … 2911 2913 } 2912 2914 2913 / * finalize spawning anyway (this is why we don't return on errors above) */2914 if ( mData->mSession.mState == SessionState_Spawning)2915 // finalize spawning anyway (this is why we don't return on errors above) 2916 if (fLaunchingVMProcess) 2915 2917 { 2916 2918 /* Note that the progress object is finalized later */ -
trunk/src/VBox/Main/SessionImpl.cpp
r31019 r31070 64 64 LogFlowThisFunc(("\n")); 65 65 66 uninit( true /* aFinalRelease */);66 uninit(); 67 67 } 68 68 … … 109 109 * @note Locks this object for writing. 110 110 */ 111 void Session::uninit( bool aFinalRelease)111 void Session::uninit() 112 112 { 113 113 LogFlowThisFuncEnter(); 114 LogFlowThisFunc(("aFinalRelease=%d\n", aFinalRelease));115 114 116 115 /* Enclose the state transition Ready->InUninit->NotReady */ … … 131 130 mState == SessionState_Spawning); 132 131 133 HRESULT rc = close(aFinalRelease, false /* aFromServer */);132 HRESULT rc = unlockMachine(true /* aFinalRelease */, false /* aFromServer */); 134 133 AssertComRC(rc); 135 134 } … … 233 232 ///////////////////////////////////////////////////////////////////////////// 234 233 235 STDMETHODIMP Session:: Close()234 STDMETHODIMP Session::UnlockMachine() 236 235 { 237 236 LogFlowThisFunc(("mState=%d, mType=%d\n", mState, mType)); … … 245 244 CHECK_OPEN(); 246 245 247 return close(false /* aFinalRelease */, false /* aFromServer */);246 return unlockMachine(false /* aFinalRelease */, false /* aFromServer */); 248 247 } 249 248 … … 491 490 492 491 /* close ourselves */ 493 rc = close(false /* aFinalRelease */, true /* aFromServer */);492 rc = unlockMachine(false /* aFinalRelease */, true /* aFromServer */); 494 493 } 495 494 else if (autoCaller.state() == InUninit) … … 793 792 794 793 /** 795 * Closesthe current session.794 * Unlocks a machine associated with the current session. 796 795 * 797 796 * @param aFinalRelease called as a result of FinalRelease() 798 797 * @param aFromServer called as a result of Uninitialize() 799 798 * 800 * @note To be called only from #uninit(), # Close() or #Uninitialize().799 * @note To be called only from #uninit(), #UnlockMachine() or #Uninitialize(). 801 800 * @note Locks this object for writing. 802 801 */ 803 HRESULT Session:: close(bool aFinalRelease, bool aFromServer)802 HRESULT Session::unlockMachine(bool aFinalRelease, bool aFromServer) 804 803 { 805 804 LogFlowThisFuncEnter(); -
trunk/src/VBox/Main/cbinding/tstXPCOMCGlue.c
r31008 r31070 365 365 366 366 listVMs(vbox, session); 367 session->vtbl-> Close(session);367 session->vtbl->UnlockMachine(session); 368 368 369 369 printf("----------------------------------------------------\n"); -
trunk/src/VBox/Main/glue/glue-java.xsl
r31019 r31070 2504 2504 { 2505 2505 if (s != null) 2506 s. close();2506 s.unlockMachine(); 2507 2507 } 2508 2508 … … 2569 2569 IProgress p = m.launchVMProcess(session, type, ""); 2570 2570 progressBar(p, timeout); 2571 session. close();2571 session.unlockMachine(); 2572 2572 return true; 2573 2573 } … … 3020 3020 { 3021 3021 if (s != null) 3022 s.close();3022 s.unlockMachine(); 3023 3023 } 3024 3024 … … 3068 3068 IProgress p = vbox.openRemoteSession(session, mid, type, ""); 3069 3069 progressBar(p, timeout); 3070 session. close();3070 session.unlockMachine(); 3071 3071 return true; 3072 3072 } … … 3466 3466 { 3467 3467 if (s != null) 3468 s. close();3468 s.unlockMachine(); 3469 3469 } 3470 3470 … … 3513 3513 IProgress p = m.launchVMProcess(session, type, ""); 3514 3514 progressBar(p, timeout); 3515 session. close();3515 session.unlockMachine(); 3516 3516 return true; 3517 3517 } -
trunk/src/VBox/Main/idl/VirtualBox.xidl
r31063 r31070 4259 4259 object which controls VM execution. 4260 4260 4261 Also in all of the above cases, one must always call <link to="ISession::close" />4262 to release the lock on the machine, or the machine's state will4263 eventually be set to "Aborted".4261 Also in all of the above cases, one must always call 4262 <link to="ISession::unlockMachine" /> to release the lock on the machine, or 4263 the machine's state will eventually be set to "Aborted". 4264 4264 4265 4265 To change settings on a machine, the following sequence is typically … … 4271 4271 <li>Obtain a mutable IMachine object from <link to="ISession::machine" />.</li> 4272 4272 4273 <li>Change the settings of the machine .</li>4273 <li>Change the settings of the machine by invoking IMachine methods.</li> 4274 4274 4275 4275 <li>Call <link to="IMachine::saveSettings" />.</li> 4276 4276 4277 <li> Close the session by calling <link to="ISession::close"/>.</li>4277 <li>Release the write lock by calling <link to="ISession::unlockMachine"/>.</li> 4278 4278 </ol> 4279 4279 … … 4307 4307 <method name="launchVMProcess"> 4308 4308 <desc> 4309 Spawns a new process that will execute the virtual machine. 4310 4311 This operation can take some time (a new VM is started in a new process, 4309 Spawns a new process that will execute the virtual machine and obtains a shared 4310 lock on the machine for the calling session. 4311 4312 If launching the VM succeeds, the new VM process will create its own session 4313 and write-lock the machine for it, preventing conflicting changes from other 4314 processes. If the machine is already locked (because it is already running or 4315 because another session has a write lock), launching the VM process will therefore 4316 fail. Reversely, future attempts to obtain a write lock will also fail while the 4317 machine is running. 4318 4319 The caller's session object remains separate from the session opened by the new 4320 VM process. It receives its own <link to="IConsole" /> object which can be used 4321 to control machine execution, but it cannot be used to change all VM settings 4322 which would be available after a <link to="#lockMachine" /> call. 4323 4324 The caller must eventually release the session's shared lock by calling 4325 <link to="ISession::unlockMachine" /> on the local session object once this call 4326 has returned. However, the session's state (see <link to="ISession::state" />) 4327 will not return to "Unlocked" until the remote session has also unlocked 4328 the machine (i.e. the machine has stopped running). 4329 4330 Lauching a VM process can take some time (a new VM is started in a new process, 4312 4331 for which memory and other resources need to be set up). Because of this, 4313 4332 an <link to="IProgress" /> object is returned to allow the caller to wait … … 4320 4339 via the progress object, if available. 4321 4340 4322 If launching the VM succeeds, the new VM process will create its own 4323 session and lock the machine for it, preventing conflicting changes 4324 from other processes. If the machine is already locked (because it 4325 is already running or because another session is making changes), 4326 launching the VM process will therefore fail. Reversely, future 4327 locking attempts will also fail while the machine is running. 4328 4329 The caller's session object remains separate from the session opened 4330 by the new VM process. It receives its own <link to="IConsole" /> 4331 object which can be used to control machine execution, but it cannot 4332 be used to change all VM settings which would be available after 4333 a <link to="#lockMachine" /> call. 4334 4335 As with all <link to="ISession" /> objects, it is recommended to call 4336 <link to="ISession::close" /> on the local session object once this call 4337 has returned. However, the session's state (see <link to="ISession::state" />) 4338 will not return to "Unlocked" until the remote session has also unlocked 4339 the machine. 4341 The progress object will have at least 2 sub-operations. The first 4342 operation covers the period up to the new VM process calls powerUp. 4343 The subsequent operations mirror the <link to="IConsole::powerUp"/> 4344 progress object. Because <link to="IConsole::powerUp"/> may require 4345 some extra sub-operations, the <link to="IProgress::operationCount"/> 4346 may change at the completion of operation. 4347 4348 For details on the teleportation progress operation, see 4349 <link to="IConsole::powerUp"/>. 4340 4350 4341 4351 The @a environment argument is a string containing definitions of … … 4354 4364 If the environment string is @c null or empty, the server environment 4355 4365 is inherited by the started process as is. 4356 4357 The progress object will have at least 2 sub-operations. The first4358 operation covers the period up to the new VM process calls powerUp.4359 The subsequent operations mirror the <link to="IConsole::powerUp"/>4360 progress object. Because <link to="IConsole::powerUp"/> may require4361 some extra sub-operations, the <link to="IProgress::operationCount"/>4362 may change at the completion of operation.4363 4364 For details on the teleportation progress operation, see4365 <link to="IConsole::powerUp"/>.4366 4366 4367 4367 <result name="E_UNEXPECTED"> … … 12771 12771 > 12772 12772 <desc> 12773 The ISession interface represents a serialization primitive for virtual 12774 machines. Any caller wishing to manipulate a virtual machine (represented 12775 by an IMachine object) needs to create a session object first, which lives 12776 in its own process space. Such session objects are then attached to the 12777 <link to="IMachine" /> objects living in the VirtualBox server process to 12778 coordinate possibly conflicting changes. 12773 The ISession interface represents a client process and allows for locking 12774 virtual machines (represented by IMachine objects) to prevent conflicting 12775 changes to the machine. 12776 12777 Any caller wishing to manipulate a virtual machine needs to create a session 12778 object first, which lives in its own process space. Such session objects are 12779 then associated with <link to="IMachine" /> objects living in the VirtualBox 12780 server process to coordinate such changes. 12779 12781 12780 12782 There are two typical scenarios in which sessions are used: 12781 12783 12782 12784 <ul> 12783 <li>To alter machine settings, one needs to lock a machine for a given session 12784 (client process) by calling <link to="IMachine::lockMachine"/>. While a 12785 machine is thus locked, no any other process may lock the machine again. 12786 12787 The same applies for any process which indends to actually run a virtual 12788 machine in its own context, such as the VirtualBox GUI or VBoxHeadless 12789 executables. They must also lock a machine for their own sessions before 12790 being allowed to power up the virtual machine. 12791 12792 As a result, no machine can be altered while another process is already 12793 using it, either because that process is modifying machine settings or 12794 because the machine is running. 12785 <li>To alter machine settings or control a running virtual machine, one 12786 needs to lock a machine for a given session (client process) by calling 12787 <link to="IMachine::lockMachine"/>. 12788 12789 Whereas multiple sessions may control a running virtual machine, only 12790 one process can obtain a write lock on the machine to prevent conflicting 12791 changes. A write lock is also needed if a process wants to actually run a 12792 virtual machine in its own context, such as the VirtualBox GUI or 12793 VBoxHeadless front-ends. They must also lock a machine for their own 12794 sessions before they are allowed to power up the virtual machine. 12795 12796 As a result, no machine settings can be altered while another process is 12797 already using it, either because that process is modifying machine settings 12798 or because the machine is running. 12795 12799 </li> 12796 12800 <li> 12797 To initiate virtual machine execution using one of the existing VirtualBox 12798 front-ends (e.g. the GUI or VBoxHeadless), one would instead call 12799 <link to="IMachine::launchVMProcess"/>, which also requires a session 12800 object as its first parameter. This session then identifies the caller 12801 and lets the caller control the started machine (for example, pause machine 12802 execution or power it down) as well as be notified about machine execution 12803 state changes. 12801 To start a VM using one of the existing VirtualBox front-ends (e.g. the 12802 VirtualBox GUI or VBoxHeadless), one would use 12803 <link to="IMachine::launchVMProcess"/>, which also takes a session object 12804 as its first parameter. This session then identifies the caller and lets the 12805 caller control the started machine (for example, pause machine execution or 12806 power it down) as well as be notified about machine execution state changes. 12804 12807 </li> 12805 12808 </ul> 12806 12809 12807 How sessions objects are used depends on whether you use the Main API12808 via COM or via the webservice:12810 How sessions objects are created in a client process depends on whether you use 12811 the Main API via COM or via the webservice: 12809 12812 12810 12813 <ul> … … 12844 12847 </attribute> 12845 12848 12846 <method name=" close">12847 <desc> 12848 Closes a session that was previously opened.12849 12850 Calling this method is eventually required every time a machine has been12851 lockedfor a particular session using the <link to="IMachine::launchVMProcess" />12852 or <link to="IMachine::lockMachine" /> )calls. Otherwise the state of12849 <method name="unlockMachine"> 12850 <desc> 12851 Unlocks a machine that was previously locked for the current session. 12852 12853 Calling this method is required every time a machine has been locked 12854 for a particular session using the <link to="IMachine::launchVMProcess" /> 12855 or <link to="IMachine::lockMachine" /> calls. Otherwise the state of 12853 12856 the machine will be set to <link to="MachineState_Aborted" /> on the 12854 12857 server, and changes made to the machine settings will be lost. 12855 12858 12856 Generally, it is recommended to close all open sessions explicitly12859 Generally, it is recommended to unlock all machines explicitly 12857 12860 before terminating the application (regardless of the reason for 12858 12861 the termination). … … 12860 12863 <note> 12861 12864 Do not expect the session state (<link to="ISession::state" /> 12862 to return to "Closed" immediately after you invoke 12863 ISession::close(), particularly if you have started a remote 12864 session to execute the VM in a new process. The session state will 12865 automatically return to "Closed" once the VM is no longer executing, 12866 which can of course take a very long time. 12865 to return to "Unlocked" immediately after you invoke this method, 12866 particularly if you have started a new VM process. The session 12867 state will automatically return to "Unlocked" once the VM is no 12868 longer executing, which can of course take a very long time. 12867 12869 </note> 12868 12870 12869 12871 <result name="E_UNEXPECTED"> 12870 Session is not open.12872 Session is not locked. 12871 12873 </result> 12872 12874 -
trunk/src/VBox/Main/include/SessionImpl.h
r30764 r31070 66 66 // public initializers/uninitializers only for internal purposes 67 67 HRESULT init(); 68 void uninit( bool aFinalRelease);68 void uninit(); 69 69 70 70 // ISession properties … … 75 75 76 76 // ISession methods 77 STDMETHOD( Close)();77 STDMETHOD(UnlockMachine)(); 78 78 79 79 // IInternalSessionControl methods … … 112 112 private: 113 113 114 HRESULT close(bool aFinalRelease, bool aFromServer);114 HRESULT unlockMachine(bool aFinalRelease, bool aFromServer); 115 115 HRESULT grabIPCSemaphore(); 116 116 void releaseIPCSemaphore(); -
trunk/src/VBox/Main/testcase/tstVBoxAPILinux.cpp
r31019 r31070 406 406 * necessary any more. 407 407 */ 408 session-> Close();408 session->UnlockMachine(); 409 409 } 410 410 -
trunk/src/VBox/Main/testcase/tstVBoxAPIWin.cpp
r31008 r31070 238 238 239 239 /* Close the session. */ 240 rc = session-> Close();240 rc = session->UnlockMachine(); 241 241 242 242 } while (0);
Note:
See TracChangeset
for help on using the changeset viewer.

