-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Partial SDK implementation #14211
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
Merged
JohnMcPMS
merged 27 commits into
microsoft:feature/wsl-for-apps
from
JohnMcPMS:sdk-session
Feb 17, 2026
Merged
Partial SDK implementation #14211
Changes from 21 commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
694443e
Add Clang requirement to vswhere usage
JohnMcPMS 437a912
EOD checkin - session settings done, creation needs work
JohnMcPMS 4216049
Primary session management implemented, needs TODOs looked at, needs …
JohnMcPMS cb3f04d
Merge from user/rechfr
JohnMcPMS 5fca876
Post-merge fixes and implementations
JohnMcPMS 243d358
Pull image almost impl
JohnMcPMS ca94797
WSLA error info wrapper and use
JohnMcPMS 6ca21d3
Merge from user/richfr
JohnMcPMS d15c57e
Merge branch 'user/richfr' into sdk-session
JohnMcPMS 694734e
Update for wsla feature merge
JohnMcPMS 3181022
Implement for demo and fixes for same
JohnMcPMS 37e9a89
Swap to always attach at container start
JohnMcPMS 877bf26
Merge from user/richfr
JohnMcPMS 4557def
Update for pull and implement container flags and delete
JohnMcPMS 7f800ed
clang format
JohnMcPMS d33a7fa
implement getprocessexitevent
JohnMcPMS 144d00c
Merge branch 'feature/wsl-for-apps' into sdk-session
JohnMcPMS bc357c7
cleanup
JohnMcPMS 0bdb1df
clang format
JohnMcPMS f542a14
clang format
JohnMcPMS c65c4a2
Update src/windows/WslcSDK/ProgressCallback.h
JohnMcPMS 61f1c5e
PR feedback
JohnMcPMS 32d797b
clang format
JohnMcPMS 713dff4
Revert cmake cp
JohnMcPMS fd8d237
Merge remote-tracking branch 'upstream/feature/wsl-for-apps' into sdk…
JohnMcPMS 42a4313
PR feedback
JohnMcPMS fa31680
PR feedback
JohnMcPMS 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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| /*++ | ||
|
|
||
| Copyright (c) Microsoft. All rights reserved. | ||
|
|
||
| Module Name: | ||
|
|
||
| ProgressCallback.cpp | ||
|
|
||
| Abstract: | ||
|
|
||
| Implementation of a type that implements IProgressCallback. | ||
|
|
||
| --*/ | ||
| #include "precomp.h" | ||
| #include "ProgressCallback.h" | ||
|
|
||
| using namespace std::string_view_literals; | ||
|
|
||
| namespace { | ||
| WslcImageProgressStatus ConvertStatus(LPCSTR Status) | ||
| { | ||
| #define WSLC_STRING_TO_STATUS_MAPPING(_status_, _string_) \ | ||
| if (_string_##sv == Status) \ | ||
| { \ | ||
| return _status_; \ | ||
| } | ||
|
|
||
| // TODO: Mapping engine strings to status values seems fragile. | ||
| // WSLA is intentionally avoiding this kind of thing for localization of engine strings, which amounts to the same | ||
| // thing. If we keep this, a test should be added to explicitly validate that each status is returned properly. | ||
| WSLC_STRING_TO_STATUS_MAPPING(WSLC_IMAGE_PROGRESS_STATUS_PULLING, "Pulling fs layer"); | ||
| WSLC_STRING_TO_STATUS_MAPPING(WSLC_IMAGE_PROGRESS_STATUS_WAITING, "Waiting"); | ||
| WSLC_STRING_TO_STATUS_MAPPING(WSLC_IMAGE_PROGRESS_STATUS_DOWNLOADING, "Downloading"); | ||
| WSLC_STRING_TO_STATUS_MAPPING(WSLC_IMAGE_PROGRESS_STATUS_VERIFYING, "Verifying Checksum"); | ||
| WSLC_STRING_TO_STATUS_MAPPING(WSLC_IMAGE_PROGRESS_STATUS_EXTRACTING, "Extracting"); | ||
| WSLC_STRING_TO_STATUS_MAPPING(WSLC_IMAGE_PROGRESS_STATUS_COMPLETE, "Pull complete"); | ||
|
JohnMcPMS marked this conversation as resolved.
|
||
|
|
||
| return WSLC_IMAGE_PROGRESS_STATUS_UNKNOWN; | ||
| } | ||
| } // namespace | ||
|
|
||
| ProgressCallback::ProgressCallback(WslcContainerImageProgressCallback callback, PVOID context) : | ||
| m_callback(callback), m_context(context) | ||
| { | ||
| } | ||
|
|
||
| HRESULT STDMETHODCALLTYPE ProgressCallback::OnProgress(LPCSTR Status, LPCSTR Id, ULONGLONG Current, ULONGLONG Total) | ||
| { | ||
| if (m_callback) | ||
| { | ||
| WslcImageProgressMessage message{}; | ||
|
|
||
| message.id = Id; | ||
| message.status = ConvertStatus(Status); | ||
| message.detail.current = Current; | ||
| message.detail.total = Total; | ||
|
|
||
| m_callback(&message, m_context); | ||
|
JohnMcPMS marked this conversation as resolved.
Outdated
|
||
| } | ||
|
|
||
| return S_OK; | ||
| } | ||
|
|
||
| winrt::com_ptr<ProgressCallback> ProgressCallback::CreateIf(const WslcPullImageOptions* options) | ||
| { | ||
| if (options->progressCallback) | ||
| { | ||
| return winrt::make_self<ProgressCallback>(options->progressCallback, options->progressCallbackContext); | ||
| } | ||
| else | ||
| { | ||
| return nullptr; | ||
| } | ||
| } | ||
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,32 @@ | ||
| /*++ | ||
|
|
||
| Copyright (c) Microsoft. All rights reserved. | ||
|
|
||
| Module Name: | ||
|
|
||
| ProgressCallback.h | ||
|
|
||
| Abstract: | ||
|
|
||
| Header for a type that implements IProgressCallback. | ||
|
|
||
| --*/ | ||
| #pragma once | ||
| #include "wslaservice.h" | ||
| #include "wslcsdkprivate.h" | ||
| #include <winrt/base.h> | ||
|
|
||
| struct ProgressCallback : public winrt::implements<ProgressCallback, IProgressCallback> | ||
| { | ||
| ProgressCallback(WslcContainerImageProgressCallback callback, PVOID context); | ||
|
|
||
| // IProgressCallback | ||
| HRESULT STDMETHODCALLTYPE OnProgress(LPCSTR Status, LPCSTR Id, ULONGLONG Current, ULONGLONG Total) override; | ||
|
|
||
| // Creates a ProgressCallback if the options provides a callback. | ||
| static winrt::com_ptr<ProgressCallback> CreateIf(const WslcPullImageOptions* options); | ||
|
|
||
| private: | ||
| WslcContainerImageProgressCallback m_callback; | ||
| PVOID m_context; | ||
|
JohnMcPMS marked this conversation as resolved.
Outdated
|
||
| }; | ||
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,58 @@ | ||
| /*++ | ||
|
|
||
| Copyright (c) Microsoft. All rights reserved. | ||
|
|
||
| Module Name: | ||
|
|
||
| TerminationCallback.cpp | ||
|
|
||
| Abstract: | ||
|
|
||
| Implementation of a type that implements ITerminationCallback. | ||
|
|
||
| --*/ | ||
| #include "precomp.h" | ||
| #include "TerminationCallback.h" | ||
|
|
||
| namespace { | ||
| WslcSessionTerminationReason ConvertReason(WSLAVirtualMachineTerminationReason Reason) | ||
| { | ||
| switch (Reason) | ||
| { | ||
| case WSLAVirtualMachineTerminationReasonShutdown: | ||
| return WSLC_SESSION_TERMINATION_REASON_SHUTDOWN; | ||
| case WSLAVirtualMachineTerminationReasonCrashed: | ||
| return WSLC_SESSION_TERMINATION_REASON_CRASHED; | ||
| default: | ||
| return WSLC_SESSION_TERMINATION_REASON_UNKNOWN; | ||
| } | ||
| } | ||
| } // namespace | ||
|
|
||
| TerminationCallback::TerminationCallback(WslcSessionTerminationCallback callback, PVOID context) : | ||
| m_callback(callback), m_context(context) | ||
| { | ||
| } | ||
|
|
||
| // TODO: Details from the runtime are dropped; should the SDK callback function be updated to include the reasons string? | ||
| HRESULT STDMETHODCALLTYPE TerminationCallback::OnTermination(WSLAVirtualMachineTerminationReason Reason, LPCWSTR) | ||
| { | ||
| if (m_callback) | ||
| { | ||
| m_callback(ConvertReason(Reason), m_context); | ||
| } | ||
|
|
||
| return S_OK; | ||
| } | ||
|
|
||
| winrt::com_ptr<TerminationCallback> TerminationCallback::CreateIf(const WSLC_SESSION_OPTIONS_INTERNAL* options) | ||
| { | ||
| if (options->terminationCallback) | ||
| { | ||
| return winrt::make_self<TerminationCallback>(options->terminationCallback, options->terminationCallbackContext); | ||
| } | ||
| else | ||
| { | ||
| return nullptr; | ||
| } | ||
| } |
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,32 @@ | ||
| /*++ | ||
|
|
||
| Copyright (c) Microsoft. All rights reserved. | ||
|
|
||
| Module Name: | ||
|
|
||
| TerminationCallback.h | ||
|
|
||
| Abstract: | ||
|
|
||
| Header for a type that implements ITerminationCallback. | ||
|
|
||
| --*/ | ||
| #pragma once | ||
| #include "wslaservice.h" | ||
| #include "wslcsdkprivate.h" | ||
| #include <winrt/base.h> | ||
|
|
||
| struct TerminationCallback : public winrt::implements<TerminationCallback, ITerminationCallback> | ||
| { | ||
| TerminationCallback(WslcSessionTerminationCallback callback, PVOID context); | ||
|
|
||
| // ITerminationCallback | ||
| HRESULT STDMETHODCALLTYPE OnTermination(WSLAVirtualMachineTerminationReason Reason, LPCWSTR Details) override; | ||
|
|
||
| // Creates a TerminationCallback if the options provides a callback. | ||
| static winrt::com_ptr<TerminationCallback> CreateIf(const WSLC_SESSION_OPTIONS_INTERNAL* options); | ||
|
|
||
| private: | ||
| WslcSessionTerminationCallback m_callback; | ||
| PVOID m_context; | ||
| }; |
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,46 @@ | ||
| /*++ | ||
|
|
||
| Copyright (c) Microsoft. All rights reserved. | ||
|
|
||
| Module Name: | ||
|
|
||
| WslcSDKPrivate.cpp | ||
|
|
||
| Abstract: | ||
|
|
||
| This file contains the private WSL Container SDK implementations. | ||
|
|
||
| --*/ | ||
| #include "precomp.h" | ||
|
|
||
| #include "wslcsdkprivate.h" | ||
|
|
||
| WSLC_SESSION_OPTIONS_INTERNAL* GetInternalType(WslcSessionSettings* settings) | ||
| { | ||
| return reinterpret_cast<WSLC_SESSION_OPTIONS_INTERNAL*>(settings); | ||
| } | ||
|
|
||
| WSLC_CONTAINER_PROCESS_OPTIONS_INTERNAL* GetInternalType(WslcProcessSettings* settings) | ||
| { | ||
| return reinterpret_cast<WSLC_CONTAINER_PROCESS_OPTIONS_INTERNAL*>(settings); | ||
| } | ||
|
|
||
| WSLC_CONTAINER_OPTIONS_INTERNAL* GetInternalType(WslcContainerSettings* settings) | ||
| { | ||
| return reinterpret_cast<WSLC_CONTAINER_OPTIONS_INTERNAL*>(settings); | ||
| } | ||
|
|
||
| WslcSessionImpl* GetInternalType(WslcSession handle) | ||
| { | ||
| return reinterpret_cast<WslcSessionImpl*>(handle); | ||
| } | ||
|
|
||
| WslcContainerImpl* GetInternalType(WslcContainer handle) | ||
| { | ||
| return reinterpret_cast<WslcContainerImpl*>(handle); | ||
| } | ||
|
|
||
| WslcProcessImpl* GetInternalType(WslcProcess handle) | ||
| { | ||
| return reinterpret_cast<WslcProcessImpl*>(handle); | ||
| } |
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.
Uh oh!
There was an error while loading. Please reload this page.