Index: /trunk/src/VBox/Frontends/VBoxHeadless/VBoxHeadless.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VBoxHeadless/VBoxHeadless.cpp	(revision 31007)
+++ /trunk/src/VBox/Frontends/VBoxHeadless/VBoxHeadless.cpp	(revision 31008)
@@ -803,8 +803,9 @@
         }
 
+        ComPtr<IMachine> m;
+
         /* find ID by name */
         if (id.isEmpty())
         {
-            ComPtr <IMachine> m;
             rc = virtualBox->FindMachine(Bstr(name), m.asOutParam());
             if (FAILED(rc))
@@ -823,16 +824,16 @@
 
         // open a session
-        CHECK_ERROR_BREAK(virtualBox, OpenSession(session, id));
+        CHECK_ERROR_BREAK(m, LockForSession(session, false /* fPermitShared */, NULL));
         fSessionOpened = true;
 
         /* get the console */
-        ComPtr <IConsole> console;
+        ComPtr<IConsole> console;
         CHECK_ERROR_BREAK(session, COMGETTER(Console)(console.asOutParam()));
 
-        /* get the machine */
-        ComPtr <IMachine> machine;
+        /* get the mutable machine */
+        ComPtr<IMachine> machine;
         CHECK_ERROR_BREAK(console, COMGETTER(Machine)(machine.asOutParam()));
 
-        ComPtr <IDisplay> display;
+        ComPtr<IDisplay> display;
         CHECK_ERROR_BREAK(console, COMGETTER(Display)(display.asOutParam()));
 
Index: /trunk/src/VBox/Frontends/VBoxHeadless/testcase/tstHeadless.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VBoxHeadless/testcase/tstHeadless.cpp	(revision 31007)
+++ /trunk/src/VBox/Frontends/VBoxHeadless/testcase/tstHeadless.cpp	(revision 31008)
@@ -112,19 +112,16 @@
         EventQueue eventQ;
 
+        ComPtr <IMachine> m;
+
         // find ID by name
-        Bstr id;
-        {
-            ComPtr <IMachine> m;
-            CHECK_ERROR_BREAK (virtualBox, FindMachine (Bstr (name), m.asOutParam()));
-            CHECK_ERROR_BREAK (m, COMGETTER(Id) (id.asOutParam()));
-        }
-
-        if (!strcmp (operation, "on"))
+        CHECK_ERROR_BREAK(virtualBox, FindMachine(Bstr(name), m.asOutParam()));
+
+        if (!strcmp(operation, "on"))
         {
             ComPtr <IProgress> progress;
             RTPrintf ("Opening a new (remote) session...\n");
-            CHECK_ERROR_BREAK (virtualBox,
-                               OpenRemoteSession (session, id, Bstr ("vrdp"),
-                                                  NULL, progress.asOutParam()));
+            CHECK_ERROR_BREAK (m,
+                               LaunchVMProcess(session, Bstr("vrdp"),
+                                               NULL, progress.asOutParam()));
 
             RTPrintf ("Waiting for the remote session to open...\n");
@@ -153,8 +150,8 @@
         {
             RTPrintf ("Opening an existing session...\n");
-            CHECK_ERROR_BREAK (virtualBox, OpenExistingSession (session, id));
+            CHECK_ERROR_BREAK(m, LockForSession(session, true /* fPermitShared */, NULL));
 
             ComPtr <IConsole> console;
-            CHECK_ERROR_BREAK (session, COMGETTER (Console) (console.asOutParam()));
+            CHECK_ERROR_BREAK(session, COMGETTER(Console)(console.asOutParam()));
 
             if (!strcmp (operation, "off"))
Index: /trunk/src/VBox/Frontends/VBoxManage/VBoxInternalManage.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VBoxManage/VBoxInternalManage.cpp	(revision 31007)
+++ /trunk/src/VBox/Frontends/VBoxManage/VBoxInternalManage.cpp	(revision 31008)
@@ -1864,7 +1864,5 @@
         CHECK_ERROR_RET(aVirtualBox, FindMachine(Bstr(argv[0]), ptrMachine.asOutParam()), 1);
 
-    Bstr bstrMachineUuid;
-    CHECK_ERROR_RET(ptrMachine, COMGETTER(Id)(bstrMachineUuid.asOutParam()), 1);
-    CHECK_ERROR_RET(aVirtualBox, OpenExistingSession(aSession, bstrMachineUuid), 1);
+    CHECK_ERROR_RET(ptrMachine, LockForSession(aSession, true /* fPermitShared */, NULL), 1);
 
     /*
Index: /trunk/src/VBox/Frontends/VBoxManage/VBoxManageControlVM.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VBoxManage/VBoxManageControlVM.cpp	(revision 31007)
+++ /trunk/src/VBox/Frontends/VBoxManage/VBoxManageControlVM.cpp	(revision 31008)
@@ -73,5 +73,5 @@
     /* try to find the given machine */
     ComPtr <IMachine> machine;
-    Bstr machineuuid (a->argv[0]);
+    Bstr machineuuid(a->argv[0]);
     if (!Guid(machineuuid).isEmpty())
     {
@@ -88,5 +88,5 @@
 
     /* open a session for the VM */
-    CHECK_ERROR_RET(a->virtualBox, OpenExistingSession(a->session, machineuuid), 1);
+    CHECK_ERROR_RET(machine, LockForSession(a->session, true /* fPermitShared */, NULL), 1);
 
     do
Index: /trunk/src/VBox/Frontends/VBoxManage/VBoxManageGuestCtrl.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VBoxManage/VBoxManageGuestCtrl.cpp	(revision 31007)
+++ /trunk/src/VBox/Frontends/VBoxManage/VBoxManageGuestCtrl.cpp	(revision 31008)
@@ -285,9 +285,7 @@
         do
         {
-            Bstr uuid;
-            machine->COMGETTER(Id)(uuid.asOutParam());
-
-            /* open an existing session for VM - so the VM has to be running */
-            CHECK_ERROR_BREAK(a->virtualBox, OpenExistingSession(a->session, uuid));
+            /* open an existing session for VM */
+            CHECK_ERROR_BREAK(machine, LockForSession(a->session, true /* fPermitShared */, NULL));
+            // @todo r=dj assert that it's an existing session
 
             /* get the mutable session machine */
Index: /trunk/src/VBox/Frontends/VBoxManage/VBoxManageGuestProp.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VBoxManage/VBoxManageGuestProp.cpp	(revision 31007)
+++ /trunk/src/VBox/Frontends/VBoxManage/VBoxManageGuestProp.cpp	(revision 31008)
@@ -87,10 +87,6 @@
     if (machine)
     {
-        Bstr uuid;
-        machine->COMGETTER(Id)(uuid.asOutParam());
-
         /* open a session for the VM - new or existing */
-        if (FAILED (a->virtualBox->OpenSession(a->session, uuid)))
-            CHECK_ERROR_RET(a->virtualBox, OpenExistingSession(a->session, uuid), 1);
+        CHECK_ERROR_RET(machine, LockForSession(a->session, true /* fPermitShared */, NULL), 1);
 
         /* get the mutable session machine */
@@ -156,10 +152,6 @@
     if (machine)
     {
-        Bstr uuid;
-        machine->COMGETTER(Id)(uuid.asOutParam());
-
         /* open a session for the VM - new or existing */
-        if (FAILED (a->virtualBox->OpenSession(a->session, uuid)))
-            CHECK_ERROR_RET (a->virtualBox, OpenExistingSession(a->session, uuid), 1);
+        CHECK_ERROR_RET(machine, LockForSession(a->session, true /* fPermitShared */, NULL), 1);
 
         /* get the mutable session machine */
@@ -220,18 +212,14 @@
     if (machine)
     {
-        Bstr uuid;
-        machine->COMGETTER(Id)(uuid.asOutParam());
-
         /* open a session for the VM - new or existing */
-        if (FAILED(a->virtualBox->OpenSession(a->session, uuid)))
-            CHECK_ERROR_RET (a->virtualBox, OpenExistingSession(a->session, uuid), 1);
+        CHECK_ERROR_RET(machine, LockForSession(a->session, true /* fPermitShared */, NULL), 1);
 
         /* get the mutable session machine */
         a->session->COMGETTER(Machine)(machine.asOutParam());
 
-        com::SafeArray <BSTR> names;
-        com::SafeArray <BSTR> values;
-        com::SafeArray <ULONG64> timestamps;
-        com::SafeArray <BSTR> flags;
+        com::SafeArray<BSTR> names;
+        com::SafeArray<BSTR> values;
+        com::SafeArray<ULONG64> timestamps;
+        com::SafeArray<BSTR> flags;
         CHECK_ERROR(machine, EnumerateGuestProperties(Bstr(Utf8Patterns),
                                                       ComSafeArrayAsOutParam(names),
Index: /trunk/src/VBox/Frontends/VBoxManage/VBoxManageInfo.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VBoxManage/VBoxManageInfo.cpp	(revision 31007)
+++ /trunk/src/VBox/Frontends/VBoxManage/VBoxManageInfo.cpp	(revision 31008)
@@ -2132,8 +2132,8 @@
             details = VMINFO_STANDARD;
 
-        ComPtr <IConsole> console;
+        ComPtr<IConsole> console;
 
         /* open an existing session for the VM */
-        rc = a->virtualBox->OpenExistingSession(a->session, uuid);
+        rc = machine->LockForSession(a->session, true /* fPermitShared */, NULL);
         if (SUCCEEDED(rc))
             /* get the session machine */
Index: /trunk/src/VBox/Frontends/VBoxManage/VBoxManageMisc.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VBoxManage/VBoxManageMisc.cpp	(revision 31007)
+++ /trunk/src/VBox/Frontends/VBoxManage/VBoxManageMisc.cpp	(revision 31008)
@@ -356,8 +356,4 @@
     if (machine)
     {
-        Bstr uuid;
-        machine->COMGETTER(Id)(uuid.asOutParam());
-
-
         Bstr env;
 #if defined(RT_OS_LINUX) || defined(RT_OS_SOLARIS)
@@ -373,6 +369,5 @@
 #endif
         ComPtr<IProgress> progress;
-        CHECK_ERROR_RET(a->virtualBox, OpenRemoteSession(a->session, uuid, sessionType,
-                                                         env, progress.asOutParam()), rc);
+        CHECK_ERROR_RET(machine, LaunchVMProcess(a->session, sessionType, env, progress.asOutParam()), rc);
         RTPrintf("Waiting for the VM to power on...\n");
         CHECK_ERROR_RET(progress, WaitForCompletion(-1), 1);
@@ -423,7 +418,5 @@
         {
             /* we have to open a session for this task */
-            Bstr guid;
-            machine->COMGETTER(Id)(guid.asOutParam());
-            CHECK_ERROR_BREAK(a->virtualBox, OpenSession(a->session, guid));
+            CHECK_ERROR_BREAK(machine, LockForSession(a->session, false /* fPermitShared */, NULL));
             do
             {
@@ -459,7 +452,5 @@
         {
             /* we have to open a session for this task */
-            Bstr guid;
-            machine->COMGETTER(Id)(guid.asOutParam());
-            CHECK_ERROR_BREAK(a->virtualBox, OpenSession(a->session, guid));
+            CHECK_ERROR_BREAK(machine, LockForSession(a->session, false /* fPermitShared */, NULL));
             do
             {
@@ -671,6 +662,4 @@
     if (!machine)
         return 1;
-    Bstr uuid;
-    machine->COMGETTER(Id)(uuid.asOutParam());
 
     if (!strcmp(a->argv[0], "add"))
@@ -737,5 +726,5 @@
 
             /* open an existing session for the VM */
-            CHECK_ERROR_RET(a->virtualBox, OpenExistingSession(a->session, uuid), 1);
+            CHECK_ERROR_RET(machine, LockForSession(a->session, true /* fPermitShared */, NULL), 1);
             /* get the session machine */
             CHECK_ERROR_RET(a->session, COMGETTER(Machine)(machine.asOutParam()), 1);
@@ -751,5 +740,5 @@
         {
             /* open a session for the VM */
-            CHECK_ERROR_RET(a->virtualBox, OpenSession(a->session, uuid), 1);
+            CHECK_ERROR_RET(machine, LockForSession(a->session, false /* fPermitShared */, NULL), 1);
 
             /* get the mutable session machine */
@@ -801,5 +790,5 @@
 
             /* open an existing session for the VM */
-            CHECK_ERROR_RET(a->virtualBox, OpenExistingSession(a->session, uuid), 1);
+            CHECK_ERROR_RET(machine, LockForSession(a->session, true /* fPermitShared */, NULL), 1);
             /* get the session machine */
             CHECK_ERROR_RET(a->session, COMGETTER(Machine)(machine.asOutParam()), 1);
@@ -815,5 +804,5 @@
         {
             /* open a session for the VM */
-            CHECK_ERROR_RET(a->virtualBox, OpenSession(a->session, uuid), 1);
+            CHECK_ERROR_RET(machine, LockForSession(a->session, false /* fPermitShared */, NULL), 1);
 
             /* get the mutable session machine */
@@ -842,12 +831,12 @@
 
     /* try to find the given machine */
-    ComPtr <IMachine> machine;
-    Bstr uuid (a->argv[0]);
-    if (!Guid (a->argv[0]).isEmpty())
+    ComPtr<IMachine> machine;
+    Bstr uuid(a->argv[0]);
+    if (!Guid(a->argv[0]).isEmpty())
         CHECK_ERROR(a->virtualBox, GetMachine(uuid, machine.asOutParam()));
     else
     {
         CHECK_ERROR(a->virtualBox, FindMachine(Bstr(a->argv[0]), machine.asOutParam()));
-        if (SUCCEEDED (rc))
+        if (SUCCEEDED(rc))
             machine->COMGETTER(Id)(uuid.asOutParam());
     }
@@ -885,5 +874,5 @@
 
     /* open an existing session for the VM. */
-    CHECK_ERROR(a->virtualBox, OpenExistingSession(a->session, uuid));
+    CHECK_ERROR(machine, LockForSession(a->session, true /* fPermitShared */, NULL));
     if (SUCCEEDED(rc))
     {
Index: /trunk/src/VBox/Frontends/VBoxManage/VBoxManageModifyVM.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VBoxManage/VBoxManageModifyVM.cpp	(revision 31007)
+++ /trunk/src/VBox/Frontends/VBoxManage/VBoxManageModifyVM.cpp	(revision 31008)
@@ -275,5 +275,5 @@
     HRESULT rc;
     Bstr name;
-    Bstr machineuuid (a->argv[0]);
+    Bstr machineuuid(a->argv[0]);
     RTGETOPTUNION ValueUnion;
     RTGETOPTSTATE GetOptState;
@@ -312,5 +312,5 @@
 
     /* open a session for the VM */
-    CHECK_ERROR_RET(a->virtualBox, OpenSession(a->session, machineuuid), 1);
+    CHECK_ERROR_RET(machine, LockForSession(a->session, false /* fPermitShared */, NULL), 1);
 
     /* get the mutable session machine */
Index: /trunk/src/VBox/Frontends/VBoxManage/VBoxManageSnapshot.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VBoxManage/VBoxManageSnapshot.cpp	(revision 31007)
+++ /trunk/src/VBox/Frontends/VBoxManage/VBoxManageSnapshot.cpp	(revision 31008)
@@ -236,13 +236,9 @@
     if (!pMachine)
         return 1;
-    Bstr guidMachine;
-    pMachine->COMGETTER(Id)(guidMachine.asOutParam());
 
     do
     {
-        /* we have to open a session for this task. First try an existing session */
-        rc = a->virtualBox->OpenExistingSession(a->session, guidMachine);
-        if (FAILED(rc))
-            CHECK_ERROR_BREAK(a->virtualBox, OpenSession(a->session, guidMachine));
+        /* we have to open a session for this task (new or shared) */
+        rc = pMachine->LockForSession(a->session, true /* fPermitShared */, NULL);
         ComPtr<IConsole> console;
         CHECK_ERROR_BREAK(a->session, COMGETTER(Console)(console.asOutParam()));
Index: /trunk/src/VBox/Frontends/VBoxManage/VBoxManageStorageController.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VBoxManage/VBoxManageStorageController.cpp	(revision 31007)
+++ /trunk/src/VBox/Frontends/VBoxManage/VBoxManageStorageController.cpp	(revision 31008)
@@ -60,5 +60,4 @@
     ULONG port   = ~0U;
     ULONG device = ~0U;
-    bool fRunTime = false;
     bool fForceUnmount = false;
     const char *pszCtl  = NULL;
@@ -148,5 +147,5 @@
         }
     }
-    
+
     if (FAILED(rc))
         return 1;
@@ -173,13 +172,8 @@
     }
 
-    /* open a session for the VM */
-    rc = a->virtualBox->OpenSession(a->session, machineuuid);
-    if (FAILED(rc))
-    {
-        /* try to open an existing session for the VM */
-        CHECK_ERROR_RET(a->virtualBox, OpenExistingSession(a->session, machineuuid), 1);
-        fRunTime = true;
-    }
-
+    /* open a session for the VM (new or shared) */
+    SessionType_T type;
+    rc = machine->LockForSession(a->session, true /* fPermitShared */, &type);
+    bool fRunTime = (type == SessionType_Shared);
     if (fRunTime && !RTStrICmp(pszType, "hdd"))
     {
@@ -761,5 +755,5 @@
 
     /* open a session for the VM */
-    CHECK_ERROR_RET(a->virtualBox, OpenSession (a->session, machineuuid), 1);
+    CHECK_ERROR_RET(machine, LockForSession(a->session, false /* fPermitShared */, NULL), 1);
 
     /* get the mutable session machine */
Index: /trunk/src/VBox/Frontends/VBoxManage/VBoxManageUSB.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VBoxManage/VBoxManageUSB.cpp	(revision 31007)
+++ /trunk/src/VBox/Frontends/VBoxManage/VBoxManageUSB.cpp	(revision 31008)
@@ -416,12 +416,10 @@
     else
     {
-        Bstr uuid;
-        cmd.mMachine->COMGETTER(Id)(uuid.asOutParam());
         /* open a session for the VM */
-        CHECK_ERROR_RET (a->virtualBox, OpenSession(a->session, uuid), 1);
+        CHECK_ERROR_RET(cmd.mMachine, LockForSession(a->session, false /* fPermitShared */, NULL), 1);
         /* get the mutable session machine */
         a->session->COMGETTER(Machine)(cmd.mMachine.asOutParam());
         /* and get the USB controller */
-        CHECK_ERROR_RET (cmd.mMachine, COMGETTER(USBController) (ctl.asOutParam()), 1);
+        CHECK_ERROR_RET(cmd.mMachine, COMGETTER(USBController)(ctl.asOutParam()), 1);
     }
 
Index: /trunk/src/VBox/Frontends/VBoxSDL/VBoxSDL.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VBoxSDL/VBoxSDL.cpp	(revision 31007)
+++ /trunk/src/VBox/Frontends/VBoxSDL/VBoxSDL.cpp	(revision 31008)
@@ -1316,4 +1316,6 @@
     const CLSID sessionID = CLSID_Session;
 
+    ComPtr<IMachine> pMachine;
+
     rc = virtualBox.createLocalObject(CLSID_VirtualBox);
     if (FAILED(rc))
@@ -1339,11 +1341,10 @@
     if (vmName && uuidVM.isEmpty())
     {
-        ComPtr<IMachine> aMachine;
         Bstr  bstrVMName = vmName;
-        rc = virtualBox->FindMachine(bstrVMName, aMachine.asOutParam());
-        if ((rc == S_OK) && aMachine)
+        rc = virtualBox->FindMachine(bstrVMName, pMachine.asOutParam());
+        if ((rc == S_OK) && pMachine)
         {
             Bstr id;
-            aMachine->COMGETTER(Id)(id.asOutParam());
+            pMachine->COMGETTER(Id)(id.asOutParam());
             uuidVM = Guid(id);
         }
@@ -1364,5 +1365,5 @@
     AssertReleaseRC(vrc);
 
-    rc = virtualBox->OpenSession(session, uuidVM.toUtf16());
+    rc = pMachine->LockForSession(session, false /* fPermitShared */, NULL);
     if (FAILED(rc))
     {
@@ -1379,5 +1380,5 @@
     }
     sessionOpened = true;
-    // get the VM we're dealing with
+    // get the mutable VM we're dealing with
     session->COMGETTER(Machine)(gMachine.asOutParam());
     if (!gMachine)
Index: /trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp	(revision 31007)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp	(revision 31008)
@@ -2166,8 +2166,8 @@
  *                      session.
  */
-CSession VBoxGlobal::openSession (const QString &aId, bool aExisting /* = false */)
+CSession VBoxGlobal::openSession(const QString &aId, bool aExisting /* = false */)
 {
     CSession session;
-    session.createInstance (CLSID_Session);
+    session.createInstance(CLSID_Session);
     if (session.isNull())
     {
@@ -2176,21 +2176,22 @@
     }
 
-    if (aExisting)
-        mVBox.OpenExistingSession (session, aId);
-    else
-    {
-        mVBox.OpenSession (session, aId);
-        CMachine machine = session.GetMachine ();
-        /* Make sure that the language is in two letter code.
-         * Note: if languageId() returns an empty string lang.name() will
-         * return "C" which is an valid language code. */
-        QLocale lang (VBoxGlobal::languageId());
-        machine.SetGuestPropertyValue ("/VirtualBox/HostInfo/GUI/LanguageID", lang.name());
+    CMachine foundMachine = CVirtualBox(mVBox).GetMachine(aId);
+    if (!foundMachine.isNull())
+    {
+        KSessionType t = foundMachine.LockForSession(session, aExisting /* fPermitShared */);
+        if (t == KSessionType_Shared)
+        {
+            CMachine machine = session.GetMachine();
+            /* Make sure that the language is in two letter code.
+             * Note: if languageId() returns an empty string lang.name() will
+             * return "C" which is an valid language code. */
+            QLocale lang(VBoxGlobal::languageId());
+            machine.SetGuestPropertyValue ("/VirtualBox/HostInfo/GUI/LanguageID", lang.name());
+        }
     }
 
     if (!mVBox.isOk())
     {
-        CMachine machine = CVirtualBox (mVBox).GetMachine (aId);
-        vboxProblem().cannotOpenSession (mVBox, machine);
+        vboxProblem().cannotOpenSession(mVBox, foundMachine);
         session.detach();
     }
@@ -2667,8 +2668,8 @@
     mMachineStates [KMachineState_SettingUp] =  tr ("Setting Up", "MachineState");
 
-    mSessionStates [KSessionState_Closed] =     tr ("Closed", "SessionState");
-    mSessionStates [KSessionState_Open] =       tr ("Open", "SessionState");
+    mSessionStates [KSessionState_Unlocked] =   tr ("Unlocked", "SessionState");
+    mSessionStates [KSessionState_Locked] =     tr ("Locked", "SessionState");
     mSessionStates [KSessionState_Spawning] =   tr ("Spawning", "SessionState");
-    mSessionStates [KSessionState_Closing] =    tr ("Closing", "SessionState");
+    mSessionStates [KSessionState_Unlocking] =  tr ("Unlocking", "SessionState");
 
     mDeviceTypes [KDeviceType_Null] =           tr ("None", "DeviceType");
Index: /trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.h
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.h	(revision 31007)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.h	(revision 31008)
@@ -510,8 +510,8 @@
 #endif
 
-    CSession openSession (const QString &aId, bool aExisting = false);
+    CSession openSession(const QString &aId, bool aExisting = false);
 
     /** Shortcut to openSession (aId, true). */
-    CSession openExistingSession (const QString &aId) { return openSession (aId, true); }
+    CSession openExistingSession(const QString &aId) { return openSession (aId, true); }
 
     bool startMachine(const QString &strId);
Index: /trunk/src/VBox/Frontends/VirtualBox/src/selector/UIVMDesktop.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/selector/UIVMDesktop.cpp	(revision 31007)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/selector/UIVMDesktop.cpp	(revision 31008)
@@ -933,5 +933,5 @@
     {
         KMachineState state = m_machine.GetState();
-        bool running = m_machine.GetSessionState() != KSessionState_Closed;
+        bool running = m_machine.GetSessionState() != KSessionState_Unlocked;
         m_fChangeable = !running && state != KMachineState_Saved;
     }
@@ -1253,5 +1253,5 @@
     {
         bool saved = m_pVMItem->state() == KMachineState_Saved;
-        bool busy = m_pVMItem->sessionState() != KSessionState_Closed;
+        bool busy = m_pVMItem->sessionState() != KSessionState_Unlocked;
         m_pEditBtn->setEnabled(!saved && !busy);
     }
Index: /trunk/src/VBox/Frontends/VirtualBox/src/selector/UIVMListView.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/selector/UIVMListView.cpp	(revision 31007)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/selector/UIVMListView.cpp	(revision 31008)
@@ -215,5 +215,5 @@
             QFont f = qApp->font();
             f.setPointSize(f.pointSize());
-            if (m_VMItemList.at(aIndex.row())->sessionState() != KSessionState_Closed)
+            if (m_VMItemList.at(aIndex.row())->sessionState() != KSessionState_Unlocked)
                 f.setItalic(true);
             v = f;
Index: /trunk/src/VBox/Frontends/VirtualBox/src/selector/UIVMPreviewWindow.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/selector/UIVMPreviewWindow.cpp	(revision 31007)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/selector/UIVMPreviewWindow.cpp	(revision 31008)
@@ -245,5 +245,5 @@
                 {
                     CVirtualBox vbox = vboxGlobal().virtualBox();
-                    vbox.OpenExistingSession(session, m_machine.GetId());
+                    m_machine.LockForSession(session, true /* fPermitShared */);
                     if (vbox.isOk())
                     {
Index: /trunk/src/VBox/Frontends/VirtualBox/src/selector/VBoxSelectorWnd.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/selector/VBoxSelectorWnd.cpp	(revision 31007)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/selector/VBoxSelectorWnd.cpp	(revision 31008)
@@ -757,8 +757,8 @@
 #endif
 
-    CProgress progress = vbox.OpenRemoteSession (session, id, "GUI/Qt", env);
+    CProgress progress = item->machine().LaunchVMProcess(session, "GUI/Qt", env);
     if (!vbox.isOk())
     {
-        vboxProblem().cannotOpenSession (vbox, item->machine());
+        vboxProblem().cannotOpenSession(vbox, item->machine());
         return;
     }
@@ -791,8 +791,11 @@
     if (session.isNull())
     {
-        vboxProblem().cannotOpenSession (session);
+        vboxProblem().cannotOpenSession(session);
         return;
     }
-    vbox.OpenSession (session, id);
+
+    CMachine foundMachine = vbox.GetMachine(id);
+    if (!foundMachine.isNull())
+        foundMachine.LockForSession(session, false /* fPermitShared */);
     if (!vbox.isOk())
     {
@@ -1188,5 +1191,5 @@
 
         KMachineState state = item->state();
-        bool running = item->sessionState() != KSessionState_Closed;
+        bool running = item->sessionState() != KSessionState_Unlocked;
         bool modifyEnabled = !running && state != KMachineState_Saved;
 
@@ -1615,5 +1618,5 @@
         CMachine m = pItem->machine();
         KMachineState s = pItem->state();
-        bool running = pItem->sessionState() != KSessionState_Closed;
+        bool running = pItem->sessionState() != KSessionState_Unlocked;
         bool modifyEnabled = !running && s != KMachineState_Saved;
 
Index: /trunk/src/VBox/Frontends/VirtualBox/src/selector/VBoxSnapshotsWgt.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/selector/VBoxSnapshotsWgt.cpp	(revision 31007)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/selector/VBoxSnapshotsWgt.cpp	(revision 31008)
@@ -444,5 +444,5 @@
 
     /* Whether another direct session is open or not */
-    bool busy = mSessionState != KSessionState_Closed;
+    bool busy = mSessionState != KSessionState_Unlocked;
 
     /* Machine state of the current state item */
@@ -571,5 +571,5 @@
 
     /* Open a direct session (this call will handle all errors) */
-    bool busy = mSessionState != KSessionState_Closed;
+    bool busy = mSessionState != KSessionState_Unlocked;
     CSession session = vboxGlobal().openSession (mMachineId, busy /* aExisting */);
     if (session.isNull())
@@ -641,5 +641,5 @@
     {
         /* Open a direct session (this call will handle all errors) */
-        bool busy = mSessionState != KSessionState_Closed;
+        bool busy = mSessionState != KSessionState_Unlocked;
         CSession session = vboxGlobal().openSession (mMachineId, busy /* aExisting */);
         if (session.isNull())
Index: /trunk/src/VBox/Frontends/VirtualBox/src/wizards/exportappliance/UIExportApplianceWzd.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/wizards/exportappliance/UIExportApplianceWzd.cpp	(revision 31007)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/wizards/exportappliance/UIExportApplianceWzd.cpp	(revision 31008)
@@ -181,5 +181,5 @@
             strName = m.GetName();
             strUuid = m.GetId();
-            bEnabled = m.GetSessionState() == KSessionState_Closed;
+            bEnabled = m.GetSessionState() == KSessionState_Unlocked;
         }
         else
Index: /trunk/src/VBox/Main/ApplianceImplImport.cpp
===================================================================
--- /trunk/src/VBox/Main/ApplianceImplImport.cpp	(revision 31007)
+++ /trunk/src/VBox/Main/ApplianceImplImport.cpp	(revision 31008)
@@ -1233,6 +1233,5 @@
         {
             const MyHardDiskAttachment &mhda = *itM;
-            Bstr bstrUuid(mhda.bstrUuid);           // make a copy, Windows can't handle const Bstr
-            rc2 = mVirtualBox->OpenSession(stack.pSession, bstrUuid);
+            rc2 = mhda.pMachine->LockForSession(stack.pSession, false /* fPermitShared */, NULL);
             if (SUCCEEDED(rc2))
             {
@@ -1761,5 +1760,5 @@
         {
             // to attach things we need to open a session for the new machine
-            rc = mVirtualBox->OpenSession(stack.pSession, bstrNewMachineId);
+            rc = pNewMachine->LockForSession(stack.pSession, false /* fPermitShared */, NULL);
             if (FAILED(rc)) DebugBreakThrow(rc);
             stack.fSessionOpen = true;
@@ -1782,5 +1781,4 @@
                 // this is for rollback later
                 MyHardDiskAttachment mhda;
-                mhda.bstrUuid = bstrNewMachineId;
                 mhda.pMachine = pNewMachine;
                 mhda.controllerType = bstrName;
@@ -1828,5 +1826,4 @@
                 // this is for rollback later
                 MyHardDiskAttachment mhda;
-                mhda.bstrUuid = bstrNewMachineId;
                 mhda.pMachine = pNewMachine;
 
@@ -1875,5 +1872,5 @@
         {
             // to attach things we need to open a session for the new machine
-            rc = mVirtualBox->OpenSession(stack.pSession, bstrNewMachineId);
+            rc = pNewMachine->LockForSession(stack.pSession, false /* fPermitShared */, NULL);
             if (FAILED(rc)) DebugBreakThrow(rc);
             stack.fSessionOpen = true;
@@ -1921,5 +1918,4 @@
                 // this is for rollback later
                 MyHardDiskAttachment mhda;
-                mhda.bstrUuid = bstrNewMachineId;
                 mhda.pMachine = pNewMachine;
 
Index: /trunk/src/VBox/Main/ConsoleImpl.cpp
===================================================================
--- /trunk/src/VBox/Main/ConsoleImpl.cpp	(revision 31007)
+++ /trunk/src/VBox/Main/ConsoleImpl.cpp	(revision 31008)
@@ -5664,5 +5664,5 @@
              * which can lead to various unexpected results (like the machine
              * state being >= MachineState_Running on the server, while the
-             * session state is already SessionState_Closed at the same time
+             * session state is already SessionState_Unlocked at the same time
              * there).
              *
Index: /trunk/src/VBox/Main/Global.cpp
===================================================================
--- /trunk/src/VBox/Main/Global.cpp	(revision 31007)
+++ /trunk/src/VBox/Main/Global.cpp	(revision 31008)
@@ -364,8 +364,8 @@
     {
         case SessionState_Null:         return "Null";
-        case SessionState_Closed:       return "Closed";
-        case SessionState_Open:         return "Open";
+        case SessionState_Unlocked:     return "Unlocked";
+        case SessionState_Locked:       return "Locked";
         case SessionState_Spawning:     return "Spawning";
-        case SessionState_Closing:      return "Closing";
+        case SessionState_Unlocking:    return "Unlocking";
         default:
         {
Index: /trunk/src/VBox/Main/MachineImpl.cpp
===================================================================
--- /trunk/src/VBox/Main/MachineImpl.cpp	(revision 31007)
+++ /trunk/src/VBox/Main/MachineImpl.cpp	(revision 31008)
@@ -116,5 +116,5 @@
 
     mSession.mPid = NIL_RTPROCESS;
-    mSession.mState = SessionState_Closed;
+    mSession.mState = SessionState_Unlocked;
 }
 
@@ -2676,4 +2676,119 @@
 
     return S_OK;
+}
+
+/**
+ *  @note Locks objects!
+ */
+STDMETHODIMP Machine::LockForSession(ISession *aSession,
+                                     BOOL fPermitShared,
+                                     SessionType_T *pSessionType)
+{
+    CheckComArgNotNull(aSession);
+
+    AutoCaller autoCaller(this);
+    if (FAILED(autoCaller.rc())) return autoCaller.rc();
+
+    /* check the session state */
+    SessionState_T state;
+    HRESULT rc = aSession->COMGETTER(State)(&state);
+    if (FAILED(rc)) return rc;
+
+    if (state != SessionState_Unlocked)
+        return setError(VBOX_E_INVALID_OBJECT_STATE,
+                        tr("The given session is busy"));
+
+    /* get the IInternalSessionControl interface */
+    ComPtr<IInternalSessionControl> control = aSession;
+    ComAssertMsgRet(!!control, ("No IInternalSessionControl interface"),
+                    E_INVALIDARG);
+
+    rc = openSession(control);
+
+    if (FAILED(rc) && fPermitShared)
+        // try again @todo r=dj check exact error code!
+        rc = openExistingSession(control);
+
+    if (SUCCEEDED(rc))
+    {
+        /*
+        *  tell the client watcher thread to update the set of
+        *  machines that have open sessions
+        */
+        mParent->updateClientWatcher();
+
+        /* fire an event */
+        mParent->onSessionStateChange(getId(), SessionState_Locked);
+
+        // return session type to caller
+        if (pSessionType)
+            aSession->COMGETTER(Type)(pSessionType);
+    }
+
+    return rc;
+}
+
+/**
+ *  @note Locks objects!
+ */
+STDMETHODIMP Machine::LaunchVMProcess(ISession *aSession,
+                                      IN_BSTR aType,
+                                      IN_BSTR aEnvironment,
+                                      IProgress **aProgress)
+{
+    CheckComArgNotNull(aSession);
+    CheckComArgStrNotEmptyOrNull(aType);
+    CheckComArgOutSafeArrayPointerValid(aProgress);
+
+    AutoCaller autoCaller(this);
+    if (FAILED(autoCaller.rc())) return autoCaller.rc();
+
+    /* check the session state */
+    SessionState_T state;
+    HRESULT rc = aSession->COMGETTER(State)(&state);
+    if (FAILED(rc)) return rc;
+
+    if (state != SessionState_Unlocked)
+        return setError(VBOX_E_INVALID_OBJECT_STATE,
+                        tr("The given session is busy"));
+
+    /* get the IInternalSessionControl interface */
+    ComPtr<IInternalSessionControl> control = aSession;
+    ComAssertMsgRet(!!control, ("No IInternalSessionControl interface"),
+                      E_INVALIDARG);
+
+    /* get the teleporter enable state for the progress object init. */
+    BOOL fTeleporterEnabled;
+    rc = COMGETTER(TeleporterEnabled)(&fTeleporterEnabled);
+    if (FAILED(rc))
+        return rc;
+
+    /* create a progress object */
+    ComObjPtr<ProgressProxy> progress;
+    progress.createObject();
+    rc = progress->init(mParent,
+                        static_cast<IMachine*>(this),
+                        Bstr(tr("Spawning session")),
+                        TRUE /* aCancelable */,
+                        fTeleporterEnabled ? 20 : 10 /* uTotalOperationsWeight */,
+                        Bstr(tr("Spawning session")),
+                        2 /* uFirstOperationWeight */,
+                        fTeleporterEnabled ? 3 : 1 /* cOtherProgressObjectOperations */);
+    if (SUCCEEDED(rc))
+    {
+        rc = openRemoteSession(control, aType, aEnvironment, progress);
+        if (SUCCEEDED(rc))
+        {
+            progress.queryInterfaceTo(aProgress);
+
+            /* signal the client watcher thread */
+            mParent->updateClientWatcher();
+
+            /* fire an event */
+            mParent->onSessionStateChange(getId(), SessionState_Spawning);
+        }
+    }
+
+    return rc;
 }
 
@@ -3697,7 +3812,7 @@
 
     MediaList llMedia;
-    if (mData->mSession.mState != SessionState_Closed)
+    if (mData->mSession.mState != SessionState_Unlocked)
         return setError(VBOX_E_INVALID_OBJECT_STATE,
-                        tr("Cannot unregister the machine '%ls' because it has an open session"),
+                        tr("Cannot unregister the machine '%ls' while it is locked"),
                            mUserData->mName.raw());
 
@@ -4014,7 +4129,7 @@
         AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
 
-        if (mData->mSession.mState != SessionState_Open)
+        if (mData->mSession.mState != SessionState_Locked)
             return setError(VBOX_E_INVALID_VM_STATE,
-                            tr("Machine session is not open (session state: %s)"),
+                            tr("Machine is not locked for session (session state: %s)"),
                             Global::stringifySessionState(mData->mSession.mState));
 
@@ -4041,7 +4156,7 @@
         AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
 
-        if (mData->mSession.mState != SessionState_Open)
+        if (mData->mSession.mState != SessionState_Locked)
             return setError(E_FAIL,
-                            tr("Machine session is not open (session state: %s)"),
+                            tr("Machine is not locked for session (session state: %s)"),
                             Global::stringifySessionState(mData->mSession.mState));
 
@@ -5265,5 +5380,5 @@
      * and do a limited wait (max. 1 second). This helps a lot when the system
      * is busy and thus session closing can take a little while. */
-    if (    mData->mSession.mState == SessionState_Closing
+    if (    mData->mSession.mState == SessionState_Unlocking
         &&  mData->mSession.mProgress)
     {
@@ -5274,8 +5389,9 @@
     }
 
-    if (mData->mSession.mState == SessionState_Open ||
-        mData->mSession.mState == SessionState_Closing)
+    if (    mData->mSession.mState == SessionState_Locked
+         || mData->mSession.mState == SessionState_Unlocking
+       )
         return setError(VBOX_E_INVALID_OBJECT_STATE,
-                        tr("A session for the machine '%ls' is currently open (or being closed)"),
+                        tr("The machine '%ls' is already locked for a session (or being unlocked)"),
                         mUserData->mName.raw());
 
@@ -5301,7 +5417,6 @@
         if (mData->mSession.mPid != pid)
             return setError(E_ACCESSDENIED,
-                            tr("An unexpected process (PID=0x%08X) has tried to open a direct "
-                               "session with the machine named '%ls', while only a process "
-                               "started by OpenRemoteSession (PID=0x%08X) is allowed"),
+                            tr("An unexpected process (PID=0x%08X) has tried to lock the "
+                               "machine '%ls', while only the process started by launchVMProcess (PID=0x%08X) is allowed"),
                             pid, mUserData->mName.raw(), mData->mSession.mPid);
     }
@@ -5418,5 +5533,5 @@
 
             mData->mSession.mRemoteControls.clear();
-            mData->mSession.mState = SessionState_Closed;
+            mData->mSession.mState = SessionState_Unlocked;
         }
     }
@@ -5432,5 +5547,5 @@
         /* memorize the direct session control and cache IUnknown for it */
         mData->mSession.mDirectControl = aControl;
-        mData->mSession.mState = SessionState_Open;
+        mData->mSession.mState = SessionState_Locked;
         /* associate the SessionMachine with this Machine */
         mData->mSession.mMachine = sessionMachine;
@@ -5482,9 +5597,9 @@
     LogFlowThisFunc(("mSession.mState=%s\n", Global::stringifySessionState(mData->mSession.mState)));
 
-    if (mData->mSession.mState == SessionState_Open ||
-        mData->mSession.mState == SessionState_Spawning ||
-        mData->mSession.mState == SessionState_Closing)
+    if (    mData->mSession.mState == SessionState_Locked
+         || mData->mSession.mState == SessionState_Spawning
+         || mData->mSession.mState == SessionState_Unlocking)
         return setError(VBOX_E_INVALID_OBJECT_STATE,
-                        tr("A session for the machine '%ls' is currently open (or being opened or closed)"),
+                        tr("The machine '%ls' is already locked by a session (or being locked or unlocked)"),
                         mUserData->mName.raw());
 
@@ -5669,5 +5784,5 @@
     {
         /* restore the session state */
-        mData->mSession.mState = SessionState_Closed;
+        mData->mSession.mState = SessionState_Unlocked;
         /* The failure may occur w/o any error info (from RPC), so provide one */
         return setError(VBOX_E_VM_ERROR,
@@ -5710,7 +5825,7 @@
     LogFlowThisFunc(("mSession.state=%s\n", Global::stringifySessionState(mData->mSession.mState)));
 
-    if (mData->mSession.mState != SessionState_Open)
+    if (mData->mSession.mState != SessionState_Locked)
         return setError(VBOX_E_INVALID_SESSION_STATE,
-                        tr("The machine '%ls' does not have an open session"),
+                        tr("The machine '%ls' is not currently locked for a session"),
                         mUserData->mName.raw());
 
@@ -5756,10 +5871,10 @@
 
     /* need to revalidate the state after entering the lock again */
-    if (mData->mSession.mState != SessionState_Open)
+    if (mData->mSession.mState != SessionState_Locked)
     {
         aControl->Uninitialize();
 
         return setError(VBOX_E_INVALID_SESSION_STATE,
-                        tr("The machine '%ls' does not have an open session"),
+                        tr("The machine '%ls' is not currently locked for a session"),
                         mUserData->mName.raw());
     }
@@ -5810,6 +5925,7 @@
     AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
 
-    if (mData->mSession.mState == SessionState_Open ||
-        (aAllowClosing && mData->mSession.mState == SessionState_Closing))
+    if (    mData->mSession.mState == SessionState_Locked
+         || (aAllowClosing && mData->mSession.mState == SessionState_Unlocking)
+       )
     {
         AssertReturn(!mData->mSession.mMachine.isNull(), false);
@@ -5961,5 +6077,5 @@
 
         mData->mSession.mRemoteControls.clear();
-        mData->mSession.mState = SessionState_Closed;
+        mData->mSession.mState = SessionState_Unlocked;
 
         /* finalize the progress after setting the state */
@@ -5973,5 +6089,5 @@
         mData->mSession.mPid = NIL_RTPROCESS;
 
-        mParent->onSessionStateChange(mData->mUuid, SessionState_Closed);
+        mParent->onSessionStateChange(mData->mUuid, SessionState_Unlocked);
         return true;
     }
@@ -9718,5 +9834,5 @@
     {
         /* mType is not null when this machine's process has been started by
-         * VirtualBox::OpenRemoteSession(), therefore it is our child.  We
+         * Machine::launchVMProcess(), therefore it is our child.  We
          * need to queue the PID to reap the process (and avoid zombies on
          * Linux). */
@@ -9778,5 +9894,5 @@
         /* this must be null here (see #OnSessionEnd()) */
         Assert(mData->mSession.mDirectControl.isNull());
-        Assert(mData->mSession.mState == SessionState_Closing);
+        Assert(mData->mSession.mState == SessionState_Unlocking);
         Assert(!mData->mSession.mProgress.isNull());
     }
@@ -9799,5 +9915,5 @@
     /* reset the rest of session data */
     mData->mSession.mMachine.setNull();
-    mData->mSession.mState = SessionState_Closed;
+    mData->mSession.mState = SessionState_Unlocked;
     mData->mSession.mType.setNull();
 
@@ -9823,5 +9939,5 @@
 
     /* fire an event */
-    mParent->onSessionStateChange(mData->mUuid, SessionState_Closed);
+    mParent->onSessionStateChange(mData->mUuid, SessionState_Unlocked);
 
     uninitDataAndChildObjects();
@@ -9918,5 +10034,5 @@
     AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
 
-    if (mData->mSession.mState != SessionState_Open)
+    if (mData->mSession.mState != SessionState_Locked)
         return VBOX_E_INVALID_OBJECT_STATE;
 
@@ -9938,5 +10054,5 @@
     AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
 
-    if (mData->mSession.mState != SessionState_Open)
+    if (mData->mSession.mState != SessionState_Locked)
         return VBOX_E_INVALID_OBJECT_STATE;
 
@@ -10133,6 +10249,6 @@
         /* go to the closing state (essential for all open*Session() calls and
          * for #checkForDeath()) */
-        Assert(mData->mSession.mState == SessionState_Open);
-        mData->mSession.mState = SessionState_Closing;
+        Assert(mData->mSession.mState == SessionState_Locked);
+        mData->mSession.mState = SessionState_Unlocking;
 
         /* set direct control to NULL to release the remote instance */
@@ -10513,5 +10629,5 @@
          * threat the latter also as an abnormal termination (see
          * Session::uninit() for details). */
-        reason = mData->mSession.mState == SessionState_Closing ?
+        reason = mData->mSession.mState == SessionState_Unlocking ?
                  Uninit::Normal :
                  Uninit::Abnormal;
@@ -11265,5 +11381,5 @@
          * and simply do nothing here. */
 
-        if (mData->mSession.mState == SessionState_Closing)
+        if (mData->mSession.mState == SessionState_Unlocking)
             return S_OK;
 
Index: /trunk/src/VBox/Main/SessionImpl.cpp
===================================================================
--- /trunk/src/VBox/Main/SessionImpl.cpp	(revision 31007)
+++ /trunk/src/VBox/Main/SessionImpl.cpp	(revision 31008)
@@ -46,6 +46,6 @@
 #define CHECK_OPEN() \
     do { \
-        if (mState != SessionState_Open) \
-            return setError(E_UNEXPECTED, tr ("The session is not open (session state: %s)"), Global::stringifySessionState(mState)); \
+        if (mState != SessionState_Locked) \
+            return setError(E_UNEXPECTED, tr ("The session is not locked (session state: %s)"), Global::stringifySessionState(mState)); \
     } while (0)
 
@@ -81,5 +81,5 @@
     LogFlowThisFuncEnter();
 
-    mState = SessionState_Closed;
+    mState = SessionState_Unlocked;
     mType = SessionType_Null;
 
@@ -126,7 +126,7 @@
     AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
 
-    if (mState != SessionState_Closed)
-    {
-        Assert(mState == SessionState_Open ||
+    if (mState != SessionState_Unlocked)
+    {
+        Assert(mState == SessionState_Locked ||
                mState == SessionState_Spawning);
 
@@ -276,5 +276,5 @@
     AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
 
-    AssertReturn(mState != SessionState_Closed, VBOX_E_INVALID_VM_STATE);
+    AssertReturn(mState != SessionState_Unlocked, VBOX_E_INVALID_VM_STATE);
 
     AssertMsgReturn(mType == SessionType_Direct && !!mConsole,
@@ -284,5 +284,5 @@
     /* return a failure if the session already transitioned to Closing
      * but the server hasn't processed Machine::OnSessionEnd() yet. */
-    if (mState != SessionState_Open)
+    if (mState != SessionState_Locked)
         return VBOX_E_INVALID_VM_STATE;
 
@@ -304,5 +304,5 @@
     AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
 
-    AssertReturn(mState == SessionState_Closed, VBOX_E_INVALID_VM_STATE);
+    AssertReturn(mState == SessionState_Unlocked, VBOX_E_INVALID_VM_STATE);
 
     if (!aMachine)
@@ -310,7 +310,6 @@
         /*
          *  A special case: the server informs us that this session has been
-         *  passed to IVirtualBox::OpenRemoteSession() so this session will
-         *  become remote (but not existing) when AssignRemoteMachine() is
-         *  called.
+         *  passed to IMachine::launchVMProcess() so this session will become
+         *  remote (but not existing) when AssignRemoteMachine() is called.
          */
 
@@ -347,5 +346,5 @@
     {
         mType = SessionType_Direct;
-        mState = SessionState_Open;
+        mState = SessionState_Locked;
     }
     else
@@ -375,5 +374,5 @@
     AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
 
-    AssertReturn(mState == SessionState_Closed ||
+    AssertReturn(mState == SessionState_Unlocked ||
                   mState == SessionState_Spawning, VBOX_E_INVALID_VM_STATE);
 
@@ -416,9 +415,9 @@
          */
         if (mType != SessionType_Remote)
-            mType = SessionType_Existing;
+            mType = SessionType_Shared;
         else
             Assert(mState == SessionState_Spawning);
 
-        mState = SessionState_Open;
+        mState = SessionState_Locked;
     }
     else
@@ -452,11 +451,11 @@
     AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
 
-    if (mState == SessionState_Closing)
-    {
-        LogFlowThisFunc(("Already being closed.\n"));
+    if (mState == SessionState_Unlocking)
+    {
+        LogFlowThisFunc(("Already being unlocked.\n"));
         return S_OK;
     }
 
-    AssertReturn(mState == SessionState_Open, VBOX_E_INVALID_VM_STATE);
+    AssertReturn(mState == SessionState_Locked, VBOX_E_INVALID_VM_STATE);
     AssertReturn(mType == SessionType_Direct, VBOX_E_INVALID_OBJECT_STATE);
 
@@ -482,11 +481,11 @@
         LogFlowThisFunc(("mState=%s, mType=%d\n", Global::stringifySessionState(mState), mType));
 
-        if (mState == SessionState_Closing)
+        if (mState == SessionState_Unlocking)
         {
-            LogFlowThisFunc(("Already being closed.\n"));
+            LogFlowThisFunc(("Already being unlocked.\n"));
             return S_OK;
         }
 
-        AssertReturn(mState == SessionState_Open ||
+        AssertReturn(mState == SessionState_Locked ||
                       mState == SessionState_Spawning, VBOX_E_INVALID_VM_STATE);
 
@@ -522,5 +521,5 @@
 
     AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
-    AssertReturn(mState == SessionState_Open, VBOX_E_INVALID_VM_STATE);
+    AssertReturn(mState == SessionState_Locked, VBOX_E_INVALID_VM_STATE);
     AssertReturn(mType == SessionType_Direct, VBOX_E_INVALID_OBJECT_STATE);
 
@@ -536,5 +535,5 @@
 
     AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
-    AssertReturn(mState == SessionState_Open, VBOX_E_INVALID_VM_STATE);
+    AssertReturn(mState == SessionState_Locked, VBOX_E_INVALID_VM_STATE);
     AssertReturn(mType == SessionType_Direct, VBOX_E_INVALID_OBJECT_STATE);
 
@@ -550,5 +549,5 @@
 
     AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
-    AssertReturn(mState == SessionState_Open, VBOX_E_INVALID_VM_STATE);
+    AssertReturn(mState == SessionState_Locked, VBOX_E_INVALID_VM_STATE);
     AssertReturn(mType == SessionType_Direct, VBOX_E_INVALID_OBJECT_STATE);
 
@@ -564,5 +563,5 @@
 
     AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
-    AssertReturn(mState == SessionState_Open, VBOX_E_INVALID_VM_STATE);
+    AssertReturn(mState == SessionState_Locked, VBOX_E_INVALID_VM_STATE);
     AssertReturn(mType == SessionType_Direct, VBOX_E_INVALID_OBJECT_STATE);
 
@@ -578,5 +577,5 @@
 
     AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
-    AssertReturn(mState == SessionState_Open, VBOX_E_INVALID_VM_STATE);
+    AssertReturn(mState == SessionState_Locked, VBOX_E_INVALID_VM_STATE);
     AssertReturn(mType == SessionType_Direct, VBOX_E_INVALID_OBJECT_STATE);
 
@@ -592,5 +591,5 @@
 
     AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
-    AssertReturn(mState == SessionState_Open, VBOX_E_INVALID_VM_STATE);
+    AssertReturn(mState == SessionState_Locked, VBOX_E_INVALID_VM_STATE);
     AssertReturn(mType == SessionType_Direct, VBOX_E_INVALID_OBJECT_STATE);
 
@@ -606,5 +605,5 @@
 
     AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
-    AssertReturn(mState == SessionState_Open, VBOX_E_INVALID_VM_STATE);
+    AssertReturn(mState == SessionState_Locked, VBOX_E_INVALID_VM_STATE);
     AssertReturn(mType == SessionType_Direct, VBOX_E_INVALID_OBJECT_STATE);
 
@@ -620,5 +619,5 @@
 
     AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
-    AssertReturn(mState == SessionState_Open, VBOX_E_INVALID_VM_STATE);
+    AssertReturn(mState == SessionState_Locked, VBOX_E_INVALID_VM_STATE);
     AssertReturn(mType == SessionType_Direct, VBOX_E_INVALID_OBJECT_STATE);
 
@@ -634,5 +633,5 @@
 
     AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
-    AssertReturn(mState == SessionState_Open, VBOX_E_INVALID_VM_STATE);
+    AssertReturn(mState == SessionState_Locked, VBOX_E_INVALID_VM_STATE);
     AssertReturn(mType == SessionType_Direct, VBOX_E_INVALID_OBJECT_STATE);
 
@@ -650,5 +649,5 @@
 
     AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
-    AssertReturn(mState == SessionState_Open, VBOX_E_INVALID_VM_STATE);
+    AssertReturn(mState == SessionState_Locked, VBOX_E_INVALID_VM_STATE);
     AssertReturn(mType == SessionType_Direct, VBOX_E_INVALID_OBJECT_STATE);
 
@@ -665,5 +664,5 @@
 
     AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
-    AssertReturn(mState == SessionState_Open, VBOX_E_INVALID_VM_STATE);
+    AssertReturn(mState == SessionState_Locked, VBOX_E_INVALID_VM_STATE);
     AssertReturn(mType == SessionType_Direct, VBOX_E_INVALID_OBJECT_STATE);
 
@@ -680,5 +679,5 @@
     AssertReturn(mType == SessionType_Direct, VBOX_E_INVALID_OBJECT_STATE);
 
-    if (mState != SessionState_Open)
+    if (mState != SessionState_Locked)
     {
         /* the call from Machine issued when the session is open can arrive
@@ -701,7 +700,7 @@
     AssertComRCReturn(autoCaller.rc(), autoCaller.rc());
 
-    if (mState != SessionState_Open)
+    if (mState != SessionState_Locked)
         return setError(VBOX_E_INVALID_VM_STATE,
-                        tr("Machine session is not open (session state: %s)."),
+                        tr("Machine is not locked by session (session state: %s)."),
                         Global::stringifySessionState(mState));
     AssertReturn(mType == SessionType_Direct, VBOX_E_INVALID_OBJECT_STATE);
@@ -738,7 +737,7 @@
     AssertComRCReturn(autoCaller.rc(), autoCaller.rc());
 
-    if (mState != SessionState_Open)
+    if (mState != SessionState_Locked)
         return setError(VBOX_E_INVALID_VM_STATE,
-                        tr("Machine session is not open (session state: %s)."),
+                        tr("Machine is not locked by session (session state: %s)."),
                         Global::stringifySessionState(mState));
     AssertReturn(mType == SessionType_Direct, VBOX_E_INVALID_OBJECT_STATE);
@@ -774,7 +773,7 @@
     AssertComRCReturn(autoCaller.rc(), autoCaller.rc());
 
-    if (mState != SessionState_Open)
+    if (mState != SessionState_Locked)
         return setError(VBOX_E_INVALID_VM_STATE,
-                        tr("Machine session is not open (session state: %s)."),
+                        tr("Machine is not locked by session (session state: %s)."),
                         Global::stringifySessionState(mState));
     AssertReturn(mType == SessionType_Direct, VBOX_E_INVALID_OBJECT_STATE);
@@ -815,5 +814,5 @@
     LogFlowThisFunc(("mState=%s, mType=%d\n", Global::stringifySessionState(mState), mType));
 
-    if (mState != SessionState_Open)
+    if (mState != SessionState_Locked)
     {
         Assert(mState == SessionState_Spawning);
@@ -829,5 +828,5 @@
         Assert(aFromServer);
 
-        mState = SessionState_Closed;
+        mState = SessionState_Unlocked;
         mType = SessionType_Null;
 #if defined(RT_OS_WINDOWS)
@@ -846,5 +845,5 @@
 
     /* go to the closing state */
-    mState = SessionState_Closing;
+    mState = SessionState_Unlocking;
 
     if (mType == SessionType_Direct)
@@ -919,5 +918,5 @@
     }
 
-    mState = SessionState_Closed;
+    mState = SessionState_Unlocked;
     mType = SessionType_Null;
 
Index: /trunk/src/VBox/Main/SnapshotImpl.cpp
===================================================================
--- /trunk/src/VBox/Main/SnapshotImpl.cpp	(revision 31007)
+++ /trunk/src/VBox/Main/SnapshotImpl.cpp	(revision 31008)
@@ -3120,7 +3120,7 @@
             AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
 
-            if (mData->mSession.mState != SessionState_Open)
+            if (mData->mSession.mState != SessionState_Locked)
                 throw setError(VBOX_E_INVALID_VM_STATE,
-                                tr("Machine session is not open (session state: %s)"),
+                                tr("Machine is not locked by a session (session state: %s)"),
                                 Global::stringifySessionState(mData->mSession.mState));
             directControl = mData->mSession.mDirectControl;
Index: /trunk/src/VBox/Main/VirtualBoxImpl.cpp
===================================================================
--- /trunk/src/VBox/Main/VirtualBoxImpl.cpp	(revision 31007)
+++ /trunk/src/VBox/Main/VirtualBoxImpl.cpp	(revision 31008)
@@ -1872,170 +1872,4 @@
 }
 
-/**
- *  @note Locks objects!
- */
-STDMETHODIMP VirtualBox::OpenSession(ISession *aSession, IN_BSTR aMachineId)
-{
-    CheckComArgNotNull(aSession);
-
-    AutoCaller autoCaller(this);
-    if (FAILED(autoCaller.rc())) return autoCaller.rc();
-
-    Guid id(aMachineId);
-    ComObjPtr<Machine> machine;
-
-    HRESULT rc = findMachine(id,
-                             false /* fPermitInaccessible */,
-                             true /* setError */,
-                             &machine);
-    if (FAILED(rc)) return rc;
-
-    /* check the session state */
-    SessionState_T state;
-    rc = aSession->COMGETTER(State)(&state);
-    if (FAILED(rc)) return rc;
-
-    if (state != SessionState_Closed)
-        return setError(VBOX_E_INVALID_OBJECT_STATE,
-                        tr("The given session is already open or being opened"));
-
-    /* get the IInternalSessionControl interface */
-    ComPtr<IInternalSessionControl> control = aSession;
-    ComAssertMsgRet(!!control, ("No IInternalSessionControl interface"),
-                    E_INVALIDARG);
-
-    rc = machine->openSession(control);
-
-    if (SUCCEEDED(rc))
-    {
-        /*
-         *  tell the client watcher thread to update the set of
-         *  machines that have open sessions
-         */
-        updateClientWatcher();
-
-        /* fire an event */
-        onSessionStateChange(id, SessionState_Open);
-    }
-
-    return rc;
-}
-
-/**
- *  @note Locks objects!
- */
-STDMETHODIMP VirtualBox::OpenRemoteSession(ISession *aSession,
-                                           IN_BSTR aMachineId,
-                                           IN_BSTR aType,
-                                           IN_BSTR aEnvironment,
-                                           IProgress **aProgress)
-{
-    LogRel(("remotesession=%s\n", Utf8Str(aMachineId).c_str()));
-
-    CheckComArgStrNotEmptyOrNull(aMachineId);
-    CheckComArgNotNull(aSession);
-    CheckComArgStrNotEmptyOrNull(aType);
-    CheckComArgOutSafeArrayPointerValid(aProgress);
-
-    AutoCaller autoCaller(this);
-    if (FAILED(autoCaller.rc())) return autoCaller.rc();
-
-    Guid id(aMachineId);
-    ComObjPtr<Machine> machine;
-
-    HRESULT rc = findMachine(id,
-                             false /* fPermitInaccessible */,
-                             true /* setError */,
-                             &machine);
-    if (FAILED(rc)) return rc;
-
-    /* check the session state */
-    SessionState_T state;
-    rc = aSession->COMGETTER(State)(&state);
-    if (FAILED(rc)) return rc;
-
-    if (state != SessionState_Closed)
-        return setError(VBOX_E_INVALID_OBJECT_STATE,
-                        tr("The given session is already open or being opened"));
-
-    /* get the IInternalSessionControl interface */
-    ComPtr<IInternalSessionControl> control = aSession;
-    ComAssertMsgRet(!!control, ("No IInternalSessionControl interface"),
-                    E_INVALIDARG);
-
-    /* get the teleporter enable state for the progress object init. */
-    BOOL fTeleporterEnabled;
-    rc = machine->COMGETTER(TeleporterEnabled)(&fTeleporterEnabled);
-    if (FAILED(rc))
-        return rc;
-
-    /* create a progress object */
-    ComObjPtr<ProgressProxy> progress;
-    progress.createObject();
-    rc = progress->init(this,
-                        static_cast<IMachine *>(machine),
-                        Bstr(tr("Spawning session")),
-                        TRUE /* aCancelable */,
-                        fTeleporterEnabled ? 20 : 10 /* uTotalOperationsWeight */,
-                        Bstr(tr("Spawning session")),
-                        2 /* uFirstOperationWeight */,
-                        fTeleporterEnabled ? 3 : 1 /* cOtherProgressObjectOperations */);
-    if (SUCCEEDED(rc))
-    {
-        rc = machine->openRemoteSession(control, aType, aEnvironment, progress);
-        if (SUCCEEDED(rc))
-        {
-            progress.queryInterfaceTo(aProgress);
-
-            /* signal the client watcher thread */
-            updateClientWatcher();
-
-            /* fire an event */
-            onSessionStateChange(id, SessionState_Spawning);
-        }
-    }
-
-    return rc;
-}
-
-/**
- *  @note Locks objects!
- */
-STDMETHODIMP VirtualBox::OpenExistingSession(ISession *aSession,
-                                             IN_BSTR  aMachineId)
-{
-    CheckComArgNotNull(aSession);
-
-    AutoCaller autoCaller(this);
-    if (FAILED(autoCaller.rc())) return autoCaller.rc();
-
-    Guid id(aMachineId);
-    ComObjPtr<Machine> machine;
-
-    HRESULT rc = findMachine(id,
-                             false /* fPermitInaccessible */,
-                             true /* setError */,
-                             &machine);
-    if (FAILED(rc)) return rc;
-
-    /* check the session state */
-    SessionState_T state;
-    rc = aSession->COMGETTER(State)(&state);
-    if (FAILED(rc)) return rc;
-
-    if (state != SessionState_Closed)
-        return setError(VBOX_E_INVALID_OBJECT_STATE,
-                        tr("The given session is already open or being opened"));
-
-    /* get the IInternalSessionControl interface */
-    ComPtr<IInternalSessionControl> control = aSession;
-    ComAssertMsgRet(!!control, ("No IInternalSessionControl interface"),
-                    E_INVALIDARG);
-
-    rc = machine->openExistingSession(control);
-
-    return rc;
-}
-
 STDMETHODIMP VirtualBox::WaitForPropertyChange(IN_BSTR /* aWhat */,
                                                ULONG /* aTimeout */,
@@ -3889,5 +3723,5 @@
 /**
  *  Thread function that watches the termination of all client processes
- *  that have opened sessions using IVirtualBox::OpenSession()
+ *  that have opened sessions using IMachine::LockForSession()
  */
 // static
Index: /trunk/src/VBox/Main/cbinding/tstXPCOMCGlue.c
===================================================================
--- /trunk/src/VBox/Main/cbinding/tstXPCOMCGlue.c	(revision 31007)
+++ /trunk/src/VBox/Main/cbinding/tstXPCOMCGlue.c	(revision 31008)
@@ -216,8 +216,6 @@
     g_pVBoxFuncs->pfnUtf8ToUtf16("gui", &sessionType);
 
-    rc = virtualBox->vtbl->OpenRemoteSession(
-        virtualBox,
+    rc = machine->vtbl->LaunchVMProcess(machine,
         session,
-        id,
         sessionType,
         env,
Index: /trunk/src/VBox/Main/glue/glue-java.xsl
===================================================================
--- /trunk/src/VBox/Main/glue/glue-java.xsl	(revision 31007)
+++ /trunk/src/VBox/Main/glue/glue-java.xsl	(revision 31008)
@@ -2494,24 +2494,9 @@
     }
 
-    public ISession openMachineSession(String mid) throws Exception
+    public ISession openMachineSession(IMachine m) throws Exception
     {
         ISession s = getSessionObject();
-        try {
-          this.vbox.openExistingSession(s, mid);
-          return s;
-        } catch (Exception e) {
-          try {
-            this.vbox.openSession(s, mid);
-            return s;
-          } catch (Exception e1) {
-            closeMachineSession(s);
-            throw e1;
-          }
-        }
-    }
-
-    public ISession openMachineSession(IMachine m) throws Exception
-    {
-          return openMachineSession(m.getId());
+        m.lockForSession(s, true /* fPermitShared */);
+        return s;
     }
 
@@ -2580,8 +2565,7 @@
         ISession session = getSessionObject();
 
-        String mid = m.getId();
         if (type == null)
             type = "gui";
-        IProgress p = vbox.openRemoteSession(session, mid, type, "");
+        IProgress p = m.launchVMProcess(session, type, "");
         progressBar(p, timeout);
         session.close();
@@ -3472,24 +3456,9 @@
     }
 
-    public ISession openMachineSession(String mid) throws Exception
+    public ISession openMachineSession(IMachine m) throws Exception
     {
         ISession s = getSessionObject();
-        try {
-          this.vbox.openExistingSession(s, mid);
-          return s;
-        } catch (Exception e) {
-          try {
-            this.vbox.openSession(s, mid);
-            return s;
-          } catch (Exception e1) {
-            closeMachineSession(s);
-            throw e1;
-          }
-        }
-    }
-
-    public ISession openMachineSession(IMachine m) throws Exception
-    {
-          return openMachineSession(m.getId());
+        m.lockForSession(s, true /* fPermitShared */ );
+        return s;
     }
 
@@ -3540,8 +3509,7 @@
         ISession session = getSessionObject();
 
-        String mid = m.getId();
         if (type == null)
             type = "gui";
-        IProgress p = vbox.openRemoteSession(session, mid, type, "");
+        IProgress p = m.launchVMProcess(session, type, "");
         progressBar(p, timeout);
         session.close();
Index: /trunk/src/VBox/Main/idl/VirtualBox.xidl
===================================================================
--- /trunk/src/VBox/Main/idl/VirtualBox.xidl	(revision 31007)
+++ /trunk/src/VBox/Main/idl/VirtualBox.xidl	(revision 31008)
@@ -794,6 +794,5 @@
       Session state. This enumeration represents possible values of
       <link to="IMachine::sessionState"/> and <link to="ISession::state"/>
-      attributes. See individual enumerator descriptions for the meaning for
-      every value.
+      attributes.
     </desc>
 
@@ -801,29 +800,36 @@
       <desc>Null value (never used by the API).</desc>
     </const>
-    <const name="Closed"                value="1">
-      <desc>
-        The machine has no open sessions (<link to="IMachine::sessionState"/>);
-        the session is closed (<link to="ISession::state"/>)
-      </desc>
-    </const>
-    <const name="Open"                  value="2">
-      <desc>
-        The machine has an open direct session (<link to="IMachine::sessionState"/>);
-        the session is open (<link to="ISession::state"/>)
+    <const name="Unlocked"              value="1">
+      <desc>
+        In <link to="IMachine::sessionState"/>, this means that the machine
+        is not locked for any sessions.
+
+        In <link to="ISession::state"/>, this means that no machine is
+        currently locked for this session.
+      </desc>
+    </const>
+    <const name="Locked"                value="2">
+      <desc>
+        In <link to="IMachine::sessionState"/>, this means that the machine
+        is currently locked for a session, whose process identifier can
+        then be found in the <link to="IMachine::sessionPid" /> attribute.
+
+        In <link to="ISession::state"/>, this means that a machine is
+        currently locked for this session, and the mutable machine object
+        can be found in the <link to="ISession::machine"/> attribute
+        (see <link to="IMachine::lockForSession" /> for details).
       </desc>
     </const>
     <const name="Spawning"              value="3">
       <desc>
-        A new (direct) session is being opened for the machine as a result of
-        <link to="IVirtualBox::openRemoteSession"/> call
-        (<link to="IMachine::sessionState"/> or <link to="ISession::state"/>).
-        This state also occurs as a short transient state when a new direct
-        session is opened by calling <link to="IVirtualBox::openSession"/>.
-      </desc>
-    </const>
-    <const name="Closing"               value="4">
-      <desc>
-        The direct session is being closed (<link to="IMachine::sessionState"/>);
-        the session is being closed (<link to="ISession::state"/>)
+        A new process is being spawned for the machine as a result of
+        <link to="IMachine::launchVMProcess"/> call. This state also occurs
+        as a short transient state during an <link to="IMachine::lockForSession"/>
+        call.
+      </desc>
+    </const>
+    <const name="Unlocking"             value="4">
+      <desc>
+        The session is being unlocked.
       </desc>
     </const>
@@ -914,17 +920,17 @@
       <desc>
         Direct session
-        (opened by <link to="IVirtualBox::openSession"/>)
+        (used with <link to="IMachine::lockForSession"/>)
       </desc>
     </const>
     <const name="Remote"                value="2">
       <desc>
-        Remote session
-        (opened by <link to="IVirtualBox::openRemoteSession"/>)
-      </desc>
-    </const>
-    <const name="Existing"              value="3">
-      <desc>
-        Existing session
-        (opened by <link to="IVirtualBox::openExistingSession"/>)
+        Remote VM process
+        (opened by <link to="IMachine::launchVMProcess"/>)
+      </desc>
+    </const>
+    <const name="Shared"                value="3">
+      <desc>
+        Shared session; remote link to an existing direct session opened
+        by <link to="IMachine::lockForSession"/> with fPermitShared = true
       </desc>
     </const>
@@ -2265,259 +2271,4 @@
       <param name="value" type="wstring" dir="in">
         <desc>Value to assign to the key.</desc>
-      </param>
-    </method>
-
-    <method name="openSession">
-      <desc>
-        Opens a new direct session with the given virtual machine.
-
-        A direct session acts as a local lock on the given VM.
-        There can be only one direct session open at a time for every
-        virtual machine, protecting the VM from being manipulated by
-        conflicting actions from different processes. Only after a
-        direct session has been opened, one can change all VM settings
-        and execute the VM in the process space of the session object.
-
-        Sessions therefore can be compared to mutex semaphores that
-        lock a given VM for modification and execution.
-        See <link to="ISession">ISession</link> for details.
-
-        <note>Unless you are writing a new VM frontend, you will not
-        want to execute a VM in the current process. To spawn a new
-        process that executes a VM, use
-        <link to="IVirtualBox::openRemoteSession" />
-        instead.</note>
-
-        Upon successful return, the session object can be used to
-        get access to the machine and to the VM console.
-
-        In VirtualBox terminology, the machine becomes "mutable" after
-        a session has been opened. Note that the "mutable" machine
-        object, on which you may invoke IMachine methods to change its
-        settings, will be a different object from the immutable IMachine
-        objects returned by various IVirtualBox methods. To obtain a
-        mutable IMachine object (upon which you can invoke settings methods),
-        use the <link to="ISession::machine" /> attribute.
-
-        One must always call <link to="ISession::close" /> to release the
-        lock on the machine, or the machine's state will eventually be
-        set to "Aborted".
-
-        In other words, to change settings on a machine, the following
-        sequence is typically performed:
-
-        <ol>
-        <li>Call this method (openSession) to have a machine locked for
-        the current session.</li>
-
-        <li>Obtain a mutable IMachine object from <link to="ISession::machine" />.</li>
-
-        <li>Change the settings of the machine.</li>
-
-        <li>Call <link to="IMachine::saveSettings" />.</li>
-
-        <li>Close the session by calling <link to="ISession::close"/>.</li>
-        </ol>
-
-        <result name="E_UNEXPECTED">
-          Virtual machine not registered.
-        </result>
-        <result name="E_ACCESSDENIED">
-          Process not started by OpenRemoteSession.
-        </result>
-        <result name="VBOX_E_OBJECT_NOT_FOUND">
-          No matching virtual machine found.
-        </result>
-        <result name="VBOX_E_INVALID_OBJECT_STATE">
-          Session already open or being opened.
-        </result>
-        <result name="VBOX_E_VM_ERROR">
-          Failed to assign machine to session.
-        </result>
-
-      </desc>
-      <param name="session" type="ISession" dir="in">
-        <desc>
-          Session object that will represent the opened session after
-          successful method invocation. This object must not represent
-          the already open session.
-          <note>
-            This session will be automatically closed if the
-            VirtualBox server is terminated for some reason.
-          </note>
-        </desc>
-      </param>
-      <param name="machineId" type="uuid" mod="string" dir="in">
-        <desc>ID of the virtual machine to open a session with.</desc>
-      </param>
-    </method>
-
-    <method name="openRemoteSession">
-      <desc>
-        Spawns a new process that executes a virtual machine (called a
-        "remote session").
-
-        Opening a remote session causes the VirtualBox server to start a new
-        process that opens a direct session with the given VM. As a result, the
-        VM is locked by that direct session in the new process, preventing
-        conflicting changes from other processes. Since sessions act as locks
-        that prevent conflicting changes, one cannot open a remote session
-        for a VM that already has another open session (direct or remote), or
-        is currently in the process of opening one (see <link
-          to="IMachine::sessionState"/>).
-
-        While the remote session still provides some level of control over the
-        VM execution to the caller (using the <link to="IConsole" /> interface),
-        not all VM settings are available for modification within the remote
-        session context.
-
-        This operation can take some time (a new VM is started in a new process,
-        for which memory and other resources need to be set up). Because of this,
-        an <link to="IProgress" /> is returned to allow the caller to wait for this
-        asynchronous operation to be completed. Until then, the remote session
-        object remains in the closed state, and accessing the machine or its
-        console through it is invalid. It is recommended to use
-        <link to="IProgress::waitForCompletion" /> or similar calls to wait for
-        completion. Completion is signalled when the VM is powered on. Error
-        messages etc. can be queried via the progress object, if available.
-
-        As with all <link to="ISession" /> objects, it is recommended to call
-        <link to="ISession::close" /> on the local session object once openRemoteSession()
-        has been called. However, the session's state (see <link to="ISession::state" />)
-        will not return to "Closed" until the remote session has also closed (i.e.
-        until the VM is no longer running). In that case, however, the state of
-        the session will automatically change back to "Closed".
-
-        Currently supported session types (values of the @a type
-        argument) are:
-        <ul>
-          <li><tt>"gui"</tt>: VirtualBox Qt GUI session</li>
-          <li><tt>"vrdp"</tt>: VirtualBox VRDP Server session</li>
-          <li><tt>"sdl"</tt>: VirtualBox SDL GUI session</li>
-        </ul>
-
-        The @a environment argument is a string containing definitions of
-        environment variables in the following format:
-        @code
-          NAME[=VALUE]\n
-          NAME[=VALUE]\n
-          ...
-        @endcode
-        where <tt>\\n</tt> is the new line character. These environment
-        variables will be appended to the environment of the VirtualBox server
-        process. If an environment variable exists both in the server process
-        and in this list, the value from this list takes precedence over the
-        server's variable. If the value of the environment variable is
-        omitted, this variable will be removed from the resulting environment.
-        If the environment string is @c null or empty, the server environment
-        is inherited by the started process as is.
-
-        The progress object will have at least 2 operation. The first operation
-        covers the period up to the new VM process calls powerUp. The
-        subsequent operations mirrors the <link to="IConsole::powerUp"/>
-        progress object. Because <link to="IConsole::powerUp"/> may require
-        some extra operation, the <link to="IProgress::operationCount"/> may
-        change at the completion of operation1.
-
-        For details on the teleportation progress operation, see
-        <link to="IConsole::powerUp"/>.
-
-        <see>openExistingSession</see>
-
-        <result name="E_UNEXPECTED">
-          Virtual machine not registered.
-        </result>
-        <result name="E_INVALIDARG">
-          Invalid session type @a type.
-        </result>
-        <result name="VBOX_E_OBJECT_NOT_FOUND">
-          No machine matching @a machineId found.
-        </result>
-        <result name="VBOX_E_INVALID_OBJECT_STATE">
-          Session already open or being opened.
-        </result>
-        <result name="VBOX_E_IPRT_ERROR">
-          Launching process for machine failed.
-        </result>
-        <result name="VBOX_E_VM_ERROR">
-          Failed to assign machine to session.
-        </result>
-
-      </desc>
-      <param name="session" type="ISession" dir="in">
-        <desc>
-          Session object that will represent the opened remote session
-          after successful method invocation (this object must not
-          represent an already open session).
-        </desc>
-      </param>
-      <param name="machineId" type="uuid" mod="string" dir="in">
-        <desc>ID of the virtual machine to open a session with.</desc>
-      </param>
-      <param name="type" type="wstring" dir="in">
-        <desc>
-          Type of the remote session (case sensitive).
-        </desc>
-      </param>
-      <param name="environment" type="wstring" dir="in">
-        <desc>
-          Environment to pass to the opened session.
-        </desc>
-      </param>
-      <param name="progress" type="IProgress" dir="return">
-        <desc>Progress object to track the operation completion.</desc>
-      </param>
-    </method>
-
-    <method name="openExistingSession">
-      <desc>
-        Opens a new remote session with the virtual machine for
-        which a direct session is already open.
-
-        The remote session provides some level of control over the VM
-        execution (using the IConsole interface) to the caller; however,
-        within the remote session context, not all VM settings are available
-        for modification.
-
-        As opposed to <link to="#openRemoteSession"/>, the number of
-        remote sessions opened this way is not limited by the API
-
-        <note>
-          It is an error to open a remote session with the machine that
-          doesn't have an open direct session.
-        </note>
-
-        <result name="E_UNEXPECTED">
-          Virtual machine not registered.
-        </result>
-        <result name="VBOX_E_OBJECT_NOT_FOUND">
-          No machine matching @a machineId found.
-        </result>
-        <result name="VBOX_E_INVALID_OBJECT_STATE">
-          Session already open or being opened.
-        </result>
-        <result name="VBOX_E_INVALID_SESSION_STATE">
-          Direct session state not Open.
-        </result>
-        <result name="VBOX_E_VM_ERROR">
-          Failed to get console object from direct session or assign
-          machine to session.
-        </result>
-
-        <see>openRemoteSession</see>
-      </desc>
-      <param name="session" type="ISession" dir="in">
-        <desc>
-          Session object that will represent the open remote session
-          after successful method invocation. This object must not
-          represent an already open session.
-          <note>
-            This session will be automatically closed when the peer
-            (direct) session dies or gets closed.
-          </note>
-        </desc>
-      </param>
-      <param name="machineId" type="uuid" mod="string" dir="in">
-        <desc>ID of the virtual machine to open a session with.</desc>
       </param>
     </method>
@@ -3457,10 +3208,10 @@
       <desc>
         Tells VBoxSVC that <link to="IConsole::powerUp"/> is under ways and
-	gives it the progress object that should be part of any pending
-	<link to="IVirtualBox::openRemoteSession"/> operations.  The progress
-	object may be called back to reflect an early cancelation, so some care
-	have to be taken with respect to any cancelation callbacks. The console
-	object will call <link to="IInternalMachineControl::endPowerUp"/>
-	to signal the completion of the progress object.
+        gives it the progress object that should be part of any pending
+        <link to="IMachine::launchVMProcess"/> operations.  The progress
+        object may be called back to reflect an early cancelation, so some care
+        have to be taken with respect to any cancelation callbacks. The console
+        object will call <link to="IInternalMachineControl::endPowerUp"/>
+        to signal the completion of the progress object.
       </desc>
       <param name="progress" type="IProgress" dir="in"/>
@@ -3472,5 +3223,5 @@
         This method may query status information from the progress object it
         received in <link to="IInternalMachineControl::beginPowerUp"/> and copy
-        it over to any in progress <link to="IVirtualBox::openRemoteSession"/>
+        it over to any in-progress <link to="IMachine::launchVMProcess"/>
         call in order to complete that progress object.
       </desc>
@@ -3901,12 +3652,12 @@
       <link to="IVirtualBox::machines"/> collection, all attributes are
       read-only unless explicitly stated otherwise in individual attribute
-      and method descriptions. In order to change a machine setting, a session
-      for this machine must be opened using one of
-      <link to="IVirtualBox::openSession"/>,
-      <link to="IVirtualBox::openRemoteSession"/> or
-      <link to="IVirtualBox::openExistingSession"/> methods. After the
-      session has been successfully opened, a mutable machine object needs to
-      be queried from the session object and then the desired settings changes
-      can be applied to the returned object using IMachine attributes and
+      and method descriptions.
+
+      In order to change a machine setting, a session for this machine must be
+      opened using one of the <link to="IMachine::lockForSession" /> or
+      <link to="IMachine::launchVMProcess"/> methods. After the
+      machine has been successfully locked for a session, a mutable machine object
+      needs to be queried from the session object and then the desired settings
+      changes can be applied to the returned object using IMachine attributes and
       methods. See the <link to="ISession"/> interface description for more
       information about sessions.
@@ -4245,7 +3996,7 @@
         SessionSpawning or SessionOpen, this attribute contains the
         same value as passed to the
-        <link to="IVirtualBox::openRemoteSession"/> method in the
+        <link to="IMachine::launchVMProcess"/> method in the
         @a type parameter. If the session was opened directly using
-        <link to="IVirtualBox::openSession"/>, or if
+        <link to="IMachine::lockForSession" />, or if
         <link to="#sessionState"/> is SessionClosed, the value of this
         attribute is an empty string.
@@ -4258,5 +4009,5 @@
         platform-dependent identifier of the process that has opened a
         direct session for this machine using the
-        <link to="IVirtualBox::openSession"/> call. The returned value
+        <link to="IMachine::lockForSession" /> call. The returned value
         is only valid if <link to="#sessionState"/> is SessionOpen or
         SessionClosing (i.e. a session is currently open or being
@@ -4441,4 +4192,204 @@
       </desc>
     </attribute>
+
+    <method name="lockForSession">
+      <desc>
+        Locks the machine for the given session to enable the caller
+        to make changes to the machine or start the VM.
+
+        A single machine can only be locked for a single sesseion
+        at a time, protecting the VM from being manipulated by
+        conflicting actions from different processes. Only after this
+        method has been called, one can change all VM settings
+        or execute the VM in the process space of the session object.
+        See <link to="ISession">ISession</link> for details.
+
+        Locking the machine for a session creates a second copy of
+        the IMachine object. It is this second object upon which
+        changes can be made; in VirtualBox terminology, the second
+        copy is "mutable". It is only this second, mutable machine
+        object upon which you can call methods that change the
+        machine state. After having called this method, you can
+        obtain this second, mutable machine object using the
+        <link to="ISession::machine" /> attribute. This way, you can
+        also get access to the <link to="IConsole" /> object which
+        controls VM execution.
+
+        <note>Unless you are writing a new VM frontend, you will not
+        want to execute a VM in the current process. To spawn a new
+        process that executes a VM, use <link to="IMachine::launchVMProcess" />
+        instead.</note>
+
+        One must always call <link to="ISession::close" /> to release the
+        lock on the machine, or the machine's state will eventually be
+        set to "Aborted".
+
+        In other words, to change settings on a machine, the following
+        sequence is typically performed:
+
+        <ol>
+          <li>Call this method (openSession) to have a machine locked for
+            the current session.</li>
+
+          <li>Obtain a mutable IMachine object from <link to="ISession::machine" />.</li>
+
+          <li>Change the settings of the machine.</li>
+
+          <li>Call <link to="IMachine::saveSettings" />.</li>
+
+          <li>Close the session by calling <link to="ISession::close"/>.</li>
+        </ol>
+
+        If the @a fPermitShared parameter is set to true, this method will also
+        succeed on a machine which has already been locked by another session.
+        The caller will then be attached to that existing session, and its own
+        session will be marked as "Shared". While not all machine settings can
+        be changed in that case, an IConsole object will still be created which
+        provides to the caller some level of control over the VM execution, for
+        example to pause the machine. The number of such shared sessions per
+        machine is not limited by the API.
+
+        The return value will then indicate whether a direct session was opened
+        (<link to="SessionType::Direct" />) or whether an existing direct session
+        was shared ((<link to="SessionType::Shared" />).
+
+        If the @a fPermitShared parameter is @c false, then this can only
+        possibly return <link to="SessionType::Direct" />.
+
+        <result name="E_UNEXPECTED">
+          Virtual machine not registered.
+        </result>
+        <result name="E_ACCESSDENIED">
+          Process not started by OpenRemoteSession.
+        </result>
+        <result name="VBOX_E_INVALID_OBJECT_STATE">
+          Session already open or being opened.
+        </result>
+        <result name="VBOX_E_VM_ERROR">
+          Failed to assign machine to session.
+        </result>
+      </desc>
+      <param name="session" type="ISession" dir="in">
+        <desc>
+          Session object for which the machine will be locked.
+        </desc>
+      </param>
+      <param name="fPermitShared" type="boolean" dir="in">
+        <desc>
+          Whether to allow for sharing a direct session remotely.
+        </desc>
+      </param>
+      <param name="sessionType" type="SessionType" dir="return">
+        <desc>
+        </desc>
+      </param>
+    </method>
+
+    <method name="launchVMProcess">
+      <desc>
+        Spawns a new process that will execute the virtual machine.
+
+        This operation can take some time (a new VM is started in a new process,
+        for which memory and other resources need to be set up). Because of this,
+        an <link to="IProgress" /> object is returned to allow the caller to wait
+        for this asynchronous operation to be completed. Until then, the caller's
+        session object remains in the "Unlocked" state, and its <link to="ISession::machine" />
+        and <link to="ISession::console" /> attributes cannot be accessed.
+        It is recommended to use <link to="IProgress::waitForCompletion" /> or
+        similar calls to wait for completion. Completion is signalled when the VM
+        is powered on. If launching the VM fails, error messages can be queried
+        via the progress object, if available.
+
+        If launching the VM succeeds, the new VM process will create its own
+        session and lock the machine for it, preventing conflicting changes
+        from other processes. If the machine is already locked (because it
+        is already running or because another session is making changes),
+        launching the VM process will therefore fail. Reversely, future
+        locking attempts will also fail while the machine is running.
+
+        The caller's session object remains separate from the session opened
+        by the new VM process. It receives its own <link to="IConsole" />
+        object which can be used to control machine execution, but it cannot
+        be used to change all VM settings which would be available after
+        a <link to="#lockForSession" /> call.
+
+        As with all <link to="ISession" /> objects, it is recommended to call
+        <link to="ISession::close" /> on the local session object once this call
+        has returned. However, the session's state (see <link to="ISession::state" />)
+        will not return to "Unlocked" until the remote session has also unlocked
+        the machine.
+
+        The @a environment argument is a string containing definitions of
+        environment variables in the following format:
+        @code
+        NAME[=VALUE]\n
+        NAME[=VALUE]\n
+        ...
+        @endcode
+        where <tt>\\n</tt> is the new line character. These environment
+        variables will be appended to the environment of the VirtualBox server
+        process. If an environment variable exists both in the server process
+        and in this list, the value from this list takes precedence over the
+        server's variable. If the value of the environment variable is
+        omitted, this variable will be removed from the resulting environment.
+        If the environment string is @c null or empty, the server environment
+        is inherited by the started process as is.
+
+        The progress object will have at least 2 sub-operations. The first
+        operation covers the period up to the new VM process calls powerUp.
+        The subsequent operations mirror the <link to="IConsole::powerUp"/>
+        progress object. Because <link to="IConsole::powerUp"/> may require
+        some extra sub-operations, the <link to="IProgress::operationCount"/>
+        may change at the completion of operation.
+
+        For details on the teleportation progress operation, see
+        <link to="IConsole::powerUp"/>.
+
+        <result name="E_UNEXPECTED">
+          Virtual machine not registered.
+        </result>
+        <result name="E_INVALIDARG">
+          Invalid session type @a type.
+        </result>
+        <result name="VBOX_E_OBJECT_NOT_FOUND">
+          No machine matching @a machineId found.
+        </result>
+        <result name="VBOX_E_INVALID_OBJECT_STATE">
+          Session already open or being opened.
+        </result>
+        <result name="VBOX_E_IPRT_ERROR">
+          Launching process for machine failed.
+        </result>
+        <result name="VBOX_E_VM_ERROR">
+          Failed to assign machine to session.
+        </result>
+      </desc>
+      <param name="session" type="ISession" dir="in">
+        <desc>
+          Session object that will represent the opened remote session
+          after successful method invocation (this object must not
+          represent an already open session).
+        </desc>
+      </param>
+      <param name="type" type="wstring" dir="in">
+        <desc>
+          Type of the remote session (case sensitive). The following are
+          currently supported:
+          <ul>
+            <li><tt>"gui"</tt>: VirtualBox Qt GUI front-end</li>
+            <li><tt>"vrdp"</tt>: VBoxHeadless (VRDP Server) front-end</li>
+            <li><tt>"sdl"</tt>: VirtualBox SDL front-end</li>
+          </ul>
+        </desc>
+      </param>
+      <param name="environment" type="wstring" dir="in">
+        <desc>
+          Environment to pass to the VM process.
+        </desc>
+      </param>
+      <param name="progress" type="IProgress" dir="return">
+        <desc>Progress object to track the operation completion.</desc>
+      </param>
+    </method>
 
     <method name="setBootOrder">
@@ -5972,9 +5923,8 @@
       machine execution.
 
-      The console object that implements the IConsole interface is obtained
-      from a session object after the session for the given machine has been
-      opened using one of <link to="IVirtualBox::openSession"/>,
-      <link to="IVirtualBox::openRemoteSession"/> or
-      <link to="IVirtualBox::openExistingSession"/> methods.
+      A console object gets created when a machine has been locked for a
+      particular session (client process) using <link to="IMachine::lockForSession" />
+      or <link to="IMachine::launchVMProcess"/>. The console object can
+      then be found in the session's <link to="ISession::console" /> attribute.
 
       Methods of the IConsole interface allow the caller to query the current
@@ -6099,4 +6049,15 @@
         current storage devices).
 
+        <note>
+          This method is only useful for front-ends that want to actually
+          execute virtual machines in their own process (like the VirtualBox
+          or VBoxSDL front-ends). Unless you are intending to write such a
+          front-end, do not call this method.  If you simply want to
+          start virtual machine execution using one of the existing front-ends
+          (for example the VirtualBox GUI or headless server), use
+          <link to="IMachine::launchVMProcess"/> instead; these
+          front-ends will power up the machine automatically for you.
+        </note>
+
         If the machine is powered off or aborted, the execution will
         start from the beginning (as if the real hardware were just
@@ -6115,19 +6076,8 @@
         (3) perform teleportation. These operations will be reflected as the
         last three operations of the progress objected returned by
-        <link to="IVirtualBox::openRemoteSession"/> as well.
-
-        <note>
-          Unless you are trying to write a new VirtualBox front-end that
-          performs direct machine execution (like the VirtualBox or VBoxSDL
-          front-ends), don't call <link to="IConsole::powerUp"/> in a direct
-          session opened by <link to="IVirtualBox::openSession"/> and use this
-          session only to change virtual machine settings. If you simply want to
-          start virtual machine execution using one of the existing front-ends
-          (for example the VirtualBox GUI or headless server), simply use
-          <link to="IVirtualBox::openRemoteSession"/>; these front-ends will
-          power up the machine automatically for you.
-        </note>
+        <link to="IMachine::launchVMProcess"/> as well.
 
         <see>#saveState</see>
+
         <result name="VBOX_E_INVALID_VM_STATE">
           Virtual machine already running.
@@ -12795,17 +12745,36 @@
     <desc>
       The ISession interface represents a serialization primitive for virtual
-      machines.
-
-      With VirtualBox, every time one wishes to manipulate a virtual machine
-      (e.g. change its settings or start execution), a session object is
-      required. Such an object must be passed to one of the session methods
-      that open the given session, which then initiates the machine manipulation.
-
-      A session serves several purposes: it identifies to the inter-process VirtualBox
-      code which process is currently working with the virtual machine, and it ensures
-      that there are no incompatible requests from several processes for the
-      same virtual machine. Session objects can therefore be thought of as mutex
-      semaphores that lock virtual machines to prevent conflicting accesses from
-      several processes.
+      machines. Any caller wishing to manipulate a virtual machine (represented
+      by an IMachine object) needs to create a session object first, which lives
+      in its own process space. Such session objects are then attached to the
+      <link to="IMachine" /> objects living in the VirtualBox server process to
+      coordinate possibly conflicting changes.
+
+      There are two typical scenarios in which sessions are used:
+
+      <ul>
+        <li>To alter machine settings, one needs to lock a machine for a given session
+          (client process) by calling <link to="IMachine::lockForSession"/>. While a
+          machine is thus locked, no any other process may lock the machine again.
+
+          The same applies for any process which indends to actually run a virtual
+          machine in its own context, such as the VirtualBox GUI or VBoxHeadless
+          executables. They must also lock a machine for their own sessions before
+          being allowed to power up the virtual machine.
+
+          As a result, no machine can be altered while another process is already
+          using it, either because that process is modifying machine settings or
+          because the machine is running.
+        </li>
+        <li>
+          To initiate virtual machine execution using one of the existing VirtualBox
+          front-ends (e.g. the GUI or VBoxHeadless), one would instead call
+          <link to="IMachine::launchVMProcess"/>, which also requires a session
+          object as its first parameter. This session then identifies the caller
+          and lets the caller control the started machine (for example, pause machine
+          execution or power it down) as well as be notified about machine execution
+          state changes.
+        </li>
+      </ul>
 
       How sessions objects are used depends on whether you use the Main API
@@ -12813,56 +12782,17 @@
 
       <ul>
-      <li>When using the COM API directly, an object of the Session class from the
-      VirtualBox type library needs to be created. In regular COM C++ client code,
-      this can be done by calling <tt>createLocalObject()</tt>, a standard COM API.
-      This object will  then act as a local session object in further calls to open
-      a session.
-      </li>
-
-      <li>In the webservice, the session manager (IWebsessionManager) instead creates
-      one session object automatically when <link to="IWebsessionManager::logon" />
-      is called. A managed object reference to that session object can be retrieved by
-      calling <link to="IWebsessionManager::getSessionObject" />. This session object
-      reference can then be used to open sessions.
-      </li>
+        <li>When using the COM API directly, an object of the Session class from the
+          VirtualBox type library needs to be created. In regular COM C++ client code,
+          this can be done by calling <tt>createLocalObject()</tt>, a standard COM API.
+          This object will  then act as a local session object in further calls to open
+          a session.
+        </li>
+
+        <li>In the webservice, the session manager (IWebsessionManager) instead creates
+          a session object automatically whenever <link to="IWebsessionManager::logon" />
+          is called. A managed object reference to that session object can be retrieved by
+          calling <link to="IWebsessionManager::getSessionObject" />.
+        </li>
       </ul>
-
-      Sessions are mainly used in two variations:
-
-      <ul>
-      <li>
-      To start a virtual machine in a separate process, one would call
-      <link to="IVirtualBox::openRemoteSession"/>, which requires a session
-      object as its first parameter. This session then identifies the caller
-      and lets him control the started machine (for example, pause machine
-      execution or power it down) as well as be notified about machine
-      execution state changes.
-      </li>
-
-      <li>To alter machine settings, or to start machine execution within the
-      current process, one needs to open a direct session for the machine first by
-      calling <link to="IVirtualBox::openSession"/>. While a direct session
-      is open within one process, no any other process may open another direct
-      session for the same machine. This prevents the machine from being changed
-      by other processes while it is running or while the machine is being configured.
-      </li>
-      </ul>
-
-      One also can attach to an existing direct session already opened by
-      another process (for example, in order to send a control request to the
-      virtual machine such as the pause or the reset request). This is done by
-      calling <link to="IVirtualBox::openExistingSession"/>.
-
-      <note>
-        Unless you are trying to write a new VirtualBox front-end that
-        performs direct machine execution (like the VirtualBox or VBoxSDL
-        front-ends), don't call <link to="IConsole::powerUp"/> in a direct
-        session opened by <link to="IVirtualBox::openSession"/> and use this
-        session only to change virtual machine settings. If you simply want to
-        start virtual machine execution using one of the existing front-ends
-        (for example the VirtualBox GUI or headless server), simply use
-        <link to="IVirtualBox::openRemoteSession"/>; these front-ends
-        will power up the machine automatically for you.
-      </note>
     </desc>
 
@@ -12874,6 +12804,6 @@
       <desc>
         Type of this session. The value of this attribute is valid only
-        if the session is currently open (i.e. its #state is
-        SessionType_SessionOpen), otherwise an error will be returned.
+        if the session is currently open (i.e. its <link to="#state" /> is
+        SessionState_SessionOpen), otherwise an error will be returned.
       </desc>
     </attribute>
@@ -12891,17 +12821,9 @@
         Closes a session that was previously opened.
 
-        It is recommended that every time an "open session" method (such as
-        <link to="IVirtualBox::openRemoteSession" /> or
-        <link to="IVirtualBox::openSession" />) has been called to
-        manipulate a virtual machine, the caller invoke
-        ISession::close() when it's done doing so. Since sessions are
-        serialization primitives much like ordinary mutexes, they are
-        best used the same way: for each "open" call, there should be
-        a matching "close" call, even when errors occur.
-
-        Otherwise, if a direct session for a machine opened with
-        <link to="IVirtualBox::openSession"/> is not explicitly closed
-        when the application terminates, the state of the machine will
-        be set to <link to="MachineState_Aborted" /> on the server.
+        Calling this method is eventually required every time a machine has been
+        locked for a particular session using the <link to="IMachine::launchVMProcess" />
+        or <link to="IMachine::lockForSession" />) calls. Otherwise the state of
+        the machine will be set to <link to="MachineState_Aborted" /> on the
+        server, and changes made to the machine settings will be lost.
 
         Generally, it is recommended to close all open sessions explicitly
Index: /trunk/src/VBox/Main/include/ApplianceImplPrivate.h
===================================================================
--- /trunk/src/VBox/Main/include/ApplianceImplPrivate.h	(revision 31007)
+++ /trunk/src/VBox/Main/include/ApplianceImplPrivate.h	(revision 31008)
@@ -127,5 +127,4 @@
 struct MyHardDiskAttachment
 {
-    Bstr                bstrUuid;
     ComPtr<IMachine>    pMachine;
     Bstr                controllerType;
Index: /trunk/src/VBox/Main/include/MachineImpl.h
===================================================================
--- /trunk/src/VBox/Main/include/MachineImpl.h	(revision 31007)
+++ /trunk/src/VBox/Main/include/MachineImpl.h	(revision 31008)
@@ -115,5 +115,5 @@
         struct Session
         {
-            /** Control of the direct session opened by openSession() */
+            /** Control of the direct session opened by lockForSession() */
             ComPtr<IInternalSessionControl> mDirectControl;
 
@@ -455,4 +455,7 @@
 
     // IMachine methods
+    STDMETHOD(LockForSession)(ISession *aSession, BOOL fPermitShared, SessionType_T *sessionType);
+    STDMETHOD(LaunchVMProcess)(ISession *aSession,  IN_BSTR aType, IN_BSTR aEnvironment, IProgress **aProgress);
+
     STDMETHOD(SetBootOrder)(ULONG aPosition, DeviceType_T aDevice);
     STDMETHOD(GetBootOrder)(ULONG aPosition, DeviceType_T *aDevice);
Index: /trunk/src/VBox/Main/include/VirtualBoxImpl.h
===================================================================
--- /trunk/src/VBox/Main/include/VirtualBoxImpl.h	(revision 31007)
+++ /trunk/src/VBox/Main/include/VirtualBoxImpl.h	(revision 31008)
@@ -155,9 +155,4 @@
     STDMETHOD(GetExtraData) (IN_BSTR aKey, BSTR *aValue);
     STDMETHOD(SetExtraData) (IN_BSTR aKey, IN_BSTR aValue);
-    STDMETHOD(OpenSession) (ISession *aSession, IN_BSTR aMachineId);
-    STDMETHOD(OpenRemoteSession) (ISession *aSession, IN_BSTR aMachineId,
-                                  IN_BSTR aType, IN_BSTR aEnvironment,
-                                  IProgress **aProgress);
-    STDMETHOD(OpenExistingSession) (ISession *aSession, IN_BSTR aMachineId);
 
     STDMETHOD(WaitForPropertyChange) (IN_BSTR aWhat, ULONG aTimeout,
Index: /trunk/src/VBox/Main/testcase/tstVBoxAPILinux.cpp
===================================================================
--- /trunk/src/VBox/Main/testcase/tstVBoxAPILinux.cpp	(revision 31007)
+++ /trunk/src/VBox/Main/testcase/tstVBoxAPILinux.cpp	(revision 31008)
@@ -266,7 +266,5 @@
         }
 
-        nsXPIDLString machineUUID;
-        machine->GetId(getter_Copies(machineUUID));
-        rc = virtualBox->OpenSession(session, machineUUID);
+        machine->LockForSession(session, false /* fPermitShared */, NULL);
         if (NS_FAILED(rc))
         {
Index: /trunk/src/VBox/Main/testcase/tstVBoxAPIWin.cpp
===================================================================
--- /trunk/src/VBox/Main/testcase/tstVBoxAPIWin.cpp	(revision 31007)
+++ /trunk/src/VBox/Main/testcase/tstVBoxAPIWin.cpp	(revision 31008)
@@ -209,6 +209,6 @@
 
             /* Start a VM session using the delivered VBox GUI. */
-            rc = virtualBox->OpenRemoteSession (session, guid, sessiontype,
-                                                NULL, &progress);
+            rc = machine->LaunchVMProcess(session, sessiontype,
+                                          NULL, &progress);
             if (!SUCCEEDED(rc))
             {
Index: /trunk/src/VBox/Main/webservice/samples/java/jax-ws/clienttest.java
===================================================================
--- /trunk/src/VBox/Main/webservice/samples/java/jax-ws/clienttest.java	(revision 31007)
+++ /trunk/src/VBox/Main/webservice/samples/java/jax-ws/clienttest.java	(revision 31008)
@@ -227,8 +227,7 @@
                 String env = "DISPLAY=:0.0";
                 IProgress oProgress =
-                    vbox.openRemoteSession(oSession,
-                                            uuid,
-                                            sessionType,
-                                            env);
+                    oMachine.launchVMProcess(oSession,
+                                             sessionType,
+                                             env);
                 System.out.println("Session for VM " + uuid + " is opening...");
                 oProgress.waitForCompletion(10000);
Index: /trunk/src/libs/xpcom18a4/java/src/org/virtualbox/VirtualBoxManager.java
===================================================================
--- /trunk/src/libs/xpcom18a4/java/src/org/virtualbox/VirtualBoxManager.java	(revision 31007)
+++ /trunk/src/libs/xpcom18a4/java/src/org/virtualbox/VirtualBoxManager.java	(revision 31008)
@@ -106,8 +106,7 @@
 
 
-        String mid = m.getId();
         if (type == null)
             type = "gui";
-        IProgress p = vbox.openRemoteSession(session, mid, type, "");
+        IProgress p = m.openRemoteSession(session, type, "");
         progressBar(p, timeout);
         session.close();
