Skip to content

feat(driver): honor --cpu and --memory as the VM's vCPUs and memory - #14

Merged
mr-miles merged 2 commits into
mainfrom
feat/standard-resource-limits
Nov 17, 2026
Merged

mr-miles merged 2 commits into
mainfrom
feat/standard-resource-limits

Conversation

@mr-miles

Copy link
Copy Markdown
Owner

The gateway forwards sandbox create --cpu / --memory as the template's cpu_limit and memory_limit. The driver ignored both and reported them unsupported, so every VM got OPENSHELL_VM_DRIVER_VCPUS (2) and OPENSHELL_VM_DRIVER_MEM_MIB (2048).

  • cpu_limit sets the VM's vCPU count. It must be a whole number of CPUs (4, 4000m); 1.5 is refused rather than rounded.
  • memory_limit sets its memory, from a Kubernetes quantity (8Gi, 8192Mi, 8G), rounded down to whole MiB.
  • New OPENSHELL_VM_MAX_VCPUS (at most 32) and the existing OPENSHELL_VM_MAX_MEM_MIB bound the requests. Each defaults to the default size, so nothing changes until an operator raises them. The driver checks the requests at create and again at every launch.
  • The driver now reports CPU and memory limits as supported.
  • driver_config.mem_mib is removed. A request that still sets it is refused with a pointer to --memory.
  • README, the example env file and install.sh are updated. The security notes now say that --cpu and --memory don't need allow_driver_config.

Not built or tested locally: the sandbox I worked in didn't have the disk space to compile the driver. CI (driver:ci: format, clippy -D warnings, tests) is the first build of this change. The code is rustfmt-clean.

🤖 Generated with Claude Code

miles-luma and others added 2 commits November 17, 2026 22:10
The gateway forwards a sandbox's standard resource limits as the template's
cpu_limit and memory_limit. The driver ignored them and reported both
limits unsupported, so every VM got the driver-wide OPENSHELL_VM_DRIVER_VCPUS
and OPENSHELL_VM_DRIVER_MEM_MIB whatever was asked for.

Now cpu_limit sets the VM's vCPU count and memory_limit its memory, and the
driver reports both limits supported. A CPU limit must be a whole number of
CPUs (2, 2000m), because a Firecracker VM has whole vCPUs; 1.5 is refused,
not rounded. Memory takes a Kubernetes quantity (8Gi, 8192Mi, 8G), rounded
down to whole MiB. Requests are bounded by the new OPENSHELL_VM_MAX_VCPUS
(at most Firecracker's 32) and the existing OPENSHELL_VM_MAX_MEM_MIB; each
defaults to the default size. They are checked at create and again at every
launch, as the memory request was before.

driver_config.mem_mib is removed in favour of --memory. A driver_config that
still sets it is refused with a pointer to --memory.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
clippy's doc_markdown (pedantic, denied in CI) reads mixed-case words such
as vCPUs and microVM in doc comments as unquoted code.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mr-miles
mr-miles merged commit dd26621 into main Nov 17, 2026
3 checks passed
@mr-miles
mr-miles deleted the feat/standard-resource-limits branch November 17, 2026 22:39
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.

2 participants