Skip to content

POC: Windows host & guest scaffolding — remove cygpath, add WINDOWS OS schema#4991

Draft
mn-ram wants to merge 1 commit into
lima-vm:masterfrom
mn-ram:poc/pure-go-cygpath-replacement
Draft

POC: Windows host & guest scaffolding — remove cygpath, add WINDOWS OS schema#4991
mn-ram wants to merge 1 commit into
lima-vm:masterfrom
mn-ram:poc/pure-go-cygpath-replacement

Conversation

@mn-ram
Copy link
Copy Markdown
Contributor

@mn-ram mn-ram commented May 16, 2026

Summary

Two complementary primary-goal contributions for the LFX 2026 Term 2 project Improve Windows support (host and guest) (#4907):

  1. Windows host UXcygpath.exe shell-out in pkg/ioutilx/ioutilx.go replaced with deterministic pure-Go path translation. All eight production callers continue to work; the implicit Cygwin/MSYS2 dependency is removed from Windows hosts.
  2. Windows guest scaffoldingWINDOWS OS = "Windows" added to the schema (pkg/limatype, pkg/limayaml/validate.go), plus templates/experimental/windows.yaml. This is the shared groundwork that any Windows-guest provisioning route (Cloudbase-Init or autounattend.xml) needs.

Both are signature-preserving / additive: every existing caller compiles unchanged, every existing template still validates.

What's in the diff

Area Files Notes
Pure-Go path translation pkg/ioutilx/ioutilx.go, pkg/ioutilx/ioutilx_test.go WindowsSubsystemPath signature unchanged; cygpath subprocess removed; 23 sub-tests
Windows OS enum + validator pkg/limatype/lima_yaml.go, pkg/limayaml/validate.go, pkg/limayaml/validate_test.go WINDOWS OS = "Windows"; NewOS normalizes lowercase alias; positive + negative validator tests
Experimental template templates/experimental/windows.yaml QEMU + UEFI + TPM stub; image URL is a 404 placeholder until follow-up image work lands
Sandbox PoC (kept as runnable demo, may be stripped on merge) poc/ Self-contained Go module that prototyped the conversion logic in isolation

Verification

  • go build ./... clean
  • go vet ./... clean
  • go test ./pkg/ioutilx/ ./pkg/limayaml/ ./pkg/limatype/ — all green (23 new sub-tests in ioutilx, 4 new sub-tests in limayaml)
  • All 8 production callers of WindowsSubsystemPath still compile (cmd/limactl/shell.go, pkg/copytool, pkg/hostagent/mount, pkg/sshutil × 3, pkg/limayaml/defaults)
  • No remaining cygpath shell-out in the production tree
  • All existing validate_test.go tests still pass after the OS list change

Cygpath conversion table

Detected style Trigger C:\Users\me\.lima
native Win32-OpenSSH at C:\Windows\System32\OpenSSH C:/Users/me/.lima
msys MSYSTEM set, or ssh under Git-for-Windows /c/Users/me/.lima
cygwin CYGWIN set, or ssh under cygwin64 /cygdrive/c/Users/me/.lima

UNC paths pass through with slashes normalized, matching cygpath -u's behavior. WindowsSubsystemPathForLinux on line 62 is intentionally left alone — it shells out to wsl --exec wslpath, which is not a Cygwin dependency.

Scope not in this PR

Documented as next steps in the project plan, intentionally left for follow-up:

  • pkg/cidata branching on guestOS == Windows to emit Cloudbase-Init NoCloud data or autounattend.xml ISOs (mentor's choice).
  • pkg/driver/qemu TPM 2.0 + UEFI plumbing when os: Windows.
  • pkg/driver/hcs external driver against Microsoft hcsshim (secondary goal).
  • WSL2 multi-instance + WSLg (tertiary goal).
  • limactl doctor for Windows-host first-run wizard.
  • poc/ sandbox directory — keep for now as a runnable demo; maintainers may strip before merge.

Status

Draft for LFX mentorship visibility. Happy to split into separate PRs or drop the poc/ sandbox if preferred.

@mn-ram mn-ram force-pushed the poc/pure-go-cygpath-replacement branch from 037ad29 to 15d2f9d Compare May 16, 2026 12:43
@mn-ram mn-ram changed the title poc: pure-Go replacement for cygpath.exe (LFX 2026 Term 2 — Windows support) ioutilx: remove cygpath.exe dependency, use pure-Go path translation May 16, 2026
@mn-ram mn-ram changed the title ioutilx: remove cygpath.exe dependency, use pure-Go path translation Windows host & guest scaffolding: remove cygpath, add WINDOWS OS schema, experimental template May 16, 2026
@mn-ram mn-ram force-pushed the poc/pure-go-cygpath-replacement branch from 2a74da4 to e28e198 Compare May 16, 2026 13:08
…S OS schema, experimental template

Two complementary primary-goal contributions for the LFX 2026 Term 2
project "Improve Windows support (host and guest)" (lima-vm#4907):

1. Windows host UX
   Replaces the cygpath.exe subprocess at pkg/ioutilx/ioutilx.go:54
   with deterministic pure-Go path translation. The implicit Cygwin /
   MSYS2 dependency is removed from Windows hosts. The public
   signature of WindowsSubsystemPath is unchanged, so all eight
   production callers (cmd/limactl/shell.go, pkg/copytool,
   pkg/hostagent/mount, pkg/sshutil x3, pkg/limayaml/defaults)
   continue to work without edits.

   - detectSubsystemStyle() picks one of {native, msys, cygwin} from
     MSYSTEM, CYGWIN, the SSH env var, and the resolved ssh binary
     path. Env vars win over heuristics so a user-asserted MSYSTEM is
     honored.
   - convertWindowsSubsystemPath() does the namespace remapping with
     pure string operations (no path/filepath calls), so the package
     builds and tests on any host. UNC paths pass through with slashes
     normalized, matching cygpath -u's behavior.
   - WindowsSubsystemPathForLinux on line 62 is intentionally left
     alone; it shells out to "wsl --exec wslpath", which is correct
     and not a Cygwin dependency.
   - 23 sub-tests cover style detection, drive-letter and UNC
     conversion, and the public end-to-end entry point. Uses
     gotest.tools/v3/assert per Lima's .golangci.yml.

2. Windows guest scaffolding
   Adds the schema groundwork any Windows-guest provisioning route
   needs:

   - WINDOWS OS = "Windows" added to pkg/limatype/lima_yaml.go and
     the OSTypes slice. NewOS() normalizes the lowercase "windows"
     alias the same way it does "linux" and "darwin".
   - pkg/limayaml/validate.go switch on *y.OS whitelists Windows.
   - TestValidateMultipleErrors updated to use "plan9" as the
     rejected OS (was using "windows" as the invalid example, which
     is now valid) and refreshed the expected OSTypes message.
   - TestValidateWindowsGuestOS added — positive + negative cases.
   - templates/experimental/windows.yaml — minimal QEMU-driven
     Windows guest template. Image URL is intentionally a 404
     placeholder so the template is reviewable for its schema shape
     without misleading anyone into thinking limactl start is
     functional yet; the file header documents the follow-up work in
     pkg/cidata and pkg/driver/qemu.

A self-contained Go module under poc/ prototypes the conversion
logic in isolation and is kept in the tree as a runnable demo
(go run ./poc/cmd/winpath-demo 'C:\...'). It is not required by the
production code path and maintainers may strip it before merge.

Out of scope, deferred to follow-up PRs and documented in the
project plan: pkg/cidata branching for Cloudbase-Init data, QEMU
TPM/UEFI plumbing for Windows guests, pkg/driver/hcs external
driver, WSL2 multi-instance + WSLg, limactl doctor for the first-
run Windows wizard.

Signed-off-by: mn-ram <235066282+mn-ram@users.noreply.github.com>
@mn-ram mn-ram force-pushed the poc/pure-go-cygpath-replacement branch from e28e198 to 2b2e22c Compare May 16, 2026 13:09
@mn-ram mn-ram changed the title Windows host & guest scaffolding: remove cygpath, add WINDOWS OS schema, experimental template POC: Windows host & guest scaffolding — remove cygpath, add WINDOWS OS schema May 16, 2026
@jandubois
Copy link
Copy Markdown
Member

@jandubois
Copy link
Copy Markdown
Member

Note that Windows host implementation is likely already solved by #4998 in a much more comprehensive way, so I would not spend any further effort on it, and concentrate on the Windows guest support instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants