Implement HCS driver - #5449
Implement HCS driver#5449
Conversation
2feeeef to
e8a71dd
Compare
| - `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) |
There was a problem hiding this comment.
Move vmType:hcs around this line
| go.opencensus.io v0.24.0 // indirect | ||
| ) | ||
|
|
||
| replace github.com/Microsoft/hcsshim => github.com/AkihiroSuda/hcsshim v0.0.0-20260714172934-dc466dcf888f |
There was a problem hiding this comment.
microsoft/hcsshim#2825 is not merged yet, so you can just copy the code from https://github.com/AkihiroSuda/hcstest.tmp/blob/28a4feaa8f5d7f1f3eba59c418a60dfc5ec048fa/main_windows.go#L76-L87 instead
There was a problem hiding this comment.
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) | |
| arch: "x86_64" | ||
| digest: "sha256:117816726abbdefc5ef3e38902e81a76f1c76c3610e709999d0885f9d5d9b477" | ||
| plain: true | ||
| dns: - 8.8.8.8 |
There was a problem hiding this comment.
YAML format seems broken for DNS
|
Needs rebasing |
| @@ -1,4 +1,4 @@ | |||
| //go:build !external_wsl2 | |||
| //go:build windows && !external_wsl2 | |||
There was a problem hiding this comment.
This line does not need to be changed
There was a problem hiding this comment.
I revised the change and I update the code in main_hcs_windows.go too.
There was a problem hiding this comment.
The file name should be like main_wsl2_windows.go
There was a problem hiding this comment.
Thank you, I changed the file name. I also update main_hcs.go -> main_hcs_windows.go.
| go.opencensus.io v0.24.0 // indirect | ||
| ) | ||
|
|
||
| replace github.com/Microsoft/hcsshim => github.com/AkihiroSuda/hcsshim v0.0.0-20260714172934-dc466dcf888f |
There was a problem hiding this comment.
This replace should not longer be needed
| > **Warning** | ||
| > "hcs" mode is experimental | ||
|
|
||
| | ⚡ Requirement | Lima >= 2.3 + (Windows >= Windows 10 OR Windows Server 2019) | |
There was a problem hiding this comment.
No need to support Windows 10 and its server derivative
There was a problem hiding this comment.
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.
8c3a3c5 to
1a673c7
Compare
| 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 |
There was a problem hiding this comment.
You need to update the license list to allow MIT-0:
lima/hack/allowed-licenses.txt
Line 1 in fa0f5f6
CNCF has already approved MIT-0:
https://github.com/cncf/foundation/blob/87e70a07d5a0cf06cd6f8208b8d52c16f035724a/policies-guidance/allowed-third-party-license-policy.md?plain=1#L53
There was a problem hiding this comment.
go-licenses still doesn't seem to support MIT-0
So you can just add --ignore
Lines 645 to 650 in fa0f5f6
|
|
||
| require github.com/clipperhouse/uax29/v2 v2.2.0 // indirect | ||
|
|
||
| require github.com/Microsoft/hcsshim v0.14.1 |
There was a problem hiding this comment.
nit: merge to the existing require () block
|
|
||
| require github.com/Microsoft/hcsshim v0.14.1 | ||
|
|
||
| require ( |
There was a problem hiding this comment.
nit: merge to the existing indirect require () block
| @@ -0,0 +1,10 @@ | |||
| //go:build windows | |||
| # 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 |
There was a problem hiding this comment.
Add a comment line to explain the reason of ignoring github.com/segmentio/asm
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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).
| for range 50 { | ||
| e, err := hcn.GetEndpointByName(endpointName(inst.Name)) | ||
| if err != nil { | ||
| logrus.Errorf("error: %s", err.Error()) |
| } | ||
| if state == "Running" { | ||
| inst.Status = limatype.StatusRunning | ||
| for range 50 { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Thank you, you are completely right.
I have removed the for loop as you suggested.
| if o.HostResolver.Enabled != nil { | ||
| y.HostResolver.Enabled = o.HostResolver.Enabled | ||
| } | ||
| if y.HostResolver.Enabled == nil { |
There was a problem hiding this comment.
Other drivers code are not updated to fill this value. I think we should keep the global default and have the HCS driver override
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
3fbc9c4 to
c532ab6
Compare
Signed-off-by: mie313 <mie313.tanaka@gmail.com>
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:hcson 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.