cleanup: move common functonality out of service exe (#13788)

Co-authored-by: Ben Hillis <benhill@ntdev.microsoft.com>
This commit is contained in:
Ben Hillis 2025-11-26 15:50:42 -08:00 committed by GitHub
parent ba90ee11fa
commit be82716c40
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
36 changed files with 35 additions and 37 deletions

View File

@ -1,9 +1,16 @@
set(SOURCES set(SOURCES
ConsoleProgressBar.cpp ConsoleProgressBar.cpp
ConsoleProgressIndicator.cpp ConsoleProgressIndicator.cpp
DeviceHostProxy.cpp
disk.cpp disk.cpp
Distribution.cpp Distribution.cpp
Dmesg.cpp
DnsResolver.cpp
DnsTunnelingChannel.cpp
filesystem.cpp filesystem.cpp
GnsChannel.cpp
GnsPortTrackerChannel.cpp
GuestDeviceManager.cpp
HandleConsoleProgressBar.cpp HandleConsoleProgressBar.cpp
hcs.cpp hcs.cpp
helpers.cpp helpers.cpp
@ -15,21 +22,28 @@ set(SOURCES
lxssbusclient.cpp lxssbusclient.cpp
lxssclient.cpp lxssclient.cpp
LxssMessagePort.cpp LxssMessagePort.cpp
LxssSecurity.cpp
LxssServerPort.cpp LxssServerPort.cpp
NatNetworking.cpp
Redirector.cpp Redirector.cpp
registry.cpp registry.cpp
relay.cpp relay.cpp
RingBuffer.cpp
string.cpp string.cpp
SubProcess.cpp SubProcess.cpp
svccomm.cpp svccomm.cpp
svccommio.cpp svccommio.cpp
WslClient.cpp WslClient.cpp
WslCoreConfig.cpp WslCoreConfig.cpp
WslCoreFilesystem.cpp
WslCoreFirewallSupport.cpp WslCoreFirewallSupport.cpp
WslCoreHostDnsInfo.cpp
WslCoreNetworkEndpointSettings.cpp
WslCoreNetworkingSupport.cpp WslCoreNetworkingSupport.cpp
WslInstall.cpp WslInstall.cpp
WslSecurity.cpp WslSecurity.cpp
WslTelemetry.cpp WslTelemetry.cpp
VirtioNetworking.cpp
wslutil.cpp wslutil.cpp
notifications.cpp) notifications.cpp)
@ -60,9 +74,16 @@ set(HEADERS
../inc/wslrelay.h ../inc/wslrelay.h
ConsoleProgressBar.h ConsoleProgressBar.h
ConsoleProgressIndicator.h ConsoleProgressIndicator.h
DeviceHostProxy.h
disk.hpp disk.hpp
Distribution.h Distribution.h
Dmesg.h
DnsResolver.h
DnsTunnelingChannel.h
filesystem.hpp filesystem.hpp
GnsChannel.h
GnsPortTrackerChannel.h
GuestDeviceManager.h
HandleConsoleProgressBar.h HandleConsoleProgressBar.h
hcs.hpp hcs.hpp
hcs_schema.h hcs_schema.h
@ -71,13 +92,17 @@ set(HEADERS
ExecutionContext.h ExecutionContext.h
socket.hpp socket.hpp
hvsocket.hpp hvsocket.hpp
INetworkingEngine.h
LxssMessagePort.h LxssMessagePort.h
LxssPort.h LxssPort.h
LxssSecurity.h
LxssServerPort.h LxssServerPort.h
NatNetworking.h
precomp.h precomp.h
Redirector.h Redirector.h
registry.hpp registry.hpp
relay.hpp relay.hpp
RingBuffer.h
string.hpp string.hpp
Stringify.h Stringify.h
SubProcess.h SubProcess.h
@ -85,11 +110,16 @@ set(HEADERS
svccommio.hpp svccommio.hpp
WslClient.h WslClient.h
WslCoreConfig.h WslCoreConfig.h
WslCoreFilesystem.h
WslCoreFirewallSupport.h WslCoreFirewallSupport.h
WslCoreHostDnsInfo.h
WslCoreMessageQueue.h
WslCoreNetworkEndpointSettings.h
WslCoreNetworkingSupport.h WslCoreNetworkingSupport.h
WslInstall.h WslInstall.h
WslSecurity.h WslSecurity.h
WslTelemetry.h WslTelemetry.h
VirtioNetworking.h
wslutil.h wslutil.h
notifications.h) notifications.h)

View File

@ -6,7 +6,6 @@
#include "WslCoreHostDnsInfo.h" #include "WslCoreHostDnsInfo.h"
#include "Stringify.h" #include "Stringify.h"
#include "WslCoreFirewallSupport.h" #include "WslCoreFirewallSupport.h"
#include "WslCoreVm.h"
#include "hcs.hpp" #include "hcs.hpp"
using namespace wsl::core::networking; using namespace wsl::core::networking;
@ -672,7 +671,7 @@ wsl::windows::common::hcs::unique_hcn_network NatNetworking::CreateNetwork(wsl::
wil::ResultFromException(WI_DIAGNOSTICS_INFO, [&] { wil::ResultFromException(WI_DIAGNOSTICS_INFO, [&] {
try try
{ {
wsl::core::networking::ConfigureHyperVFirewall(config.FirewallConfig, c_vmOwner); wsl::core::networking::ConfigureHyperVFirewall(config.FirewallConfig, wsl::windows::common::wslutil::c_vmOwner);
natNetwork = CreateNetworkInternal(config); natNetwork = CreateNetworkInternal(config);
} }
catch (...) catch (...)

View File

@ -44,6 +44,7 @@ inline auto c_msixPackageFamilyName = L"MicrosoftCorporationII.WindowsSubsystemF
inline auto c_githubUrlOverrideRegistryValue = L"GitHubUrlOverride"; inline auto c_githubUrlOverrideRegistryValue = L"GitHubUrlOverride";
inline auto c_vhdFileExtension = L".vhd"; inline auto c_vhdFileExtension = L".vhd";
inline auto c_vhdxFileExtension = L".vhdx"; inline auto c_vhdxFileExtension = L".vhdx";
inline constexpr auto c_vmOwner = L"WSL";
struct GitHubReleaseAsset struct GitHubReleaseAsset
{ {

View File

@ -1,40 +1,25 @@
set(SOURCES set(SOURCES
DistributionRegistration.cpp DistributionRegistration.cpp
LxssSecurity.cpp
LxssUserCallback.cpp LxssUserCallback.cpp
LxssUserSession.cpp LxssUserSession.cpp
LxssUserSessionFactory.cpp LxssUserSessionFactory.cpp
LxssIptables.cpp LxssIptables.cpp
LxssUserCallback.cpp
LxssHttpProxy.cpp LxssHttpProxy.cpp
LxssInstance.cpp LxssInstance.cpp
PluginManager.cpp PluginManager.cpp
ServiceMain.cpp ServiceMain.cpp
BridgedNetworking.cpp BridgedNetworking.cpp
DeviceHostProxy.cpp
Dmesg.cpp
DnsTunnelingChannel.cpp
GnsChannel.cpp
GnsPortTrackerChannel.cpp
GnsRpcServer.cpp GnsRpcServer.cpp
GuestDeviceManager.cpp
GuestTelemetryLogger.cpp GuestTelemetryLogger.cpp
Lifetime.cpp Lifetime.cpp
LxssConsoleManager.cpp LxssConsoleManager.cpp
LxssCreateProcess.cpp LxssCreateProcess.cpp
MirroredNetworking.cpp MirroredNetworking.cpp
NatNetworking.cpp
RingBuffer.cpp
WslCoreFilesystem.cpp
WslCoreGuestNetworkService.cpp WslCoreGuestNetworkService.cpp
WslCoreHostDnsInfo.cpp
WslCoreInstance.cpp WslCoreInstance.cpp
WslMirroredNetworking.cpp WslMirroredNetworking.cpp
WslCoreNetworkEndpointSettings.cpp
DnsResolver.cpp
WslCoreTcpIpStateTracking.cpp WslCoreTcpIpStateTracking.cpp
WslCoreVm.cpp WslCoreVm.cpp
VirtioNetworking.cpp
main.rc main.rc
${CMAKE_CURRENT_BINARY_DIR}/../mc/${TARGET_PLATFORM}/${CMAKE_BUILD_TYPE}/wsleventschema.rc ${CMAKE_CURRENT_BINARY_DIR}/../mc/${TARGET_PLATFORM}/${CMAKE_BUILD_TYPE}/wsleventschema.rc
application.manifest) application.manifest)
@ -42,7 +27,6 @@ set(SOURCES
set(HEADERS set(HEADERS
../../inc/comservicehelper.h ../../inc/comservicehelper.h
DistributionRegistration.h DistributionRegistration.h
LxssSecurity.h
LxssUserCallback.h LxssUserCallback.h
LxssUserSession.h LxssUserSession.h
LxssUserSessionFactory.h LxssUserSessionFactory.h
@ -51,31 +35,17 @@ set(HEADERS
PluginManager.h PluginManager.h
LxssInstance.h LxssInstance.h
BridgedNetworking.h BridgedNetworking.h
DeviceHostProxy.h
Dmesg.h
DnsTunnelingChannel.h
GnsChannel.h
GnsPortTrackerChannel.h
GnsRpcServer.h GnsRpcServer.h
GuestDeviceManager.h
GuestTelemetryLogger.h GuestTelemetryLogger.h
INetworkingEngine.h
IMirroredNetworkManager.h IMirroredNetworkManager.h
Lifetime.h Lifetime.h
LxssConsoleManager.h LxssConsoleManager.h
LxssCreateProcess.h LxssCreateProcess.h
MirroredNetworking.h MirroredNetworking.h
NatNetworking.h
RingBuffer.h
WslCoreFilesystem.h
WslCoreGuestNetworkService.h WslCoreGuestNetworkService.h
WslCoreHostDnsInfo.h
WslCoreInstance.h WslCoreInstance.h
WslCoreMessageQueue.h
WslMirroredNetworking.h WslMirroredNetworking.h
WslCoreNetworkEndpoint.h WslCoreNetworkEndpoint.h
WslCoreNetworkEndpointSettings.h
DnsResolver.h
WslCoreTcpIpStateTracking.h WslCoreTcpIpStateTracking.h
WslCoreVm.h) WslCoreVm.h)

View File

@ -256,7 +256,7 @@ void MirroredNetworking::Initialize()
m_config.FirewallConfig.Enabled(), m_config.IgnoredPorts, m_runtimeId, m_gnsRpcServer->GetServerUuid(), s_GuestNetworkServiceCallback, this); m_config.FirewallConfig.Enabled(), m_config.IgnoredPorts, m_runtimeId, m_gnsRpcServer->GetServerUuid(), s_GuestNetworkServiceCallback, this);
m_ephemeralPortRange = m_guestNetworkService.AllocateEphemeralPortRange(); m_ephemeralPortRange = m_guestNetworkService.AllocateEphemeralPortRange();
networking::ConfigureHyperVFirewall(m_config.FirewallConfig, c_vmOwner); networking::ConfigureHyperVFirewall(m_config.FirewallConfig, wsl::windows::common::wslutil::c_vmOwner);
// must keep all m_networkManager interactions (including) creation queued // must keep all m_networkManager interactions (including) creation queued
// also must queue GNS callbacks to keep them serialized // also must queue GNS callbacks to keep them serialized

View File

@ -1411,7 +1411,7 @@ void WslCoreVm::FreeLun(_In_ ULONG lun)
std::wstring WslCoreVm::GenerateConfigJson() std::wstring WslCoreVm::GenerateConfigJson()
{ {
hcs::ComputeSystem systemSettings{}; hcs::ComputeSystem systemSettings{};
systemSettings.Owner = c_vmOwner; systemSettings.Owner = wsl::windows::common::wslutil::c_vmOwner;
systemSettings.ShouldTerminateOnLastHandleClosed = true; systemSettings.ShouldTerminateOnLastHandleClosed = true;
systemSettings.SchemaVersion.Major = 2; systemSettings.SchemaVersion.Major = 2;
systemSettings.SchemaVersion.Minor = 3; systemSettings.SchemaVersion.Minor = 3;
@ -1518,7 +1518,7 @@ std::wstring WslCoreVm::GenerateConfigJson()
// Set the vmmem suffix which will change the process name in task manager. // Set the vmmem suffix which will change the process name in task manager.
if (IsVmemmSuffixSupported()) if (IsVmemmSuffixSupported())
{ {
vmSettings.ComputeTopology.Memory.HostingProcessNameSuffix = c_vmOwner; vmSettings.ComputeTopology.Memory.HostingProcessNameSuffix = wsl::windows::common::wslutil::c_vmOwner;
} }
// If nested virtualization was requested, ensure the platform supports it. // If nested virtualization was requested, ensure the platform supports it.

View File

@ -40,8 +40,6 @@ inline constexpr auto c_optionsValueName = L"Options";
inline constexpr auto c_typeValueName = L"Type"; inline constexpr auto c_typeValueName = L"Type";
inline constexpr auto c_mountNameValueName = L"Name"; inline constexpr auto c_mountNameValueName = L"Name";
inline constexpr auto c_vmOwner = L"WSL";
static constexpr GUID c_virtiofsAdminClassId = {0x7e6ad219, 0xd1b3, 0x42d5, {0xb8, 0xee, 0xd9, 0x63, 0x24, 0xe6, 0x4f, 0xf6}}; static constexpr GUID c_virtiofsAdminClassId = {0x7e6ad219, 0xd1b3, 0x42d5, {0xb8, 0xee, 0xd9, 0x63, 0x24, 0xe6, 0x4f, 0xf6}};
// {60285AE6-AAF3-4456-B444-A6C2D0DEDA38} // {60285AE6-AAF3-4456-B444-A6C2D0DEDA38}