VirtualBox

Changeset 75495 in vbox for trunk/src/VBox/Main/src-client


Ignore:
Timestamp:
Nov 15, 2018 8:53:00 PM (6 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
126652
Message:

HGCM,Main,SharedFolder,SharedClipboard,GuestProperties: Added HGCM service helpers for statistics and dbg info registration/deregistration. A PUVM is passed to HGCMService (where the helpers are implemented) when the service is loaded. Since this drags in both dbg.h and stam.h, LOG_GROUP defines now have to be at the top of the include list as everywhere else (i.e. hgcmsvc.h will define LOG_GROUP default by dragging in log.h). Added generic statistics of HGCM message processing and function level statistics to the shared folder service.

Location:
trunk/src/VBox/Main/src-client
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-client/ConsoleImpl.cpp

    r75488 r75495  
    82188218        alock.release();
    82198219
    8220         DBGFR3InfoDeregisterExternal(pUVM, "guestprops"); /* will crash in unloaded code if we guru later */
    82218220        m_pVMMDev->hgcmShutdown();
    82228221
  • trunk/src/VBox/Main/src-client/ConsoleImpl2.cpp

    r75352 r75495  
    31923192         * Guest property service.
    31933193         */
    3194         rc = i_configGuestProperties(this, pUVM);
    3195 #endif /* VBOX_WITH_GUEST_PROPS defined */
     3194        rc = i_configGuestProperties(this);
     3195#endif
    31963196
    31973197#ifdef VBOX_WITH_GUEST_CONTROL
     
    32003200         */
    32013201        rc = i_configGuestControl(this);
    3202 #endif /* VBOX_WITH_GUEST_CONTROL defined */
     3202#endif
    32033203
    32043204        /*
     
    60916091 * the machine XML and set a couple of initial properties.
    60926092 */
    6093 /* static */ int Console::i_configGuestProperties(void *pvConsole, PUVM pUVM)
     6093/* static */ int Console::i_configGuestProperties(void *pvConsole)
    60946094{
    60956095#ifdef VBOX_WITH_GUEST_PROPS
     
    61156115         * change.
    61166116         */
    6117 
    6118         {
    6119             VBOXHGCMSVCPARM Params[2];
    6120             int rc2 = pConsole->m_pVMMDev->hgcmHostCall("VBoxGuestPropSvc", GUEST_PROP_FN_HOST_GET_DBGF_INFO, 2, &Params[0]);
    6121             if (RT_SUCCESS(rc2))
    6122             {
    6123                 PFNDBGFHANDLEREXT pfnHandler = (PFNDBGFHANDLEREXT)(uintptr_t)Params[0].u.pointer.addr;
    6124                 void *pvService = Params[1].u.pointer.addr;
    6125                 DBGFR3InfoRegisterExternal(pUVM, "guestprops", "Display the guest properties", pfnHandler, pvService);
    6126             }
    6127         }
    61286117
    61296118        /* Sysprep execution by VBoxService. */
  • trunk/src/VBox/Main/src-client/HGCM.cpp

    r75406 r75495  
    2525#include <VBox/hgcmsvc.h>
    2626#include <VBox/vmm/ssm.h>
     27#include <VBox/vmm/stam.h>
    2728#include <VBox/sup.h>
    2829
     
    115116        HGCMSVCEXTHANDLE m_hExtension;
    116117
     118        PUVM m_pUVM;
     119
     120        /** @name Statistics
     121         * @{ */
     122        STAMPROFILE m_StatHandleMsg;
     123        /** @} */
     124
    117125        int loadServiceDLL(void);
    118126        void unloadServiceDLL(void);
     
    121129         * Main HGCM thread methods.
    122130         */
    123         int instanceCreate(const char *pszServiceLibrary, const char *pszServiceName);
     131        int instanceCreate(const char *pszServiceLibrary, const char *pszServiceName, PUVM pUVM);
    124132        void instanceDestroy(void);
    125133
     
    133141        static DECLCALLBACK(void) svcHlpDisconnectClient(void *pvInstance, uint32_t u32ClientId);
    134142        static DECLCALLBACK(bool) svcHlpIsCallRestored(VBOXHGCMCALLHANDLE callHandle);
     143        static DECLCALLBACK(int)  svcHlpStamRegisterV(void *pvInstance, void *pvSample, STAMTYPE enmType,
     144                                                      STAMVISIBILITY enmVisibility, STAMUNIT enmUnit, const char *pszDesc,
     145                                                      const char *pszName, va_list va);
     146        static DECLCALLBACK(int)  svcHlpStamDeregisterV(void *pvInstance, const char *pszPatFmt, va_list va);
     147        static DECLCALLBACK(int)  svcHlpInfoRegister(void *pvInstance, const char *pszName, const char *pszDesc,
     148                                                     PFNDBGFHANDLEREXT pfnHandler, void *pvUser);
     149        static DECLCALLBACK(int)  svcHlpInfoDeregister(void *pvInstance, const char *pszName);
    135150
    136151    public:
     
    139154         * Main HGCM thread methods.
    140155         */
    141         static int LoadService(const char *pszServiceLibrary, const char *pszServiceName);
     156        static int LoadService(const char *pszServiceLibrary, const char *pszServiceName, PUVM pUVM);
    142157        void UnloadService(void);
    143158
     
    243258    m_cHandleAcquires (0),
    244259#endif
    245     m_hExtension (NULL)
     260    m_hExtension (NULL),
     261    m_pUVM       (NULL)
    246262{
    247263    RT_ZERO(m_fntable);
     
    380396class HGCMMsgSvcLoad: public HGCMMsgCore
    381397{
     398    public:
     399        HGCMMsgSvcLoad() : HGCMMsgCore(), pUVM() {}
     400
     401        /** The user mode VM handle (for statistics and such). */
     402        PUVM pUVM;
    382403};
    383404
     
    525546        }
    526547
     548        STAM_REL_PROFILE_START(&pSvc->m_StatHandleMsg, a);
     549
    527550        /* Cache required information to avoid unnecessary pMsgCore access. */
    528551        uint32_t u32MsgId = pMsgCore->MsgId();
     
    753776            hgcmMsgComplete (pMsgCore, rc);
    754777        }
     778        STAM_REL_PROFILE_STOP(&pSvc->m_StatHandleMsg, a);
    755779    }
    756780}
     
    807831}
    808832
     833/**
     834 * @interface_method_impl{VBOXHGCMSVCHELPERS,pfnStamRegisterV}
     835 */
     836/* static */ DECLCALLBACK(int)
     837HGCMService::svcHlpStamRegisterV(void *pvInstance, void *pvSample, STAMTYPE enmType, STAMVISIBILITY enmVisibility,
     838                                 STAMUNIT enmUnit, const char *pszDesc, const char *pszName, va_list va)
     839{
     840     HGCMService *pService = static_cast <HGCMService *>(pvInstance);
     841     AssertPtrReturn(pService, VERR_INVALID_PARAMETER);
     842
     843     return STAMR3RegisterVU(pService->m_pUVM, pvSample, enmType, enmVisibility, enmUnit, pszDesc, pszName, va);
     844}
     845
     846/**
     847 * @interface_method_impl{VBOXHGCMSVCHELPERS,pfnStamDeregisterV}
     848 */
     849/* static */ DECLCALLBACK(int) HGCMService::svcHlpStamDeregisterV(void *pvInstance, const char *pszPatFmt, va_list va)
     850{
     851     HGCMService *pService = static_cast <HGCMService *>(pvInstance);
     852     AssertPtrReturn(pService, VERR_INVALID_PARAMETER);
     853
     854     return STAMR3DeregisterV(pService->m_pUVM, pszPatFmt, va);
     855}
     856
     857/**
     858 * @interface_method_impl{VBOXHGCMSVCHELPERS,pfnInfoRegister}
     859 */
     860/* static */ DECLCALLBACK(int) HGCMService::svcHlpInfoRegister(void *pvInstance, const char *pszName, const char *pszDesc,
     861                                                               PFNDBGFHANDLEREXT pfnHandler, void *pvUser)
     862{
     863     HGCMService *pService = static_cast <HGCMService *>(pvInstance);
     864     AssertPtrReturn(pService, VERR_INVALID_PARAMETER);
     865
     866     return DBGFR3InfoRegisterExternal(pService->m_pUVM, pszName, pszDesc, pfnHandler, pvUser);
     867}
     868
     869/**
     870 * @interface_method_impl{VBOXHGCMSVCHELPERS,pfnInfoDeregister}
     871 */
     872/* static */ DECLCALLBACK(int) HGCMService::svcHlpInfoDeregister(void *pvInstance, const char *pszName)
     873{
     874     HGCMService *pService = static_cast <HGCMService *>(pvInstance);
     875     AssertPtrReturn(pService, VERR_INVALID_PARAMETER);
     876
     877     return DBGFR3InfoDeregisterExternal(pService->m_pUVM, pszName);
     878}
     879
     880
    809881static DECLCALLBACK(void) hgcmMsgCompletionCallback(int32_t result, HGCMMsgCore *pMsgCore)
    810882{
     
    824896 */
    825897
    826 int HGCMService::instanceCreate(const char *pszServiceLibrary, const char *pszServiceName)
     898int HGCMService::instanceCreate(const char *pszServiceLibrary, const char *pszServiceName, PUVM pUVM)
    827899{
    828900    LogFlowFunc(("name %s, lib %s\n", pszServiceName, pszServiceLibrary));
    829 
    830901    /* The maximum length of the thread name, allowed by the RT is 15. */
    831902    char szThreadName[16];
     
    856927        else
    857928        {
     929            /* Register statistics: */
     930            m_pUVM = pUVM;
     931            STAMR3RegisterFU(pUVM, &m_StatHandleMsg, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES,
     932                             "Message handling", "/HGCM/%s/Msg", pszServiceName);
     933
    858934            /* Initialize service helpers table. */
    859935            m_svcHelpers.pfnCallComplete     = svcHlpCallComplete;
     
    861937            m_svcHelpers.pfnDisconnectClient = svcHlpDisconnectClient;
    862938            m_svcHelpers.pfnIsCallRestored   = svcHlpIsCallRestored;
     939            m_svcHelpers.pfnStamRegisterV    = svcHlpStamRegisterV;
     940            m_svcHelpers.pfnStamDeregisterV  = svcHlpStamDeregisterV;
     941            m_svcHelpers.pfnInfoRegister     = svcHlpInfoRegister;
     942            m_svcHelpers.pfnInfoDeregister   = svcHlpInfoDeregister;
    863943
    864944            /* Execute the load request on the service thread. */
     
    868948            if (RT_SUCCESS(rc))
    869949            {
     950                HGCMMsgSvcLoad *pMsg = (HGCMMsgSvcLoad *)hgcmObjReference(hMsg, HGCMOBJ_MSG);
     951                AssertRelease(pMsg);
     952                pMsg->pUVM = pUVM;
     953                hgcmObjDereference(pMsg);
     954
    870955                rc = hgcmMsgSend(hMsg);
    871956            }
     
    899984    }
    900985
     986    if (m_pszSvcName)
     987        STAMR3DeregisterF(m_pUVM, "/HGCM/%s/*", m_pszSvcName);
     988    m_pUVM = NULL;
     989
    901990    RTStrFree(m_pszSvcLibrary);
    902991    m_pszSvcLibrary = NULL;
     
    9601049 * @param pszServiceLibrary  The library to be loaded.
    9611050 * @param pszServiceName     The name of the service.
     1051 * @param pUVM               The user mode VM handle (for statistics and such).
    9621052 * @return VBox rc.
    9631053 * @thread main HGCM
    9641054 */
    965 /* static */ int HGCMService::LoadService(const char *pszServiceLibrary, const char *pszServiceName)
    966 {
    967     LogFlowFunc(("lib %s, name = %s\n", pszServiceLibrary, pszServiceName));
     1055/* static */ int HGCMService::LoadService(const char *pszServiceLibrary, const char *pszServiceName, PUVM pUVM)
     1056{
     1057    LogFlowFunc(("lib %s, name = %s, pUVM = %p\n", pszServiceLibrary, pszServiceName, pUVM));
    9681058
    9691059    /* Look at already loaded services to avoid double loading. */
     
    9811071    {
    9821072        /* Create the new service. */
    983         pSvc = new HGCMService();
     1073        pSvc = new (std::nothrow) HGCMService();
    9841074
    9851075        if (!pSvc)
     
    9901080        {
    9911081            /* Load the library and call the initialization entry point. */
    992             rc = pSvc->instanceCreate(pszServiceLibrary, pszServiceName);
     1082            rc = pSvc->instanceCreate(pszServiceLibrary, pszServiceName, pUVM);
    9931083
    9941084            if (RT_SUCCESS(rc))
     
    17441834        /* Name to be assigned to the service. */
    17451835        const char *pszServiceName;
     1836        /** The user mode VM handle (for statistics and such). */
     1837        PUVM pUVM;
    17461838};
    17471839
     
    19162008                HGCMMsgMainLoad *pMsg = (HGCMMsgMainLoad *)pMsgCore;
    19172009
    1918                 LogFlowFunc(("HGCM_MSG_LOAD pszServiceName = %s, pMsg->pszServiceLibrary = %s\n",
    1919                              pMsg->pszServiceName, pMsg->pszServiceLibrary));
    1920 
    1921                 rc = HGCMService::LoadService(pMsg->pszServiceLibrary, pMsg->pszServiceName);
     2010                LogFlowFunc(("HGCM_MSG_LOAD pszServiceName = %s, pMsg->pszServiceLibrary = %s, pMsg->pUVM = %p\n",
     2011                             pMsg->pszServiceName, pMsg->pszServiceLibrary, pMsg->pUVM));
     2012
     2013                rc = HGCMService::LoadService(pMsg->pszServiceLibrary, pMsg->pszServiceName, pMsg->pUVM);
    19222014            } break;
    19232015
     
    21092201 * @param pszServiceLibrary  The library to be loaded.
    21102202 * @param pszServiceName     The name to be assigned to the service.
     2203 * @param pUVM               The user mode VM handle (for statistics and such).
    21112204 * @return VBox rc.
    21122205 */
    21132206int HGCMHostLoad(const char *pszServiceLibrary,
    2114                  const char *pszServiceName)
     2207                 const char *pszServiceName,
     2208                 PUVM pUVM)
    21152209{
    21162210    LogFlowFunc(("lib = %s, name = %s\n", pszServiceLibrary, pszServiceName));
     
    21342228        pMsg->pszServiceLibrary = pszServiceLibrary;
    21352229        pMsg->pszServiceName    = pszServiceName;
     2230        pMsg->pUVM              = pUVM;
    21362231
    21372232        hgcmObjDereference(pMsg);
  • trunk/src/VBox/Main/src-client/VMMDevInterface.cpp

    r75167 r75495  
    9898    {
    9999        ASMAtomicWriteBool(&m_fHGCMActive, false);
    100         if (mParent)
    101         {
    102             Console::SafeVMPtrQuiet ptrVM(mParent);
    103             if (ptrVM.rawUVM())
    104                 DBGFR3InfoDeregisterExternal(ptrVM.rawUVM(), "guestprops"); /* will crash in unloaded code if we guru later */
    105         }
    106100        HGCMHostShutdown();
    107101    }
     
    701695        return VERR_INVALID_STATE;
    702696
    703     return HGCMHostLoad(pszServiceLibrary, pszServiceName);
     697    Console::SafeVMPtrQuiet ptrVM(mParent);
     698    return HGCMHostLoad(pszServiceLibrary, pszServiceName, ptrVM.rawUVM());
    704699}
    705700
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