Skip to content

fix: set the Hyper-V UVM memory annotation in MB - #5338

Open
vitaliy-leschenko wants to merge 1 commit into
containerd:mainfrom
vitaliy-leschenko:fix-hyperv-memory-annotation
Open

vitaliy-leschenko wants to merge 1 commit into
containerd:mainfrom
vitaliy-leschenko:fix-hyperv-memory-annotation

Conversation

@vitaliy-leschenko

Copy link
Copy Markdown

Fixes #5337

nerdctl run --isolation hyperv --memory writes the value parsed by units.RAMInBytes (bytes) into io.microsoft.virtualmachine.computetopology.memory.sizeinmb, which hcsshim reads as megabytes. With --memory 2g the utility VM is requested with 2147483648 MB and hcs::CreateComputeSystem fails.

This converts the value to MB before setting the annotation.

Testing on Windows Server 2025 with Hyper-V isolation, using a patched build:

  • --memory 2g: the annotation is 2048, and the utility VM has 2047 MB. Unpatched nerdctl fails with the same arguments.
  • --memory 1536m: the utility VM has 1535 MB.

GOOS=windows go build ./cmd/nerdctl and go vet ./pkg/cmd/container/ pass. I did not add a unit test, because the value is set inline in setPlatformOptions.

`nerdctl run --isolation hyperv --memory` wrote the parsed value in
bytes into io.microsoft.virtualmachine.computetopology.memory.sizeinmb,
which hcsshim reads as megabytes. With `--memory 2g` the utility VM was
requested with 2147483648 MB and creation failed.

Fixes containerd#5337

Signed-off-by: Vitaliy Leschenko <v.leschenko@vitaliy.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

nerdctl run --isolation hyperv --memory fails: UVM memory annotation is set in bytes

1 participant