Add configurable storage path for the default wslc session (#40956)
* Add configurable storage path for the default wslc session The default wslc CLI session always created its storage VHD under %LOCALAPPDATA%\wslc\sessions, which is a problem when the system drive is small. Add a `session.storagePath` setting (settings.yaml) that lets users redirect the default session's storage to another location (e.g. a larger data drive). The value must be an absolute path; relative/empty values are rejected and fall back to %LOCALAPPDATA%. Named (custom) sessions are unaffected since they already accept an explicit path. Fixes #40953 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Clarify storagePath is a base directory in settings template Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * wslc: warn when configured storagePath would orphan existing default-session storage Surfaces a one-time warning on default-session creation when session.storagePath is set and an existing session exists at the default %LOCALAPPDATA% location but not yet at the configured one, so users are not surprised by their previous session/containers/images not being migrated. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * wslc: address review nits on storagePath setting Drop unneeded MultiByteToWide in the SessionStoragePath validator (std::filesystem::path constructs from std::string and is_absolute only inspects the root) and clarify the settings template to show the full per-session VHD path. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * wslc: fix localization comment for storage-orphaned string validate-localization.py enforces a canonical comment derived from auto-detected tokens; a manual {Locked=...} for a non-argument token (session.storagePath) diverges from the expected comment and fails CI. Use the canonical comment. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * wslc: lock session.storagePath key name in orphaned-storage warning Per PR review, the literal setting key should not be translated. Append a Locked token after the canonical comment so the validator canonical substring stays intact. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * wslc: simplify storagePath warning to custom-location notice Per PR feedback (dkbennett, benhillis), drop the default-vs-configured orphan detection. Warn once when creating a session VHD at a non-default storagePath, and document the orphan-on-change behavior in the settings template comment. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * wslc: emit storagePath warning from wslcsession at VHD creation Move the custom storagePath notice out of the service's CreateSession, where it was raised via the IWarningCallback COM callback (which can stall the service if the client call hangs), into wslcsession where the VHD is actually created. A new WSLCSessionStorageFlagsWarnCustomLocation flag is set by the service when session.storagePath is configured, and wslcsession emits the warning via EMIT_USER_WARNING only when it creates a new VHD, so the notice fires once at creation. Also reword the message to note the data can be deleted to reclaim space. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * wslc: fix CI clang-format and storage-flags validation test Collapse the SessionSettings::Default return onto one line to satisfy clang-format (the constructor args shrank when the warning moved to a storage flag), and update CreateSessionValidation to use 0x4 as its invalid storage-flags value now that 0x2 (WSLCSessionStorageFlagsWarnCustomLocation) is a valid flag. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Ben Hillis <benhill@ntdev.microsoft.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>