VirtualBox

Changeset 39427 in vbox for trunk/src/VBox/Additions


Ignore:
Timestamp:
Nov 25, 2011 2:29:43 PM (13 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
75056
Message:

r=bird: pre-review comments.

Location:
trunk/src/VBox/Additions/common
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3LibGuestCtrl.cpp

    r38133 r39427  
    55
    66/*
    7  * Copyright (C) 2010 Oracle Corporation
     7 * Copyright (C) 2010-2011 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    109109    VBoxGuestCtrlHGCMMsgType Msg;
    110110
    111     Msg.hdr.result = VERR_WRONG_ORDER;
     111    Msg.hdr.result      = VERR_WRONG_ORDER;
    112112    Msg.hdr.u32ClientID = u32ClientId;
    113113    Msg.hdr.u32Function = GUEST_GET_HOST_MSG; /* Tell the host we want our next command. */
    114     Msg.hdr.cParms = 2;                       /* Just peek for the next message! */
     114    Msg.hdr.cParms      = 2;                  /* Just peek for the next message! */
    115115
    116116    VbglHGCMParmUInt32Set(&Msg.msg, 0);
     
    141141    VBoxGuestCtrlHGCMMsgCancelPendingWaits Msg;
    142142
    143     Msg.hdr.result = VERR_WRONG_ORDER;
     143    Msg.hdr.result      = VERR_WRONG_ORDER;
    144144    Msg.hdr.u32ClientID = u32ClientId;
    145145    Msg.hdr.u32Function = GUEST_CANCEL_PENDING_WAITS;
    146     Msg.hdr.cParms = 0;
     146    Msg.hdr.cParms      = 0;
    147147
    148148    int rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_CALL(sizeof(Msg)), &Msg, sizeof(Msg));
     
    167167 ** @todo Docs!
    168168 */
    169 VBGLR3DECL(int) VbglR3GuestCtrlExecGetHostCmd(uint32_t  u32ClientId,    uint32_t  uNumParms,
    170                                               uint32_t *puContext,
    171                                               char     *pszCmd,         uint32_t  cbCmd,
    172                                               uint32_t *puFlags,
    173                                               char     *pszArgs,        uint32_t  cbArgs,   uint32_t *puNumArgs,
    174                                               char     *pszEnv,         uint32_t *pcbEnv,   uint32_t *puNumEnvVars,
    175                                               char     *pszUser,        uint32_t  cbUser,
    176                                               char     *pszPassword,    uint32_t  cbPassword,
    177                                               uint32_t *puTimeLimit)
     169VBGLR3DECL(int) VbglR3GuestCtrlExecGetHostCmdExec(uint32_t  u32ClientId,    uint32_t  cParms,
     170                                                  uint32_t *puContext,
     171                                                  char     *pszCmd,         uint32_t  cbCmd,
     172                                                  uint32_t *puFlags,
     173                                                  char     *pszArgs,        uint32_t  cbArgs,   uint32_t *pcArgs,
     174                                                  char     *pszEnv,         uint32_t *pcbEnv,   uint32_t *pcEnvVars,
     175                                                  char     *pszUser,        uint32_t  cbUser,
     176                                                  char     *pszPassword,    uint32_t  cbPassword,
     177                                                  uint32_t *pcMsTimeLimit)
    178178{
    179179    AssertPtrReturn(puContext, VERR_INVALID_PARAMETER);
     
    181181    AssertPtrReturn(puFlags, VERR_INVALID_PARAMETER);
    182182    AssertPtrReturn(pszArgs, VERR_INVALID_PARAMETER);
    183     AssertPtrReturn(puNumArgs, VERR_INVALID_PARAMETER);
     183    AssertPtrReturn(pcArgs, VERR_INVALID_PARAMETER);
    184184    AssertPtrReturn(pszEnv, VERR_INVALID_PARAMETER);
    185185    AssertPtrReturn(pcbEnv, VERR_INVALID_PARAMETER);
    186     AssertPtrReturn(puNumEnvVars, VERR_INVALID_PARAMETER);
     186    AssertPtrReturn(pcEnvVars, VERR_INVALID_PARAMETER);
    187187    AssertPtrReturn(pszUser, VERR_INVALID_PARAMETER);
    188188    AssertPtrReturn(pszPassword, VERR_INVALID_PARAMETER);
    189     AssertPtrReturn(puTimeLimit, VERR_INVALID_PARAMETER);
     189    AssertPtrReturn(pcMsTimeLimit, VERR_INVALID_PARAMETER);
    190190
    191191    VBoxGuestCtrlHGCMMsgExecCmd Msg;
    192192
    193     Msg.hdr.result = VERR_WRONG_ORDER;
     193    Msg.hdr.result      = VERR_WRONG_ORDER;
    194194    Msg.hdr.u32ClientID = u32ClientId;
    195195    Msg.hdr.u32Function = GUEST_GET_HOST_MSG;
    196     Msg.hdr.cParms = uNumParms;
     196    Msg.hdr.cParms      = cParms; /** @todo r=bird: This isn't safe/right. The parameter count of this HGCM call
     197                                   * is fixed from our point of view. */
    197198
    198199    VbglHGCMParmUInt32Set(&Msg.context, 0);
     
    220221            Msg.context.GetUInt32(puContext);
    221222            Msg.flags.GetUInt32(puFlags);
    222             Msg.num_args.GetUInt32(puNumArgs);
    223             Msg.num_env.GetUInt32(puNumEnvVars);
     223            Msg.num_args.GetUInt32(pcArgs);
     224            Msg.num_env.GetUInt32(pcEnvVars);
    224225            Msg.cb_env.GetUInt32(pcbEnv);
    225             Msg.timeout.GetUInt32(puTimeLimit);
     226            Msg.timeout.GetUInt32(pcMsTimeLimit);
    226227        }
    227228    }
     
    237238 * @returns VBox status code.
    238239 * @param   u32ClientId     The client id returned by VbglR3GuestCtrlConnect().
    239  * @param   uNumParms
    240  ** @todo Docs!
    241  */
    242 VBGLR3DECL(int) VbglR3GuestCtrlExecGetHostCmdOutput(uint32_t  u32ClientId,    uint32_t  uNumParms,
     240 * @param   cParms
     241 ** @todo Docs!
     242 */
     243VBGLR3DECL(int) VbglR3GuestCtrlExecGetHostCmdOutput(uint32_t  u32ClientId,    uint32_t  cParms,
    243244                                                    uint32_t *puContext,      uint32_t *puPID,
    244245                                                    uint32_t *puHandle,       uint32_t *puFlags)
     
    254255    Msg.hdr.u32ClientID = u32ClientId;
    255256    Msg.hdr.u32Function = GUEST_GET_HOST_MSG;
    256     Msg.hdr.cParms = uNumParms;
     257    Msg.hdr.cParms = cParms;
    257258
    258259    VbglHGCMParmUInt32Set(&Msg.context, 0);
     
    289290 * @returns VBox status code.
    290291 * @param   u32ClientId     The client id returned by VbglR3GuestCtrlConnect().
    291  * @param   uNumParms
    292  ** @todo Docs!
    293  */
    294 VBGLR3DECL(int) VbglR3GuestCtrlExecGetHostCmdInput(uint32_t  u32ClientId,    uint32_t   uNumParms,
     292 * @param   cParms
     293 ** @todo Docs!
     294 */
     295VBGLR3DECL(int) VbglR3GuestCtrlExecGetHostCmdInput(uint32_t  u32ClientId,    uint32_t   cParms,
    295296                                                   uint32_t *puContext,      uint32_t  *puPID,
    296297                                                   uint32_t *puFlags,
    297                                                    void      *pvData,        uint32_t  cbData,
     298                                                   void     *pvData,         uint32_t  cbData,
    298299                                                   uint32_t *pcbSize)
    299300{
     
    306307    VBoxGuestCtrlHGCMMsgExecIn Msg;
    307308
    308     Msg.hdr.result = VERR_WRONG_ORDER;
     309    Msg.hdr.result      = VERR_WRONG_ORDER;
    309310    Msg.hdr.u32ClientID = u32ClientId;
    310311    Msg.hdr.u32Function = GUEST_GET_HOST_MSG;
    311     Msg.hdr.cParms = uNumParms;
     312    Msg.hdr.cParms      = cParms;
    312313
    313314    VbglHGCMParmUInt32Set(&Msg.context, 0);
  • trunk/src/VBox/Additions/common/VBoxService/VBoxServiceControl.cpp

    r39418 r39427  
    3737*******************************************************************************/
    3838/** The control interval (milliseconds). */
    39 uint32_t g_ControlInterval = 0;
     39static uint32_t             g_cMsControlInterval = 0;
    4040/** The semaphore we're blocking our main control thread on. */
    41 RTSEMEVENTMULTI             g_hControlEvent = NIL_RTSEMEVENTMULTI;
     41static RTSEMEVENTMULTI      g_hControlEvent = NIL_RTSEMEVENTMULTI;
    4242/** The guest control service client ID. */
    4343static uint32_t             g_GuestControlSvcClientID = 0;
     
    4545 *  information to the host. Default is 25 processes. If 0 is specified,
    4646 *  the maximum number of processes is unlimited. */
    47 uint32_t                    g_GuestControlProcsMaxKept = 25;
     47static uint32_t             g_GuestControlProcsMaxKept = 25;
    4848/** List of guest control threads. */
    49 RTLISTNODE                  g_GuestControlThreads;
     49static RTLISTNODE           g_GuestControlThreads;
    5050/** Critical section protecting g_GuestControlExecThreads. */
    51 RTCRITSECT                  g_GuestControlThreadsCritSect;
    52 
     51static RTCRITSECT           g_GuestControlThreadsCritSect;
     52
     53
     54/*******************************************************************************
     55*   Internal Functions                                                         *
     56*******************************************************************************/
     57/** @todo Shorten "VBoxServiceControl" to "vbgsvcCntl". */
    5358static int VBoxServiceControlStartAllowed(bool *pbAllowed);
     59static int VBoxServiceControlHandleCmdStartProc(uint32_t u32ClientId, uint32_t uNumParms);
     60static int VBoxServiceControlHandleCmdSetInput(uint32_t u32ClientId, uint32_t uNumParms, size_t cbMaxBufSize);
     61static int VBoxServiceControlHandleCmdGetOutput(uint32_t u32ClientId, uint32_t uNumParms);
     62
     63
    5464
    5565/** @copydoc VBOXSERVICE::pfnPreInit */
     
    99109    else if (!strcmp(argv[*pi], "--control-interval"))
    100110        rc = VBoxServiceArgUInt32(argc, argv, "", pi,
    101                                   &g_ControlInterval, 1, UINT32_MAX - 1);
     111                                  &g_cMsControlInterval, 1, UINT32_MAX - 1);
    102112    else if (!strcmp(argv[*pi], "--control-procs-max-kept"))
    103113        rc = VBoxServiceArgUInt32(argc, argv, "", pi,
     
    114124     * Then create the event sem to block on.
    115125     */
    116     if (!g_ControlInterval)
    117         g_ControlInterval = 1000;
     126    if (!g_cMsControlInterval)
     127        g_cMsControlInterval = 1000;
    118128
    119129    int rc = RTSemEventMultiCreate(&g_hControlEvent);
     
    167177    for (;;)
    168178    {
     179        VBoxServiceVerbose(3, "Control: Waiting for host msg ...\n");
    169180        uint32_t uMsg;
    170         uint32_t uNumParms;
    171         VBoxServiceVerbose(3, "Control: Waiting for host msg ...\n");
    172         rc = VbglR3GuestCtrlWaitForHostMsg(g_GuestControlSvcClientID, &uMsg, &uNumParms);
    173         if (RT_FAILURE(rc))
    174         {
    175             if (rc == VERR_TOO_MUCH_DATA)
    176             {
    177                 VBoxServiceVerbose(4, "Control: Message requires %ld parameters, but only 2 supplied -- retrying request (no error!)...\n", uNumParms);
    178                 rc = VINF_SUCCESS; /* Try to get "real" message in next block below. */
    179             }
    180             else
    181                 VBoxServiceVerbose(3, "Control: Getting host message failed with %Rrc\n", rc); /* VERR_GEN_IO_FAILURE seems to be normal if ran  into timeout. */
    182         }
    183 
     181        uint32_t cParms;
     182        rc = VbglR3GuestCtrlWaitForHostMsg(g_GuestControlSvcClientID, &uMsg, &cParms);
     183        if (rc == VERR_TOO_MUCH_DATA)
     184        {
     185            VBoxServiceVerbose(4, "Control: Message requires %ld parameters, but only 2 supplied -- retrying request (no error!)...\n", cParms);
     186            rc = VINF_SUCCESS; /* Try to get "real" message in next block below. */
     187        }
     188        else if (RT_FAILURE(rc))
     189            VBoxServiceVerbose(3, "Control: Getting host message failed with %Rrc\n", rc); /* VERR_GEN_IO_FAILURE seems to be normal if ran  into timeout. */
    184190        if (RT_SUCCESS(rc))
    185191        {
    186             VBoxServiceVerbose(3, "Control: Msg=%u (%u parms) retrieved\n", uMsg, uNumParms);
    187             switch(uMsg)
     192            VBoxServiceVerbose(3, "Control: Msg=%u (%u parms) retrieved\n", uMsg, cParms);
     193            switch (uMsg)
    188194            {
    189195                case HOST_CANCEL_PENDING_WAITS:
     
    192198
    193199                case HOST_EXEC_CMD:
    194                     rc = VBoxServiceControlHandleCmdStartProc(g_GuestControlSvcClientID, uNumParms);
     200                    rc = VBoxServiceControlHandleCmdStartProc(g_GuestControlSvcClientID, cParms);
    195201                    break;
    196202
    197203                case HOST_EXEC_SET_INPUT:
    198204                    /** @todo Make buffer size configurable via guest properties/argv! */
    199                     rc = VBoxServiceControlHandleCmdSetInput(g_GuestControlSvcClientID, uNumParms, _1M /* Buffer size */);
     205                    rc = VBoxServiceControlHandleCmdSetInput(g_GuestControlSvcClientID, cParms, _1M /* Buffer size */);
    200206                    break;
    201207
    202208                case HOST_EXEC_GET_OUTPUT:
    203                     rc = VBoxServiceControlHandleCmdGetOutput(g_GuestControlSvcClientID, uNumParms);
     209                    rc = VBoxServiceControlHandleCmdGetOutput(g_GuestControlSvcClientID, cParms);
    204210                    break;
    205211
     
    231237 *
    232238 * @returns IPRT status code.
    233  * @param   u32ClientId                 The HGCM client session ID.
    234  * @param   uNumParms                   The number of parameters the host is offering.
    235  */
    236 int VBoxServiceControlHandleCmdStartProc(uint32_t uClientID, uint32_t uNumParms)
    237 {
    238     uint32_t uContextID;
    239     char szCmd[_1K];
    240     uint32_t uFlags;
    241     char szArgs[_1K];
    242     uint32_t uNumArgs;
    243     char szEnv[_64K];
    244     uint32_t cbEnv = sizeof(szEnv);
    245     uint32_t uNumEnvVars;
    246     char szUser[128];
    247     char szPassword[128];
    248     uint32_t uTimeLimitMS;
     239 * @param   idClient        The HGCM client session ID.
     240 * @param   cParms          The number of parameters the host is offering.
     241 */
     242static int VBoxServiceControlHandleCmdStartProc(uint32_t idClient, uint32_t cParms)
     243{
     244    uint32_t    uContextID;
     245    char        szCmd[_1K];
     246    uint32_t    uFlags;
     247    char        szArgs[_1K];
     248    uint32_t    cArgs;
     249    char        szEnv[_64K];
     250    uint32_t    cbEnv = sizeof(szEnv);
     251    uint32_t    cEnvVars;
     252    char        szUser[128];
     253    char        szPassword[128];
     254    uint32_t    uTimeLimitMS;
    249255
    250256#if 0 /* for valgrind */
     
    256262#endif
    257263
    258     if (uNumParms != 11)
     264    if (cParms != 11)
    259265        return VERR_INVALID_PARAMETER;
    260266
    261     int rc = VbglR3GuestCtrlExecGetHostCmd(uClientID,
    262                                            uNumParms,
    263                                            &uContextID,
    264                                            /* Command */
    265                                            szCmd,      sizeof(szCmd),
    266                                            /* Flags */
    267                                            &uFlags,
    268                                            /* Arguments */
    269                                            szArgs,     sizeof(szArgs), &uNumArgs,
    270                                            /* Environment */
    271                                            szEnv, &cbEnv, &uNumEnvVars,
    272                                            /* Credentials */
    273                                            szUser,     sizeof(szUser),
    274                                            szPassword, sizeof(szPassword),
    275                                            /* Timelimit */
    276                                            &uTimeLimitMS);
     267    int rc = VbglR3GuestCtrlExecGetHostCmdExec(idClient,
     268                                               cParms,
     269                                               &uContextID,
     270                                               /* Command */
     271                                               szCmd,      sizeof(szCmd),
     272                                               /* Flags */
     273                                               &uFlags,
     274                                               /* Arguments */
     275                                               szArgs,     sizeof(szArgs), &cArgs,
     276                                               /* Environment */
     277                                               szEnv, &cbEnv, &cEnvVars,
     278                                               /* Credentials */
     279                                               szUser,     sizeof(szUser),
     280                                               szPassword, sizeof(szPassword),
     281                                               /* Timelimit */
     282                                               &uTimeLimitMS);
    277283    if (RT_SUCCESS(rc))
    278284    {
    279285#ifdef DEBUG
    280286        VBoxServiceVerbose(3, "Control: Start process szCmd=%s, uFlags=%u, szArgs=%s, szEnv=%s, szUser=%s, szPW=%s, uTimeout=%u\n",
    281                            szCmd, uFlags, uNumArgs ? szArgs : "<None>", uNumEnvVars ? szEnv : "<None>", szUser, szPassword, uTimeLimitMS);
     287                           szCmd, uFlags, cArgs ? szArgs : "<None>", cEnvVars ? szEnv : "<None>", szUser, szPassword, uTimeLimitMS);
    282288#endif
    283289        bool fAllowed = false;
     
    294300                /** @todo Put the following params into a struct! */
    295301                RTLISTNODE *pThreadNode;
    296                 rc = VBoxServiceControlThreadStart(uClientID, uContextID,
    297                                                    szCmd, uFlags, szArgs, uNumArgs,
    298                                                    szEnv, cbEnv, uNumEnvVars,
     302                rc = VBoxServiceControlThreadStart(idClient, uContextID,
     303                                                   szCmd, uFlags, szArgs, cArgs,
     304                                                   szEnv, cbEnv, cEnvVars,
    299305                                                   szUser, szPassword, uTimeLimitMS,
    300306                                                   &pThreadNode);
     
    309315                    rc = rc2;
    310316            }
     317/** @todo r=bird: VbglR3GuestCtrlExecReportStatus isn't called for a number
     318 * of error paths. Both here and in the thread.  I guess that will leave the
     319 * host waiting, possibly for ever, for a status report that never arrives.
     320 *
     321 * There are similar concerns with the termination status report in case the
     322 * loop exitted with an error status (VBoxServiceControlThreadProcLoop).
     323 */
    311324        }
    312325        else /* Process start is not allowed due to policy settings. */
    313326        {
    314327            /* Tell the host. */
    315             rc = VbglR3GuestCtrlExecReportStatus(uClientID, uContextID, 0 /* PID, invalid. */,
     328            rc = VbglR3GuestCtrlExecReportStatus(idClient, uContextID, 0 /* PID, invalid. */,
    316329                                                 PROC_STS_ERROR,
    317330                                                 !fAllowed ? VERR_MAX_PROCS_REACHED : rc,
     
    427440 *
    428441 * @returns IPRT status code.
    429  * @param   u32ClientId                 The HGCM client session ID.
    430  * @param   uNumParms                   The number of parameters the host is offering.
     442 * @param   idClient                    The HGCM client session ID.
     443 * @param   cParms                      The number of parameters the host is
     444 *                                      offering.
    431445 * @param   cMaxBufSize                 The maximum buffer size for retrieving the input data.
    432446 */
    433 int VBoxServiceControlHandleCmdSetInput(uint32_t u32ClientId, uint32_t uNumParms, size_t cbMaxBufSize)
     447static int VBoxServiceControlHandleCmdSetInput(uint32_t idClient, uint32_t cParms, size_t cbMaxBufSize)
    434448{
    435449    uint32_t uContextID;
     
    448462     * Ask the host for the input data.
    449463     */
    450     int rc = VbglR3GuestCtrlExecGetHostCmdInput(u32ClientId, uNumParms,
     464    int rc = VbglR3GuestCtrlExecGetHostCmdInput(idClient, cParms,
    451465                                                &uContextID, &uPID, &uFlags,
    452466                                                pabBuffer, cbMaxBufSize, &cbSize);
     
    515529     *       regardless whether we got data or not! Otherwise the progress object
    516530     *       on the host never will get completed! */
    517     rc = VbglR3GuestCtrlExecReportStatusIn(u32ClientId, uContextID, uPID,
     531    rc = VbglR3GuestCtrlExecReportStatusIn(idClient, uContextID, uPID,
    518532                                           uStatus, uFlags, (uint32_t)cbWritten);
    519533
     
    529543 *
    530544 * @return  IPRT status code.
    531  * @param   u32ClientId     idClient    The HGCM client session ID.
    532  * @param   uNumParms       cParms      The number of parameters the host is
    533  *                                      offering.
    534  */
    535 int VBoxServiceControlHandleCmdGetOutput(uint32_t u32ClientId, uint32_t uNumParms)
     545 * @param   idClient        The HGCM client session ID.
     546 * @param   cParms          The number of parameters the host is offering.
     547 */
     548static int VBoxServiceControlHandleCmdGetOutput(uint32_t idClient, uint32_t cParms)
    536549{
    537550    uint32_t uContextID;
     
    540553    uint32_t uFlags;
    541554
    542     int rc = VbglR3GuestCtrlExecGetHostCmdOutput(u32ClientId, uNumParms,
     555    int rc = VbglR3GuestCtrlExecGetHostCmdOutput(idClient, cParms,
    543556                                                 &uContextID, &uPID, &uHandleID, &uFlags);
    544557    if (RT_SUCCESS(rc))
     
    567580             *       on the host never will get completed! */
    568581            /* cbRead now contains actual size. */
    569             int rc2 = VbglR3GuestCtrlExecSendOut(u32ClientId, uContextID, uPID, uHandleID, uFlags,
     582            int rc2 = VbglR3GuestCtrlExecSendOut(idClient, uContextID, uPID, uHandleID, uFlags,
    570583                                                 pBuf, cbRead);
    571584            if (RT_SUCCESS(rc))
     
    741754 * @param   uPID                        PID to search for.
    742755 */
    743 const PVBOXSERVICECTRLTHREAD VBoxServiceControlGetThreadLocked(uint32_t uPID)
     756PVBOXSERVICECTRLTHREAD VBoxServiceControlGetThreadLocked(uint32_t uPID)
    744757{
    745758    PVBOXSERVICECTRLTHREAD pThread = NULL;
  • trunk/src/VBox/Additions/common/VBoxService/VBoxServiceControlThread.cpp

    r39423 r39427  
    4545
    4646/**
    47  *  Allocates and gives back a thread data struct which then can be used by the worker thread.
    48  *  Needs to be freed with VBoxServiceControlExecDestroyThreadData().
     47 * Initialies the passed in thread data structure with the parameters given.
    4948 *
    5049 * @return  IPRT status code.
     
    6362 * @param   uTimeLimitMS                Time limit (in ms) of the process' life time.
    6463 */
    65 int VBoxServiceControlExecThreadAlloc(PVBOXSERVICECTRLTHREAD pThread,
    66                                       uint32_t u32ContextID,
    67                                       const char *pszCmd, uint32_t uFlags,
    68                                       const char *pszArgs, uint32_t uNumArgs,
    69                                       const char *pszEnv, uint32_t cbEnv, uint32_t uNumEnvVars,
    70                                       const char *pszUser, const char *pszPassword, uint32_t uTimeLimitMS)
     64static int gstsvcCntlExecThreadInit(PVBOXSERVICECTRLTHREAD pThread,
     65                                    uint32_t u32ContextID,
     66                                    const char *pszCmd, uint32_t uFlags,
     67                                    const char *pszArgs, uint32_t uNumArgs,
     68                                    const char *pszEnv, uint32_t cbEnv, uint32_t uNumEnvVars,
     69                                    const char *pszUser, const char *pszPassword, uint32_t uTimeLimitMS)
    7170{
    7271    AssertPtr(pThread);
     
    392391    if (fPollEvt == RTPOLL_EVT_READ)
    393392    {
    394         char abBuf[_64K];
     393        /** @todo r=bird: Drop this in favor of using /dev/null
     394         * (RTFileOpenBitBucket) instead of pipes. That'll simplify the code,
     395         * speed stuff up, avoid trouble is RTPoll is buggy and be
     396         * compatible with future wait-for-writeable-stderr/out host
     397         * notifications. */
     398        char   abBuf[_64K];
    395399        size_t cbRead;
    396400        rc = RTPipeRead(*phPipeR, abBuf, sizeof(abBuf), &cbRead);
     
    444448
    445449    PVBOXSERVICECTRLREQUEST pRequest = pThread->pRequest;
    446     AssertPtr(pRequest);
     450    AssertPtr(pRequest); /** @todo r=bird: Print error and return if invalid pointer! */
    447451
    448452    switch (pRequest->enmType)
     
    458462
    459463        case VBOXSERVICECTRLREQUEST_STDIN_WRITE:
    460             /* Fall through is intentional. */
    461464        case VBOXSERVICECTRLREQUEST_STDIN_WRITE_EOF:
    462465        {
     
    484487
    485488        case VBOXSERVICECTRLREQUEST_STDOUT_READ:
    486             /* Fall through is intentional. */
    487489        case VBOXSERVICECTRLREQUEST_STDERR_READ:
    488490        {
     
    864866 * @param   phPipe              Where to return the end of the pipe that we
    865867 *                              should service.  Always set.
     868 *
     869 * @todo r=bird: Open the bitbucket like txsDoExecHlpRedir does when the host
     870 *       isn't interested in the guest output.  This is easier to handle
     871 *       elsewhere.
    866872 */
    867873static int VBoxServiceControlThreadSetupPipe(int fd, PRTHANDLE ph, PRTHANDLE *pph, PRTPIPE phPipe)
     
    11411147
    11421148/**
    1143  * The actual worker routine (lopp) for a started guest process.
     1149 * The actual worker routine (loop) for a started guest process.
    11441150 *
    11451151 * @return  IPRT status code.
    11461152 * @param   PVBOXSERVICECTRLTHREAD         Thread data associated with a started process.
    11471153 */
    1148 static DECLCALLBACK(int) VBoxServiceControlThreadProcessWorker(PVBOXSERVICECTRLTHREAD pThread)
     1154static int VBoxServiceControlThreadProcessWorker(PVBOXSERVICECTRLTHREAD pThread)
    11491155{
    11501156    AssertPtrReturn(pThread, VERR_INVALID_POINTER);
     
    14291435        return VERR_NO_MEMORY;
    14301436
    1431     int rc = VBoxServiceControlExecThreadAlloc(pThread,
    1432                                                uContextID,
    1433                                                pszCmd, uFlags,
    1434                                                pszArgs, uNumArgs,
    1435                                                pszEnv, cbEnv, uNumEnvVars,
    1436                                                pszUser, pszPassword,
    1437                                                uTimeLimitMS);
     1437    int rc = gstsvcCntlExecThreadInit(pThread,
     1438                                      uContextID,
     1439                                      pszCmd, uFlags,
     1440                                      pszArgs, uNumArgs,
     1441                                      pszEnv, cbEnv, uNumEnvVars,
     1442                                      pszUser, pszPassword,
     1443                                      uTimeLimitMS);
    14381444    if (RT_SUCCESS(rc))
    14391445    {
    1440         static uint32_t uCtrlExecThread = 0;
    1441         char szThreadName[32];
    1442         if (!RTStrPrintf(szThreadName, sizeof(szThreadName), "controlexec%ld", uCtrlExecThread++))
    1443             AssertMsgFailed(("Unable to create unique control exec thread name!\n"));
    1444 
    1445         rc = RTThreadCreate(&pThread->Thread, VBoxServiceControlThread,
    1446                             (void *)(PVBOXSERVICECTRLTHREAD*)pThread, 0,
    1447                             RTTHREADTYPE_DEFAULT, RTTHREADFLAGS_WAITABLE, szThreadName);
     1446        static uint32_t s_uCtrlExecThread = 0;
     1447
     1448        rc = RTThreadCreateF(&pThread->Thread, VBoxServiceControlThread,
     1449                             pThread /*pvUser*/, 0 /*cbStack*/,
     1450                             RTTHREADTYPE_DEFAULT, RTTHREADFLAGS_WAITABLE, "controlexec%u", s_uCtrlExecThread++);
    14481451        if (RT_FAILURE(rc))
    14491452        {
     
    14941497
    14951498    int rc = VINF_SUCCESS;
    1496     const PVBOXSERVICECTRLTHREAD pThread = VBoxServiceControlGetThreadLocked(uPID);
     1499    PVBOXSERVICECTRLTHREAD pThread = VBoxServiceControlGetThreadLocked(uPID);
    14971500    if (pThread)
    14981501    {
  • trunk/src/VBox/Additions/common/VBoxService/VBoxServiceInternal.h

    r39418 r39427  
    340340#ifdef VBOX_WITH_GUEST_CONTROL
    341341/* Guest control functions. */
    342 extern int          VBoxServiceControlHandleCmdStartProc(uint32_t u32ClientId, uint32_t uNumParms);
    343 extern int          VBoxServiceControlHandleCmdSetInput(uint32_t u32ClientId, uint32_t uNumParms, size_t cbMaxBufSize);
    344 extern int          VBoxServiceControlHandleCmdGetOutput(uint32_t u32ClientId, uint32_t uNumParms);
    345 extern const PVBOXSERVICECTRLTHREAD VBoxServiceControlGetThreadLocked(uint32_t uPID);
     342extern PVBOXSERVICECTRLTHREAD VBoxServiceControlGetThreadLocked(uint32_t uPID);
    346343extern void         VBoxServiceControlThreadUnlock(const PVBOXSERVICECTRLTHREAD pThread);
    347344extern int          VBoxServiceControlAssignPID(PVBOXSERVICECTRLTHREAD pThread, uint32_t uPID);
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette