Changeset 47551 in vbox for trunk/src/VBox/Additions
- Timestamp:
- Aug 6, 2013 9:37:11 AM (11 years ago)
- Location:
- trunk/src/VBox/Additions/common/VBoxService
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxService/VBoxServiceControl.cpp
r47545 r47551 76 76 static DECLCALLBACK(int) VBoxServiceControlPreInit(void) 77 77 { 78 int rc; 78 79 #ifdef VBOX_WITH_GUEST_PROPS 79 80 /* … … 82 83 */ 83 84 uint32_t uGuestPropSvcClientID; 84 intrc = VbglR3GuestPropConnect(&uGuestPropSvcClientID);85 rc = VbglR3GuestPropConnect(&uGuestPropSvcClientID); 85 86 if (RT_FAILURE(rc)) 86 87 { … … 91 92 } 92 93 else 93 VBoxServiceError("Failed to connect to the guest property service ! Error:%Rrc\n", rc);94 VBoxServiceError("Failed to connect to the guest property service, rc=%Rrc\n", rc); 94 95 } 95 96 else … … 100 101 if (rc == VERR_NOT_FOUND) /* If a value is not found, don't be sad! */ 101 102 rc = VINF_SUCCESS; 102 return rc;103 103 #else 104 104 /* Nothing to do here yet. */ 105 return VINF_SUCCESS; 106 #endif 105 rc = VINF_SUCCESS; 106 #endif 107 108 if (RT_SUCCESS(rc)) 109 { 110 /* Init session object. */ 111 rc = GstCntlSessionInit(&g_Session, 0 /* Flags */); 112 } 113 114 return rc; 107 115 } 108 116 … … 149 157 /* The status code is ignored as this information is not available with VBox < 3.2.10. */ 150 158 151 /* Init session object. */152 rc = GstCntlSessionInit(&g_Session, 0 /* Flags */);153 159 if (RT_SUCCESS(rc)) 154 160 rc = VbglR3GuestCtrlConnect(&g_uControlSvcClientID); … … 329 335 330 336 rc = GstCntlSessionThreadCreate(&g_lstControlSessionThreads, 331 &ssInfo, NULL /* Session*/);337 &ssInfo, NULL /* ppSessionThread */); 332 338 } 333 339 -
trunk/src/VBox/Additions/common/VBoxService/VBoxServiceControl.h
r47545 r47551 143 143 * as the main executable. */ 144 144 #define VBOXSERVICECTRLSESSION_FLAG_ANONYMOUS RT_BIT(1) 145 /** Flag indicating that start guest processes will dump their145 /** Flag indicating that started guest processes will dump their 146 146 * stdout output to a separate file on disk. For debugging. */ 147 147 #define VBOXSERVICECTRLSESSION_FLAG_DUMPSTDOUT RT_BIT(2) 148 /** Flag indicating that start guest processes will dump their148 /** Flag indicating that started guest processes will dump their 149 149 * stderr output to a separate file on disk. For debugging. */ 150 150 #define VBOXSERVICECTRLSESSION_FLAG_DUMPSTDERR RT_BIT(3) … … 174 174 /** The session's critical section. */ 175 175 RTCRITSECT CritSect; 176 /** Session flags. */ 176 /** Internal session flags, not related 177 * to StartupInfo stuff. 178 * @sa VBOXSERVICECTRLSESSION_FLAG_* flags. */ 177 179 uint32_t uFlags; 178 180 /** How many processes do we allow keeping around at a time? */ -
trunk/src/VBox/Additions/common/VBoxService/VBoxServiceControlProcess.cpp
r47545 r47551 1381 1381 return rc; 1382 1382 } 1383 1384 1385 #ifdef DEBUG 1386 static int gstcntlProcessDumpToFile(const char *pszFileName, void *pvBuf, size_t cbBuf) 1387 { 1388 AssertPtrReturn(pszFileName, VERR_INVALID_POINTER); 1389 AssertPtrReturn(pvBuf, VERR_INVALID_POINTER); 1390 1391 if (!cbBuf) 1392 return VINF_SUCCESS; 1393 1394 char szFile[RTPATH_MAX]; 1395 1396 int rc = RTPathTemp(szFile, sizeof(szFile)); 1397 if (RT_SUCCESS(rc)) 1398 rc = RTPathAppend(szFile, sizeof(szFile), pszFileName); 1399 1400 if (RT_SUCCESS(rc)) 1401 { 1402 VBoxServiceVerbose(4, "Dumping %ld bytes to \"%s\"\n", cbBuf, szFile); 1403 1404 RTFILE fh; 1405 rc = RTFileOpen(&fh, szFile, RTFILE_O_OPEN_CREATE | RTFILE_O_WRITE | RTFILE_O_DENY_WRITE); 1406 if (RT_SUCCESS(rc)) 1407 { 1408 rc = RTFileWrite(fh, pvBuf, cbBuf, NULL /* pcbWritten */); 1409 RTFileClose(fh); 1410 } 1411 } 1412 1413 return rc; 1414 } 1415 #endif 1416 1383 1417 1384 1418 /** … … 1894 1928 rc = VINF_EOF; 1895 1929 1896 #if 01930 #ifdef DEBUG 1897 1931 if (RT_SUCCESS(rc)) 1898 1932 { 1899 if ( (pSession->uFlags & VBOXSERVICECTRLSESSION_FLAG_DUMPSTDOUT) 1900 && (uHandle == OUTPUT_HANDLE_ID_STDERR)) 1901 { 1933 if ( pSession->uFlags & VBOXSERVICECTRLSESSION_FLAG_DUMPSTDOUT 1934 && ( uHandle == OUTPUT_HANDLE_ID_STDOUT 1935 || uHandle == OUTPUT_HANDLE_ID_STDOUT_DEPRECATED) 1936 ) 1937 { 1938 VBoxServiceVerbose(3, "[PID %RU32]: dump stdout\n", 1939 pThis->uPID); 1902 1940 char szDumpFile[RTPATH_MAX]; 1903 1941 if (!RTStrPrintf(szDumpFile, sizeof(szDumpFile), "VBoxService_Session%RU32_PID%RU32_StdOut.txt", 1904 1942 pSession->StartupInfo.uSessionID, pThis->uPID)) rc = VERR_BUFFER_UNDERFLOW; 1905 1943 if (RT_SUCCESS(rc)) 1906 rc = gstcntl SessionDumpToFile(szDumpFile, pvBuf, cbRead);1944 rc = gstcntlProcessDumpToFile(szDumpFile, pvBuf, cbRead); 1907 1945 AssertRC(rc); 1908 1946 } 1909 else if ( (pSession->uFlags & VBOXSERVICECTRLSESSION_FLAG_DUMPSTDERR) 1910 && ( uHandle == OUTPUT_HANDLE_ID_STDOUT 1911 || uHandle == OUTPUT_HANDLE_ID_STDOUT_DEPRECATED)) 1947 else if ( pSession->uFlags & VBOXSERVICECTRLSESSION_FLAG_DUMPSTDERR 1948 && uHandle == OUTPUT_HANDLE_ID_STDERR) 1912 1949 { 1913 1950 char szDumpFile[RTPATH_MAX]; … … 1916 1953 rc = VERR_BUFFER_UNDERFLOW; 1917 1954 if (RT_SUCCESS(rc)) 1918 rc = gstcntl SessionDumpToFile(szDumpFile, pvBuf, cbRead);1955 rc = gstcntlProcessDumpToFile(szDumpFile, pvBuf, cbRead); 1919 1956 AssertRC(rc); 1920 1957 } -
trunk/src/VBox/Additions/common/VBoxService/VBoxServiceControlSession.cpp
r47545 r47551 74 74 enum 75 75 { 76 VBOXSERVICESESSIONOPT_LOG_FILE = 1000, 76 VBOXSERVICESESSIONOPT_FIRST = 1000, /* For initialization. */ 77 #ifdef DEBUG 78 VBOXSERVICESESSIONOPT_DUMP_STDOUT, 79 VBOXSERVICESESSIONOPT_DUMP_STDERR, 80 #endif 81 VBOXSERVICESESSIONOPT_LOG_FILE, 77 82 VBOXSERVICESESSIONOPT_USERNAME, 78 83 VBOXSERVICESESSIONOPT_SESSION_ID, … … 114 119 return NULL; 115 120 } 116 117 118 #ifdef DEBUG119 static int gstcntlSessionDumpToFile(const char *pszFileName, void *pvBuf, size_t cbBuf)120 {121 AssertPtrReturn(pszFileName, VERR_INVALID_POINTER);122 AssertPtrReturn(pvBuf, VERR_INVALID_POINTER);123 124 if (!cbBuf)125 return VINF_SUCCESS;126 127 char szFile[RTPATH_MAX];128 129 int rc = RTPathTemp(szFile, sizeof(szFile));130 if (RT_SUCCESS(rc))131 rc = RTPathAppend(szFile, sizeof(szFile), pszFileName);132 133 if (RT_SUCCESS(rc))134 {135 VBoxServiceVerbose(4, "Dumping %ld bytes to \"%s\"\n", cbBuf, szFile);136 137 RTFILE fh;138 rc = RTFileOpen(&fh, szFile, RTFILE_O_OPEN_CREATE | RTFILE_O_WRITE | RTFILE_O_DENY_WRITE);139 if (RT_SUCCESS(rc))140 {141 rc = RTFileWrite(fh, pvBuf, cbBuf, NULL /* pcbWritten */);142 RTFileClose(fh);143 }144 }145 146 return rc;147 }148 #endif149 121 150 122 … … 1378 1350 1379 1351 pSession->uFlags = uFlags; 1380 1381 if (pSession->uFlags & VBOXSERVICECTRLSESSION_FLAG_FORK)1382 {1383 /* Protocol must be specified explicitly. */1384 pSession->StartupInfo.uProtocol = UINT32_MAX;1385 1386 /* Session ID must be specified explicitly. */1387 pSession->StartupInfo.uSessionID = UINT32_MAX;1388 }1389 1352 1390 1353 /* Init critical section for protecting the thread lists. */ … … 1707 1670 if (RT_SUCCESS(rc2)) 1708 1671 papszArgs[iOptIdx++] = szParmLogFile; 1709 papszArgs[iOptIdx++] = NULL; 1672 1673 rc = rc2; 1710 1674 } 1711 else 1712 papszArgs[iOptIdx++] = NULL; 1675 else if (RT_FAILURE(rc2)) 1676 rc = rc2; 1677 #ifdef DEBUG 1678 VBoxServiceVerbose(4, "rc=%Rrc, session flags=%x\n", 1679 rc, g_Session.uFlags); 1680 char szParmDumpStdOut[32]; 1681 if ( RT_SUCCESS(rc) 1682 && g_Session.uFlags & VBOXSERVICECTRLSESSION_FLAG_DUMPSTDOUT) 1683 { 1684 if (!RTStrPrintf(szParmDumpStdOut, sizeof(szParmDumpStdOut), "--dump-stdout")) 1685 rc = VERR_BUFFER_OVERFLOW; 1686 if (RT_SUCCESS(rc)) 1687 papszArgs[iOptIdx++] = szParmDumpStdOut; 1688 } 1689 char szParmDumpStdErr[32]; 1690 if ( RT_SUCCESS(rc) 1691 && g_Session.uFlags & VBOXSERVICECTRLSESSION_FLAG_DUMPSTDERR) 1692 { 1693 if (!RTStrPrintf(szParmDumpStdErr, sizeof(szParmDumpStdErr), "--dump-stderr")) 1694 rc = VERR_BUFFER_OVERFLOW; 1695 if (RT_SUCCESS(rc)) 1696 papszArgs[iOptIdx++] = szParmDumpStdErr; 1697 } 1698 #endif 1699 papszArgs[iOptIdx++] = NULL; 1713 1700 1714 1701 if (g_cVerbosity > 3) … … 1777 1764 #else 1778 1765 RTHANDLE hStdIn; 1779 rc = RTFileOpenBitBucket(&hStdIn.u.hFile, RTFILE_O_READ); 1766 if (RT_SUCCESS(rc)) 1767 rc = RTFileOpenBitBucket(&hStdIn.u.hFile, RTFILE_O_READ); 1780 1768 if (RT_SUCCESS(rc)) 1781 1769 { … … 1973 1961 static const RTGETOPTDEF s_aOptions[] = 1974 1962 { 1963 #ifdef DEBUG 1964 { "--dump-stdout", VBOXSERVICESESSIONOPT_DUMP_STDOUT, RTGETOPT_REQ_NOTHING }, 1965 { "--dump-stderr", VBOXSERVICESESSIONOPT_DUMP_STDERR, RTGETOPT_REQ_NOTHING }, 1966 #endif 1975 1967 { "--logfile", VBOXSERVICESESSIONOPT_LOG_FILE, RTGETOPT_REQ_STRING }, 1976 1968 { "--user", VBOXSERVICESESSIONOPT_USERNAME, RTGETOPT_REQ_STRING }, … … 1992 1984 uint32_t uSessionFlags = VBOXSERVICECTRLSESSION_FLAG_FORK; 1993 1985 1994 /* Init the session object. */ 1995 int rc = GstCntlSessionInit(&g_Session, uSessionFlags); 1996 if (RT_FAILURE(rc)) 1997 return RTMsgErrorExit(RTEXITCODE_FAILURE, "Failed to initialize session object, rc=%Rrc\n", rc); 1986 /* Protocol and session ID must be specified explicitly. */ 1987 g_Session.StartupInfo.uProtocol = UINT32_MAX; 1988 g_Session.StartupInfo.uSessionID = UINT32_MAX; 1989 1990 int rc = VINF_SUCCESS; 1998 1991 1999 1992 while ( (ch = RTGetOpt(&GetState, &ValueUnion)) … … 2008 2001 ValueUnion.psz); 2009 2002 break; 2010 2003 #ifdef DEBUG 2004 case VBOXSERVICESESSIONOPT_DUMP_STDOUT: 2005 uSessionFlags |= VBOXSERVICECTRLSESSION_FLAG_DUMPSTDOUT; 2006 break; 2007 2008 case VBOXSERVICESESSIONOPT_DUMP_STDERR: 2009 uSessionFlags |= VBOXSERVICECTRLSESSION_FLAG_DUMPSTDERR; 2010 break; 2011 #endif 2011 2012 case VBOXSERVICESESSIONOPT_USERNAME: 2012 /** @todo . */2013 /** @todo Information not needed right now, skip. */ 2013 2014 break; 2014 2015 … … 2049 2050 if (g_Session.StartupInfo.uSessionID == UINT32_MAX) 2050 2051 return RTMsgErrorExit(RTEXITCODE_SYNTAX, "No session ID specified"); 2052 2053 /* Init the session object. */ 2054 rc = GstCntlSessionInit(&g_Session, uSessionFlags); 2055 if (RT_FAILURE(rc)) 2056 return RTMsgErrorExit(RTEXITCODE_FAILURE, "Failed to initialize session object, rc=%Rrc\n", rc); 2051 2057 2052 2058 rc = VBoxServiceLogCreate(strlen(g_szLogFile) ? g_szLogFile : NULL);
Note:
See TracChangeset
for help on using the changeset viewer.