Skip to content

wslc service com api support for emit warning message as optional com callback#40558

Open
yao-msft wants to merge 16 commits into
masterfrom
user/yaosun/wslcservicewarning
Open

wslc service com api support for emit warning message as optional com callback#40558
yao-msft wants to merge 16 commits into
masterfrom
user/yaosun/wslcservicewarning

Conversation

@yao-msft
Copy link
Copy Markdown
Contributor

@yao-msft yao-msft commented May 15, 2026

Summary of the Pull Request

Added IWarningCallback to COM api that may emit warning messages. Scanned through wslcsession to add warning messages as applicable.

PR Checklist

  • Closes: Link to issue #xxx
  • Communication: I've discussed this with core contributors already. If work hasn't been agreed, this work might be rejected
  • Tests: Added/updated if needed and all pass
  • Localization: All end user facing strings can be localized
  • Dev docs: Added/updated if needed
  • Documentation updated: If checked, please file a pull request on our docs repo and link it here: #xxx

Detailed Description of the Pull Request / Additional comments

Validation Steps Performed

Added 2 tests that test the warning callback where we can create a warning situation deterministically. Other places we do not have a deterministic way to get to the warning state.

Copy link
Copy Markdown
Collaborator

@OneBlue OneBlue left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this structure because it will nicely integrate with the EMIT_USER_WARNING() macros that we have.

Sadly there's one tricky that we need to consider: If the caller doesn't read from the handle, we need to be able to Cancel the IO so that we don't get stuck when trying to terminate a session if the caller doesn't read from the HANDLE and the pipe gets full.

(This is how we do it on the regular session handles

The issue would be the same if we decided to use a COM callback, we would need to keep track of the callback, and cancel it if the session terminates (pointer to how we terminate COM callbacks today

One way we could make this work would be by adding a pointer to the WSLCSession to COMServiceExecutionContext, and do something like this:

HRESULT WSLCSession::CreateContainer(const WSLCContainerOptions* containerOptions, IWSLCContainer** Container)
{
    COMServiceExecutionContext context(this);
[...]
}

So that way, we can register the COM callback / IO with the session when we emit a warning, and so it will be correctly cancelled if the session terminates.

Regarding the pipe vs COM callback, I think I have a small preference for the COM callback, since we already do that in other places (like for the pull / build callbacks), and at least it won't force the caller to create a thread if no warning are emitted

Comment thread src/windows/common/ExecutionContext.h Outdated
Copilot AI review requested due to automatic review settings May 26, 2026 22:16
@yao-msft yao-msft force-pushed the user/yaosun/wslcservicewarning branch from 38f0edb to bc55b39 Compare May 26, 2026 22:16
Copy link
Copy Markdown
Contributor

Copilot AI left a 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 introduces a new IWarningCallback COM callback and threads warning emission through WSLC session/container operations, so non-fatal issues (e.g., recovery failures, Docker warnings) can be surfaced to callers instead of only being logged.

Changes:

  • Adds a new IWarningCallback interface and plumbs an optional callback parameter through many WSLC COM APIs and their implementations.
  • Introduces WSLCExecutionContext to route EMIT_USER_WARNING(...) to the callback (with lazy COM cancellation registration).
  • Adds localized warning strings and new tests that validate warning callback delivery during container/volume recovery scenarios.

Reviewed changes

Copilot reviewed 23 out of 23 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
test/windows/WSLCTests.cpp Updates call sites for new optional callback parameters; adds warning-callback tests for recovery paths.
test/windows/wslc/e2e/WSLCE2EHelpers.cpp Updates session creation to pass the new optional warning callback argument.
test/windows/wslc/e2e/WSLCE2EGlobalTests.cpp Updates session creation calls to include the optional warning callback argument.
test/windows/PluginTests.cpp Updates session/image calls for new optional warning callback parameters.
test/windows/Common.cpp Updates LoadTestImage to pass the new optional warning callback argument.
src/windows/wslcsession/WSLCVolumes.cpp Emits user warnings on volume recovery/release failures.
src/windows/wslcsession/WSLCSessionFactory.h Extends factory CreateSession signature to accept IWarningCallback.
src/windows/wslcsession/WSLCSessionFactory.cpp Passes IWarningCallback through to WSLCSession::Initialize.
src/windows/wslcsession/WSLCSession.h Extends WSLC session COM methods to accept optional IWarningCallback parameters; adds IsUserCOMCallbackRegistered().
src/windows/wslcsession/WSLCSession.cpp Switches to WSLCExecutionContext and emits warnings for various non-fatal failure paths and Docker warnings.
src/windows/wslcsession/WSLCExecutionContext.h New execution context that forwards EMIT_USER_WARNING to IWarningCallback with cancellation support.
src/windows/wslcsession/WSLCContainer.h Extends Start to accept optional IWarningCallback; threads session reference into wrapper.
src/windows/wslcsession/WSLCContainer.cpp Uses WSLCExecutionContext and emits warnings for additional container-related failure scenarios and Docker warnings.
src/windows/WslcSDK/wslcsdk.cpp Updates SDK internal calls to pass nullptr for the new warning-callback parameters.
src/windows/wslc/services/WarningCallback.h Adds a CLI-side IWarningCallback implementation that writes warnings to stderr.
src/windows/wslc/services/SessionService.cpp Updates session creation/enter calls for new optional warning callback parameter (currently passing nullptr).
src/windows/wslc/services/ImageService.cpp Updates image operations to pass nullptr for the new optional warning callback parameter.
src/windows/wslc/services/ContainerService.cpp Updates container start calls to pass nullptr for the new optional warning callback parameter.
src/windows/service/inc/wslc.idl Defines IWarningCallback and adds optional callback parameters to multiple existing COM interfaces/methods.
src/windows/service/exe/WSLCSessionManager.h Extends session manager signatures to accept optional IWarningCallback.
src/windows/service/exe/WSLCSessionManager.cpp Plumbs IWarningCallback through to session factory creation and enter-session flow.
src/windows/common/WSLCContainerLauncher.cpp Updates container creation/start calls for new optional warning callback parameters.
localization/strings/en-US/Resources.resw Adds new localized warning strings for recovery and other warning scenarios.

Comment thread src/windows/service/inc/wslc.idl
Comment thread src/windows/service/inc/wslc.idl
Comment thread src/windows/wslc/services/SessionService.cpp
Comment thread src/windows/wslc/services/WarningCallback.h Outdated
Comment thread test/windows/WSLCTests.cpp Outdated
Comment thread test/windows/WSLCTests.cpp Outdated
Comment thread src/windows/wslcsession/WSLCExecutionContext.h Outdated
Comment thread localization/strings/en-US/Resources.resw Outdated
@yao-msft yao-msft changed the title Draft service warning emit wslc service com api support for emit warning message as optional com callback May 27, 2026
Copy link
Copy Markdown
Collaborator

@OneBlue OneBlue left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This approach looks great and integrate nicely into our existing warning infrastructure.

I think the next step would be to add logic to print the warnings on stderr in wslc, and this should be ready to merge

Comment thread src/windows/wslcsession/WSLCExecutionContext.h
@yao-msft yao-msft marked this pull request as ready for review May 27, 2026 18:06
@yao-msft yao-msft requested a review from a team as a code owner May 27, 2026 18:06
Copilot AI review requested due to automatic review settings May 27, 2026 18:06
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 23 out of 23 changed files in this pull request and generated 5 comments.

Comment thread src/windows/service/inc/wslc.idl
Comment thread src/windows/service/inc/wslc.idl
Comment thread localization/strings/en-US/Resources.resw
Comment thread test/windows/WSLCTests.cpp
Comment thread test/windows/WSLCTests.cpp
Copilot AI review requested due to automatic review settings May 28, 2026 02:45
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 26 out of 26 changed files in this pull request and generated no new comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants