@@ -2172,13 +2172,22 @@ HRESULT LxssUserSessionImpl::Shutdown(_In_ bool PreventNewInstances, ShutdownBeh
21722172 return S_OK;
21732173}
21742174
2175- void LxssUserSessionImpl::TelemetryWorker (_In_ wil::unique_socket&& socket, _In_ bool drvFsNotifications ) const
2175+ void LxssUserSessionImpl::TelemetryWorker (_In_ wil::unique_socket&& socket) const
21762176try
21772177{
21782178 wsl::windows::common::wslutil::SetThreadDescription (L" Telemetry" );
21792179
21802180 wsl::shared::SocketChannel channel (std::move (socket), " Telemetry" , m_vmTerminating.get ());
21812181
2182+ // Check if drvfs notifications are enabled for the user.
2183+ bool drvFsNotifications{};
2184+ {
2185+ auto impersonate = wil::impersonate_token (m_userToken.get ());
2186+ const auto lxssKey = wsl::windows::common::registry::OpenLxssUserKey ();
2187+ drvFsNotifications =
2188+ wsl::windows::common::registry::ReadDword (lxssKey.get (), LXSS_NOTIFICATIONS_KEY, LXSS_NOTIFICATION_DRVFS_PERF_DISABLED, 0 ) == 0 ;
2189+ }
2190+
21822191 // Aggregate information about what is running inside the VM. This is logged
21832192 // periodically because logging each event individually would be too noisy.
21842193 for (;;)
@@ -2852,17 +2861,9 @@ void LxssUserSessionImpl::_CreateVm()
28522861 // If the telemetry is enabled, launch the telemetry agent inside the VM.
28532862 if (m_utilityVm->GetConfig ().EnableTelemetry && TraceLoggingProviderEnabled (g_hTraceLoggingProvider, WINEVENT_LEVEL_INFO, 0 ))
28542863 {
2855- bool drvFsNotifications = false ;
2856- {
2857- auto impersonate = wil::impersonate_token (m_userToken.get ());
2858- const auto lxssKey = wsl::windows::common::registry::OpenLxssUserKey ();
2859- drvFsNotifications = wsl::windows::common::registry::ReadDword (
2860- lxssKey.get (), LXSS_NOTIFICATIONS_KEY, LXSS_NOTIFICATION_DRVFS_PERF_DISABLED, 0 ) == 0 ;
2861- }
2862-
28632864 LPCSTR Arguments[] = {LX_INIT_TELEMETRY_AGENT, nullptr };
28642865 auto socket = m_utilityVm->CreateRootNamespaceProcess (LX_INIT_PATH, Arguments);
2865- m_telemetryThread = std::thread (&LxssUserSessionImpl::TelemetryWorker, this , std::move (socket), drvFsNotifications );
2866+ m_telemetryThread = std::thread (&LxssUserSessionImpl::TelemetryWorker, this , std::move (socket));
28662867 }
28672868
28682869 m_pluginManager.OnVmStarted (&m_session, &userSettings);
0 commit comments