Skip to content

Implement HCS driver - #5449

Merged
AkihiroSuda merged 1 commit into
lima-vm:masterfrom
mie313:hcs-driver
Sep 1, 2026
Merged

AkihiroSuda merged 1 commit into
lima-vm:masterfrom
mie313:hcs-driver

Conversation

@mie313

@mie313 mie313 commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

What This PR Changes

This PR addresses #4961 .
It adds HCS driver as VM driver options on Windows hosts.

Linked Issue (Required in most cases)

#4961

Closes #

How I Tested This

I validated that a Linux(Ubuntu and Fedora) VM successfully launched with vmType:hcs on Windows 11 (x86_64).

AI Usage

Assisted-by: Claude
I used AI as a reference when exploring some implementation ideas and generating sample code, but I worte the actual code by myself.

@mie313
mie313 force-pushed the hcs-driver branch 4 times, most recently from 2feeeef to e8a71dd Compare August 27, 2026 13:14
- `tpm: true`
- `user.passwordlessSudo` (See [Sudo](../config/sudo))
- `External drivers`: building and using drivers as separate executables (see [Virtual Machine Drivers](../dev/drivers))
- [`vmType: krunkit`](../config/vmtype/krunkit.md)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move vmType:hcs around this line

Comment thread go.mod Outdated
go.opencensus.io v0.24.0 // indirect
)

replace github.com/Microsoft/hcsshim => github.com/AkihiroSuda/hcsshim v0.0.0-20260714172934-dc466dcf888f

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, based on the file you shared, I have removed the dependency on hcsshim/internal/computecore.
I am still struggling to remove hcsshim/hcn dependency.

> **Warning**
> "hcs" mode is experimental

| ⚡ Requirement | Lima >= TBD + (Windows >= Windows 10 OR Windows Server 2019) |

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will be in v2.3

arch: "x86_64"
digest: "sha256:117816726abbdefc5ef3e38902e81a76f1c76c3610e709999d0885f9d5d9b477"
plain: true
dns: - 8.8.8.8

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

YAML format seems broken for DNS

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I fixed the document. (link).

@AkihiroSuda

Copy link
Copy Markdown
Member

Needs rebasing

Comment thread cmd/limactl/main_wsl2.go Outdated
@@ -1,4 +1,4 @@
//go:build !external_wsl2
//go:build windows && !external_wsl2

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line does not need to be changed

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I revised the change and I update the code in main_hcs_windows.go too.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The file name should be like main_wsl2_windows.go

@mie313 mie313 Aug 28, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, I changed the file name. I also update main_hcs.go -> main_hcs_windows.go.

Comment thread go.mod Outdated
go.opencensus.io v0.24.0 // indirect
)

replace github.com/Microsoft/hcsshim => github.com/AkihiroSuda/hcsshim v0.0.0-20260714172934-dc466dcf888f

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This replace should not longer be needed

> **Warning**
> "hcs" mode is experimental

| ⚡ Requirement | Lima >= 2.3 + (Windows >= Windows 10 OR Windows Server 2019) |

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to support Windows 10 and its server derivative

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated the requirement to Windows >= 11, since that's the only OS I have tested on.
Please let me know if Windows Server 2022 should be included here.

@mie313
mie313 force-pushed the hcs-driver branch 3 times, most recently from 8c3a3c5 to 1a673c7 Compare August 28, 2026 14:42
Comment thread go.mod
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06 // indirect
github.com/segmentio/asm v1.1.3 // indirect
github.com/segmentio/asm v1.2.1 // indirect

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to update the license list to allow MIT-0:

Apache-2.0,BSD-2-Clause,BSD-2-Clause-FreeBSD,BSD-3-Clause,MIT,ISC,Python-2.0,PostgreSQL,X11,Zlib

CNCF has already approved MIT-0:
https://github.com/cncf/foundation/blob/87e70a07d5a0cf06cd6f8208b8d52c16f035724a/policies-guidance/allowed-third-party-license-policy.md?plain=1#L53

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

go-licenses still doesn't seem to support MIT-0

So you can just add --ignore

lima/Makefile

Lines 645 to 650 in fa0f5f6

.PHONY: go-licenses
go-licenses:
# the allow list corresponds to https://github.com/cncf/foundation/blob/e5db022a0009f4db52b89d9875640cf3137153fe/allowed-third-party-license-policy.md
# hashicorp/hcl/v2 is MPL-2.0; covered by the CNCF license exception for hashicorp/hcl
# see also https://github.com/cncf/foundation/issues/1242
go-licenses check --include_tests --ignore github.com/hashicorp/hcl/v2 ./... --allowed_licenses=$$(cat ./hack/allowed-licenses.txt)

Comment thread go.mod Outdated

require github.com/clipperhouse/uax29/v2 v2.2.0 // indirect

require github.com/Microsoft/hcsshim v0.14.1

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: merge to the existing require () block

Comment thread go.mod

require github.com/Microsoft/hcsshim v0.14.1

require (

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: merge to the existing indirect require () block

Comment thread pkg/driver/hcs/errors_windows.go Outdated
@@ -0,0 +1,10 @@
//go:build windows

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unneeded line

Comment thread Makefile
# the allow list corresponds to https://github.com/cncf/foundation/blob/e5db022a0009f4db52b89d9875640cf3137153fe/allowed-third-party-license-policy.md
# the allow list corresponds to https://github.com/cncf/foundation/blob/87e70a07d5a0cf06cd6f8208b8d52c16f035724a/policies-guidance/allowed-third-party-license-policy.md
# hashicorp/hcl/v2 is MPL-2.0; covered by the CNCF license exception for hashicorp/hcl
# see also https://github.com/cncf/foundation/issues/1242

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a comment line to explain the reason of ignoring github.com/segmentio/asm

@mie313
mie313 marked this pull request as ready for review August 28, 2026 23:44
AkihiroSuda
AkihiroSuda previously approved these changes Aug 29, 2026

@AkihiroSuda AkihiroSuda left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@AkihiroSuda AkihiroSuda linked an issue Aug 29, 2026 that may be closed by this pull request
@AkihiroSuda
AkihiroSuda requested a review from unsuman August 29, 2026 00:18

@unsuman unsuman Aug 29, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we not build it as an external driver? Since it's experimental

[EDIT]: I also see you have built the HCS driver as external below, but lima prioritises the one which is built as internal

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought that I have not built the HCS driver as external, because cmd/limactl/main_hcs_windows.go is only built when !external_hcs is true and I have not created cmd/lima-driver-hcs/main.go. Am I wrong?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My bad I didn't see that! But I think for now building HCS as internal is OK, because external driver transport is not well tested on Windows and can have some bug(s).

Comment thread pkg/driver/hcs/hcs_driver_windows.go Outdated
for range 50 {
e, err := hcn.GetEndpointByName(endpointName(inst.Name))
if err != nil {
logrus.Errorf("error: %s", err.Error())

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs a break or continue

Comment thread pkg/driver/hcs/hcs_driver_windows.go Outdated
}
if state == "Running" {
inst.Status = limatype.StatusRunning
for range 50 {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But why are we iterating for 100s here? If the state is running then we should just try to retrieve the IP once and error out if we don't get one

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, you are completely right.
I have removed the for loop as you suggested.

Comment thread pkg/limayaml/defaults.go
if o.HostResolver.Enabled != nil {
y.HostResolver.Enabled = o.HostResolver.Enabled
}
if y.HostResolver.Enabled == nil {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other drivers code are not updated to fill this value. I think we should keep the global default and have the HCS driver override

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HostResolver.Enabled value was only referred to in pkg/cidata/cidata.go and pkg/hostagent/hostagent.go.
They are replaced by the helper function HostResolverEnabled() (here)
So, I think the behavior in other drivers remains the same as before.

@mie313 mie313 Aug 30, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After double-checking, I noticed that HostResolver.Enabled is also referred to in pkg/limayaml/validate.go .
So, I have update the code as follows:
[EDIT]

	if y.VMType != nil && *y.VMType == limatype.HCS {
		if y.HostResolver.Enabled != nil && *y.HostResolver.Enabled && len(y.DNS) > 0 {
			errs = errors.Join(errs, errors.New("field `dns` must be empty when field `HostResolver.Enabled` is true"))
		}
	} else {
		if HostResolverEnabled(y) && len(y.DNS) > 0 {
			errs = errors.Join(errs, errors.New("field `dns` must be empty when field `HostResolver.Enabled` is true"))
		}
	}

Thank you for pointing that out.

@mie313
mie313 force-pushed the hcs-driver branch 2 times, most recently from 3fbc9c4 to c532ab6 Compare August 30, 2026 12:35
Signed-off-by: mie313 <mie313.tanaka@gmail.com>

@unsuman unsuman left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@AkihiroSuda AkihiroSuda left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@AkihiroSuda
AkihiroSuda merged commit dd909d0 into lima-vm:master Sep 1, 2026
62 of 64 checks passed
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.

Support for Windows hosts, without depending on QEMU

3 participants