Index: /trunk/src/VBox/Frontends/VBoxShell/vboxshell.py
===================================================================
--- /trunk/src/VBox/Frontends/VBoxShell/vboxshell.py	(revision 31013)
+++ /trunk/src/VBox/Frontends/VBoxShell/vboxshell.py	(revision 31014)
@@ -233,6 +233,5 @@
     perf = ctx['perf']
     session = mgr.getSessionObject(vb)
-    uuid = mach.id
-    progress = vb.openRemoteSession(session, uuid, type, "")
+    progress = mach.launchVMProcess(session, type, "")
     if progressBar(ctx, progress, 100) and int(progress.resultCode) == 0:
         # we ignore exceptions to allow starting VM even if
@@ -492,5 +491,5 @@
         vb = ctx['vb']
         session = ctx['mgr'].getSessionObject(vb)
-        vb.openExistingSession(session, mach.id)
+        mach.lockForSession(session, True)
     except Exception,e:
         printErr(ctx, "Session to '%s' not open: %s" %(mach.name,str(e)))
@@ -498,5 +497,5 @@
             traceback.print_exc()
         return
-    if session.state != ctx['const'].SessionState_Open:
+    if session.state != ctx['const'].SessionState_Locked:
         print "Session to '%s' in wrong state: %s" %(mach.name, session.state)
         session.close()
@@ -536,5 +535,5 @@
 
 def cmdClosedVm(ctx,mach,cmd,args=[],save=True):
-    session = ctx['global'].openMachineSession(mach.id)
+    session = ctx['global'].openMachineSession(mach, False)
     mach = session.machine
     try:
@@ -551,5 +550,5 @@
 
 def cmdAnyVm(ctx,mach,cmd, args=[],save=False):
-    session = ctx['global'].openMachineSession(mach.id)
+    session = ctx['global'].openMachineSession(mach)
     mach = session.machine
     try:
@@ -1039,5 +1038,5 @@
     if mach == None:
         return 0
-    if str(mach.sessionState) != str(ctx['const'].SessionState_Open):
+    if str(mach.sessionState) != str(ctx['const'].SessionState_Locked):
         cmdClosedVm(ctx, mach, lambda ctx, mach, a: guestExec (ctx, mach, None, ' '.join(args[2:])))
     else:
@@ -1129,5 +1128,5 @@
     if mach == None:
         return 0
-    if str(mach.sessionState) != str(ctx['const'].SessionState_Open):
+    if str(mach.sessionState) != str(ctx['const'].SessionState_Locked):
         if mach.CPUHotPlugEnabled:
             cmdClosedVm(ctx, mach, plugcpu, [True, int(args[2])])
@@ -1143,5 +1142,5 @@
     if mach == None:
         return 0
-    if str(mach.sessionState) != str(ctx['const'].SessionState_Open):
+    if str(mach.sessionState) != str(ctx['const'].SessionState_Locked):
         if mach.CPUHotPlugEnabled:
             cmdClosedVm(ctx, mach, plugcpu, [False, int(args[2])])
@@ -1348,5 +1347,5 @@
     guestPort = int(args[4])
     proto = "TCP"
-    session = ctx['global'].openMachineSession(mach.id)
+    session = ctx['global'].openMachineSession(mach)
     mach = session.machine
 
@@ -2533,5 +2532,5 @@
     if len(cmdargs) > 1:
         rosession = 0
-        session = ctx['global'].openMachineSession(mach.id);
+        session = ctx['global'].openMachineSession(mach, False);
         mach = session.machine;
 
@@ -2710,5 +2709,5 @@
     func = args[3]
     session = None
-    session = ctx['global'].openMachineSession(vm.id)
+    session = ctx['global'].openMachineSession(vm)
     vm = session.machine
     adapter = vm.getNetworkAdapter(nicnum)
Index: /trunk/src/VBox/Main/glue/vboxapi.py
===================================================================
--- /trunk/src/VBox/Main/glue/vboxapi.py	(revision 31013)
+++ /trunk/src/VBox/Main/glue/vboxapi.py	(revision 31014)
@@ -519,10 +519,7 @@
         self.platform.initPerThread()
 
-    def openMachineSession(self, machineId):
+    def openMachineSession(self, mach, permitSharing = True):
          session = self.mgr.getSessionObject(self.vbox)
-         try:
-             self.vbox.openExistingSession(session, machineId)
-         except:
-             self.vbox.openSession(session, machineId)
+         mach.lockForSession(session, permitSharing)
          return session
 
