Skip to content
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

Command machine init fails to check if WSL is installed #25234

Open
l0rd opened this issue Feb 5, 2025 · 2 comments · May be fixed by #25522
Open

Command machine init fails to check if WSL is installed #25234

l0rd opened this issue Feb 5, 2025 · 2 comments · May be fixed by #25522
Labels
jira kind/bug Categorizes issue or PR as related to a bug. machine windows issue/bug on Windows

Comments

@l0rd
Copy link
Member

l0rd commented Feb 5, 2025

Issue Description

Podman tries to import the machine-os into WSL even when it's impossible because the Windows features Microsoft-Windows-Subsystem-Linux and VirtualMachinePlatform aren't enabled.

This is a regression observed with the latest version of the WSL client (2.3.26.0 or later).

Steps to reproduce the issue

Steps to reproduce the issue

  1. Make sure to have latest version WSL (wsl --update)
  2. Disable the Windows features Microsoft-Windows-Subsystem-Linux and VirtualMachinePlatform
  3. Run podman machine init

Describe the results you received

Extracting compressed file: podman-machine-default-amd64: done
Importing operating system into WSL (this may take a few minutes on a new WSL install)...
Import in progress, this may take a few minutes.
The operation could not be started because a required feature is not installed.
Error code: Wsl/Service/RegisterDistro/CreateVm/HCS/HCS_E_SERVICE_NOT_AVAILABLE
Error: the WSL import of guest OS failed: command C:\Users\mario\AppData\Local\Microsoft\WindowsApps\wsl.exe [--import podman-machine-default C:\Users\mario\.local\share\containers\podman\machine\wsl\wsldist\podman-machine-default C:\Users\mario\.local\share\containers\podman\machine\wsl\podman-machine-default-amd64 --version 2] failed: exit status 0xffffffff

Describe the results you expected

The command should NOT try to import the machine OS in WSL and propose to install WSL to the user:

WSL is not installed on this system, installing it.

NOTE: A system reboot will be required as part of this process. 
If you prefer, you may abort now, and perform a manual installation using the "wsl --install" command.

podman info output

OS: windows/amd64
provider: wsl
version: 5.4.0-dev

Podman in a container

No

Privileged Or Rootless

None

Upstream Latest Release

Yes

Additional environment details

Additional environment details

Additional information

Additional information like issue happens only occasionally or issue happens with a particular architecture or on a particular setting

@l0rd l0rd added kind/bug Categorizes issue or PR as related to a bug. windows issue/bug on Windows machine labels Feb 5, 2025
@l0rd l0rd added the jira label Feb 13, 2025
@BlackHole1
Copy link
Contributor

Currently, there is only one way to directly determine whether a certain feature is enabled in Windows:

Get-WindowsOptionalFeature -Online -FeatureName VirtualMachinePlatform
Get-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux

However, this method requires administrative privileges, and asking users for administrative permissions at every startup is generally unacceptable.

We encountered this in our requirements as well. After testing, we found a workaround to make the judgment, and the relevant code is:

https://github.com/oomol-lab/ovm-win/blob/0c27841224d2daa8f96d789ee3e1a32105858f7d/pkg/wsl/check.go#L243-L294

I'm not sure if podman needs a check like this. If it does, I can submit a related PR.

By the way, just checking the Feature is not enough. It's also necessary to check if BIOS virtualization is enabled, if the WSL version is too low, and if the user has modified the kernel configuration in .wslconfig.

@l0rd
Copy link
Member Author

l0rd commented Mar 7, 2025

Thank you @BlackHole1. I am about to submit a PR that uses a similar approach (look for sentences in wsl --status), and I will cc you. I would be happy if you could look at it. My approach has one main difference: from my tests, the VirtualMachinePlatform is sufficient to run WSL2, and the Microsoft-Windows-Subsystem-Linux is no longer required.

l0rd added a commit to l0rd/podman that referenced this issue Mar 10, 2025
l0rd added a commit to l0rd/podman that referenced this issue Mar 10, 2025
l0rd added a commit to l0rd/podman that referenced this issue Mar 11, 2025
l0rd added a commit to l0rd/podman that referenced this issue Mar 11, 2025
@l0rd l0rd linked a pull request Mar 11, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
jira kind/bug Categorizes issue or PR as related to a bug. machine windows issue/bug on Windows
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants