pass VM CPU and RAM spec through OCI annotations#93
Conversation
There was a problem hiding this comment.
Pull request overview
Adds support for configuring VM vCPU count and RAM via OCI annotations and plumbs that configuration into VM creation/startup.
Changes:
- Introduces
io.containerd.nerdbox.resources.cpuand.memoryannotations and parses them from the OCI bundle. - Adds a VM instance API (
SetCPUAndMemory) and wires it into the libkrun implementation. - Updates documentation and cross-links to the new VM configuration doc section.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| internal/vm/vm.go | Extends the VM Instance interface with a CPU/memory configuration method. |
| internal/vm/libkrun/instance.go | Implements SetCPUAndMemory and removes hardcoded CPU/mem defaults from Start. |
| internal/shim/task/service.go | Adds resource config parsing during bundle load and applies it to the VM before start. |
| internal/shim/task/resource_config.go | New bundle transformer + VM setup logic for CPU/memory annotations. |
| docs/vm-configuration.md | Documents resource annotations and reorganizes networking section under VM configuration. |
| docs/ctr-networking.md | Updates link to point to the new VM configuration networking section. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
995c776 to
eb488c3
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Add support for two new OCI annotations: - `io.containerd.nerdbox.resources.cpu`: numnber of vCPUs to allocate to the VM. - `io.containerd.nerdbox.resources.memory`: amount of RAM to allocate to the VM, in MiB. Signed-off-by: Albin Kerouanton <albin.kerouanton@docker.com>
eb488c3 to
592f7b9
Compare
dmcgowan
left a comment
There was a problem hiding this comment.
Annotations LGTM
I would like to have another pass at the VM instance interface, but we can take this in for now. Mostly I think there is a life cycle issue today, the instance is an instance from the underlying driver perspective but does not represent the state of the VM. Having functions such as setting resources or adding disks which can only be done before/on start is not a great interface. Likely we should move more of these options in the start interface and the only "instance" functions should be usable on a running VM, possibly with type assertion based on what the instance supports. For example, add disk to a running VM would be a good feature, but not necessarily implemented by all backends or necessary for the single container use case.
Add support for two new OCI annotations:
io.containerd.nerdbox.resources.cpu: numnber of vCPUs to allocate to the VM.io.containerd.nerdbox.resources.memory: amount of RAM to allocate to the VM, in MiB.