From b420cc6ca7567f5ac418ad7535cdfd9ab4c7bec4 Mon Sep 17 00:00:00 2001 From: Mario Loriedo Date: Fri, 2 Oct 2026 15:07:52 +0200 Subject: [PATCH] Fix the regression on WSL v3: force using cgroufs Fixes #29749 It's the same fix as podman-container-tools/podman-machine-os#319 but this PR fixes existing machines, the ones that have been created with an older podman-machine-os image. The podman-machine-os PR makes still sense for users that are creating a new podman machine with a podman client with version <= v6.1.3. Signed-off-by: Mario Loriedo --- pkg/machine/wsl/declares.go | 4 ++++ pkg/machine/wsl/stubber.go | 15 +++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/pkg/machine/wsl/declares.go b/pkg/machine/wsl/declares.go index 6782c864a7..f40706ab54 100644 --- a/pkg/machine/wsl/declares.go +++ b/pkg/machine/wsl/declares.go @@ -8,6 +8,10 @@ const ( currentMachineVersion = 3 ) +const cgroupManager = `[engine] +cgroup_manager="cgroupfs" +` + const appendPort = `grep -q Port\ %d /etc/ssh/sshd_config || echo Port %d >> /etc/ssh/sshd_config` const changePort = `sed -E -i 's/^Port[[:space:]]+[0-9]+/Port %d/' /etc/ssh/sshd_config` diff --git a/pkg/machine/wsl/stubber.go b/pkg/machine/wsl/stubber.go index 1794add35f..d5b523cb8a 100644 --- a/pkg/machine/wsl/stubber.go +++ b/pkg/machine/wsl/stubber.go @@ -215,14 +215,25 @@ func (w WSLStubber) StartVM(mc *vmconfigs.MachineConfig) (func() error, func() e err := wslInvoke(dist, "/root/bootstrap") if err != nil { - err = fmt.Errorf("the WSL bootstrap script failed: %w", err) + return nil, nil, fmt.Errorf("the WSL bootstrap script failed: %w", err) + } + + // We need to set cgroup_manager="cgroupfs" in the [engine] section + // of containers.conf until we use the WSL supported systemd. + // The details are in this GitHub issue: + // https://github.com/podman-container-tools/podman/issues/29749 + // The issue about using the WSL supported systemd: + // https://github.com/podman-container-tools/podman/issues/15967 + err = wslPipe(cgroupManager, dist, "sh", "-c", "cat > /usr/share/containers/containers.conf.d/999-podman-machine-wsl-cgroupfs.conf") + if err != nil { + return nil, nil, fmt.Errorf("failed creating the cgroupfs config file: %w", err) } readyFunc := func() error { return nil } - return nil, readyFunc, err + return nil, readyFunc, nil } func (w WSLStubber) State(mc *vmconfigs.MachineConfig, _ bool) (define.Status, error) {