Changeset 75574 in vbox for trunk/src/VBox/Main/src-client
- Timestamp:
- Nov 19, 2018 2:31:44 PM (6 years ago)
- Location:
- trunk/src/VBox/Main/src-client
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-client/ConsoleImpl.cpp
r75495 r75574 10396 10396 * If VMR3Create() failed it has released the VM memory. 10397 10397 */ 10398 if (pConsole->m_pVMMDev) 10399 { 10400 alock.release(); /* just to be on the safe side... */ 10401 pConsole->m_pVMMDev->hgcmShutdown(true /*fUvmIsInvalid*/); 10402 alock.acquire(); 10403 } 10398 10404 VMR3ReleaseUVM(pConsole->mpUVM); 10399 10405 pConsole->mpUVM = NULL; -
trunk/src/VBox/Main/src-client/HGCM.cpp
r75541 r75574 156 156 */ 157 157 static int LoadService(const char *pszServiceLibrary, const char *pszServiceName, PUVM pUVM); 158 void UnloadService( void);159 160 static void UnloadAll( void);158 void UnloadService(bool fUvmIsInvalid); 159 160 static void UnloadAll(bool fUvmIsInvalid); 161 161 162 162 static int ResolveService(HGCMService **ppsvc, const char *pszServiceName); … … 865 865 AssertPtrReturn(pService, VERR_INVALID_PARAMETER); 866 866 867 return STAMR3DeregisterV(pService->m_pUVM, pszPatFmt, va); 867 if (pService->m_pUVM) 868 return STAMR3DeregisterV(pService->m_pUVM, pszPatFmt, va); 869 return VINF_SUCCESS; 868 870 } 869 871 … … 887 889 HGCMService *pService = static_cast <HGCMService *>(pvInstance); 888 890 AssertPtrReturn(pService, VERR_INVALID_PARAMETER); 889 890 return DBGFR3InfoDeregisterExternal(pService->m_pUVM, pszName); 891 if (pService->m_pUVM) 892 return DBGFR3InfoDeregisterExternal(pService->m_pUVM, pszName); 893 return VINF_SUCCESS; 891 894 } 892 895 … … 994 997 } 995 998 996 if (m_pszSvcName )999 if (m_pszSvcName && m_pUVM) 997 1000 STAMR3DeregisterF(m_pUVM, "/HGCM/%s/*", m_pszSvcName); 998 1001 m_pUVM = NULL; … … 1121 1124 * @thread main HGCM 1122 1125 */ 1123 void HGCMService::UnloadService( void)1126 void HGCMService::UnloadService(bool fUvmIsInvalid) 1124 1127 { 1125 1128 LogFlowFunc(("name = %s\n", m_pszSvcName)); 1129 1130 if (fUvmIsInvalid) 1131 m_pUVM = NULL; 1126 1132 1127 1133 /* Remove the service from the list. */ … … 1158 1164 * @thread main HGCM 1159 1165 */ 1160 /* static */ void HGCMService::UnloadAll( void)1166 /* static */ void HGCMService::UnloadAll(bool fUvmIsInvalid) 1161 1167 { 1162 1168 while (sm_pSvcListHead) 1163 1169 { 1164 sm_pSvcListHead->UnloadService( );1170 sm_pSvcListHead->UnloadService(fUvmIsInvalid); 1165 1171 } 1166 1172 } … … 1844 1850 class HGCMMsgMainQuit: public HGCMMsgCore 1845 1851 { 1852 public: 1853 /** Whether UVM has gone invalid already or not. */ 1854 bool fUvmIsInvalid; 1846 1855 }; 1847 1856 … … 1849 1858 { 1850 1859 public: 1851 /* Returned handle to be used in HGCMMsgMainUnregisterExtension. */1860 /** Returned handle to be used in HGCMMsgMainUnregisterExtension. */ 1852 1861 HGCMSVCEXTHANDLE *pHandle; 1853 /* Name of the service. */1862 /** Name of the service. */ 1854 1863 const char *pszServiceName; 1855 /* The extension entry point. */1864 /** The extension entry point. */ 1856 1865 PFNHGCMSVCEXT pfnExtension; 1857 /* The extension pointer. */1866 /** The extension pointer. */ 1858 1867 void *pvExtension; 1859 1868 }; … … 2079 2088 case HGCM_MSG_QUIT: 2080 2089 { 2090 HGCMMsgMainQuit *pMsg = (HGCMMsgMainQuit *)pMsgCore; 2081 2091 LogFlowFunc(("HGCM_MSG_QUIT\n")); 2082 2092 2083 HGCMService::UnloadAll( );2093 HGCMService::UnloadAll(pMsg->fUvmIsInvalid); 2084 2094 2085 2095 fQuit = true; … … 2636 2646 } 2637 2647 2638 int HGCMHostShutdown( void)2648 int HGCMHostShutdown(bool fUvmIsInvalid /*= false*/) 2639 2649 { 2640 2650 LogFlowFunc(("\n")); … … 2649 2659 { 2650 2660 /* Send the quit message to the main hgcmThread. */ 2651 HGCMMsgCore *pMsg ;2652 rc = hgcmMsgAlloc(g_pHgcmThread, &pMsg , HGCM_MSG_QUIT, hgcmMainMessageAlloc);2661 HGCMMsgCore *pMsgCore; 2662 rc = hgcmMsgAlloc(g_pHgcmThread, &pMsgCore, HGCM_MSG_QUIT, hgcmMainMessageAlloc); 2653 2663 2654 2664 if (RT_SUCCESS(rc)) 2655 2665 { 2666 HGCMMsgMainQuit *pMsg = (HGCMMsgMainQuit *)pMsgCore; 2667 pMsg->fUvmIsInvalid = fUvmIsInvalid; 2668 2656 2669 rc = hgcmMsgSend(pMsg); 2657 2670 -
trunk/src/VBox/Main/src-client/VMMDevInterface.cpp
r75500 r75574 59 59 { 60 60 /** Pointer to the VMMDev object. */ 61 VMMDev 61 VMMDev *pVMMDev; 62 62 /** Pointer to the driver instance structure. */ 63 63 PPDMDRVINS pDrvIns; … … 95 95 { 96 96 #ifdef VBOX_WITH_HGCM 97 if (hgcmIsActive()) 98 { 99 ASMAtomicWriteBool(&m_fHGCMActive, false); 100 HGCMHostShutdown(); 101 } 102 #endif /* VBOX_WITH_HGCM */ 97 if (ASMAtomicCmpXchgBool(&m_fHGCMActive, false, true)) 98 HGCMHostShutdown(true /*fUvmIsInvalid*/); 99 #endif 103 100 RTSemEventDestroy(mCredentialsEvent); 104 101 if (mpDrv) … … 707 704 } 708 705 709 void VMMDev::hgcmShutdown(void) 710 { 711 ASMAtomicWriteBool(&m_fHGCMActive, false); 712 HGCMHostShutdown(); 706 /** 707 * Used by Console::i_powerDown to shut down the services before the VM is destroyed. 708 */ 709 void VMMDev::hgcmShutdown(bool fUvmIsInvalid /*= false*/) 710 { 711 if (ASMAtomicCmpXchgBool(&m_fHGCMActive, false, true)) 712 HGCMHostShutdown(fUvmIsInvalid); 713 713 } 714 714 … … 777 777 LogFlow(("VMMDev::drvDestruct: iInstance=%d\n", pDrvIns->iInstance)); 778 778 779 #ifdef VBOX_WITH_HGCM780 /* HGCM is shut down on the VMMDev destructor. */781 #endif /* VBOX_WITH_HGCM */782 779 if (pThis->pVMMDev) 780 { 781 #ifdef VBOX_WITH_HGCM 782 /* When VM construction goes wrong, we prefer shutting down HGCM here 783 while pUVM is still valid, rather than in ~VMMDev. */ 784 if (ASMAtomicCmpXchgBool(&pThis->pVMMDev->m_fHGCMActive, false, true)) 785 HGCMHostShutdown(); 786 #endif 783 787 pThis->pVMMDev->mpDrv = NULL; 788 } 784 789 } 785 790
Note:
See TracChangeset
for help on using the changeset viewer.