Changeset 31008 in vbox
- Timestamp:
- Jul 22, 2010 3:24:27 PM (15 years ago)
- svn:sync-xref-src-repo-rev:
- 63924
- Location:
- trunk/src
- Files:
-
- 38 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxHeadless/VBoxHeadless.cpp
r30871 r31008 803 803 } 804 804 805 ComPtr<IMachine> m; 806 805 807 /* find ID by name */ 806 808 if (id.isEmpty()) 807 809 { 808 ComPtr <IMachine> m;809 810 rc = virtualBox->FindMachine(Bstr(name), m.asOutParam()); 810 811 if (FAILED(rc)) … … 823 824 824 825 // open a session 825 CHECK_ERROR_BREAK( virtualBox, OpenSession(session, id));826 CHECK_ERROR_BREAK(m, LockForSession(session, false /* fPermitShared */, NULL)); 826 827 fSessionOpened = true; 827 828 828 829 /* get the console */ 829 ComPtr 830 ComPtr<IConsole> console; 830 831 CHECK_ERROR_BREAK(session, COMGETTER(Console)(console.asOutParam())); 831 832 832 /* get the m achine */833 ComPtr 833 /* get the mutable machine */ 834 ComPtr<IMachine> machine; 834 835 CHECK_ERROR_BREAK(console, COMGETTER(Machine)(machine.asOutParam())); 835 836 836 ComPtr 837 ComPtr<IDisplay> display; 837 838 CHECK_ERROR_BREAK(console, COMGETTER(Display)(display.asOutParam())); 838 839 -
trunk/src/VBox/Frontends/VBoxHeadless/testcase/tstHeadless.cpp
r30681 r31008 112 112 EventQueue eventQ; 113 113 114 ComPtr <IMachine> m; 115 114 116 // find ID by name 115 Bstr id; 116 { 117 ComPtr <IMachine> m; 118 CHECK_ERROR_BREAK (virtualBox, FindMachine (Bstr (name), m.asOutParam())); 119 CHECK_ERROR_BREAK (m, COMGETTER(Id) (id.asOutParam())); 120 } 121 122 if (!strcmp (operation, "on")) 117 CHECK_ERROR_BREAK(virtualBox, FindMachine(Bstr(name), m.asOutParam())); 118 119 if (!strcmp(operation, "on")) 123 120 { 124 121 ComPtr <IProgress> progress; 125 122 RTPrintf ("Opening a new (remote) session...\n"); 126 CHECK_ERROR_BREAK ( virtualBox,127 OpenRemoteSession (session, id, Bstr("vrdp"),128 123 CHECK_ERROR_BREAK (m, 124 LaunchVMProcess(session, Bstr("vrdp"), 125 NULL, progress.asOutParam())); 129 126 130 127 RTPrintf ("Waiting for the remote session to open...\n"); … … 153 150 { 154 151 RTPrintf ("Opening an existing session...\n"); 155 CHECK_ERROR_BREAK (virtualBox, OpenExistingSession (session, id));152 CHECK_ERROR_BREAK(m, LockForSession(session, true /* fPermitShared */, NULL)); 156 153 157 154 ComPtr <IConsole> console; 158 CHECK_ERROR_BREAK (session, COMGETTER (Console)(console.asOutParam()));155 CHECK_ERROR_BREAK(session, COMGETTER(Console)(console.asOutParam())); 159 156 160 157 if (!strcmp (operation, "off")) -
trunk/src/VBox/Frontends/VBoxManage/VBoxInternalManage.cpp
r30321 r31008 1864 1864 CHECK_ERROR_RET(aVirtualBox, FindMachine(Bstr(argv[0]), ptrMachine.asOutParam()), 1); 1865 1865 1866 Bstr bstrMachineUuid; 1867 CHECK_ERROR_RET(ptrMachine, COMGETTER(Id)(bstrMachineUuid.asOutParam()), 1); 1868 CHECK_ERROR_RET(aVirtualBox, OpenExistingSession(aSession, bstrMachineUuid), 1); 1866 CHECK_ERROR_RET(ptrMachine, LockForSession(aSession, true /* fPermitShared */, NULL), 1); 1869 1867 1870 1868 /* -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageControlVM.cpp
r30396 r31008 73 73 /* try to find the given machine */ 74 74 ComPtr <IMachine> machine; 75 Bstr machineuuid 75 Bstr machineuuid(a->argv[0]); 76 76 if (!Guid(machineuuid).isEmpty()) 77 77 { … … 88 88 89 89 /* open a session for the VM */ 90 CHECK_ERROR_RET( a->virtualBox, OpenExistingSession(a->session, machineuuid), 1);90 CHECK_ERROR_RET(machine, LockForSession(a->session, true /* fPermitShared */, NULL), 1); 91 91 92 92 do -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageGuestCtrl.cpp
r30681 r31008 285 285 do 286 286 { 287 Bstr uuid; 288 machine->COMGETTER(Id)(uuid.asOutParam()); 289 290 /* open an existing session for VM - so the VM has to be running */ 291 CHECK_ERROR_BREAK(a->virtualBox, OpenExistingSession(a->session, uuid)); 287 /* open an existing session for VM */ 288 CHECK_ERROR_BREAK(machine, LockForSession(a->session, true /* fPermitShared */, NULL)); 289 // @todo r=dj assert that it's an existing session 292 290 293 291 /* get the mutable session machine */ -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageGuestProp.cpp
r30871 r31008 87 87 if (machine) 88 88 { 89 Bstr uuid;90 machine->COMGETTER(Id)(uuid.asOutParam());91 92 89 /* open a session for the VM - new or existing */ 93 if (FAILED (a->virtualBox->OpenSession(a->session, uuid))) 94 CHECK_ERROR_RET(a->virtualBox, OpenExistingSession(a->session, uuid), 1); 90 CHECK_ERROR_RET(machine, LockForSession(a->session, true /* fPermitShared */, NULL), 1); 95 91 96 92 /* get the mutable session machine */ … … 156 152 if (machine) 157 153 { 158 Bstr uuid;159 machine->COMGETTER(Id)(uuid.asOutParam());160 161 154 /* open a session for the VM - new or existing */ 162 if (FAILED (a->virtualBox->OpenSession(a->session, uuid))) 163 CHECK_ERROR_RET (a->virtualBox, OpenExistingSession(a->session, uuid), 1); 155 CHECK_ERROR_RET(machine, LockForSession(a->session, true /* fPermitShared */, NULL), 1); 164 156 165 157 /* get the mutable session machine */ … … 220 212 if (machine) 221 213 { 222 Bstr uuid;223 machine->COMGETTER(Id)(uuid.asOutParam());224 225 214 /* open a session for the VM - new or existing */ 226 if (FAILED(a->virtualBox->OpenSession(a->session, uuid))) 227 CHECK_ERROR_RET (a->virtualBox, OpenExistingSession(a->session, uuid), 1); 215 CHECK_ERROR_RET(machine, LockForSession(a->session, true /* fPermitShared */, NULL), 1); 228 216 229 217 /* get the mutable session machine */ 230 218 a->session->COMGETTER(Machine)(machine.asOutParam()); 231 219 232 com::SafeArray 233 com::SafeArray 234 com::SafeArray 235 com::SafeArray 220 com::SafeArray<BSTR> names; 221 com::SafeArray<BSTR> values; 222 com::SafeArray<ULONG64> timestamps; 223 com::SafeArray<BSTR> flags; 236 224 CHECK_ERROR(machine, EnumerateGuestProperties(Bstr(Utf8Patterns), 237 225 ComSafeArrayAsOutParam(names), -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageInfo.cpp
r30976 r31008 2132 2132 details = VMINFO_STANDARD; 2133 2133 2134 ComPtr 2134 ComPtr<IConsole> console; 2135 2135 2136 2136 /* open an existing session for the VM */ 2137 rc = a->virtualBox->OpenExistingSession(a->session, uuid);2137 rc = machine->LockForSession(a->session, true /* fPermitShared */, NULL); 2138 2138 if (SUCCEEDED(rc)) 2139 2139 /* get the session machine */ -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageMisc.cpp
r31002 r31008 356 356 if (machine) 357 357 { 358 Bstr uuid;359 machine->COMGETTER(Id)(uuid.asOutParam());360 361 362 358 Bstr env; 363 359 #if defined(RT_OS_LINUX) || defined(RT_OS_SOLARIS) … … 373 369 #endif 374 370 ComPtr<IProgress> progress; 375 CHECK_ERROR_RET(a->virtualBox, OpenRemoteSession(a->session, uuid, sessionType, 376 env, progress.asOutParam()), rc); 371 CHECK_ERROR_RET(machine, LaunchVMProcess(a->session, sessionType, env, progress.asOutParam()), rc); 377 372 RTPrintf("Waiting for the VM to power on...\n"); 378 373 CHECK_ERROR_RET(progress, WaitForCompletion(-1), 1); … … 423 418 { 424 419 /* we have to open a session for this task */ 425 Bstr guid; 426 machine->COMGETTER(Id)(guid.asOutParam()); 427 CHECK_ERROR_BREAK(a->virtualBox, OpenSession(a->session, guid)); 420 CHECK_ERROR_BREAK(machine, LockForSession(a->session, false /* fPermitShared */, NULL)); 428 421 do 429 422 { … … 459 452 { 460 453 /* we have to open a session for this task */ 461 Bstr guid; 462 machine->COMGETTER(Id)(guid.asOutParam()); 463 CHECK_ERROR_BREAK(a->virtualBox, OpenSession(a->session, guid)); 454 CHECK_ERROR_BREAK(machine, LockForSession(a->session, false /* fPermitShared */, NULL)); 464 455 do 465 456 { … … 671 662 if (!machine) 672 663 return 1; 673 Bstr uuid;674 machine->COMGETTER(Id)(uuid.asOutParam());675 664 676 665 if (!strcmp(a->argv[0], "add")) … … 737 726 738 727 /* open an existing session for the VM */ 739 CHECK_ERROR_RET( a->virtualBox, OpenExistingSession(a->session, uuid), 1);728 CHECK_ERROR_RET(machine, LockForSession(a->session, true /* fPermitShared */, NULL), 1); 740 729 /* get the session machine */ 741 730 CHECK_ERROR_RET(a->session, COMGETTER(Machine)(machine.asOutParam()), 1); … … 751 740 { 752 741 /* open a session for the VM */ 753 CHECK_ERROR_RET( a->virtualBox, OpenSession(a->session, uuid), 1);742 CHECK_ERROR_RET(machine, LockForSession(a->session, false /* fPermitShared */, NULL), 1); 754 743 755 744 /* get the mutable session machine */ … … 801 790 802 791 /* open an existing session for the VM */ 803 CHECK_ERROR_RET( a->virtualBox, OpenExistingSession(a->session, uuid), 1);792 CHECK_ERROR_RET(machine, LockForSession(a->session, true /* fPermitShared */, NULL), 1); 804 793 /* get the session machine */ 805 794 CHECK_ERROR_RET(a->session, COMGETTER(Machine)(machine.asOutParam()), 1); … … 815 804 { 816 805 /* open a session for the VM */ 817 CHECK_ERROR_RET( a->virtualBox, OpenSession(a->session, uuid), 1);806 CHECK_ERROR_RET(machine, LockForSession(a->session, false /* fPermitShared */, NULL), 1); 818 807 819 808 /* get the mutable session machine */ … … 842 831 843 832 /* try to find the given machine */ 844 ComPtr 845 Bstr uuid 846 if (!Guid 833 ComPtr<IMachine> machine; 834 Bstr uuid(a->argv[0]); 835 if (!Guid(a->argv[0]).isEmpty()) 847 836 CHECK_ERROR(a->virtualBox, GetMachine(uuid, machine.asOutParam())); 848 837 else 849 838 { 850 839 CHECK_ERROR(a->virtualBox, FindMachine(Bstr(a->argv[0]), machine.asOutParam())); 851 if (SUCCEEDED 840 if (SUCCEEDED(rc)) 852 841 machine->COMGETTER(Id)(uuid.asOutParam()); 853 842 } … … 885 874 886 875 /* open an existing session for the VM. */ 887 CHECK_ERROR( a->virtualBox, OpenExistingSession(a->session, uuid));876 CHECK_ERROR(machine, LockForSession(a->session, true /* fPermitShared */, NULL)); 888 877 if (SUCCEEDED(rc)) 889 878 { -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageModifyVM.cpp
r30976 r31008 275 275 HRESULT rc; 276 276 Bstr name; 277 Bstr machineuuid 277 Bstr machineuuid(a->argv[0]); 278 278 RTGETOPTUNION ValueUnion; 279 279 RTGETOPTSTATE GetOptState; … … 312 312 313 313 /* open a session for the VM */ 314 CHECK_ERROR_RET( a->virtualBox, OpenSession(a->session, machineuuid), 1);314 CHECK_ERROR_RET(machine, LockForSession(a->session, false /* fPermitShared */, NULL), 1); 315 315 316 316 /* get the mutable session machine */ -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageSnapshot.cpp
r28870 r31008 236 236 if (!pMachine) 237 237 return 1; 238 Bstr guidMachine;239 pMachine->COMGETTER(Id)(guidMachine.asOutParam());240 238 241 239 do 242 240 { 243 /* we have to open a session for this task. First try an existing session */ 244 rc = a->virtualBox->OpenExistingSession(a->session, guidMachine); 245 if (FAILED(rc)) 246 CHECK_ERROR_BREAK(a->virtualBox, OpenSession(a->session, guidMachine)); 241 /* we have to open a session for this task (new or shared) */ 242 rc = pMachine->LockForSession(a->session, true /* fPermitShared */, NULL); 247 243 ComPtr<IConsole> console; 248 244 CHECK_ERROR_BREAK(a->session, COMGETTER(Console)(console.asOutParam())); -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageStorageController.cpp
r30403 r31008 60 60 ULONG port = ~0U; 61 61 ULONG device = ~0U; 62 bool fRunTime = false;63 62 bool fForceUnmount = false; 64 63 const char *pszCtl = NULL; … … 148 147 } 149 148 } 150 149 151 150 if (FAILED(rc)) 152 151 return 1; … … 173 172 } 174 173 175 /* open a session for the VM */ 176 rc = a->virtualBox->OpenSession(a->session, machineuuid); 177 if (FAILED(rc)) 178 { 179 /* try to open an existing session for the VM */ 180 CHECK_ERROR_RET(a->virtualBox, OpenExistingSession(a->session, machineuuid), 1); 181 fRunTime = true; 182 } 183 174 /* open a session for the VM (new or shared) */ 175 SessionType_T type; 176 rc = machine->LockForSession(a->session, true /* fPermitShared */, &type); 177 bool fRunTime = (type == SessionType_Shared); 184 178 if (fRunTime && !RTStrICmp(pszType, "hdd")) 185 179 { … … 761 755 762 756 /* open a session for the VM */ 763 CHECK_ERROR_RET( a->virtualBox, OpenSession (a->session, machineuuid), 1);757 CHECK_ERROR_RET(machine, LockForSession(a->session, false /* fPermitShared */, NULL), 1); 764 758 765 759 /* get the mutable session machine */ -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageUSB.cpp
r28800 r31008 416 416 else 417 417 { 418 Bstr uuid;419 cmd.mMachine->COMGETTER(Id)(uuid.asOutParam());420 418 /* open a session for the VM */ 421 CHECK_ERROR_RET (a->virtualBox, OpenSession(a->session, uuid), 1);419 CHECK_ERROR_RET(cmd.mMachine, LockForSession(a->session, false /* fPermitShared */, NULL), 1); 422 420 /* get the mutable session machine */ 423 421 a->session->COMGETTER(Machine)(cmd.mMachine.asOutParam()); 424 422 /* and get the USB controller */ 425 CHECK_ERROR_RET (cmd.mMachine, COMGETTER(USBController)(ctl.asOutParam()), 1);423 CHECK_ERROR_RET(cmd.mMachine, COMGETTER(USBController)(ctl.asOutParam()), 1); 426 424 } 427 425 -
trunk/src/VBox/Frontends/VBoxSDL/VBoxSDL.cpp
r30871 r31008 1316 1316 const CLSID sessionID = CLSID_Session; 1317 1317 1318 ComPtr<IMachine> pMachine; 1319 1318 1320 rc = virtualBox.createLocalObject(CLSID_VirtualBox); 1319 1321 if (FAILED(rc)) … … 1339 1341 if (vmName && uuidVM.isEmpty()) 1340 1342 { 1341 ComPtr<IMachine> aMachine;1342 1343 Bstr bstrVMName = vmName; 1343 rc = virtualBox->FindMachine(bstrVMName, aMachine.asOutParam());1344 if ((rc == S_OK) && aMachine)1344 rc = virtualBox->FindMachine(bstrVMName, pMachine.asOutParam()); 1345 if ((rc == S_OK) && pMachine) 1345 1346 { 1346 1347 Bstr id; 1347 aMachine->COMGETTER(Id)(id.asOutParam());1348 pMachine->COMGETTER(Id)(id.asOutParam()); 1348 1349 uuidVM = Guid(id); 1349 1350 } … … 1364 1365 AssertReleaseRC(vrc); 1365 1366 1366 rc = virtualBox->OpenSession(session, uuidVM.toUtf16());1367 rc = pMachine->LockForSession(session, false /* fPermitShared */, NULL); 1367 1368 if (FAILED(rc)) 1368 1369 { … … 1379 1380 } 1380 1381 sessionOpened = true; 1381 // get the VM we're dealing with1382 // get the mutable VM we're dealing with 1382 1383 session->COMGETTER(Machine)(gMachine.asOutParam()); 1383 1384 if (!gMachine) -
trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp
r30976 r31008 2166 2166 * session. 2167 2167 */ 2168 CSession VBoxGlobal::openSession 2168 CSession VBoxGlobal::openSession(const QString &aId, bool aExisting /* = false */) 2169 2169 { 2170 2170 CSession session; 2171 session.createInstance 2171 session.createInstance(CLSID_Session); 2172 2172 if (session.isNull()) 2173 2173 { … … 2176 2176 } 2177 2177 2178 if (aExisting) 2179 mVBox.OpenExistingSession (session, aId); 2180 else 2181 { 2182 mVBox.OpenSession (session, aId); 2183 CMachine machine = session.GetMachine (); 2184 /* Make sure that the language is in two letter code. 2185 * Note: if languageId() returns an empty string lang.name() will 2186 * return "C" which is an valid language code. */ 2187 QLocale lang (VBoxGlobal::languageId()); 2188 machine.SetGuestPropertyValue ("/VirtualBox/HostInfo/GUI/LanguageID", lang.name()); 2178 CMachine foundMachine = CVirtualBox(mVBox).GetMachine(aId); 2179 if (!foundMachine.isNull()) 2180 { 2181 KSessionType t = foundMachine.LockForSession(session, aExisting /* fPermitShared */); 2182 if (t == KSessionType_Shared) 2183 { 2184 CMachine machine = session.GetMachine(); 2185 /* Make sure that the language is in two letter code. 2186 * Note: if languageId() returns an empty string lang.name() will 2187 * return "C" which is an valid language code. */ 2188 QLocale lang(VBoxGlobal::languageId()); 2189 machine.SetGuestPropertyValue ("/VirtualBox/HostInfo/GUI/LanguageID", lang.name()); 2190 } 2189 2191 } 2190 2192 2191 2193 if (!mVBox.isOk()) 2192 2194 { 2193 CMachine machine = CVirtualBox (mVBox).GetMachine (aId); 2194 vboxProblem().cannotOpenSession (mVBox, machine); 2195 vboxProblem().cannotOpenSession(mVBox, foundMachine); 2195 2196 session.detach(); 2196 2197 } … … 2667 2668 mMachineStates [KMachineState_SettingUp] = tr ("Setting Up", "MachineState"); 2668 2669 2669 mSessionStates [KSessionState_ Closed] = tr ("Closed", "SessionState");2670 mSessionStates [KSessionState_ Open] = tr ("Open", "SessionState");2670 mSessionStates [KSessionState_Unlocked] = tr ("Unlocked", "SessionState"); 2671 mSessionStates [KSessionState_Locked] = tr ("Locked", "SessionState"); 2671 2672 mSessionStates [KSessionState_Spawning] = tr ("Spawning", "SessionState"); 2672 mSessionStates [KSessionState_ Closing] = tr ("Closing", "SessionState");2673 mSessionStates [KSessionState_Unlocking] = tr ("Unlocking", "SessionState"); 2673 2674 2674 2675 mDeviceTypes [KDeviceType_Null] = tr ("None", "DeviceType"); -
trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.h
r30677 r31008 510 510 #endif 511 511 512 CSession openSession 512 CSession openSession(const QString &aId, bool aExisting = false); 513 513 514 514 /** Shortcut to openSession (aId, true). */ 515 CSession openExistingSession 515 CSession openExistingSession(const QString &aId) { return openSession (aId, true); } 516 516 517 517 bool startMachine(const QString &strId); -
trunk/src/VBox/Frontends/VirtualBox/src/selector/UIVMDesktop.cpp
r30905 r31008 933 933 { 934 934 KMachineState state = m_machine.GetState(); 935 bool running = m_machine.GetSessionState() != KSessionState_ Closed;935 bool running = m_machine.GetSessionState() != KSessionState_Unlocked; 936 936 m_fChangeable = !running && state != KMachineState_Saved; 937 937 } … … 1253 1253 { 1254 1254 bool saved = m_pVMItem->state() == KMachineState_Saved; 1255 bool busy = m_pVMItem->sessionState() != KSessionState_ Closed;1255 bool busy = m_pVMItem->sessionState() != KSessionState_Unlocked; 1256 1256 m_pEditBtn->setEnabled(!saved && !busy); 1257 1257 } -
trunk/src/VBox/Frontends/VirtualBox/src/selector/UIVMListView.cpp
r30868 r31008 215 215 QFont f = qApp->font(); 216 216 f.setPointSize(f.pointSize()); 217 if (m_VMItemList.at(aIndex.row())->sessionState() != KSessionState_ Closed)217 if (m_VMItemList.at(aIndex.row())->sessionState() != KSessionState_Unlocked) 218 218 f.setItalic(true); 219 219 v = f; -
trunk/src/VBox/Frontends/VirtualBox/src/selector/UIVMPreviewWindow.cpp
r30981 r31008 245 245 { 246 246 CVirtualBox vbox = vboxGlobal().virtualBox(); 247 vbox.OpenExistingSession(session, m_machine.GetId());247 m_machine.LockForSession(session, true /* fPermitShared */); 248 248 if (vbox.isOk()) 249 249 { -
trunk/src/VBox/Frontends/VirtualBox/src/selector/VBoxSelectorWnd.cpp
r30956 r31008 757 757 #endif 758 758 759 CProgress progress = vbox.OpenRemoteSession (session, id, "GUI/Qt", env);759 CProgress progress = item->machine().LaunchVMProcess(session, "GUI/Qt", env); 760 760 if (!vbox.isOk()) 761 761 { 762 vboxProblem().cannotOpenSession 762 vboxProblem().cannotOpenSession(vbox, item->machine()); 763 763 return; 764 764 } … … 791 791 if (session.isNull()) 792 792 { 793 vboxProblem().cannotOpenSession 793 vboxProblem().cannotOpenSession(session); 794 794 return; 795 795 } 796 vbox.OpenSession (session, id); 796 797 CMachine foundMachine = vbox.GetMachine(id); 798 if (!foundMachine.isNull()) 799 foundMachine.LockForSession(session, false /* fPermitShared */); 797 800 if (!vbox.isOk()) 798 801 { … … 1188 1191 1189 1192 KMachineState state = item->state(); 1190 bool running = item->sessionState() != KSessionState_ Closed;1193 bool running = item->sessionState() != KSessionState_Unlocked; 1191 1194 bool modifyEnabled = !running && state != KMachineState_Saved; 1192 1195 … … 1615 1618 CMachine m = pItem->machine(); 1616 1619 KMachineState s = pItem->state(); 1617 bool running = pItem->sessionState() != KSessionState_ Closed;1620 bool running = pItem->sessionState() != KSessionState_Unlocked; 1618 1621 bool modifyEnabled = !running && s != KMachineState_Saved; 1619 1622 -
trunk/src/VBox/Frontends/VirtualBox/src/selector/VBoxSnapshotsWgt.cpp
r30868 r31008 444 444 445 445 /* Whether another direct session is open or not */ 446 bool busy = mSessionState != KSessionState_ Closed;446 bool busy = mSessionState != KSessionState_Unlocked; 447 447 448 448 /* Machine state of the current state item */ … … 571 571 572 572 /* Open a direct session (this call will handle all errors) */ 573 bool busy = mSessionState != KSessionState_ Closed;573 bool busy = mSessionState != KSessionState_Unlocked; 574 574 CSession session = vboxGlobal().openSession (mMachineId, busy /* aExisting */); 575 575 if (session.isNull()) … … 641 641 { 642 642 /* Open a direct session (this call will handle all errors) */ 643 bool busy = mSessionState != KSessionState_ Closed;643 bool busy = mSessionState != KSessionState_Unlocked; 644 644 CSession session = vboxGlobal().openSession (mMachineId, busy /* aExisting */); 645 645 if (session.isNull()) -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/exportappliance/UIExportApplianceWzd.cpp
r29730 r31008 181 181 strName = m.GetName(); 182 182 strUuid = m.GetId(); 183 bEnabled = m.GetSessionState() == KSessionState_ Closed;183 bEnabled = m.GetSessionState() == KSessionState_Unlocked; 184 184 } 185 185 else -
trunk/src/VBox/Main/ApplianceImplImport.cpp
r30956 r31008 1233 1233 { 1234 1234 const MyHardDiskAttachment &mhda = *itM; 1235 Bstr bstrUuid(mhda.bstrUuid); // make a copy, Windows can't handle const Bstr 1236 rc2 = mVirtualBox->OpenSession(stack.pSession, bstrUuid); 1235 rc2 = mhda.pMachine->LockForSession(stack.pSession, false /* fPermitShared */, NULL); 1237 1236 if (SUCCEEDED(rc2)) 1238 1237 { … … 1761 1760 { 1762 1761 // to attach things we need to open a session for the new machine 1763 rc = mVirtualBox->OpenSession(stack.pSession, bstrNewMachineId);1762 rc = pNewMachine->LockForSession(stack.pSession, false /* fPermitShared */, NULL); 1764 1763 if (FAILED(rc)) DebugBreakThrow(rc); 1765 1764 stack.fSessionOpen = true; … … 1782 1781 // this is for rollback later 1783 1782 MyHardDiskAttachment mhda; 1784 mhda.bstrUuid = bstrNewMachineId;1785 1783 mhda.pMachine = pNewMachine; 1786 1784 mhda.controllerType = bstrName; … … 1828 1826 // this is for rollback later 1829 1827 MyHardDiskAttachment mhda; 1830 mhda.bstrUuid = bstrNewMachineId;1831 1828 mhda.pMachine = pNewMachine; 1832 1829 … … 1875 1872 { 1876 1873 // to attach things we need to open a session for the new machine 1877 rc = mVirtualBox->OpenSession(stack.pSession, bstrNewMachineId);1874 rc = pNewMachine->LockForSession(stack.pSession, false /* fPermitShared */, NULL); 1878 1875 if (FAILED(rc)) DebugBreakThrow(rc); 1879 1876 stack.fSessionOpen = true; … … 1921 1918 // this is for rollback later 1922 1919 MyHardDiskAttachment mhda; 1923 mhda.bstrUuid = bstrNewMachineId;1924 1920 mhda.pMachine = pNewMachine; 1925 1921 -
trunk/src/VBox/Main/ConsoleImpl.cpp
r31002 r31008 5664 5664 * which can lead to various unexpected results (like the machine 5665 5665 * state being >= MachineState_Running on the server, while the 5666 * session state is already SessionState_ Closed at the same time5666 * session state is already SessionState_Unlocked at the same time 5667 5667 * there). 5668 5668 * -
trunk/src/VBox/Main/Global.cpp
r30825 r31008 364 364 { 365 365 case SessionState_Null: return "Null"; 366 case SessionState_ Closed: return "Closed";367 case SessionState_ Open: return "Open";366 case SessionState_Unlocked: return "Unlocked"; 367 case SessionState_Locked: return "Locked"; 368 368 case SessionState_Spawning: return "Spawning"; 369 case SessionState_ Closing: return "Closing";369 case SessionState_Unlocking: return "Unlocking"; 370 370 default: 371 371 { -
trunk/src/VBox/Main/MachineImpl.cpp
r31002 r31008 116 116 117 117 mSession.mPid = NIL_RTPROCESS; 118 mSession.mState = SessionState_ Closed;118 mSession.mState = SessionState_Unlocked; 119 119 } 120 120 … … 2676 2676 2677 2677 return S_OK; 2678 } 2679 2680 /** 2681 * @note Locks objects! 2682 */ 2683 STDMETHODIMP Machine::LockForSession(ISession *aSession, 2684 BOOL fPermitShared, 2685 SessionType_T *pSessionType) 2686 { 2687 CheckComArgNotNull(aSession); 2688 2689 AutoCaller autoCaller(this); 2690 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 2691 2692 /* check the session state */ 2693 SessionState_T state; 2694 HRESULT rc = aSession->COMGETTER(State)(&state); 2695 if (FAILED(rc)) return rc; 2696 2697 if (state != SessionState_Unlocked) 2698 return setError(VBOX_E_INVALID_OBJECT_STATE, 2699 tr("The given session is busy")); 2700 2701 /* get the IInternalSessionControl interface */ 2702 ComPtr<IInternalSessionControl> control = aSession; 2703 ComAssertMsgRet(!!control, ("No IInternalSessionControl interface"), 2704 E_INVALIDARG); 2705 2706 rc = openSession(control); 2707 2708 if (FAILED(rc) && fPermitShared) 2709 // try again @todo r=dj check exact error code! 2710 rc = openExistingSession(control); 2711 2712 if (SUCCEEDED(rc)) 2713 { 2714 /* 2715 * tell the client watcher thread to update the set of 2716 * machines that have open sessions 2717 */ 2718 mParent->updateClientWatcher(); 2719 2720 /* fire an event */ 2721 mParent->onSessionStateChange(getId(), SessionState_Locked); 2722 2723 // return session type to caller 2724 if (pSessionType) 2725 aSession->COMGETTER(Type)(pSessionType); 2726 } 2727 2728 return rc; 2729 } 2730 2731 /** 2732 * @note Locks objects! 2733 */ 2734 STDMETHODIMP Machine::LaunchVMProcess(ISession *aSession, 2735 IN_BSTR aType, 2736 IN_BSTR aEnvironment, 2737 IProgress **aProgress) 2738 { 2739 CheckComArgNotNull(aSession); 2740 CheckComArgStrNotEmptyOrNull(aType); 2741 CheckComArgOutSafeArrayPointerValid(aProgress); 2742 2743 AutoCaller autoCaller(this); 2744 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 2745 2746 /* check the session state */ 2747 SessionState_T state; 2748 HRESULT rc = aSession->COMGETTER(State)(&state); 2749 if (FAILED(rc)) return rc; 2750 2751 if (state != SessionState_Unlocked) 2752 return setError(VBOX_E_INVALID_OBJECT_STATE, 2753 tr("The given session is busy")); 2754 2755 /* get the IInternalSessionControl interface */ 2756 ComPtr<IInternalSessionControl> control = aSession; 2757 ComAssertMsgRet(!!control, ("No IInternalSessionControl interface"), 2758 E_INVALIDARG); 2759 2760 /* get the teleporter enable state for the progress object init. */ 2761 BOOL fTeleporterEnabled; 2762 rc = COMGETTER(TeleporterEnabled)(&fTeleporterEnabled); 2763 if (FAILED(rc)) 2764 return rc; 2765 2766 /* create a progress object */ 2767 ComObjPtr<ProgressProxy> progress; 2768 progress.createObject(); 2769 rc = progress->init(mParent, 2770 static_cast<IMachine*>(this), 2771 Bstr(tr("Spawning session")), 2772 TRUE /* aCancelable */, 2773 fTeleporterEnabled ? 20 : 10 /* uTotalOperationsWeight */, 2774 Bstr(tr("Spawning session")), 2775 2 /* uFirstOperationWeight */, 2776 fTeleporterEnabled ? 3 : 1 /* cOtherProgressObjectOperations */); 2777 if (SUCCEEDED(rc)) 2778 { 2779 rc = openRemoteSession(control, aType, aEnvironment, progress); 2780 if (SUCCEEDED(rc)) 2781 { 2782 progress.queryInterfaceTo(aProgress); 2783 2784 /* signal the client watcher thread */ 2785 mParent->updateClientWatcher(); 2786 2787 /* fire an event */ 2788 mParent->onSessionStateChange(getId(), SessionState_Spawning); 2789 } 2790 } 2791 2792 return rc; 2678 2793 } 2679 2794 … … 3697 3812 3698 3813 MediaList llMedia; 3699 if (mData->mSession.mState != SessionState_ Closed)3814 if (mData->mSession.mState != SessionState_Unlocked) 3700 3815 return setError(VBOX_E_INVALID_OBJECT_STATE, 3701 tr("Cannot unregister the machine '%ls' because it has an open session"),3816 tr("Cannot unregister the machine '%ls' while it is locked"), 3702 3817 mUserData->mName.raw()); 3703 3818 … … 4014 4129 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 4015 4130 4016 if (mData->mSession.mState != SessionState_ Open)4131 if (mData->mSession.mState != SessionState_Locked) 4017 4132 return setError(VBOX_E_INVALID_VM_STATE, 4018 tr("Machine session is not open (session state: %s)"),4133 tr("Machine is not locked for session (session state: %s)"), 4019 4134 Global::stringifySessionState(mData->mSession.mState)); 4020 4135 … … 4041 4156 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 4042 4157 4043 if (mData->mSession.mState != SessionState_ Open)4158 if (mData->mSession.mState != SessionState_Locked) 4044 4159 return setError(E_FAIL, 4045 tr("Machine session is not open (session state: %s)"),4160 tr("Machine is not locked for session (session state: %s)"), 4046 4161 Global::stringifySessionState(mData->mSession.mState)); 4047 4162 … … 5265 5380 * and do a limited wait (max. 1 second). This helps a lot when the system 5266 5381 * is busy and thus session closing can take a little while. */ 5267 if ( mData->mSession.mState == SessionState_ Closing5382 if ( mData->mSession.mState == SessionState_Unlocking 5268 5383 && mData->mSession.mProgress) 5269 5384 { … … 5274 5389 } 5275 5390 5276 if (mData->mSession.mState == SessionState_Open || 5277 mData->mSession.mState == SessionState_Closing) 5391 if ( mData->mSession.mState == SessionState_Locked 5392 || mData->mSession.mState == SessionState_Unlocking 5393 ) 5278 5394 return setError(VBOX_E_INVALID_OBJECT_STATE, 5279 tr(" A session for the machine '%ls' is currently open (or being closed)"),5395 tr("The machine '%ls' is already locked for a session (or being unlocked)"), 5280 5396 mUserData->mName.raw()); 5281 5397 … … 5301 5417 if (mData->mSession.mPid != pid) 5302 5418 return setError(E_ACCESSDENIED, 5303 tr("An unexpected process (PID=0x%08X) has tried to open a direct " 5304 "session with the machine named '%ls', while only a process " 5305 "started by OpenRemoteSession (PID=0x%08X) is allowed"), 5419 tr("An unexpected process (PID=0x%08X) has tried to lock the " 5420 "machine '%ls', while only the process started by launchVMProcess (PID=0x%08X) is allowed"), 5306 5421 pid, mUserData->mName.raw(), mData->mSession.mPid); 5307 5422 } … … 5418 5533 5419 5534 mData->mSession.mRemoteControls.clear(); 5420 mData->mSession.mState = SessionState_ Closed;5535 mData->mSession.mState = SessionState_Unlocked; 5421 5536 } 5422 5537 } … … 5432 5547 /* memorize the direct session control and cache IUnknown for it */ 5433 5548 mData->mSession.mDirectControl = aControl; 5434 mData->mSession.mState = SessionState_ Open;5549 mData->mSession.mState = SessionState_Locked; 5435 5550 /* associate the SessionMachine with this Machine */ 5436 5551 mData->mSession.mMachine = sessionMachine; … … 5482 5597 LogFlowThisFunc(("mSession.mState=%s\n", Global::stringifySessionState(mData->mSession.mState))); 5483 5598 5484 if ( mData->mSession.mState == SessionState_Open ||5485 mData->mSession.mState == SessionState_Spawning ||5486 mData->mSession.mState == SessionState_Closing)5599 if ( mData->mSession.mState == SessionState_Locked 5600 || mData->mSession.mState == SessionState_Spawning 5601 || mData->mSession.mState == SessionState_Unlocking) 5487 5602 return setError(VBOX_E_INVALID_OBJECT_STATE, 5488 tr(" A session for the machine '%ls' is currently open (or being opened or closed)"),5603 tr("The machine '%ls' is already locked by a session (or being locked or unlocked)"), 5489 5604 mUserData->mName.raw()); 5490 5605 … … 5669 5784 { 5670 5785 /* restore the session state */ 5671 mData->mSession.mState = SessionState_ Closed;5786 mData->mSession.mState = SessionState_Unlocked; 5672 5787 /* The failure may occur w/o any error info (from RPC), so provide one */ 5673 5788 return setError(VBOX_E_VM_ERROR, … … 5710 5825 LogFlowThisFunc(("mSession.state=%s\n", Global::stringifySessionState(mData->mSession.mState))); 5711 5826 5712 if (mData->mSession.mState != SessionState_ Open)5827 if (mData->mSession.mState != SessionState_Locked) 5713 5828 return setError(VBOX_E_INVALID_SESSION_STATE, 5714 tr("The machine '%ls' does not have an opensession"),5829 tr("The machine '%ls' is not currently locked for a session"), 5715 5830 mUserData->mName.raw()); 5716 5831 … … 5756 5871 5757 5872 /* need to revalidate the state after entering the lock again */ 5758 if (mData->mSession.mState != SessionState_ Open)5873 if (mData->mSession.mState != SessionState_Locked) 5759 5874 { 5760 5875 aControl->Uninitialize(); 5761 5876 5762 5877 return setError(VBOX_E_INVALID_SESSION_STATE, 5763 tr("The machine '%ls' does not have an opensession"),5878 tr("The machine '%ls' is not currently locked for a session"), 5764 5879 mUserData->mName.raw()); 5765 5880 } … … 5810 5925 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 5811 5926 5812 if (mData->mSession.mState == SessionState_Open || 5813 (aAllowClosing && mData->mSession.mState == SessionState_Closing)) 5927 if ( mData->mSession.mState == SessionState_Locked 5928 || (aAllowClosing && mData->mSession.mState == SessionState_Unlocking) 5929 ) 5814 5930 { 5815 5931 AssertReturn(!mData->mSession.mMachine.isNull(), false); … … 5961 6077 5962 6078 mData->mSession.mRemoteControls.clear(); 5963 mData->mSession.mState = SessionState_ Closed;6079 mData->mSession.mState = SessionState_Unlocked; 5964 6080 5965 6081 /* finalize the progress after setting the state */ … … 5973 6089 mData->mSession.mPid = NIL_RTPROCESS; 5974 6090 5975 mParent->onSessionStateChange(mData->mUuid, SessionState_ Closed);6091 mParent->onSessionStateChange(mData->mUuid, SessionState_Unlocked); 5976 6092 return true; 5977 6093 } … … 9718 9834 { 9719 9835 /* mType is not null when this machine's process has been started by 9720 * VirtualBox::OpenRemoteSession(), therefore it is our child. We9836 * Machine::launchVMProcess(), therefore it is our child. We 9721 9837 * need to queue the PID to reap the process (and avoid zombies on 9722 9838 * Linux). */ … … 9778 9894 /* this must be null here (see #OnSessionEnd()) */ 9779 9895 Assert(mData->mSession.mDirectControl.isNull()); 9780 Assert(mData->mSession.mState == SessionState_ Closing);9896 Assert(mData->mSession.mState == SessionState_Unlocking); 9781 9897 Assert(!mData->mSession.mProgress.isNull()); 9782 9898 } … … 9799 9915 /* reset the rest of session data */ 9800 9916 mData->mSession.mMachine.setNull(); 9801 mData->mSession.mState = SessionState_ Closed;9917 mData->mSession.mState = SessionState_Unlocked; 9802 9918 mData->mSession.mType.setNull(); 9803 9919 … … 9823 9939 9824 9940 /* fire an event */ 9825 mParent->onSessionStateChange(mData->mUuid, SessionState_ Closed);9941 mParent->onSessionStateChange(mData->mUuid, SessionState_Unlocked); 9826 9942 9827 9943 uninitDataAndChildObjects(); … … 9918 10034 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 9919 10035 9920 if (mData->mSession.mState != SessionState_ Open)10036 if (mData->mSession.mState != SessionState_Locked) 9921 10037 return VBOX_E_INVALID_OBJECT_STATE; 9922 10038 … … 9938 10054 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 9939 10055 9940 if (mData->mSession.mState != SessionState_ Open)10056 if (mData->mSession.mState != SessionState_Locked) 9941 10057 return VBOX_E_INVALID_OBJECT_STATE; 9942 10058 … … 10133 10249 /* go to the closing state (essential for all open*Session() calls and 10134 10250 * for #checkForDeath()) */ 10135 Assert(mData->mSession.mState == SessionState_ Open);10136 mData->mSession.mState = SessionState_ Closing;10251 Assert(mData->mSession.mState == SessionState_Locked); 10252 mData->mSession.mState = SessionState_Unlocking; 10137 10253 10138 10254 /* set direct control to NULL to release the remote instance */ … … 10513 10629 * threat the latter also as an abnormal termination (see 10514 10630 * Session::uninit() for details). */ 10515 reason = mData->mSession.mState == SessionState_ Closing ?10631 reason = mData->mSession.mState == SessionState_Unlocking ? 10516 10632 Uninit::Normal : 10517 10633 Uninit::Abnormal; … … 11265 11381 * and simply do nothing here. */ 11266 11382 11267 if (mData->mSession.mState == SessionState_ Closing)11383 if (mData->mSession.mState == SessionState_Unlocking) 11268 11384 return S_OK; 11269 11385 -
trunk/src/VBox/Main/SessionImpl.cpp
r30134 r31008 46 46 #define CHECK_OPEN() \ 47 47 do { \ 48 if (mState != SessionState_ Open) \49 return setError(E_UNEXPECTED, tr ("The session is not open(session state: %s)"), Global::stringifySessionState(mState)); \48 if (mState != SessionState_Locked) \ 49 return setError(E_UNEXPECTED, tr ("The session is not locked (session state: %s)"), Global::stringifySessionState(mState)); \ 50 50 } while (0) 51 51 … … 81 81 LogFlowThisFuncEnter(); 82 82 83 mState = SessionState_ Closed;83 mState = SessionState_Unlocked; 84 84 mType = SessionType_Null; 85 85 … … 126 126 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 127 127 128 if (mState != SessionState_ Closed)129 { 130 Assert(mState == SessionState_ Open||128 if (mState != SessionState_Unlocked) 129 { 130 Assert(mState == SessionState_Locked || 131 131 mState == SessionState_Spawning); 132 132 … … 276 276 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 277 277 278 AssertReturn(mState != SessionState_ Closed, VBOX_E_INVALID_VM_STATE);278 AssertReturn(mState != SessionState_Unlocked, VBOX_E_INVALID_VM_STATE); 279 279 280 280 AssertMsgReturn(mType == SessionType_Direct && !!mConsole, … … 284 284 /* return a failure if the session already transitioned to Closing 285 285 * but the server hasn't processed Machine::OnSessionEnd() yet. */ 286 if (mState != SessionState_ Open)286 if (mState != SessionState_Locked) 287 287 return VBOX_E_INVALID_VM_STATE; 288 288 … … 304 304 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 305 305 306 AssertReturn(mState == SessionState_ Closed, VBOX_E_INVALID_VM_STATE);306 AssertReturn(mState == SessionState_Unlocked, VBOX_E_INVALID_VM_STATE); 307 307 308 308 if (!aMachine) … … 310 310 /* 311 311 * A special case: the server informs us that this session has been 312 * passed to IVirtualBox::OpenRemoteSession() so this session will 313 * become remote (but not existing) when AssignRemoteMachine() is 314 * called. 312 * passed to IMachine::launchVMProcess() so this session will become 313 * remote (but not existing) when AssignRemoteMachine() is called. 315 314 */ 316 315 … … 347 346 { 348 347 mType = SessionType_Direct; 349 mState = SessionState_ Open;348 mState = SessionState_Locked; 350 349 } 351 350 else … … 375 374 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 376 375 377 AssertReturn(mState == SessionState_ Closed ||376 AssertReturn(mState == SessionState_Unlocked || 378 377 mState == SessionState_Spawning, VBOX_E_INVALID_VM_STATE); 379 378 … … 416 415 */ 417 416 if (mType != SessionType_Remote) 418 mType = SessionType_ Existing;417 mType = SessionType_Shared; 419 418 else 420 419 Assert(mState == SessionState_Spawning); 421 420 422 mState = SessionState_ Open;421 mState = SessionState_Locked; 423 422 } 424 423 else … … 452 451 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 453 452 454 if (mState == SessionState_ Closing)455 { 456 LogFlowThisFunc(("Already being closed.\n"));453 if (mState == SessionState_Unlocking) 454 { 455 LogFlowThisFunc(("Already being unlocked.\n")); 457 456 return S_OK; 458 457 } 459 458 460 AssertReturn(mState == SessionState_ Open, VBOX_E_INVALID_VM_STATE);459 AssertReturn(mState == SessionState_Locked, VBOX_E_INVALID_VM_STATE); 461 460 AssertReturn(mType == SessionType_Direct, VBOX_E_INVALID_OBJECT_STATE); 462 461 … … 482 481 LogFlowThisFunc(("mState=%s, mType=%d\n", Global::stringifySessionState(mState), mType)); 483 482 484 if (mState == SessionState_ Closing)483 if (mState == SessionState_Unlocking) 485 484 { 486 LogFlowThisFunc(("Already being closed.\n"));485 LogFlowThisFunc(("Already being unlocked.\n")); 487 486 return S_OK; 488 487 } 489 488 490 AssertReturn(mState == SessionState_ Open||489 AssertReturn(mState == SessionState_Locked || 491 490 mState == SessionState_Spawning, VBOX_E_INVALID_VM_STATE); 492 491 … … 522 521 523 522 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 524 AssertReturn(mState == SessionState_ Open, VBOX_E_INVALID_VM_STATE);523 AssertReturn(mState == SessionState_Locked, VBOX_E_INVALID_VM_STATE); 525 524 AssertReturn(mType == SessionType_Direct, VBOX_E_INVALID_OBJECT_STATE); 526 525 … … 536 535 537 536 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 538 AssertReturn(mState == SessionState_ Open, VBOX_E_INVALID_VM_STATE);537 AssertReturn(mState == SessionState_Locked, VBOX_E_INVALID_VM_STATE); 539 538 AssertReturn(mType == SessionType_Direct, VBOX_E_INVALID_OBJECT_STATE); 540 539 … … 550 549 551 550 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 552 AssertReturn(mState == SessionState_ Open, VBOX_E_INVALID_VM_STATE);551 AssertReturn(mState == SessionState_Locked, VBOX_E_INVALID_VM_STATE); 553 552 AssertReturn(mType == SessionType_Direct, VBOX_E_INVALID_OBJECT_STATE); 554 553 … … 564 563 565 564 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 566 AssertReturn(mState == SessionState_ Open, VBOX_E_INVALID_VM_STATE);565 AssertReturn(mState == SessionState_Locked, VBOX_E_INVALID_VM_STATE); 567 566 AssertReturn(mType == SessionType_Direct, VBOX_E_INVALID_OBJECT_STATE); 568 567 … … 578 577 579 578 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 580 AssertReturn(mState == SessionState_ Open, VBOX_E_INVALID_VM_STATE);579 AssertReturn(mState == SessionState_Locked, VBOX_E_INVALID_VM_STATE); 581 580 AssertReturn(mType == SessionType_Direct, VBOX_E_INVALID_OBJECT_STATE); 582 581 … … 592 591 593 592 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 594 AssertReturn(mState == SessionState_ Open, VBOX_E_INVALID_VM_STATE);593 AssertReturn(mState == SessionState_Locked, VBOX_E_INVALID_VM_STATE); 595 594 AssertReturn(mType == SessionType_Direct, VBOX_E_INVALID_OBJECT_STATE); 596 595 … … 606 605 607 606 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 608 AssertReturn(mState == SessionState_ Open, VBOX_E_INVALID_VM_STATE);607 AssertReturn(mState == SessionState_Locked, VBOX_E_INVALID_VM_STATE); 609 608 AssertReturn(mType == SessionType_Direct, VBOX_E_INVALID_OBJECT_STATE); 610 609 … … 620 619 621 620 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 622 AssertReturn(mState == SessionState_ Open, VBOX_E_INVALID_VM_STATE);621 AssertReturn(mState == SessionState_Locked, VBOX_E_INVALID_VM_STATE); 623 622 AssertReturn(mType == SessionType_Direct, VBOX_E_INVALID_OBJECT_STATE); 624 623 … … 634 633 635 634 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 636 AssertReturn(mState == SessionState_ Open, VBOX_E_INVALID_VM_STATE);635 AssertReturn(mState == SessionState_Locked, VBOX_E_INVALID_VM_STATE); 637 636 AssertReturn(mType == SessionType_Direct, VBOX_E_INVALID_OBJECT_STATE); 638 637 … … 650 649 651 650 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 652 AssertReturn(mState == SessionState_ Open, VBOX_E_INVALID_VM_STATE);651 AssertReturn(mState == SessionState_Locked, VBOX_E_INVALID_VM_STATE); 653 652 AssertReturn(mType == SessionType_Direct, VBOX_E_INVALID_OBJECT_STATE); 654 653 … … 665 664 666 665 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 667 AssertReturn(mState == SessionState_ Open, VBOX_E_INVALID_VM_STATE);666 AssertReturn(mState == SessionState_Locked, VBOX_E_INVALID_VM_STATE); 668 667 AssertReturn(mType == SessionType_Direct, VBOX_E_INVALID_OBJECT_STATE); 669 668 … … 680 679 AssertReturn(mType == SessionType_Direct, VBOX_E_INVALID_OBJECT_STATE); 681 680 682 if (mState != SessionState_ Open)681 if (mState != SessionState_Locked) 683 682 { 684 683 /* the call from Machine issued when the session is open can arrive … … 701 700 AssertComRCReturn(autoCaller.rc(), autoCaller.rc()); 702 701 703 if (mState != SessionState_ Open)702 if (mState != SessionState_Locked) 704 703 return setError(VBOX_E_INVALID_VM_STATE, 705 tr("Machine session is not open (session state: %s)."),704 tr("Machine is not locked by session (session state: %s)."), 706 705 Global::stringifySessionState(mState)); 707 706 AssertReturn(mType == SessionType_Direct, VBOX_E_INVALID_OBJECT_STATE); … … 738 737 AssertComRCReturn(autoCaller.rc(), autoCaller.rc()); 739 738 740 if (mState != SessionState_ Open)739 if (mState != SessionState_Locked) 741 740 return setError(VBOX_E_INVALID_VM_STATE, 742 tr("Machine session is not open (session state: %s)."),741 tr("Machine is not locked by session (session state: %s)."), 743 742 Global::stringifySessionState(mState)); 744 743 AssertReturn(mType == SessionType_Direct, VBOX_E_INVALID_OBJECT_STATE); … … 774 773 AssertComRCReturn(autoCaller.rc(), autoCaller.rc()); 775 774 776 if (mState != SessionState_ Open)775 if (mState != SessionState_Locked) 777 776 return setError(VBOX_E_INVALID_VM_STATE, 778 tr("Machine session is not open (session state: %s)."),777 tr("Machine is not locked by session (session state: %s)."), 779 778 Global::stringifySessionState(mState)); 780 779 AssertReturn(mType == SessionType_Direct, VBOX_E_INVALID_OBJECT_STATE); … … 815 814 LogFlowThisFunc(("mState=%s, mType=%d\n", Global::stringifySessionState(mState), mType)); 816 815 817 if (mState != SessionState_ Open)816 if (mState != SessionState_Locked) 818 817 { 819 818 Assert(mState == SessionState_Spawning); … … 829 828 Assert(aFromServer); 830 829 831 mState = SessionState_ Closed;830 mState = SessionState_Unlocked; 832 831 mType = SessionType_Null; 833 832 #if defined(RT_OS_WINDOWS) … … 846 845 847 846 /* go to the closing state */ 848 mState = SessionState_ Closing;847 mState = SessionState_Unlocking; 849 848 850 849 if (mType == SessionType_Direct) … … 919 918 } 920 919 921 mState = SessionState_ Closed;920 mState = SessionState_Unlocked; 922 921 mType = SessionType_Null; 923 922 -
trunk/src/VBox/Main/SnapshotImpl.cpp
r30884 r31008 3120 3120 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 3121 3121 3122 if (mData->mSession.mState != SessionState_ Open)3122 if (mData->mSession.mState != SessionState_Locked) 3123 3123 throw setError(VBOX_E_INVALID_VM_STATE, 3124 tr("Machine session is not open (session state: %s)"),3124 tr("Machine is not locked by a session (session state: %s)"), 3125 3125 Global::stringifySessionState(mData->mSession.mState)); 3126 3126 directControl = mData->mSession.mDirectControl; -
trunk/src/VBox/Main/VirtualBoxImpl.cpp
r31002 r31008 1872 1872 } 1873 1873 1874 /**1875 * @note Locks objects!1876 */1877 STDMETHODIMP VirtualBox::OpenSession(ISession *aSession, IN_BSTR aMachineId)1878 {1879 CheckComArgNotNull(aSession);1880 1881 AutoCaller autoCaller(this);1882 if (FAILED(autoCaller.rc())) return autoCaller.rc();1883 1884 Guid id(aMachineId);1885 ComObjPtr<Machine> machine;1886 1887 HRESULT rc = findMachine(id,1888 false /* fPermitInaccessible */,1889 true /* setError */,1890 &machine);1891 if (FAILED(rc)) return rc;1892 1893 /* check the session state */1894 SessionState_T state;1895 rc = aSession->COMGETTER(State)(&state);1896 if (FAILED(rc)) return rc;1897 1898 if (state != SessionState_Closed)1899 return setError(VBOX_E_INVALID_OBJECT_STATE,1900 tr("The given session is already open or being opened"));1901 1902 /* get the IInternalSessionControl interface */1903 ComPtr<IInternalSessionControl> control = aSession;1904 ComAssertMsgRet(!!control, ("No IInternalSessionControl interface"),1905 E_INVALIDARG);1906 1907 rc = machine->openSession(control);1908 1909 if (SUCCEEDED(rc))1910 {1911 /*1912 * tell the client watcher thread to update the set of1913 * machines that have open sessions1914 */1915 updateClientWatcher();1916 1917 /* fire an event */1918 onSessionStateChange(id, SessionState_Open);1919 }1920 1921 return rc;1922 }1923 1924 /**1925 * @note Locks objects!1926 */1927 STDMETHODIMP VirtualBox::OpenRemoteSession(ISession *aSession,1928 IN_BSTR aMachineId,1929 IN_BSTR aType,1930 IN_BSTR aEnvironment,1931 IProgress **aProgress)1932 {1933 LogRel(("remotesession=%s\n", Utf8Str(aMachineId).c_str()));1934 1935 CheckComArgStrNotEmptyOrNull(aMachineId);1936 CheckComArgNotNull(aSession);1937 CheckComArgStrNotEmptyOrNull(aType);1938 CheckComArgOutSafeArrayPointerValid(aProgress);1939 1940 AutoCaller autoCaller(this);1941 if (FAILED(autoCaller.rc())) return autoCaller.rc();1942 1943 Guid id(aMachineId);1944 ComObjPtr<Machine> machine;1945 1946 HRESULT rc = findMachine(id,1947 false /* fPermitInaccessible */,1948 true /* setError */,1949 &machine);1950 if (FAILED(rc)) return rc;1951 1952 /* check the session state */1953 SessionState_T state;1954 rc = aSession->COMGETTER(State)(&state);1955 if (FAILED(rc)) return rc;1956 1957 if (state != SessionState_Closed)1958 return setError(VBOX_E_INVALID_OBJECT_STATE,1959 tr("The given session is already open or being opened"));1960 1961 /* get the IInternalSessionControl interface */1962 ComPtr<IInternalSessionControl> control = aSession;1963 ComAssertMsgRet(!!control, ("No IInternalSessionControl interface"),1964 E_INVALIDARG);1965 1966 /* get the teleporter enable state for the progress object init. */1967 BOOL fTeleporterEnabled;1968 rc = machine->COMGETTER(TeleporterEnabled)(&fTeleporterEnabled);1969 if (FAILED(rc))1970 return rc;1971 1972 /* create a progress object */1973 ComObjPtr<ProgressProxy> progress;1974 progress.createObject();1975 rc = progress->init(this,1976 static_cast<IMachine *>(machine),1977 Bstr(tr("Spawning session")),1978 TRUE /* aCancelable */,1979 fTeleporterEnabled ? 20 : 10 /* uTotalOperationsWeight */,1980 Bstr(tr("Spawning session")),1981 2 /* uFirstOperationWeight */,1982 fTeleporterEnabled ? 3 : 1 /* cOtherProgressObjectOperations */);1983 if (SUCCEEDED(rc))1984 {1985 rc = machine->openRemoteSession(control, aType, aEnvironment, progress);1986 if (SUCCEEDED(rc))1987 {1988 progress.queryInterfaceTo(aProgress);1989 1990 /* signal the client watcher thread */1991 updateClientWatcher();1992 1993 /* fire an event */1994 onSessionStateChange(id, SessionState_Spawning);1995 }1996 }1997 1998 return rc;1999 }2000 2001 /**2002 * @note Locks objects!2003 */2004 STDMETHODIMP VirtualBox::OpenExistingSession(ISession *aSession,2005 IN_BSTR aMachineId)2006 {2007 CheckComArgNotNull(aSession);2008 2009 AutoCaller autoCaller(this);2010 if (FAILED(autoCaller.rc())) return autoCaller.rc();2011 2012 Guid id(aMachineId);2013 ComObjPtr<Machine> machine;2014 2015 HRESULT rc = findMachine(id,2016 false /* fPermitInaccessible */,2017 true /* setError */,2018 &machine);2019 if (FAILED(rc)) return rc;2020 2021 /* check the session state */2022 SessionState_T state;2023 rc = aSession->COMGETTER(State)(&state);2024 if (FAILED(rc)) return rc;2025 2026 if (state != SessionState_Closed)2027 return setError(VBOX_E_INVALID_OBJECT_STATE,2028 tr("The given session is already open or being opened"));2029 2030 /* get the IInternalSessionControl interface */2031 ComPtr<IInternalSessionControl> control = aSession;2032 ComAssertMsgRet(!!control, ("No IInternalSessionControl interface"),2033 E_INVALIDARG);2034 2035 rc = machine->openExistingSession(control);2036 2037 return rc;2038 }2039 2040 1874 STDMETHODIMP VirtualBox::WaitForPropertyChange(IN_BSTR /* aWhat */, 2041 1875 ULONG /* aTimeout */, … … 3889 3723 /** 3890 3724 * Thread function that watches the termination of all client processes 3891 * that have opened sessions using I VirtualBox::OpenSession()3725 * that have opened sessions using IMachine::LockForSession() 3892 3726 */ 3893 3727 // static -
trunk/src/VBox/Main/cbinding/tstXPCOMCGlue.c
r28800 r31008 216 216 g_pVBoxFuncs->pfnUtf8ToUtf16("gui", &sessionType); 217 217 218 rc = virtualBox->vtbl->OpenRemoteSession( 219 virtualBox, 218 rc = machine->vtbl->LaunchVMProcess(machine, 220 219 session, 221 id,222 220 sessionType, 223 221 env, -
trunk/src/VBox/Main/glue/glue-java.xsl
r30987 r31008 2494 2494 } 2495 2495 2496 public ISession openMachineSession( String mid) throws Exception2496 public ISession openMachineSession(IMachine m) throws Exception 2497 2497 { 2498 2498 ISession s = getSessionObject(); 2499 try { 2500 this.vbox.openExistingSession(s, mid); 2501 return s; 2502 } catch (Exception e) { 2503 try { 2504 this.vbox.openSession(s, mid); 2505 return s; 2506 } catch (Exception e1) { 2507 closeMachineSession(s); 2508 throw e1; 2509 } 2510 } 2511 } 2512 2513 public ISession openMachineSession(IMachine m) throws Exception 2514 { 2515 return openMachineSession(m.getId()); 2499 m.lockForSession(s, true /* fPermitShared */); 2500 return s; 2516 2501 } 2517 2502 … … 2580 2565 ISession session = getSessionObject(); 2581 2566 2582 String mid = m.getId();2583 2567 if (type == null) 2584 2568 type = "gui"; 2585 IProgress p = vbox.openRemoteSession(session, mid, type, "");2569 IProgress p = m.launchVMProcess(session, type, ""); 2586 2570 progressBar(p, timeout); 2587 2571 session.close(); … … 3472 3456 } 3473 3457 3474 public ISession openMachineSession( String mid) throws Exception3458 public ISession openMachineSession(IMachine m) throws Exception 3475 3459 { 3476 3460 ISession s = getSessionObject(); 3477 try { 3478 this.vbox.openExistingSession(s, mid); 3479 return s; 3480 } catch (Exception e) { 3481 try { 3482 this.vbox.openSession(s, mid); 3483 return s; 3484 } catch (Exception e1) { 3485 closeMachineSession(s); 3486 throw e1; 3487 } 3488 } 3489 } 3490 3491 public ISession openMachineSession(IMachine m) throws Exception 3492 { 3493 return openMachineSession(m.getId()); 3461 m.lockForSession(s, true /* fPermitShared */ ); 3462 return s; 3494 3463 } 3495 3464 … … 3540 3509 ISession session = getSessionObject(); 3541 3510 3542 String mid = m.getId();3543 3511 if (type == null) 3544 3512 type = "gui"; 3545 IProgress p = vbox.openRemoteSession(session, mid, type, "");3513 IProgress p = m.launchVMProcess(session, type, ""); 3546 3514 progressBar(p, timeout); 3547 3515 session.close(); -
trunk/src/VBox/Main/idl/VirtualBox.xidl
r31002 r31008 794 794 Session state. This enumeration represents possible values of 795 795 <link to="IMachine::sessionState"/> and <link to="ISession::state"/> 796 attributes. See individual enumerator descriptions for the meaning for 797 every value. 796 attributes. 798 797 </desc> 799 798 … … 801 800 <desc>Null value (never used by the API).</desc> 802 801 </const> 803 <const name="Closed" value="1"> 804 <desc> 805 The machine has no open sessions (<link to="IMachine::sessionState"/>); 806 the session is closed (<link to="ISession::state"/>) 807 </desc> 808 </const> 809 <const name="Open" value="2"> 810 <desc> 811 The machine has an open direct session (<link to="IMachine::sessionState"/>); 812 the session is open (<link to="ISession::state"/>) 802 <const name="Unlocked" value="1"> 803 <desc> 804 In <link to="IMachine::sessionState"/>, this means that the machine 805 is not locked for any sessions. 806 807 In <link to="ISession::state"/>, this means that no machine is 808 currently locked for this session. 809 </desc> 810 </const> 811 <const name="Locked" value="2"> 812 <desc> 813 In <link to="IMachine::sessionState"/>, this means that the machine 814 is currently locked for a session, whose process identifier can 815 then be found in the <link to="IMachine::sessionPid" /> attribute. 816 817 In <link to="ISession::state"/>, this means that a machine is 818 currently locked for this session, and the mutable machine object 819 can be found in the <link to="ISession::machine"/> attribute 820 (see <link to="IMachine::lockForSession" /> for details). 813 821 </desc> 814 822 </const> 815 823 <const name="Spawning" value="3"> 816 824 <desc> 817 A new (direct) session is being opened for the machine as a result of 818 <link to="IVirtualBox::openRemoteSession"/> call 819 (<link to="IMachine::sessionState"/> or <link to="ISession::state"/>). 820 This state also occurs as a short transient state when a new direct 821 session is opened by calling <link to="IVirtualBox::openSession"/>. 822 </desc> 823 </const> 824 <const name="Closing" value="4"> 825 <desc> 826 The direct session is being closed (<link to="IMachine::sessionState"/>); 827 the session is being closed (<link to="ISession::state"/>) 825 A new process is being spawned for the machine as a result of 826 <link to="IMachine::launchVMProcess"/> call. This state also occurs 827 as a short transient state during an <link to="IMachine::lockForSession"/> 828 call. 829 </desc> 830 </const> 831 <const name="Unlocking" value="4"> 832 <desc> 833 The session is being unlocked. 828 834 </desc> 829 835 </const> … … 914 920 <desc> 915 921 Direct session 916 ( opened by <link to="IVirtualBox::openSession"/>)922 (used with <link to="IMachine::lockForSession"/>) 917 923 </desc> 918 924 </const> 919 925 <const name="Remote" value="2"> 920 926 <desc> 921 Remote session922 (opened by <link to="I VirtualBox::openRemoteSession"/>)923 </desc> 924 </const> 925 <const name=" Existing"value="3">926 <desc> 927 Existing session928 (opened by <link to="IVirtualBox::openExistingSession"/>)927 Remote VM process 928 (opened by <link to="IMachine::launchVMProcess"/>) 929 </desc> 930 </const> 931 <const name="Shared" value="3"> 932 <desc> 933 Shared session; remote link to an existing direct session opened 934 by <link to="IMachine::lockForSession"/> with fPermitShared = true 929 935 </desc> 930 936 </const> … … 2265 2271 <param name="value" type="wstring" dir="in"> 2266 2272 <desc>Value to assign to the key.</desc> 2267 </param>2268 </method>2269 2270 <method name="openSession">2271 <desc>2272 Opens a new direct session with the given virtual machine.2273 2274 A direct session acts as a local lock on the given VM.2275 There can be only one direct session open at a time for every2276 virtual machine, protecting the VM from being manipulated by2277 conflicting actions from different processes. Only after a2278 direct session has been opened, one can change all VM settings2279 and execute the VM in the process space of the session object.2280 2281 Sessions therefore can be compared to mutex semaphores that2282 lock a given VM for modification and execution.2283 See <link to="ISession">ISession</link> for details.2284 2285 <note>Unless you are writing a new VM frontend, you will not2286 want to execute a VM in the current process. To spawn a new2287 process that executes a VM, use2288 <link to="IVirtualBox::openRemoteSession" />2289 instead.</note>2290 2291 Upon successful return, the session object can be used to2292 get access to the machine and to the VM console.2293 2294 In VirtualBox terminology, the machine becomes "mutable" after2295 a session has been opened. Note that the "mutable" machine2296 object, on which you may invoke IMachine methods to change its2297 settings, will be a different object from the immutable IMachine2298 objects returned by various IVirtualBox methods. To obtain a2299 mutable IMachine object (upon which you can invoke settings methods),2300 use the <link to="ISession::machine" /> attribute.2301 2302 One must always call <link to="ISession::close" /> to release the2303 lock on the machine, or the machine's state will eventually be2304 set to "Aborted".2305 2306 In other words, to change settings on a machine, the following2307 sequence is typically performed:2308 2309 <ol>2310 <li>Call this method (openSession) to have a machine locked for2311 the current session.</li>2312 2313 <li>Obtain a mutable IMachine object from <link to="ISession::machine" />.</li>2314 2315 <li>Change the settings of the machine.</li>2316 2317 <li>Call <link to="IMachine::saveSettings" />.</li>2318 2319 <li>Close the session by calling <link to="ISession::close"/>.</li>2320 </ol>2321 2322 <result name="E_UNEXPECTED">2323 Virtual machine not registered.2324 </result>2325 <result name="E_ACCESSDENIED">2326 Process not started by OpenRemoteSession.2327 </result>2328 <result name="VBOX_E_OBJECT_NOT_FOUND">2329 No matching virtual machine found.2330 </result>2331 <result name="VBOX_E_INVALID_OBJECT_STATE">2332 Session already open or being opened.2333 </result>2334 <result name="VBOX_E_VM_ERROR">2335 Failed to assign machine to session.2336 </result>2337 2338 </desc>2339 <param name="session" type="ISession" dir="in">2340 <desc>2341 Session object that will represent the opened session after2342 successful method invocation. This object must not represent2343 the already open session.2344 <note>2345 This session will be automatically closed if the2346 VirtualBox server is terminated for some reason.2347 </note>2348 </desc>2349 </param>2350 <param name="machineId" type="uuid" mod="string" dir="in">2351 <desc>ID of the virtual machine to open a session with.</desc>2352 </param>2353 </method>2354 2355 <method name="openRemoteSession">2356 <desc>2357 Spawns a new process that executes a virtual machine (called a2358 "remote session").2359 2360 Opening a remote session causes the VirtualBox server to start a new2361 process that opens a direct session with the given VM. As a result, the2362 VM is locked by that direct session in the new process, preventing2363 conflicting changes from other processes. Since sessions act as locks2364 that prevent conflicting changes, one cannot open a remote session2365 for a VM that already has another open session (direct or remote), or2366 is currently in the process of opening one (see <link2367 to="IMachine::sessionState"/>).2368 2369 While the remote session still provides some level of control over the2370 VM execution to the caller (using the <link to="IConsole" /> interface),2371 not all VM settings are available for modification within the remote2372 session context.2373 2374 This operation can take some time (a new VM is started in a new process,2375 for which memory and other resources need to be set up). Because of this,2376 an <link to="IProgress" /> is returned to allow the caller to wait for this2377 asynchronous operation to be completed. Until then, the remote session2378 object remains in the closed state, and accessing the machine or its2379 console through it is invalid. It is recommended to use2380 <link to="IProgress::waitForCompletion" /> or similar calls to wait for2381 completion. Completion is signalled when the VM is powered on. Error2382 messages etc. can be queried via the progress object, if available.2383 2384 As with all <link to="ISession" /> objects, it is recommended to call2385 <link to="ISession::close" /> on the local session object once openRemoteSession()2386 has been called. However, the session's state (see <link to="ISession::state" />)2387 will not return to "Closed" until the remote session has also closed (i.e.2388 until the VM is no longer running). In that case, however, the state of2389 the session will automatically change back to "Closed".2390 2391 Currently supported session types (values of the @a type2392 argument) are:2393 <ul>2394 <li><tt>"gui"</tt>: VirtualBox Qt GUI session</li>2395 <li><tt>"vrdp"</tt>: VirtualBox VRDP Server session</li>2396 <li><tt>"sdl"</tt>: VirtualBox SDL GUI session</li>2397 </ul>2398 2399 The @a environment argument is a string containing definitions of2400 environment variables in the following format:2401 @code2402 NAME[=VALUE]\n2403 NAME[=VALUE]\n2404 ...2405 @endcode2406 where <tt>\\n</tt> is the new line character. These environment2407 variables will be appended to the environment of the VirtualBox server2408 process. If an environment variable exists both in the server process2409 and in this list, the value from this list takes precedence over the2410 server's variable. If the value of the environment variable is2411 omitted, this variable will be removed from the resulting environment.2412 If the environment string is @c null or empty, the server environment2413 is inherited by the started process as is.2414 2415 The progress object will have at least 2 operation. The first operation2416 covers the period up to the new VM process calls powerUp. The2417 subsequent operations mirrors the <link to="IConsole::powerUp"/>2418 progress object. Because <link to="IConsole::powerUp"/> may require2419 some extra operation, the <link to="IProgress::operationCount"/> may2420 change at the completion of operation1.2421 2422 For details on the teleportation progress operation, see2423 <link to="IConsole::powerUp"/>.2424 2425 <see>openExistingSession</see>2426 2427 <result name="E_UNEXPECTED">2428 Virtual machine not registered.2429 </result>2430 <result name="E_INVALIDARG">2431 Invalid session type @a type.2432 </result>2433 <result name="VBOX_E_OBJECT_NOT_FOUND">2434 No machine matching @a machineId found.2435 </result>2436 <result name="VBOX_E_INVALID_OBJECT_STATE">2437 Session already open or being opened.2438 </result>2439 <result name="VBOX_E_IPRT_ERROR">2440 Launching process for machine failed.2441 </result>2442 <result name="VBOX_E_VM_ERROR">2443 Failed to assign machine to session.2444 </result>2445 2446 </desc>2447 <param name="session" type="ISession" dir="in">2448 <desc>2449 Session object that will represent the opened remote session2450 after successful method invocation (this object must not2451 represent an already open session).2452 </desc>2453 </param>2454 <param name="machineId" type="uuid" mod="string" dir="in">2455 <desc>ID of the virtual machine to open a session with.</desc>2456 </param>2457 <param name="type" type="wstring" dir="in">2458 <desc>2459 Type of the remote session (case sensitive).2460 </desc>2461 </param>2462 <param name="environment" type="wstring" dir="in">2463 <desc>2464 Environment to pass to the opened session.2465 </desc>2466 </param>2467 <param name="progress" type="IProgress" dir="return">2468 <desc>Progress object to track the operation completion.</desc>2469 </param>2470 </method>2471 2472 <method name="openExistingSession">2473 <desc>2474 Opens a new remote session with the virtual machine for2475 which a direct session is already open.2476 2477 The remote session provides some level of control over the VM2478 execution (using the IConsole interface) to the caller; however,2479 within the remote session context, not all VM settings are available2480 for modification.2481 2482 As opposed to <link to="#openRemoteSession"/>, the number of2483 remote sessions opened this way is not limited by the API2484 2485 <note>2486 It is an error to open a remote session with the machine that2487 doesn't have an open direct session.2488 </note>2489 2490 <result name="E_UNEXPECTED">2491 Virtual machine not registered.2492 </result>2493 <result name="VBOX_E_OBJECT_NOT_FOUND">2494 No machine matching @a machineId found.2495 </result>2496 <result name="VBOX_E_INVALID_OBJECT_STATE">2497 Session already open or being opened.2498 </result>2499 <result name="VBOX_E_INVALID_SESSION_STATE">2500 Direct session state not Open.2501 </result>2502 <result name="VBOX_E_VM_ERROR">2503 Failed to get console object from direct session or assign2504 machine to session.2505 </result>2506 2507 <see>openRemoteSession</see>2508 </desc>2509 <param name="session" type="ISession" dir="in">2510 <desc>2511 Session object that will represent the open remote session2512 after successful method invocation. This object must not2513 represent an already open session.2514 <note>2515 This session will be automatically closed when the peer2516 (direct) session dies or gets closed.2517 </note>2518 </desc>2519 </param>2520 <param name="machineId" type="uuid" mod="string" dir="in">2521 <desc>ID of the virtual machine to open a session with.</desc>2522 2273 </param> 2523 2274 </method> … … 3457 3208 <desc> 3458 3209 Tells VBoxSVC that <link to="IConsole::powerUp"/> is under ways and 3459 3460 <link to="IVirtualBox::openRemoteSession"/> operations. The progress3461 3462 3463 3464 3210 gives it the progress object that should be part of any pending 3211 <link to="IMachine::launchVMProcess"/> operations. The progress 3212 object may be called back to reflect an early cancelation, so some care 3213 have to be taken with respect to any cancelation callbacks. The console 3214 object will call <link to="IInternalMachineControl::endPowerUp"/> 3215 to signal the completion of the progress object. 3465 3216 </desc> 3466 3217 <param name="progress" type="IProgress" dir="in"/> … … 3472 3223 This method may query status information from the progress object it 3473 3224 received in <link to="IInternalMachineControl::beginPowerUp"/> and copy 3474 it over to any in progress <link to="IVirtualBox::openRemoteSession"/>3225 it over to any in-progress <link to="IMachine::launchVMProcess"/> 3475 3226 call in order to complete that progress object. 3476 3227 </desc> … … 3901 3652 <link to="IVirtualBox::machines"/> collection, all attributes are 3902 3653 read-only unless explicitly stated otherwise in individual attribute 3903 and method descriptions. In order to change a machine setting, a session3904 for this machine must be opened using one of 3905 <link to="IVirtualBox::openSession"/>,3906 <link to="IVirtualBox::openRemoteSession"/> or3907 <link to="I VirtualBox::openExistingSession"/> methods. After the3908 session has been successfully opened, a mutable machine object needs to3909 be queried from the session object and then the desired settings changes3910 c an be applied to the returned object using IMachine attributes and3654 and method descriptions. 3655 3656 In order to change a machine setting, a session for this machine must be 3657 opened using one of the <link to="IMachine::lockForSession" /> or 3658 <link to="IMachine::launchVMProcess"/> methods. After the 3659 machine has been successfully locked for a session, a mutable machine object 3660 needs to be queried from the session object and then the desired settings 3661 changes can be applied to the returned object using IMachine attributes and 3911 3662 methods. See the <link to="ISession"/> interface description for more 3912 3663 information about sessions. … … 4245 3996 SessionSpawning or SessionOpen, this attribute contains the 4246 3997 same value as passed to the 4247 <link to="I VirtualBox::openRemoteSession"/> method in the3998 <link to="IMachine::launchVMProcess"/> method in the 4248 3999 @a type parameter. If the session was opened directly using 4249 <link to="I VirtualBox::openSession"/>, or if4000 <link to="IMachine::lockForSession" />, or if 4250 4001 <link to="#sessionState"/> is SessionClosed, the value of this 4251 4002 attribute is an empty string. … … 4258 4009 platform-dependent identifier of the process that has opened a 4259 4010 direct session for this machine using the 4260 <link to="I VirtualBox::openSession"/> call. The returned value4011 <link to="IMachine::lockForSession" /> call. The returned value 4261 4012 is only valid if <link to="#sessionState"/> is SessionOpen or 4262 4013 SessionClosing (i.e. a session is currently open or being … … 4441 4192 </desc> 4442 4193 </attribute> 4194 4195 <method name="lockForSession"> 4196 <desc> 4197 Locks the machine for the given session to enable the caller 4198 to make changes to the machine or start the VM. 4199 4200 A single machine can only be locked for a single sesseion 4201 at a time, protecting the VM from being manipulated by 4202 conflicting actions from different processes. Only after this 4203 method has been called, one can change all VM settings 4204 or execute the VM in the process space of the session object. 4205 See <link to="ISession">ISession</link> for details. 4206 4207 Locking the machine for a session creates a second copy of 4208 the IMachine object. It is this second object upon which 4209 changes can be made; in VirtualBox terminology, the second 4210 copy is "mutable". It is only this second, mutable machine 4211 object upon which you can call methods that change the 4212 machine state. After having called this method, you can 4213 obtain this second, mutable machine object using the 4214 <link to="ISession::machine" /> attribute. This way, you can 4215 also get access to the <link to="IConsole" /> object which 4216 controls VM execution. 4217 4218 <note>Unless you are writing a new VM frontend, you will not 4219 want to execute a VM in the current process. To spawn a new 4220 process that executes a VM, use <link to="IMachine::launchVMProcess" /> 4221 instead.</note> 4222 4223 One must always call <link to="ISession::close" /> to release the 4224 lock on the machine, or the machine's state will eventually be 4225 set to "Aborted". 4226 4227 In other words, to change settings on a machine, the following 4228 sequence is typically performed: 4229 4230 <ol> 4231 <li>Call this method (openSession) to have a machine locked for 4232 the current session.</li> 4233 4234 <li>Obtain a mutable IMachine object from <link to="ISession::machine" />.</li> 4235 4236 <li>Change the settings of the machine.</li> 4237 4238 <li>Call <link to="IMachine::saveSettings" />.</li> 4239 4240 <li>Close the session by calling <link to="ISession::close"/>.</li> 4241 </ol> 4242 4243 If the @a fPermitShared parameter is set to true, this method will also 4244 succeed on a machine which has already been locked by another session. 4245 The caller will then be attached to that existing session, and its own 4246 session will be marked as "Shared". While not all machine settings can 4247 be changed in that case, an IConsole object will still be created which 4248 provides to the caller some level of control over the VM execution, for 4249 example to pause the machine. The number of such shared sessions per 4250 machine is not limited by the API. 4251 4252 The return value will then indicate whether a direct session was opened 4253 (<link to="SessionType::Direct" />) or whether an existing direct session 4254 was shared ((<link to="SessionType::Shared" />). 4255 4256 If the @a fPermitShared parameter is @c false, then this can only 4257 possibly return <link to="SessionType::Direct" />. 4258 4259 <result name="E_UNEXPECTED"> 4260 Virtual machine not registered. 4261 </result> 4262 <result name="E_ACCESSDENIED"> 4263 Process not started by OpenRemoteSession. 4264 </result> 4265 <result name="VBOX_E_INVALID_OBJECT_STATE"> 4266 Session already open or being opened. 4267 </result> 4268 <result name="VBOX_E_VM_ERROR"> 4269 Failed to assign machine to session. 4270 </result> 4271 </desc> 4272 <param name="session" type="ISession" dir="in"> 4273 <desc> 4274 Session object for which the machine will be locked. 4275 </desc> 4276 </param> 4277 <param name="fPermitShared" type="boolean" dir="in"> 4278 <desc> 4279 Whether to allow for sharing a direct session remotely. 4280 </desc> 4281 </param> 4282 <param name="sessionType" type="SessionType" dir="return"> 4283 <desc> 4284 </desc> 4285 </param> 4286 </method> 4287 4288 <method name="launchVMProcess"> 4289 <desc> 4290 Spawns a new process that will execute the virtual machine. 4291 4292 This operation can take some time (a new VM is started in a new process, 4293 for which memory and other resources need to be set up). Because of this, 4294 an <link to="IProgress" /> object is returned to allow the caller to wait 4295 for this asynchronous operation to be completed. Until then, the caller's 4296 session object remains in the "Unlocked" state, and its <link to="ISession::machine" /> 4297 and <link to="ISession::console" /> attributes cannot be accessed. 4298 It is recommended to use <link to="IProgress::waitForCompletion" /> or 4299 similar calls to wait for completion. Completion is signalled when the VM 4300 is powered on. If launching the VM fails, error messages can be queried 4301 via the progress object, if available. 4302 4303 If launching the VM succeeds, the new VM process will create its own 4304 session and lock the machine for it, preventing conflicting changes 4305 from other processes. If the machine is already locked (because it 4306 is already running or because another session is making changes), 4307 launching the VM process will therefore fail. Reversely, future 4308 locking attempts will also fail while the machine is running. 4309 4310 The caller's session object remains separate from the session opened 4311 by the new VM process. It receives its own <link to="IConsole" /> 4312 object which can be used to control machine execution, but it cannot 4313 be used to change all VM settings which would be available after 4314 a <link to="#lockForSession" /> call. 4315 4316 As with all <link to="ISession" /> objects, it is recommended to call 4317 <link to="ISession::close" /> on the local session object once this call 4318 has returned. However, the session's state (see <link to="ISession::state" />) 4319 will not return to "Unlocked" until the remote session has also unlocked 4320 the machine. 4321 4322 The @a environment argument is a string containing definitions of 4323 environment variables in the following format: 4324 @code 4325 NAME[=VALUE]\n 4326 NAME[=VALUE]\n 4327 ... 4328 @endcode 4329 where <tt>\\n</tt> is the new line character. These environment 4330 variables will be appended to the environment of the VirtualBox server 4331 process. If an environment variable exists both in the server process 4332 and in this list, the value from this list takes precedence over the 4333 server's variable. If the value of the environment variable is 4334 omitted, this variable will be removed from the resulting environment. 4335 If the environment string is @c null or empty, the server environment 4336 is inherited by the started process as is. 4337 4338 The progress object will have at least 2 sub-operations. The first 4339 operation covers the period up to the new VM process calls powerUp. 4340 The subsequent operations mirror the <link to="IConsole::powerUp"/> 4341 progress object. Because <link to="IConsole::powerUp"/> may require 4342 some extra sub-operations, the <link to="IProgress::operationCount"/> 4343 may change at the completion of operation. 4344 4345 For details on the teleportation progress operation, see 4346 <link to="IConsole::powerUp"/>. 4347 4348 <result name="E_UNEXPECTED"> 4349 Virtual machine not registered. 4350 </result> 4351 <result name="E_INVALIDARG"> 4352 Invalid session type @a type. 4353 </result> 4354 <result name="VBOX_E_OBJECT_NOT_FOUND"> 4355 No machine matching @a machineId found. 4356 </result> 4357 <result name="VBOX_E_INVALID_OBJECT_STATE"> 4358 Session already open or being opened. 4359 </result> 4360 <result name="VBOX_E_IPRT_ERROR"> 4361 Launching process for machine failed. 4362 </result> 4363 <result name="VBOX_E_VM_ERROR"> 4364 Failed to assign machine to session. 4365 </result> 4366 </desc> 4367 <param name="session" type="ISession" dir="in"> 4368 <desc> 4369 Session object that will represent the opened remote session 4370 after successful method invocation (this object must not 4371 represent an already open session). 4372 </desc> 4373 </param> 4374 <param name="type" type="wstring" dir="in"> 4375 <desc> 4376 Type of the remote session (case sensitive). The following are 4377 currently supported: 4378 <ul> 4379 <li><tt>"gui"</tt>: VirtualBox Qt GUI front-end</li> 4380 <li><tt>"vrdp"</tt>: VBoxHeadless (VRDP Server) front-end</li> 4381 <li><tt>"sdl"</tt>: VirtualBox SDL front-end</li> 4382 </ul> 4383 </desc> 4384 </param> 4385 <param name="environment" type="wstring" dir="in"> 4386 <desc> 4387 Environment to pass to the VM process. 4388 </desc> 4389 </param> 4390 <param name="progress" type="IProgress" dir="return"> 4391 <desc>Progress object to track the operation completion.</desc> 4392 </param> 4393 </method> 4443 4394 4444 4395 <method name="setBootOrder"> … … 5972 5923 machine execution. 5973 5924 5974 The console object that implements the IConsole interface is obtained 5975 from a session object after the session for the given machine has been 5976 opened using one of <link to="IVirtualBox::openSession"/>, 5977 <link to="IVirtualBox::openRemoteSession"/> or 5978 <link to="IVirtualBox::openExistingSession"/> methods. 5925 A console object gets created when a machine has been locked for a 5926 particular session (client process) using <link to="IMachine::lockForSession" /> 5927 or <link to="IMachine::launchVMProcess"/>. The console object can 5928 then be found in the session's <link to="ISession::console" /> attribute. 5979 5929 5980 5930 Methods of the IConsole interface allow the caller to query the current … … 6099 6049 current storage devices). 6100 6050 6051 <note> 6052 This method is only useful for front-ends that want to actually 6053 execute virtual machines in their own process (like the VirtualBox 6054 or VBoxSDL front-ends). Unless you are intending to write such a 6055 front-end, do not call this method. If you simply want to 6056 start virtual machine execution using one of the existing front-ends 6057 (for example the VirtualBox GUI or headless server), use 6058 <link to="IMachine::launchVMProcess"/> instead; these 6059 front-ends will power up the machine automatically for you. 6060 </note> 6061 6101 6062 If the machine is powered off or aborted, the execution will 6102 6063 start from the beginning (as if the real hardware were just … … 6115 6076 (3) perform teleportation. These operations will be reflected as the 6116 6077 last three operations of the progress objected returned by 6117 <link to="IVirtualBox::openRemoteSession"/> as well. 6118 6119 <note> 6120 Unless you are trying to write a new VirtualBox front-end that 6121 performs direct machine execution (like the VirtualBox or VBoxSDL 6122 front-ends), don't call <link to="IConsole::powerUp"/> in a direct 6123 session opened by <link to="IVirtualBox::openSession"/> and use this 6124 session only to change virtual machine settings. If you simply want to 6125 start virtual machine execution using one of the existing front-ends 6126 (for example the VirtualBox GUI or headless server), simply use 6127 <link to="IVirtualBox::openRemoteSession"/>; these front-ends will 6128 power up the machine automatically for you. 6129 </note> 6078 <link to="IMachine::launchVMProcess"/> as well. 6130 6079 6131 6080 <see>#saveState</see> 6081 6132 6082 <result name="VBOX_E_INVALID_VM_STATE"> 6133 6083 Virtual machine already running. … … 12795 12745 <desc> 12796 12746 The ISession interface represents a serialization primitive for virtual 12797 machines. 12798 12799 With VirtualBox, every time one wishes to manipulate a virtual machine 12800 (e.g. change its settings or start execution), a session object is 12801 required. Such an object must be passed to one of the session methods 12802 that open the given session, which then initiates the machine manipulation. 12803 12804 A session serves several purposes: it identifies to the inter-process VirtualBox 12805 code which process is currently working with the virtual machine, and it ensures 12806 that there are no incompatible requests from several processes for the 12807 same virtual machine. Session objects can therefore be thought of as mutex 12808 semaphores that lock virtual machines to prevent conflicting accesses from 12809 several processes. 12747 machines. Any caller wishing to manipulate a virtual machine (represented 12748 by an IMachine object) needs to create a session object first, which lives 12749 in its own process space. Such session objects are then attached to the 12750 <link to="IMachine" /> objects living in the VirtualBox server process to 12751 coordinate possibly conflicting changes. 12752 12753 There are two typical scenarios in which sessions are used: 12754 12755 <ul> 12756 <li>To alter machine settings, one needs to lock a machine for a given session 12757 (client process) by calling <link to="IMachine::lockForSession"/>. While a 12758 machine is thus locked, no any other process may lock the machine again. 12759 12760 The same applies for any process which indends to actually run a virtual 12761 machine in its own context, such as the VirtualBox GUI or VBoxHeadless 12762 executables. They must also lock a machine for their own sessions before 12763 being allowed to power up the virtual machine. 12764 12765 As a result, no machine can be altered while another process is already 12766 using it, either because that process is modifying machine settings or 12767 because the machine is running. 12768 </li> 12769 <li> 12770 To initiate virtual machine execution using one of the existing VirtualBox 12771 front-ends (e.g. the GUI or VBoxHeadless), one would instead call 12772 <link to="IMachine::launchVMProcess"/>, which also requires a session 12773 object as its first parameter. This session then identifies the caller 12774 and lets the caller control the started machine (for example, pause machine 12775 execution or power it down) as well as be notified about machine execution 12776 state changes. 12777 </li> 12778 </ul> 12810 12779 12811 12780 How sessions objects are used depends on whether you use the Main API … … 12813 12782 12814 12783 <ul> 12815 <li>When using the COM API directly, an object of the Session class from the 12816 VirtualBox type library needs to be created. In regular COM C++ client code, 12817 this can be done by calling <tt>createLocalObject()</tt>, a standard COM API. 12818 This object will then act as a local session object in further calls to open 12819 a session. 12820 </li> 12821 12822 <li>In the webservice, the session manager (IWebsessionManager) instead creates 12823 one session object automatically when <link to="IWebsessionManager::logon" /> 12824 is called. A managed object reference to that session object can be retrieved by 12825 calling <link to="IWebsessionManager::getSessionObject" />. This session object 12826 reference can then be used to open sessions. 12827 </li> 12784 <li>When using the COM API directly, an object of the Session class from the 12785 VirtualBox type library needs to be created. In regular COM C++ client code, 12786 this can be done by calling <tt>createLocalObject()</tt>, a standard COM API. 12787 This object will then act as a local session object in further calls to open 12788 a session. 12789 </li> 12790 12791 <li>In the webservice, the session manager (IWebsessionManager) instead creates 12792 a session object automatically whenever <link to="IWebsessionManager::logon" /> 12793 is called. A managed object reference to that session object can be retrieved by 12794 calling <link to="IWebsessionManager::getSessionObject" />. 12795 </li> 12828 12796 </ul> 12829 12830 Sessions are mainly used in two variations:12831 12832 <ul>12833 <li>12834 To start a virtual machine in a separate process, one would call12835 <link to="IVirtualBox::openRemoteSession"/>, which requires a session12836 object as its first parameter. This session then identifies the caller12837 and lets him control the started machine (for example, pause machine12838 execution or power it down) as well as be notified about machine12839 execution state changes.12840 </li>12841 12842 <li>To alter machine settings, or to start machine execution within the12843 current process, one needs to open a direct session for the machine first by12844 calling <link to="IVirtualBox::openSession"/>. While a direct session12845 is open within one process, no any other process may open another direct12846 session for the same machine. This prevents the machine from being changed12847 by other processes while it is running or while the machine is being configured.12848 </li>12849 </ul>12850 12851 One also can attach to an existing direct session already opened by12852 another process (for example, in order to send a control request to the12853 virtual machine such as the pause or the reset request). This is done by12854 calling <link to="IVirtualBox::openExistingSession"/>.12855 12856 <note>12857 Unless you are trying to write a new VirtualBox front-end that12858 performs direct machine execution (like the VirtualBox or VBoxSDL12859 front-ends), don't call <link to="IConsole::powerUp"/> in a direct12860 session opened by <link to="IVirtualBox::openSession"/> and use this12861 session only to change virtual machine settings. If you simply want to12862 start virtual machine execution using one of the existing front-ends12863 (for example the VirtualBox GUI or headless server), simply use12864 <link to="IVirtualBox::openRemoteSession"/>; these front-ends12865 will power up the machine automatically for you.12866 </note>12867 12797 </desc> 12868 12798 … … 12874 12804 <desc> 12875 12805 Type of this session. The value of this attribute is valid only 12876 if the session is currently open (i.e. its #stateis12877 Session Type_SessionOpen), otherwise an error will be returned.12806 if the session is currently open (i.e. its <link to="#state" /> is 12807 SessionState_SessionOpen), otherwise an error will be returned. 12878 12808 </desc> 12879 12809 </attribute> … … 12891 12821 Closes a session that was previously opened. 12892 12822 12893 It is recommended that every time an "open session" method (such as 12894 <link to="IVirtualBox::openRemoteSession" /> or 12895 <link to="IVirtualBox::openSession" />) has been called to 12896 manipulate a virtual machine, the caller invoke 12897 ISession::close() when it's done doing so. Since sessions are 12898 serialization primitives much like ordinary mutexes, they are 12899 best used the same way: for each "open" call, there should be 12900 a matching "close" call, even when errors occur. 12901 12902 Otherwise, if a direct session for a machine opened with 12903 <link to="IVirtualBox::openSession"/> is not explicitly closed 12904 when the application terminates, the state of the machine will 12905 be set to <link to="MachineState_Aborted" /> on the server. 12823 Calling this method is eventually required every time a machine has been 12824 locked for a particular session using the <link to="IMachine::launchVMProcess" /> 12825 or <link to="IMachine::lockForSession" />) calls. Otherwise the state of 12826 the machine will be set to <link to="MachineState_Aborted" /> on the 12827 server, and changes made to the machine settings will be lost. 12906 12828 12907 12829 Generally, it is recommended to close all open sessions explicitly -
trunk/src/VBox/Main/include/ApplianceImplPrivate.h
r30881 r31008 127 127 struct MyHardDiskAttachment 128 128 { 129 Bstr bstrUuid;130 129 ComPtr<IMachine> pMachine; 131 130 Bstr controllerType; -
trunk/src/VBox/Main/include/MachineImpl.h
r31002 r31008 115 115 struct Session 116 116 { 117 /** Control of the direct session opened by openSession() */117 /** Control of the direct session opened by lockForSession() */ 118 118 ComPtr<IInternalSessionControl> mDirectControl; 119 119 … … 455 455 456 456 // IMachine methods 457 STDMETHOD(LockForSession)(ISession *aSession, BOOL fPermitShared, SessionType_T *sessionType); 458 STDMETHOD(LaunchVMProcess)(ISession *aSession, IN_BSTR aType, IN_BSTR aEnvironment, IProgress **aProgress); 459 457 460 STDMETHOD(SetBootOrder)(ULONG aPosition, DeviceType_T aDevice); 458 461 STDMETHOD(GetBootOrder)(ULONG aPosition, DeviceType_T *aDevice); -
trunk/src/VBox/Main/include/VirtualBoxImpl.h
r31002 r31008 155 155 STDMETHOD(GetExtraData) (IN_BSTR aKey, BSTR *aValue); 156 156 STDMETHOD(SetExtraData) (IN_BSTR aKey, IN_BSTR aValue); 157 STDMETHOD(OpenSession) (ISession *aSession, IN_BSTR aMachineId);158 STDMETHOD(OpenRemoteSession) (ISession *aSession, IN_BSTR aMachineId,159 IN_BSTR aType, IN_BSTR aEnvironment,160 IProgress **aProgress);161 STDMETHOD(OpenExistingSession) (ISession *aSession, IN_BSTR aMachineId);162 157 163 158 STDMETHOD(WaitForPropertyChange) (IN_BSTR aWhat, ULONG aTimeout, -
trunk/src/VBox/Main/testcase/tstVBoxAPILinux.cpp
r28800 r31008 266 266 } 267 267 268 nsXPIDLString machineUUID; 269 machine->GetId(getter_Copies(machineUUID)); 270 rc = virtualBox->OpenSession(session, machineUUID); 268 machine->LockForSession(session, false /* fPermitShared */, NULL); 271 269 if (NS_FAILED(rc)) 272 270 { -
trunk/src/VBox/Main/testcase/tstVBoxAPIWin.cpp
r30269 r31008 209 209 210 210 /* Start a VM session using the delivered VBox GUI. */ 211 rc = virtualBox->OpenRemoteSession (session, guid, sessiontype,212 211 rc = machine->LaunchVMProcess(session, sessiontype, 212 NULL, &progress); 213 213 if (!SUCCEEDED(rc)) 214 214 { -
trunk/src/VBox/Main/webservice/samples/java/jax-ws/clienttest.java
r30170 r31008 227 227 String env = "DISPLAY=:0.0"; 228 228 IProgress oProgress = 229 vbox.openRemoteSession(oSession, 230 uuid, 231 sessionType, 232 env); 229 oMachine.launchVMProcess(oSession, 230 sessionType, 231 env); 233 232 System.out.println("Session for VM " + uuid + " is opening..."); 234 233 oProgress.waitForCompletion(10000); -
trunk/src/libs/xpcom18a4/java/src/org/virtualbox/VirtualBoxManager.java
r29230 r31008 106 106 107 107 108 String mid = m.getId();109 108 if (type == null) 110 109 type = "gui"; 111 IProgress p = vbox.openRemoteSession(session, mid, type, "");110 IProgress p = m.openRemoteSession(session, type, ""); 112 111 progressBar(p, timeout); 113 112 session.close();
Note:
See TracChangeset
for help on using the changeset viewer.