-
Notifications
You must be signed in to change notification settings - Fork 1.5k
WSLA: Add initial wsladiag tool with basic --list command and placeholder ListSessions #13725
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
Closed
beena352
wants to merge
13
commits into
microsoft:feature/wsl-for-apps
from
beena352:user/beenachauhan/wsladiag
Closed
Changes from 3 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
7273a41
WSLA: Add initial wsladiag tool with basic --list support and placeho…
beena352 71d3514
Fix CMakeLists.txt formatting issue for wsladiag
beena352 06fd79b
Add wsladiag + MSI entries
beena352 de15229
Add initial implementation of --list command to wsladiag
beena352 7ec00b4
Update WSLA telemetry provider and improve session enumeration
beena352 dc7781e
Remove Utf8ToDisplayName and rely on std::formatter<char> for convers…
beena352 e02bd5d
WIP: before cherry-picking WSLA session fix
beena352 637a121
wsla: Fix incorrect call to EqualSid causing WSLAUserSession to alway…
OneBlue 494da27
WSLA: Implement ListSessions and correct CreateSession storage
beena352 bcb57dd
Merge branch 'feature/wsl-for-apps' into user/beenachauhan/wsladiag
beena352 b09a666
Address PR feedback: atomic session ID, CATCH_LOG, fixed-size Display…
beena352 be46f23
Address build issues and formatting corrections
beena352 f3b5903
Sync WSLAVirtualMachine interface changes from upstream
beena352 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| set(SOURCES | ||
| main.cpp | ||
| ) | ||
|
|
||
| add_executable(wsladiag ${SOURCES}) | ||
|
|
||
| target_link_libraries(wsladiag | ||
| ${COMMON_LINK_LIBRARIES} | ||
| common | ||
| ) | ||
|
|
||
| target_precompile_headers(wsladiag REUSE_FROM common) | ||
|
|
||
| set_target_properties(wsladiag PROPERTIES FOLDER windows) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,101 @@ | ||
| /*++ | ||
|
|
||
| Copyright (c) Microsoft. All rights reserved. | ||
|
|
||
| Module Name: | ||
|
|
||
| main.cpp | ||
|
|
||
| Abstract: | ||
|
|
||
| Entry point for the wsladiag tool, performs WSL runtime initialization and parses --list/--help. | ||
|
|
||
| --*/ | ||
|
|
||
| #include "precomp.h" | ||
| #include "CommandLine.h" | ||
| #include "wslutil.h" | ||
|
|
||
| using namespace wsl::shared; | ||
| namespace wslutil = wsl::windows::common::wslutil; | ||
|
|
||
| int wsladiag_main(std::wstring_view commandLine) | ||
| { | ||
| // | ||
| // Standard process initialization (matches other WSL tools) | ||
| // | ||
| wslutil::ConfigureCrt(); | ||
| wslutil::InitializeWil(); | ||
|
|
||
| WslTraceLoggingInitialize(LxssTelemetryProvider, !wsl::shared::OfficialBuild); | ||
| auto cleanupTelemetry = wil::scope_exit_log(WI_DIAGNOSTICS_INFO, []() | ||
| { | ||
| WslTraceLoggingUninitialize(); | ||
| }); | ||
|
|
||
| wslutil::SetCrtEncoding(_O_U8TEXT); | ||
|
|
||
| auto coInit = wil::CoInitializeEx(COINIT_MULTITHREADED); | ||
| wslutil::CoInitializeSecurity(); | ||
|
|
||
| WSADATA data{}; | ||
| THROW_IF_WIN32_ERROR(WSAStartup(MAKEWORD(2, 2), &data)); | ||
| auto wsaCleanup = wil::scope_exit_log(WI_DIAGNOSTICS_INFO, []() | ||
| { | ||
| WSACleanup(); | ||
| }); | ||
|
|
||
| // | ||
| // Command-line parsing using ArgumentParser | ||
| // | ||
| ArgumentParser parser(std::wstring{commandLine}, L"wsladiag"); | ||
|
|
||
| bool help = false; | ||
| bool list = false; | ||
|
|
||
| parser.AddArgument(list, L"--list"); | ||
| parser.AddArgument(help, L"--help", L'h'); // short option is a single wide char | ||
| parser.Parse(); | ||
|
|
||
| auto printUsage = []() | ||
| { | ||
| wslutil::PrintMessage( | ||
| L"wsladiag - WSLA diagnostics tool\n" | ||
| L"Usage:\n" | ||
| L" wsladiag --list List WSLA sessions\n" | ||
| L" wsladiag --help Show this help", | ||
| stdout); | ||
|
||
| }; | ||
|
|
||
| // Slightly clearer help logic | ||
| if (help) | ||
| { | ||
| printUsage(); | ||
| return 0; | ||
| } | ||
|
|
||
| if (!list) | ||
| { | ||
| // No recognized command → show usage | ||
| printUsage(); | ||
| return 0; | ||
| } | ||
|
|
||
| // --list | ||
| wslutil::PrintMessage( | ||
| L"[wsladiag] --list: placeholder.\n" | ||
| L"Next step: call WSLA service ListSessions and display sessions.", | ||
| stdout); | ||
| // TODO: call WSLA service COM interface to retrieve and display sessions. | ||
| return 0; | ||
| } | ||
|
|
||
| int wmain(int /*argc*/, wchar_t** /*argv*/) | ||
| { | ||
| try | ||
| { | ||
| // Use the full command line so ArgumentParser sees the raw string | ||
| return wsladiag_main(GetCommandLineW()); | ||
| } | ||
| CATCH_RETURN(); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
@OneBlue this seems like a strange provider to use here. Is there a more appropriate one?
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.
That's a good call.
The closest match we have is
WslaServiceTelemetryProvider, (although the same isn't a great match). We could either rename that provider toWslaTelemetryProviderand use it here as well as in the service, or create another one specifically for wsladiag.exe.I'd be OK with both, but I have a preference for the first option, since one telemetry provider just for wsldiag feels overkill
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.
I agree, I think we can just use a single provider for all of WSLA.
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.
Thanks for the clarification! I agree using a single provider makes more sense. I went with the first option and renamed the existing WslaServiceTelemetryProvider to WslaTelemetryProvider, and updated both the service and wsladiag.exe to use it. Let me know if you'd like this split out differently.