cleanup: move common functonality out of service exe (#13788)
Co-authored-by: Ben Hillis <benhill@ntdev.microsoft.com>
Ben Hillis committed
Nov 26, 2025 at 15:50 UTC
be82716c405a3d5c3a1244be20bb97145a8cd016
36 files changed
+35
-37
src/windows/common/CMakeLists.txt
+30
@@ -1,9 +1,16 @@
1
set(SOURCES
2
ConsoleProgressBar.cpp
3
ConsoleProgressIndicator.cpp
4
+ DeviceHostProxy.cpp
5
disk.cpp
6
Distribution.cpp
7
+ Dmesg.cpp
8
+ DnsResolver.cpp
9
+ DnsTunnelingChannel.cpp
10
filesystem.cpp
11
+ GnsChannel.cpp
12
+ GnsPortTrackerChannel.cpp
13
+ GuestDeviceManager.cpp
14
HandleConsoleProgressBar.cpp
15
hcs.cpp
16
helpers.cpp
@@ -15,21 +22,28 @@ set(SOURCES
22
lxssbusclient.cpp
23
lxssclient.cpp
24
LxssMessagePort.cpp
25
+ LxssSecurity.cpp
26
LxssServerPort.cpp
27
+ NatNetworking.cpp
28
Redirector.cpp
29
registry.cpp
30
relay.cpp
31
+ RingBuffer.cpp
32
string.cpp
33
SubProcess.cpp
34
svccomm.cpp
35
svccommio.cpp
36
WslClient.cpp
37
WslCoreConfig.cpp
38
+ WslCoreFilesystem.cpp
39
WslCoreFirewallSupport.cpp
40
+ WslCoreHostDnsInfo.cpp
41
+ WslCoreNetworkEndpointSettings.cpp
42
WslCoreNetworkingSupport.cpp
43
WslInstall.cpp
44
WslSecurity.cpp
45
WslTelemetry.cpp
46
+ VirtioNetworking.cpp
47
wslutil.cpp
48
notifications.cpp)
49
@@ -60,9 +74,16 @@ set(HEADERS
74
../inc/wslrelay.h
75
ConsoleProgressBar.h
76
ConsoleProgressIndicator.h
77
+ DeviceHostProxy.h
78
disk.hpp
79
Distribution.h
80
+ Dmesg.h
81
+ DnsResolver.h
82
+ DnsTunnelingChannel.h
83
filesystem.hpp
84
+ GnsChannel.h
85
+ GnsPortTrackerChannel.h
86
+ GuestDeviceManager.h
87
HandleConsoleProgressBar.h
88
hcs.hpp
89
hcs_schema.h
@@ -71,13 +92,17 @@ set(HEADERS
92
ExecutionContext.h
93
socket.hpp
94
hvsocket.hpp
95
+ INetworkingEngine.h
96
LxssMessagePort.h
97
LxssPort.h
98
+ LxssSecurity.h
99
LxssServerPort.h
100
+ NatNetworking.h
101
precomp.h
102
Redirector.h
103
registry.hpp
104
relay.hpp
105
+ RingBuffer.h
106
string.hpp
107
Stringify.h
108
SubProcess.h
@@ -85,11 +110,16 @@ set(HEADERS
110
svccommio.hpp
111
WslClient.h
112
WslCoreConfig.h
113
+ WslCoreFilesystem.h
114
WslCoreFirewallSupport.h
115
+ WslCoreHostDnsInfo.h
116
+ WslCoreMessageQueue.h
117
+ WslCoreNetworkEndpointSettings.h
118
WslCoreNetworkingSupport.h
119
WslInstall.h
120
WslSecurity.h
121
WslTelemetry.h
122
+ VirtioNetworking.h
123
wslutil.h
124
notifications.h)
125
src/windows/common/DeviceHostProxy.cpp
renamed
src/windows/common/DeviceHostProxy.h
renamed
src/windows/common/Dmesg.cpp
renamed
src/windows/common/Dmesg.h
renamed
src/windows/common/DnsResolver.cpp
renamed
src/windows/common/DnsResolver.h
renamed
src/windows/common/DnsTunnelingChannel.cpp
renamed
src/windows/common/DnsTunnelingChannel.h
renamed
src/windows/common/GnsChannel.cpp
renamed
src/windows/common/GnsChannel.h
renamed
src/windows/common/GnsPortTrackerChannel.cpp
renamed
src/windows/common/GnsPortTrackerChannel.h
renamed
src/windows/common/GuestDeviceManager.cpp
renamed
src/windows/common/GuestDeviceManager.h
renamed
src/windows/common/INetworkingEngine.h
renamed
src/windows/common/LxssSecurity.cpp
renamed
src/windows/common/LxssSecurity.h
renamed
src/windows/common/NatNetworking.cpp
renamed
+1
-2
@@ -6,7 +6,6 @@
6
#include "WslCoreHostDnsInfo.h"
7
#include "Stringify.h"
8
#include "WslCoreFirewallSupport.h"
9
-#include "WslCoreVm.h"
9
#include "hcs.hpp"
10
11
using namespace wsl::core::networking;
@@ -672,7 +671,7 @@ wsl::windows::common::hcs::unique_hcn_network NatNetworking::CreateNetwork(wsl::
671
wil::ResultFromException(WI_DIAGNOSTICS_INFO, [&] {
672
try
673
{
675
- wsl::core::networking::ConfigureHyperVFirewall(config.FirewallConfig, c_vmOwner);
674
+ wsl::core::networking::ConfigureHyperVFirewall(config.FirewallConfig, wsl::windows::common::wslutil::c_vmOwner);
675
natNetwork = CreateNetworkInternal(config);
676
}
677
catch (...)
src/windows/common/NatNetworking.h
renamed
src/windows/common/RingBuffer.cpp
renamed
src/windows/common/RingBuffer.h
renamed
src/windows/common/VirtioNetworking.cpp
renamed
src/windows/common/VirtioNetworking.h
renamed
src/windows/common/WslCoreFilesystem.cpp
renamed
src/windows/common/WslCoreFilesystem.h
renamed
src/windows/common/WslCoreHostDnsInfo.cpp
renamed
src/windows/common/WslCoreHostDnsInfo.h
renamed
src/windows/common/WslCoreMessageQueue.h
renamed
src/windows/common/WslCoreNetworkEndpointSettings.cpp
renamed
src/windows/common/WslCoreNetworkEndpointSettings.h
renamed
src/windows/common/wslutil.h
+1
@@ -44,6 +44,7 @@ inline auto c_msixPackageFamilyName = L"MicrosoftCorporationII.WindowsSubsystemF
44
inline auto c_githubUrlOverrideRegistryValue = L"GitHubUrlOverride";
45
inline auto c_vhdFileExtension = L".vhd";
46
inline auto c_vhdxFileExtension = L".vhdx";
47
+inline constexpr auto c_vmOwner = L"WSL";
48
49
struct GitHubReleaseAsset
50
{
src/windows/service/exe/CMakeLists.txt
-30
@@ -1,40 +1,25 @@
1
set(SOURCES
2
DistributionRegistration.cpp
3
- LxssSecurity.cpp
3
LxssUserCallback.cpp
4
LxssUserSession.cpp
5
LxssUserSessionFactory.cpp
6
LxssIptables.cpp
8
- LxssUserCallback.cpp
7
LxssHttpProxy.cpp
8
LxssInstance.cpp
9
PluginManager.cpp
10
ServiceMain.cpp
11
BridgedNetworking.cpp
14
- DeviceHostProxy.cpp
15
- Dmesg.cpp
16
- DnsTunnelingChannel.cpp
17
- GnsChannel.cpp
18
- GnsPortTrackerChannel.cpp
12
GnsRpcServer.cpp
20
- GuestDeviceManager.cpp
13
GuestTelemetryLogger.cpp
14
Lifetime.cpp
15
LxssConsoleManager.cpp
16
LxssCreateProcess.cpp
17
MirroredNetworking.cpp
26
- NatNetworking.cpp
27
- RingBuffer.cpp
28
- WslCoreFilesystem.cpp
18
WslCoreGuestNetworkService.cpp
30
- WslCoreHostDnsInfo.cpp
19
WslCoreInstance.cpp
20
WslMirroredNetworking.cpp
33
- WslCoreNetworkEndpointSettings.cpp
34
- DnsResolver.cpp
21
WslCoreTcpIpStateTracking.cpp
22
WslCoreVm.cpp
37
- VirtioNetworking.cpp
23
main.rc
24
${CMAKE_CURRENT_BINARY_DIR}/../mc/${TARGET_PLATFORM}/${CMAKE_BUILD_TYPE}/wsleventschema.rc
25
application.manifest)
@@ -42,7 +27,6 @@ set(SOURCES
27
set(HEADERS
28
../../inc/comservicehelper.h
29
DistributionRegistration.h
45
- LxssSecurity.h
30
LxssUserCallback.h
31
LxssUserSession.h
32
LxssUserSessionFactory.h
@@ -51,31 +35,17 @@ set(HEADERS
35
PluginManager.h
36
LxssInstance.h
37
BridgedNetworking.h
54
- DeviceHostProxy.h
55
- Dmesg.h
56
- DnsTunnelingChannel.h
57
- GnsChannel.h
58
- GnsPortTrackerChannel.h
38
GnsRpcServer.h
60
- GuestDeviceManager.h
39
GuestTelemetryLogger.h
62
- INetworkingEngine.h
40
IMirroredNetworkManager.h
41
Lifetime.h
42
LxssConsoleManager.h
43
LxssCreateProcess.h
44
MirroredNetworking.h
68
- NatNetworking.h
69
- RingBuffer.h
70
- WslCoreFilesystem.h
45
WslCoreGuestNetworkService.h
72
- WslCoreHostDnsInfo.h
46
WslCoreInstance.h
74
- WslCoreMessageQueue.h
47
WslMirroredNetworking.h
48
WslCoreNetworkEndpoint.h
77
- WslCoreNetworkEndpointSettings.h
78
- DnsResolver.h
49
WslCoreTcpIpStateTracking.h
50
WslCoreVm.h)
51
src/windows/service/exe/MirroredNetworking.cpp
+1
-1
@@ -256,7 +256,7 @@ void MirroredNetworking::Initialize()
256
m_config.FirewallConfig.Enabled(), m_config.IgnoredPorts, m_runtimeId, m_gnsRpcServer->GetServerUuid(), s_GuestNetworkServiceCallback, this);
257
m_ephemeralPortRange = m_guestNetworkService.AllocateEphemeralPortRange();
258
259
- networking::ConfigureHyperVFirewall(m_config.FirewallConfig, c_vmOwner);
259
+ networking::ConfigureHyperVFirewall(m_config.FirewallConfig, wsl::windows::common::wslutil::c_vmOwner);
260
261
// must keep all m_networkManager interactions (including) creation queued
262
// also must queue GNS callbacks to keep them serialized
src/windows/service/exe/WslCoreVm.cpp
+2
-2
@@ -1411,7 +1411,7 @@ void WslCoreVm::FreeLun(_In_ ULONG lun)
1411
std::wstring WslCoreVm::GenerateConfigJson()
1412
{
1413
hcs::ComputeSystem systemSettings{};
1414
- systemSettings.Owner = c_vmOwner;
1414
+ systemSettings.Owner = wsl::windows::common::wslutil::c_vmOwner;
1415
systemSettings.ShouldTerminateOnLastHandleClosed = true;
1416
systemSettings.SchemaVersion.Major = 2;
1417
systemSettings.SchemaVersion.Minor = 3;
@@ -1518,7 +1518,7 @@ std::wstring WslCoreVm::GenerateConfigJson()
1518
// Set the vmmem suffix which will change the process name in task manager.
1519
if (IsVmemmSuffixSupported())
1520
{
1521
- vmSettings.ComputeTopology.Memory.HostingProcessNameSuffix = c_vmOwner;
1521
+ vmSettings.ComputeTopology.Memory.HostingProcessNameSuffix = wsl::windows::common::wslutil::c_vmOwner;
1522
}
1523
1524
// If nested virtualization was requested, ensure the platform supports it.
src/windows/service/exe/WslCoreVm.h
-2
@@ -40,8 +40,6 @@ inline constexpr auto c_optionsValueName = L"Options";
40
inline constexpr auto c_typeValueName = L"Type";
41
inline constexpr auto c_mountNameValueName = L"Name";
42
43
-inline constexpr auto c_vmOwner = L"WSL";
44
-
43
static constexpr GUID c_virtiofsAdminClassId = {0x7e6ad219, 0xd1b3, 0x42d5, {0xb8, 0xee, 0xd9, 0x63, 0x24, 0xe6, 0x4f, 0xf6}};
44
45
// {60285AE6-AAF3-4456-B444-A6C2D0DEDA38}