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

View File

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

View File

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

View File

@ -1,40 +1,25 @@
set(SOURCES
DistributionRegistration.cpp
LxssSecurity.cpp
LxssUserCallback.cpp
LxssUserSession.cpp
LxssUserSessionFactory.cpp
LxssIptables.cpp
LxssUserCallback.cpp
LxssHttpProxy.cpp
LxssInstance.cpp
PluginManager.cpp
ServiceMain.cpp
BridgedNetworking.cpp
DeviceHostProxy.cpp
Dmesg.cpp
DnsTunnelingChannel.cpp
GnsChannel.cpp
GnsPortTrackerChannel.cpp
GnsRpcServer.cpp
GuestDeviceManager.cpp
GuestTelemetryLogger.cpp
Lifetime.cpp
LxssConsoleManager.cpp
LxssCreateProcess.cpp
MirroredNetworking.cpp
NatNetworking.cpp
RingBuffer.cpp
WslCoreFilesystem.cpp
WslCoreGuestNetworkService.cpp
WslCoreHostDnsInfo.cpp
WslCoreInstance.cpp
WslMirroredNetworking.cpp
WslCoreNetworkEndpointSettings.cpp
DnsResolver.cpp
WslCoreTcpIpStateTracking.cpp
WslCoreVm.cpp
VirtioNetworking.cpp
main.rc
${CMAKE_CURRENT_BINARY_DIR}/../mc/${TARGET_PLATFORM}/${CMAKE_BUILD_TYPE}/wsleventschema.rc
application.manifest)
@ -42,7 +27,6 @@ set(SOURCES
set(HEADERS
../../inc/comservicehelper.h
DistributionRegistration.h
LxssSecurity.h
LxssUserCallback.h
LxssUserSession.h
LxssUserSessionFactory.h
@ -51,31 +35,17 @@ set(HEADERS
PluginManager.h
LxssInstance.h
BridgedNetworking.h
DeviceHostProxy.h
Dmesg.h
DnsTunnelingChannel.h
GnsChannel.h
GnsPortTrackerChannel.h
GnsRpcServer.h
GuestDeviceManager.h
GuestTelemetryLogger.h
INetworkingEngine.h
IMirroredNetworkManager.h
Lifetime.h
LxssConsoleManager.h
LxssCreateProcess.h
MirroredNetworking.h
NatNetworking.h
RingBuffer.h
WslCoreFilesystem.h
WslCoreGuestNetworkService.h
WslCoreHostDnsInfo.h
WslCoreInstance.h
WslCoreMessageQueue.h
WslMirroredNetworking.h
WslCoreNetworkEndpoint.h
WslCoreNetworkEndpointSettings.h
DnsResolver.h
WslCoreTcpIpStateTracking.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_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
// 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()
{
hcs::ComputeSystem systemSettings{};
systemSettings.Owner = c_vmOwner;
systemSettings.Owner = wsl::windows::common::wslutil::c_vmOwner;
systemSettings.ShouldTerminateOnLastHandleClosed = true;
systemSettings.SchemaVersion.Major = 2;
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.
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.

View File

@ -40,8 +40,6 @@ inline constexpr auto c_optionsValueName = L"Options";
inline constexpr auto c_typeValueName = L"Type";
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}};
// {60285AE6-AAF3-4456-B444-A6C2D0DEDA38}