Changeset 4064 in vbox
- Timestamp:
- Aug 7, 2007 2:19:46 PM (18 years ago)
- svn:sync-xref-src-repo-rev:
- 23501
- Location:
- trunk/src/VBox
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxManage/VBoxManage.cpp
r3917 r4064 4236 4236 } 4237 4237 4238 Bstr env; 4239 #ifdef RT_OS_LINUX 4240 /* make sure the VM process will start on the same display as VBoxManage */ 4241 env = Utf8StrFmt ("DISPLAY=%s", getenv ("DISPLAY")); 4242 #endif 4238 4243 ComPtr<IProgress> progress; 4239 CHECK_ERROR_RET(virtualBox, OpenRemoteSession(session, uuid, sessionType, progress.asOutParam()), rc); 4244 CHECK_ERROR_RET(virtualBox, OpenRemoteSession(session, uuid, sessionType, 4245 env, progress.asOutParam()), rc); 4240 4246 RTPrintf("Waiting for the remote session to open...\n"); 4241 4247 CHECK_ERROR_RET(progress, WaitForCompletion (-1), 1); -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxSelectorWnd.cpp
r3802 r4064 848 848 #endif 849 849 850 CProgress progress = vbox.OpenRemoteSession (session, id, "gui"); 850 QString env; 851 #if defined (Q_WS_X11) 852 /* make sure the VM process will start on the same display as the Selector */ 853 env.sprintf ("DISPLAY=%s", getenv ("DISPLAY")); 854 #endif 855 856 CProgress progress = vbox.OpenRemoteSession (session, id, "gui", env); 851 857 if (!vbox.isOk()) 852 858 { -
trunk/src/VBox/Main/MachineImpl.cpp
r4041 r4064 52 52 #include <stdio.h> 53 53 #include <stdlib.h> 54 #include <VBox/err.h> 55 #include <VBox/cfgldr.h> 54 56 55 #include <iprt/path.h> 57 56 #include <iprt/dir.h> … … 59 58 #include <iprt/process.h> 60 59 #include <iprt/cpputils.h> 60 #include <iprt/env.h> 61 62 #include <VBox/err.h> 63 #include <VBox/cfgldr.h> 61 64 #include <VBox/param.h> 62 65 … … 2763 2766 */ 2764 2767 HRESULT Machine::openRemoteSession (IInternalSessionControl *aControl, 2765 INPTR BSTR aType, Progress *aProgress) 2768 INPTR BSTR aType, INPTR BSTR aEnvironment, 2769 Progress *aProgress) 2766 2770 { 2767 2771 LogFlowThisFuncEnter(); … … 2804 2808 RTPROCESS pid = NIL_RTPROCESS; 2805 2809 2810 RTENV env = NIL_RTENV; 2811 2812 if (aEnvironment) 2813 { 2814 char *newEnvStr = NULL; 2815 2816 do 2817 { 2818 /* clone the current environment */ 2819 int vrc = RTEnvClone(&env, NULL); 2820 AssertRCBreak (vrc, vrc = vrc); 2821 2822 vrc = RTStrUtf8ToCurrentCP (&newEnvStr, Utf8Str (aEnvironment)); 2823 AssertRCBreak (vrc, vrc = vrc); 2824 2825 /* put new variables to the environment 2826 * (ignore empty variable names here since RTEnv API 2827 * intentionally doesn't do that) */ 2828 char *var = newEnvStr; 2829 for (char *p = newEnvStr; *p; ++ p) 2830 { 2831 if (*p == '\n' && (p == newEnvStr || *(p - 1) != '\\')) 2832 { 2833 *p = '\0'; 2834 if (*var) 2835 if (VBOX_FAILURE (vrc = RTEnvPutEx(env, var))) 2836 break; 2837 var = p + 1; 2838 } 2839 } 2840 if (VBOX_SUCCESS (vrc) && *var) 2841 vrc = RTEnvPutEx(env, var); 2842 2843 AssertRCBreak (vrc, vrc = vrc); 2844 } 2845 while (0); 2846 2847 if (newEnvStr != NULL) 2848 RTStrFree(newEnvStr); 2849 } 2850 2806 2851 Bstr type (aType); 2807 2852 if (type == "gui") … … 2822 2867 const char * args[] = {path, "-comment", name, "-startvm", idStr, 0 }; 2823 2868 #endif 2824 vrc = RTProcCreate (path, args, NULL, 0, &pid);2869 vrc = RTProcCreate (path, args, RTEnvGetArray (env), 0, &pid); 2825 2870 } 2826 2871 else … … 2839 2884 const char * args[] = {path, "-comment", name, "-startvm", idStr, 0 }; 2840 2885 #endif 2841 vrc = RTProcCreate (path, args, NULL, 0, &pid);2886 vrc = RTProcCreate (path, args, RTEnvGetArray (env), 0, &pid); 2842 2887 } 2843 2888 else … … 2856 2901 const char * args[] = {path, "-comment", name, "-startvm", idStr, "-capture", 0 }; 2857 2902 #endif 2858 vrc = RTProcCreate (path, args, NULL, 0, &pid);2903 vrc = RTProcCreate (path, args, RTEnvGetArray (env), 0, &pid); 2859 2904 } 2860 2905 else 2861 2906 { 2907 if (env != NIL_RTENV) 2908 RTEnvDestroy (env); 2862 2909 return setError (E_INVALIDARG, 2863 2910 tr ("Invalid session type: '%ls'"), aType); 2864 2911 } 2912 2913 if (env != NIL_RTENV) 2914 RTEnvDestroy (env); 2865 2915 2866 2916 if (VBOX_FAILURE (vrc)) -
trunk/src/VBox/Main/VirtualBoxImpl.cpp
r3668 r4064 1914 1914 INPTR GUIDPARAM aMachineId, 1915 1915 INPTR BSTR aType, 1916 INPTR BSTR aEnvironment, 1916 1917 IProgress **aProgress) 1917 1918 { … … 1951 1952 FALSE /* aCancelable */); 1952 1953 1953 rc = machine->openRemoteSession (control, aType, progress);1954 rc = machine->openRemoteSession (control, aType, aEnvironment, progress); 1954 1955 1955 1956 if (SUCCEEDED (rc)) -
trunk/src/VBox/Main/idl/VirtualBox.xidl
r4041 r4064 664 664 <interface 665 665 name="IVirtualBox" extends="$dispatched" 666 uuid=" d1a2295c-d257-4a4c-a9a6-843d87db6f45"666 uuid="76b25f3c-15d4-4785-a9d3-adc6a462beec" 667 667 wsmap="global" 668 668 > … … 1382 1382 <method name="createSharedFolder"> 1383 1383 <desc> 1384 Creates a new shared folder by associating the given logical name with1385 the given host path, adds it to the collection of shared folders and1386 starts sharing it. Refer to the description of1384 Creates a new global shared folder by associating the given logical 1385 name with the given host path, adds it to the collection of shared 1386 folders and starts sharing it. Refer to the description of 1387 1387 <link to="ISharedFolder"/> to read more about logical names. 1388 1388 </desc> … … 1397 1397 <method name="removeSharedFolder"> 1398 1398 <desc> 1399 Removes a shared folder with the given name previously created1400 by <link to="#createSharedFolder"/> from the collection of1399 Removes the global shared folder with the given name previously 1400 created by <link to="#createSharedFolder"/> from the collection of 1401 1401 shared folders and stops sharing it. 1402 1402 </desc> … … 1462 1462 <method name="openSession"> 1463 1463 <desc> 1464 <p>Opens a new direct session with the given virtual machine. 1465 Within the direct session context, it is possible to change 1466 all VM settings, as well as to execute the VM in the process 1467 space of the session object. There can be only one direct 1468 session open at a time for every virtual machine.</p> 1469 <p>Upon successful return, the session object can be used to 1470 get access to the machine and to the VM console. 1471 </p> 1464 Opens a new direct session with the given virtual machine. 1465 1466 Within the direct session context, it is possible to change 1467 all VM settings, as well as to execute the VM in the process 1468 space of the session object. There can be only one direct 1469 session open at a time for every virtual machine. 1470 1471 Upon successful return, the session object can be used to 1472 get access to the machine and to the VM console. 1472 1473 </desc> 1473 1474 <param name="session" type="ISession" dir="in"> … … 1489 1490 <method name="openRemoteSession"> 1490 1491 <desc> 1491 <p>Opens a new remote session with the given virtual 1492 machine. Opening the remote session causes the server to start 1493 a new process that opens a direct session with the given VM. 1494 The remote session provides some level of control over the VM 1495 execution (using the IConsole interface) to the caller. Within 1496 the remote session context, it is not possible to change any 1497 static VM settings (such as name, HDD configuration, etc.).</p> 1498 <p>This operation can take some time, so the progress object 1499 is returned to let the caller be informed when the session is 1500 actually open. Until then, the remote session object remains in 1501 the closed state and accessing the machine or its console through 1502 it is invalid. 1503 </p> 1492 Opens a new remote session with the given virtual 1493 machine. 1494 1495 Opening a remote session causes the VirtualBox server to start a new 1496 process that opens a direct session with the given VM. The remote 1497 session provides some level of control over the VM execution to the 1498 caller (using the IConsole interface); however, within the remote 1499 session context, not all VM settings are available for modification. 1500 1501 This operation can take some time, so the progress object 1502 is returned to let the caller be informed when the session is 1503 actually open. Until then, the remote session object remains in 1504 the closed state and accessing the machine or its console through 1505 it is invalid. 1504 1506 1505 1507 Currently supported session types (values of the @a type 1506 parameter) are:1508 argument) are: 1507 1509 <ul> 1508 1510 <li><tt>gui</tt>: VirtualBox Qt GUI session</li> … … 1510 1512 </ul> 1511 1513 1512 <note> 1513 It is impossible to open a remote session with the machine 1514 The @a environment argument is a string containing definitions of 1515 environment variables in the following format: 1516 @code 1517 NAME[=VALUE]\n 1518 NAME[=VALUE]\n 1519 ... 1520 @endcode 1521 where <tt>\\n</tt> is the new line character. These environment 1522 variables will be appended to the environment of the VirtualBox server 1523 process. If an environment variable exists both in the server process 1524 and in this list, the value from this list takes precedence over the 1525 server's variable. If the value of the environment variable is 1526 omitted, this variable will be removed from the resulting environment. 1527 If the environment string is @c null, the server environment is 1528 inherited by the started process as is. 1529 1530 <note> 1531 It is an error to open a remote session with the machine 1514 1532 that already has an open direct session or waits until the 1515 1533 previous request to open the remote session is completed … … 1539 1557 </desc> 1540 1558 </param> 1559 <param name="environment" type="wstring" dir="in"> 1560 <desc> 1561 Environment to pass to the opened session (may be @c null). 1562 </desc> 1563 </param> 1541 1564 <param name="progress" type="IProgress" dir="return"> 1542 1565 <desc>Progress object to track the operation completion.</desc> … … 1546 1569 <method name="openExistingSession"> 1547 1570 <desc> 1548 <p>Opens a new remote session with the virtual machine for 1549 which a direct session is already open. 1550 The remote session provides some level of control over the VM 1551 execution (using the IConsole interface) to the caller. Within 1552 the remote session context, it is not possible to change any 1553 static VM settings (such as name, HDD configuration, etc.).</p> 1554 <p>As opposed to <link to="#openRemoteSession()"/>, the number of 1555 remote sessions opened this way is not limited by the API.</p> 1556 <note> 1557 It is impossible to open a remote session with the machine 1558 that doesn't have an open direct session. 1559 </note> 1571 Opens a new remote session with the virtual machine for 1572 which a direct session is already open. 1573 1574 The remote session provides some level of control over the VM 1575 execution (using the IConsole interface) to the caller; however, 1576 within the remote session context, not all VM settings are available 1577 for modification. 1578 1579 As opposed to <link to="#openRemoteSession()"/>, the number of 1580 remote sessions opened this way is not limited by the API 1581 1582 <note> 1583 It is an error to open a remote session with the machine that 1584 doesn't have an open direct session. 1585 </note> 1586 1560 1587 <see>openRemoteSession</see> 1561 1588 </desc> … … 2600 2627 <method name="createSharedFolder"> 2601 2628 <desc> 2602 Creates a new shared folder by associating the given logical name with2603 the given host path, adds it to the collection of shared folders and2604 starts sharing it. Refer to the description of2629 Creates a new permanent shared folder by associating the given logical 2630 name with the given host path, adds it to the collection of shared 2631 folders and starts sharing it. Refer to the description of 2605 2632 <link to="ISharedFolder"/> to read more about logical names. 2606 2633 </desc> … … 2615 2642 <method name="removeSharedFolder"> 2616 2643 <desc> 2617 Removes a shared folder with the given name previously created2618 by <link to="#createSharedFolder"/> from the collection of2644 Removes the permanent shared folder with the given name previously 2645 created by <link to="#createSharedFolder"/> from the collection of 2619 2646 shared folders and stops sharing it. 2620 2647 </desc> … … 3317 3344 <method name="createSharedFolder"> 3318 3345 <desc> 3319 Creates a new shared folder by associating the given logical name with3320 the given host path, adds it to the collection of shared folders and3321 starts sharing it. Refer to the description of3346 Creates a transient new shared folder by associating the given logical 3347 name with the given host path, adds it to the collection of shared 3348 folders and starts sharing it. Refer to the description of 3322 3349 <link to="ISharedFolder"/> to read more about logical names. 3323 3350 </desc> … … 3332 3359 <method name="removeSharedFolder"> 3333 3360 <desc> 3334 Removes a shared folder with the given name previously created3335 by <link to="#createSharedFolder"/> from the collection of3361 Removes a transient shared folder with the given name previously 3362 created by <link to="#createSharedFolder"/> from the collection of 3336 3363 shared folders and stops sharing it. 3337 3364 </desc> -
trunk/src/VBox/Main/include/MachineImpl.h
r4041 r4064 543 543 HRESULT openSession (IInternalSessionControl *aControl); 544 544 HRESULT openRemoteSession (IInternalSessionControl *aControl, 545 INPTR BSTR aType, Progress *aProgress); 545 INPTR BSTR aType, INPTR BSTR aEnvironment, 546 Progress *aProgress); 546 547 HRESULT openExistingSession (IInternalSessionControl *aControl); 547 548 -
trunk/src/VBox/Main/include/VirtualBoxImpl.h
r3668 r4064 174 174 STDMETHOD(OpenSession) (ISession *aSession, INPTR GUIDPARAM aMachineId); 175 175 STDMETHOD(OpenRemoteSession) (ISession *aSession, INPTR GUIDPARAM aMachineId, 176 INPTR BSTR aType, IProgress **aProgress); 176 INPTR BSTR aType, INPTR BSTR aEnvironment, 177 IProgress **aProgress); 177 178 STDMETHOD(OpenExistingSession) (ISession *aSession, INPTR GUIDPARAM aMachineId); 178 179 STDMETHOD(RegisterCallback) (IVirtualBoxCallback *callback); -
trunk/src/VBox/Main/testcase/tstAPI.cpp
r3834 r4064 823 823 ComPtr <IProgress> progress; 824 824 CHECK_RC_BREAK (virtualBox->OpenRemoteSession (session, guid, Bstr("gui"), 825 progress.asOutParam()));825 NULL, progress.asOutParam())); 826 826 printf ("Waiting for the session to open...\n"); 827 827 CHECK_RC_BREAK (progress->WaitForCompletion (-1));
Note:
See TracChangeset
for help on using the changeset viewer.