VirtualBox

Changeset 75858 in vbox


Ignore:
Timestamp:
Dec 1, 2018 10:13:05 PM (6 years ago)
Author:
vboxsync
Message:

VBoxService: Mark printf-style formatters as such, fixing fallout. Eliminated another redundant connection to the guest control service. bugref:9313

Location:
trunk/src/VBox/Additions/common/VBoxService
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/common/VBoxService/VBoxServiceAutoMount.cpp

    r75469 r75858  
    787787    }
    788788    else
    789         VGSvcError("vbsvcAutomounterQueryMountDirAndPrefix: RTPathAbs(%s) -> %Rrc\n", rc);
     789        VGSvcError("vbsvcAutomounterQueryMountDirAndPrefix: RTPathAbs(%s) -> %Rrc\n", pszDir, rc);
    790790
    791791
     
    967967     */
    968968    FILE *pFile = setmntent("/proc/mounts", "r");
     969    int iErrMounts = errno;
    969970    if (!pFile)
    970971        pFile = setmntent("/etc/mtab", "r");
     
    988989    else
    989990        VGSvcError("vbsvcAutomounterQueryMountPoint: Could not open mount tab '%s' (errno=%d) or '/proc/mounts' (errno=%d)\n",
    990                    _PATH_MOUNTED, errno);
     991                   _PATH_MOUNTED, errno, iErrMounts);
    991992
    992993#elif defined(RT_OS_SOLARIS)
  • trunk/src/VBox/Additions/common/VBoxService/VBoxServiceControl.h

    r75807 r75858  
    251251    /** Whether the guest process thread was started or not. */
    252252    bool                            fStarted;
    253     /** Client ID. */
    254     uint32_t                        uClientID;
    255253    /** Context ID. */
    256254    uint32_t                        uContextID;
  • trunk/src/VBox/Additions/common/VBoxService/VBoxServiceControlProcess.cpp

    r75807 r75858  
    516516                       pProcess->uPID, pProcess->StartupInfo.szCmd, pProcess->uContextID,
    517517                       pProcess->StartupInfo.szUser, pProcess->StartupInfo.uTimeLimitMS);
    518     VBGLR3GUESTCTRLCMDCTX ctxStart = { pProcess->uClientID, pProcess->uContextID };
     518    VBGLR3GUESTCTRLCMDCTX ctxStart = { g_idControlSvcClient, pProcess->uContextID };
    519519    rc = VbglR3GuestCtrlProcCbStatus(&ctxStart,
    520520                                     pProcess->uPID, PROC_STS_STARTED, 0 /* u32Flags */,
     
    694694    }
    695695
    696     VGSvcVerbose(3, "[PID %RU32]: Loop ended: rc=%Rrc, fShutdown=%RTbool, fProcessAlive=%RTbool, fProcessTimedOut=%RTbool, MsProcessKilled=%RU64\n",
     696    VGSvcVerbose(3, "[PID %RU32]: Loop ended: rc=%Rrc, fShutdown=%RTbool, fProcessAlive=%RTbool, fProcessTimedOut=%RTbool, MsProcessKilled=%RU64 (%RX64)\n",
    697697                 pProcess->uPID, rc, pProcess->fShutdown, fProcessAlive, fProcessTimedOut, MsProcessKilled, MsProcessKilled);
    698698    VGSvcVerbose(3, "[PID %RU32]: *phStdOutR=%s, *phStdErrR=%s\n",
     
    832832        else
    833833            VGSvcVerbose(1, "[PID %RU32]: Handling process status %u not implemented\n", pProcess->uPID, ProcessStatus.enmReason);
     834        VBGLR3GUESTCTRLCMDCTX ctxEnd = { g_idControlSvcClient, pProcess->uContextID };
    834835        VGSvcVerbose(2, "[PID %RU32]: Ended, ClientID=%u, CID=%u, Status=%u, Flags=0x%x\n",
    835                      pProcess->uPID, pProcess->uClientID, pProcess->uContextID, uStatus, fFlags);
    836 
    837         VBGLR3GUESTCTRLCMDCTX ctxEnd = { pProcess->uClientID, pProcess->uContextID };
     836                     pProcess->uPID, ctxEnd.uClientID, pProcess->uContextID, uStatus, fFlags);
     837
    838838        rc2 = VbglR3GuestCtrlProcCbStatus(&ctxEnd, pProcess->uPID, uStatus, fFlags, NULL /* pvData */, 0 /* cbData */);
    839839        if (   RT_FAILURE(rc2)
     
    14481448    VGSvcVerbose(3, "Thread of process pThread=0x%p = '%s' started\n", pProcess, pProcess->StartupInfo.szCmd);
    14491449
    1450     int rc = VbglR3GuestCtrlConnect(&pProcess->uClientID);
    1451     if (RT_FAILURE(rc))
    1452     {
    1453         VGSvcError("Process thread '%s' (%p) failed to connect to the guest control service, rc=%Rrc\n",
    1454                    pProcess->StartupInfo.szCmd, pProcess, rc);
    1455         RTThreadUserSignal(RTThreadSelf());
    1456         return rc;
    1457     }
    1458 
    1459     VGSvcVerbose(3, "Guest process '%s' got client ID=%u, flags=0x%x\n",
    1460                  pProcess->StartupInfo.szCmd, pProcess->uClientID, pProcess->StartupInfo.uFlags);
    1461 
    1462     /* Legacy setting: */
    1463     if (!VbglR3GuestCtrlSupportsOptimizations(pProcess->uClientID))
    1464     {
    1465         rc = VbglR3GuestCtrlMsgFilterSet(pProcess->uClientID, 0 /* Skip all */,
    1466                                          0 /* Filter mask to add */, 0 /* Filter mask to remove */);
    1467         if (RT_FAILURE(rc))
    1468             VGSvcError("Unable to set message filter, rc=%Rrc\n", rc); /* Non-critical. */
    1469     }
    1470 
    1471     rc = VGSvcGstCtrlSessionProcessAdd(pProcess->pSession, pProcess);
     1450    VGSvcVerbose(3, "Guest process '%s', flags=0x%x\n", pProcess->StartupInfo.szCmd, pProcess->StartupInfo.uFlags);
     1451
     1452    int rc = VGSvcGstCtrlSessionProcessAdd(pProcess->pSession, pProcess);
    14721453    if (RT_FAILURE(rc))
    14731454    {
     
    15831564                            {
    15841565                                uint32_t uFlags = RTPOLL_EVT_ERROR;
    1585     #if 0
     1566#if 0
    15861567                                /* Add reading event to pollset to get some more information. */
    15871568                                uFlags |= RTPOLL_EVT_READ;
    1588     #endif
     1569#endif
    15891570                                /* Stdin. */
    15901571                                if (RT_SUCCESS(rc))
     
    16981679    }
    16991680
    1700     if (pProcess->uClientID)
    1701     {
    1702         if (RT_FAILURE(rc))
    1703         {
    1704             VBGLR3GUESTCTRLCMDCTX ctx = { pProcess->uClientID, pProcess->uContextID };
    1705             int rc2 = VbglR3GuestCtrlProcCbStatus(&ctx,
    1706                                                   pProcess->uPID, PROC_STS_ERROR, rc,
    1707                                                   NULL /* pvData */, 0 /* cbData */);
    1708             if (   RT_FAILURE(rc2)
    1709                 && rc2 != VERR_NOT_FOUND)
    1710                 VGSvcError("[PID %RU32]: Could not report process failure error; rc=%Rrc (process error %Rrc)\n",
    1711                            pProcess->uPID, rc2, rc);
    1712         }
    1713 
    1714         /* Disconnect this client from the guest control service. This also cancels all
    1715          * outstanding host requests. */
    1716         VGSvcVerbose(3, "[PID %RU32]: Disconnecting (client ID=%u) ...\n", pProcess->uPID, pProcess->uClientID);
    1717         VbglR3GuestCtrlDisconnect(pProcess->uClientID);
    1718         pProcess->uClientID = 0;
     1681    if (RT_FAILURE(rc))
     1682    {
     1683        VBGLR3GUESTCTRLCMDCTX ctx = { g_idControlSvcClient, pProcess->uContextID };
     1684        int rc2 = VbglR3GuestCtrlProcCbStatus(&ctx,
     1685                                              pProcess->uPID, PROC_STS_ERROR, rc,
     1686                                              NULL /* pvData */, 0 /* cbData */);
     1687        if (   RT_FAILURE(rc2)
     1688            && rc2 != VERR_NOT_FOUND)
     1689            VGSvcError("[PID %RU32]: Could not report process failure error; rc=%Rrc (process error %Rrc)\n",
     1690                       pProcess->uPID, rc2, rc);
    17191691    }
    17201692
     
    18081780    {
    18091781        static uint32_t s_uCtrlExecThread = 0;
    1810         if (s_uCtrlExecThread++ == UINT32_MAX)
     1782        if (s_uCtrlExecThread++ == UINT32_MAX) /** @todo r=bird: ????????????? */
    18111783            s_uCtrlExecThread = 0; /* Wrap around to not let IPRT freak out. */
    18121784        rc = RTThreadCreateF(&pProcess->Thread, vgsvcGstCtrlProcessThread,
  • trunk/src/VBox/Additions/common/VBoxService/VBoxServiceControlSession.cpp

    r75853 r75858  
    256256            else
    257257            {
    258                 VGSvcError("[File %s] empty filename!\n");
     258                VGSvcError("[File %s] empty filename!\n", szFile);
    259259                rc = VERR_INVALID_NAME;
    260260            }
     
    14991499                    rc = VbglR3GuestCtrlSessionAccept(idClient, idSession, abSecretKey, sizeof(abSecretKey));
    15001500                    if (RT_SUCCESS(rc))
    1501                         VGSvcVerbose(3, "Session %u accepted\n");
     1501                        VGSvcVerbose(3, "Session %u accepted (client ID %u)\n", idClient, idSession);
    15021502                    else
    1503                         VGSvcError("Failed to accept session: %Rrc\n", rc);
     1503                        VGSvcError("Failed to accept session %u (client ID %u): %Rrc\n", idClient, idSession, rc);
    15041504                }
    15051505                else
     
    15091509                                                     VBOX_GUESTCTRL_FILTER_BY_SESSION(idSession), 0);
    15101510                    if (RT_SUCCESS(rc))
    1511                         VGSvcVerbose(3, "Session %u filtering successfully enabled\n");
     1511                        VGSvcVerbose(3, "Session %u filtering successfully enabled\n", idSession);
    15121512                    else
    15131513                        VGSvcError("Failed to set session filter: %Rrc\n", rc);
     
    15491549        return VGSvcError("Error connecting to guest control service, rc=%Rrc\n", rc);
    15501550    g_fControlSupportsOptimizations = VbglR3GuestCtrlSupportsOptimizations(idClient);
     1551    g_idControlSvcClient            = idClient;
    15511552
    15521553    rc = vgsvcGstCtrlSessionReadKeyAndAccept(idClient, pSession->StartupInfo.uSessionID);
     
    16181619    VGSvcVerbose(3, "Disconnecting client ID=%RU32 ...\n", idClient);
    16191620    VbglR3GuestCtrlDisconnect(idClient);
     1621    g_idControlSvcClient = 0;
    16201622
    16211623    VGSvcVerbose(3, "Session worker returned with rc=%Rrc\n", rc);
  • trunk/src/VBox/Additions/common/VBoxService/VBoxServiceInternal.h

    r70346 r75858  
    182182#endif
    183183
    184 extern RTEXITCODE               VGSvcSyntax(const char *pszFormat, ...);
    185 extern RTEXITCODE               VGSvcError(const char *pszFormat, ...);
    186 extern void                     VGSvcVerbose(unsigned iLevel, const char *pszFormat, ...);
     184extern RTEXITCODE               VGSvcSyntax(const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(1, 2);
     185extern RTEXITCODE               VGSvcError(const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(1, 2);
     186extern void                     VGSvcVerbose(unsigned iLevel, const char *pszFormat, ...)  RT_IPRT_FORMAT_ATTR(2, 3);
    187187extern int                      VGSvcLogCreate(const char *pszLogFile);
    188 extern void                     VGSvcLogV(const char *pszFormat, va_list va);
     188extern void                     VGSvcLogV(const char *pszFormat, va_list va) RT_IPRT_FORMAT_ATTR(1, 0);
    189189extern void                     VGSvcLogDestroy(void);
    190190extern int                      VGSvcArgUInt32(int argc, char **argv, const char *psz, int *pi, uint32_t *pu32,
Note: See TracChangeset for help on using the changeset viewer.

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