-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Refactor the session creation logic to match the new API #13814
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
1220fbe
0920c52
3d5fa8b
3a8a669
b8c5b8c
cff1cd2
29971ac
9c18826
cdf7c46
3b5c028
2a4f8d0
9dd34f2
292707e
0eda07f
e4822ba
987b1b7
a4ed4b2
ee948d5
08d5929
2c28e53
52aa7f8
9c5ed51
8d9e9cb
e786943
0760be6
70ac182
dcc0f5f
b7ff00b
251a5bb
7284d8e
f8e2119
c69c83b
4d34427
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -17,23 +17,85 @@ Module Name: | |||||||||||||
| #include "WSLAUserSession.h" | ||||||||||||||
| #include "WSLAContainer.h" | ||||||||||||||
| #include "ServiceProcessLauncher.h" | ||||||||||||||
| #include "WslCoreFilesystem.h" | ||||||||||||||
|
|
||||||||||||||
| using wsl::windows::service::wsla::WSLASession; | ||||||||||||||
| using wsl::windows::service::wsla::WSLAVirtualMachine; | ||||||||||||||
|
|
||||||||||||||
| WSLASession::WSLASession(const WSLA_SESSION_SETTINGS& Settings, WSLAUserSessionImpl& userSessionImpl, const VIRTUAL_MACHINE_SETTINGS& VmSettings) : | ||||||||||||||
| m_sessionSettings(Settings), | ||||||||||||||
| m_userSession(&userSessionImpl), | ||||||||||||||
| m_virtualMachine(wil::MakeOrThrow<WSLAVirtualMachine>(VmSettings, userSessionImpl.GetUserSid(), &userSessionImpl)), | ||||||||||||||
| m_displayName(Settings.DisplayName) | ||||||||||||||
| WSLASession::WSLASession(const WSLA_SESSION_SETTINGS& Settings, WSLAUserSessionImpl& userSessionImpl) : | ||||||||||||||
| m_sessionSettings(Settings), m_userSession(&userSessionImpl), m_displayName(Settings.DisplayName) | ||||||||||||||
| { | ||||||||||||||
| WSL_LOG("SessionCreated", TraceLoggingValue(m_displayName.c_str(), "DisplayName")); | ||||||||||||||
|
|
||||||||||||||
| m_virtualMachine = wil::MakeOrThrow<WSLAVirtualMachine>(CreateVmSettings(Settings), userSessionImpl.GetUserSid()); | ||||||||||||||
|
|
||||||||||||||
| if (Settings.TerminationCallback != nullptr) | ||||||||||||||
| { | ||||||||||||||
| m_virtualMachine->RegisterCallback(Settings.TerminationCallback); | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| m_virtualMachine->Start(); | ||||||||||||||
|
|
||||||||||||||
| ConfigureStorage(Settings); | ||||||||||||||
|
|
||||||||||||||
| // Launch the init script. | ||||||||||||||
| // TODO: Replace with something more robust once the final VHD is ready. | ||||||||||||||
| try | ||||||||||||||
| { | ||||||||||||||
| ServiceProcessLauncher launcher{"/bin/sh", {"/bin/sh", "-c", "/etc/lsw-init.sh"}}; | ||||||||||||||
| auto result = launcher.Launch(*m_virtualMachine.Get()).WaitAndCaptureOutput(); | ||||||||||||||
|
|
||||||||||||||
| THROW_HR_IF_MSG(E_FAIL, result.Code != 0, "Init script failed: %hs", launcher.FormatResult(result).c_str()); | ||||||||||||||
| } | ||||||||||||||
| catch (...) | ||||||||||||||
| { | ||||||||||||||
| // Ignore issues launching the init script with custom root VHD's, for convenience. | ||||||||||||||
| // TODO: Remove once the final VHD is ready. | ||||||||||||||
| if (Settings.RootVhdOverride == nullptr) | ||||||||||||||
| { | ||||||||||||||
| throw; | ||||||||||||||
| } | ||||||||||||||
| } | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| WSLAVirtualMachine::Settings WSLASession::CreateVmSettings(const WSLA_SESSION_SETTINGS& Settings) | ||||||||||||||
| { | ||||||||||||||
| WSLAVirtualMachine::Settings vmSettings{}; | ||||||||||||||
| vmSettings.CpuCount = Settings.CpuCount; | ||||||||||||||
| vmSettings.MemoryMb = Settings.MemoryMb; | ||||||||||||||
| vmSettings.NetworkingMode = Settings.NetworkingMode; | ||||||||||||||
| vmSettings.BootTimeoutMs = Settings.BootTimeoutMs; | ||||||||||||||
| vmSettings.FeatureFlags = static_cast<WSLAFeatureFlags>(Settings.FeatureFlags); | ||||||||||||||
| vmSettings.DisplayName = Settings.DisplayName; | ||||||||||||||
|
|
||||||||||||||
| if (Settings.RootVhdOverride != nullptr) | ||||||||||||||
| { | ||||||||||||||
| THROW_HR_IF(E_INVALIDARG, Settings.RootVhdTypeOverride == nullptr); | ||||||||||||||
|
|
||||||||||||||
| vmSettings.RootVhd = Settings.RootVhdOverride; | ||||||||||||||
| vmSettings.RootVhdType = Settings.RootVhdTypeOverride; | ||||||||||||||
|
Comment on lines
+73
to
+76
|
||||||||||||||
| THROW_HR_IF(E_INVALIDARG, Settings.RootVhdTypeOverride == nullptr); | |
| vmSettings.RootVhd = Settings.RootVhdOverride; | |
| vmSettings.RootVhdType = Settings.RootVhdTypeOverride; | |
| vmSettings.RootVhd = Settings.RootVhdOverride; | |
| vmSettings.RootVhdType = Settings.RootVhdTypeOverride != nullptr ? Settings.RootVhdTypeOverride : "ext4"; |
Uh oh!
There was an error while loading. Please reload this page.