Skip to content

Commit

Permalink
Fix crc-org#2131 Add preflight check for WSL2
Browse files Browse the repository at this point in the history
This check looks at the kernel version string and determines if a
Microsoft compiled kernel is used, as is the case with WSL2. This is to
prevent a setup that uses Nested Virtualization.
  • Loading branch information
gbraad committed May 10, 2021
1 parent b4a2109 commit 08bb9de
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
15 changes: 15 additions & 0 deletions pkg/crc/preflight/preflight_checks_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,21 @@ const (
minSupportedLibvirtVersion = "3.4.0"
)

func checkRunningInsideWSL2() error {
version, err := ioutil.ReadFile("/proc/version")
if err != nil {
return err
}

if strings.Contains(string(version), "Microsoft") {
logging.Debugf("Running inside WSL2 environment")
return fmt.Errorf("CodeReady Containers is unsupported using WSL2")
}

return nil
}


func checkVirtualizationEnabled() error {
logging.Debug("Checking if the vmx/svm flags are present in /proc/cpuinfo")
// Check if the cpu flags vmx or svm is present
Expand Down
7 changes: 7 additions & 0 deletions pkg/crc/preflight/preflight_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ import (

func libvirtPreflightChecks(distro *linux.OsRelease) []Check {
checks := []Check{
{
configKeySuffix: "check-wsl2",
checkDescription: "Checking if running inside WSL2",
check: checkRunningInsideWSL2,
fixDescription: "CodeReady Containers is unsupported using WSL2",
flags: NoFix,
},
{
configKeySuffix: "check-virt-enabled",
checkDescription: "Checking if Virtualization is enabled",
Expand Down

0 comments on commit 08bb9de

Please sign in to comment.