Follow up to the cgroup PR #40519 (#41073)

* remove redundant string conversion * Add user warning when cgroup v1 is enabled * resolve comments * resolve comments * fix the locked string

Feng Wang committed Jul 25, 2026 at 07:37 UTC 5e4f15db4f4b5907369be8405fb7e67962b21099
3 files changed +10 -1
localization/strings/en-US/Resources.resw
+4
@@ -1198,6 +1198,10 @@ See recovery instructions on: https://aka.ms/wsldiskmountrecovery</value>
1198 <value>Failed to translate '{}'</value>
1199 <comment>{FixedPlaceholder="{}"}Command line arguments, file names and string inserts should not be translated</comment>
1200 </data>
1201 + <data name="MessageCgroupV1IncompatibleWithDistroIsolation" xml:space="preserve">
1202 + <value>Cgroup v1 is incompatible with per-distribution cgroup isolation. To use cgroup v1, set isolateDistroCgroup=false under [wsl2] in .wslconfig, then run wsl --shutdown.</value>
1203 + <comment>{Locked="Cgroup v1"}{Locked="cgroup v1"}{Locked="isolateDistroCgroup=false"}{Locked="[wsl2]"}{Locked="--shutdown."}{Locked=".wslconfig"}Command line arguments, file names and string inserts should not be translated.</comment>
1204 + </data>
1205 <data name="Settings_ErrorTryAgainLater.Text" xml:space="preserve">
1206 <value>Something went wrong. Try again later.</value>
1207 </data>
src/linux/init/config.cpp
+5
@@ -1842,6 +1842,11 @@ try
1842 }
1843 }
1844
1845 + if (Config.CGroup == WslDistributionConfig::CGroupVersion::v1 && getenv(LX_WSL2_DISTRO_CGROUP_PATH) != nullptr)
1846 + {
1847 + EMIT_USER_WARNING(wsl::shared::Localization::MessageCgroupV1IncompatibleWithDistroIsolation());
1848 + }
1849 +
1850 if (Config.CGroup == WslDistributionConfig::CGroupVersion::v1)
1851 {
1852 THROW_LAST_ERROR_IF(mount("tmpfs", CGROUP_MOUNTPOINT, "tmpfs", (MS_NOSUID | MS_NODEV | MS_NOEXEC), "mode=755") < 0);
test/windows/Common.cpp
+1 -1
@@ -1462,7 +1462,7 @@ std::wstring LxssWriteWslConfig(const std::wstring& Content)
1462 // writes distro specific settings /etc/wsl.conf
1463 std::string LxssWriteWslDistroConfig(const std::string& Content, LPCWSTR DistributionName)
1464 {
1465 - std::string path = std::format("\\\\wsl.localhost\\{}\\etc\\wsl.conf", wsl::shared::string::WideToMultiByte(DistributionName));
1465 + std::string path = std::format("\\\\wsl.localhost\\{}\\etc\\wsl.conf", DistributionName);
1466
1467 std::ifstream distroConfigRead(path);
1468 auto previousContent = std::string{std::istreambuf_iterator<char>(distroConfigRead), {}};