-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Add API flags for creating & opening persistent sessions #14047
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
Conversation
|
|
||
| // Session managment. | ||
| HRESULT CreateSession([in] const struct WSLA_SESSION_SETTINGS* Settings, [out]IWSLASession** Session); | ||
| HRESULT CreateSession([in] const struct WSLA_SESSION_SETTINGS* Settings, WSLASessionFlags Flags, [out]IWSLASession** Session); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kevpar: This is one of the API changes that I mentioned. This will allow a caller to specify that a session should outlive its last COM client reference.
The WSLASessionFlagsOpenExisting flag will make it easy for the CLI to have a "create-or-open" logic when setting up its COM session
|
For persistent sessions what are you thinking for lifetime of the VM? We likely want to clean it up after some period of inactivity. |
This is something that we still need to design. Most likely we're going to need some form of configuration file for the container CLI, and in it we can have an inactivity timeout, similar to what we do in WSL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds API flags for creating and opening persistent WSL sessions that can outlive their COM reference lifetime. The main purpose is to support the CLI's ability to maintain sessions across invocations by introducing WSLASessionFlagsPersistent and WSLASessionFlagsOpenExisting flags.
Changes:
- Added session flag enums (
WSLASessionFlagsPersistent,WSLASessionFlagsOpenExisting) to control session lifecycle behavior - Removed the deprecated
IWSLAVirtualMachineinterface and migrated its functionality toIWSLASession - Replaced
Shutdown()withTerminate()and changedWSLAVirtualMachinefrom a COM object to an internalstd::optionalmember - Added comprehensive test coverage for persistent session behavior including creation, reopening, and termination
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| src/windows/wslaservice/inc/wslaservice.idl | Added WSLASessionFlags enum, updated CreateSession signature, removed IWSLAVirtualMachine interface, renamed Shutdown to Terminate, added testing methods to IWSLASession |
| src/windows/wslaservice/exe/WSLAUserSession.h | Added m_persistentSessions vector to store strong references, updated CreateSession signature, added logic to remove terminated persistent sessions |
| src/windows/wslaservice/exe/WSLAUserSession.cpp | Implemented session lookup by name with OpenExisting flag support, added persistent session reference management |
| src/windows/wslaservice/exe/WSLASession.h | Changed m_virtualMachine from ComPtr to std::optional, renamed Shutdown to Terminate, added Terminated() method, moved VM methods from IWSLAVirtualMachine |
| src/windows/wslaservice/exe/WSLASession.cpp | Refactored Terminate() to be callable explicitly, moved VM operation wrappers from deleted interface, changed VM initialization to use emplace |
| src/windows/wslaservice/exe/WSLAVirtualMachine.h | Removed COM interface inheritance, changed methods from HRESULT-returning to void/exception-throwing |
| src/windows/wslaservice/exe/WSLAVirtualMachine.cpp | Removed WaitPid, Shutdown methods, changed MapPort/Unmount/Signal to throw exceptions instead of returning HRESULT |
| src/windows/wslaservice/exe/WSLAContainer.cpp | Updated MapPort calls to use try/catch instead of LOG_IF_FAILED since it now throws |
| src/windows/wslaservice/exe/WSLAProcessControl.cpp | Updated Signal call to handle void return type |
| src/windows/common/WslClient.cpp | Updated CreateSession call to pass WSLASessionFlagsNone, removed IWSLAVirtualMachine usage |
| test/windows/WSLATests.cpp | Updated all tests to use new API, replaced Shutdown with session.reset() or Terminate(), added PersistentSession test with comprehensive coverage, removed test for process creation after VM termination |
| src/shared/inc/lxinitshared.h | Removed WSLA_WAITPID, WSLA_WAITPID_RESULT, and WSLA_SHUTDOWN message structures |
| src/linux/init/WSLAInit.cpp | Removed HandleMessageImpl for WSLA_WAITPID, removed WSLA_WAITPID from HandleMessage template list |
| msipackage/package.wix.in | Removed registry entries for WSLAVirtualMachine and IWSLAVirtualMachine COM classes |
Summary of the Pull Request
This will be needed for the CLI to open & maintain its session across invocations
PR Checklist
Detailed Description of the Pull Request / Additional comments
Validation Steps Performed