Skip to content

Add KVM device passthrough support for hardware virtualization#13618

Merged
tofarr merged 2 commits intoOpenHands:mainfrom
gpothier:feature/sandbox-kvm
Apr 6, 2026
Merged

Add KVM device passthrough support for hardware virtualization#13618
tofarr merged 2 commits intoOpenHands:mainfrom
gpothier:feature/sandbox-kvm

Conversation

@gpothier
Copy link
Copy Markdown
Contributor

Summary of PR

This PR adds support for passing through /dev/kvm to sandbox containers, enabling KVM-accelerated virtual machines inside sandboxes instead of slower emulation.

Add SANDBOX_KVM_ENABLED environment variable to enable passing /dev/kvm to sandbox containers. When enabled, sandboxes can run KVM-accelerated virtual machines instead of using slower emulation.

This is useful for workloads that need to spin up VMs inside the sandbox, such as testing operating systems or running nested virtualization.

Further work

If there is interest from the community, I could polish the feature. One things that comes to mind is to only enable it for specific sandboxes, by having a checkbox somewhere when launching one.

Demo Screenshots/Videos

Not really a screenshot, but still prooves it works. This was executed inside a sandbox:

openhands@721d061d484b:/workspace/project$ ls -la /dev/kvm
crw-rw-rw- 1 nobody nogroup 10, 232 Mar 25 22:30 /dev/kvm
openhands@721d061d484b:/workspace/project$ qemu-system-x86_64 -accel kvm -m 512 -nographic -no-reboot &
[1] 2274
openhands@721d061d484b:/workspace/project$ sleep 2

[1]+ Stopped qemu-system-x86_64 -accel kvm -m 512 -nographic -no-reboot
openhands@721d061d484b:/workspace/project$ pkill qemu

Without this feature, /dev/kvm is not there. Also, the qemu command gives an error.

Change Type

  • Bug fix
  • New feature
  • Breaking change
  • Refactor
  • Other (dependency update, docs, typo fixes, etc.)

Checklist

  • I have read and reviewed the code and I understand what the code is doing.
  • I have tested the code to the best of my ability and ensured it works as expected.

The changes are relatively straightforward and well written.

Release Notes

  • Include this change in the Release Notes.

Add SANDBOX_KVM_ENABLED environment variable to enable passing /dev/kvm to sandbox containers. When enabled, sandboxes can run KVM-accelerated virtual machines instead of using slower emulation.

@gpothier gpothier marked this pull request as ready for review March 27, 2026 04:30
@cbagwell
Copy link
Copy Markdown
Contributor

I have the same need for KVM passthrough and created a PR as well but mine was based on a more generic docker option passthrough that V0 conversations supported: #13350

…lization

Add SANDBOX_KVM_ENABLED environment variable to enable passing /dev/kvm
to sandbox containers. When enabled, sandboxes can run KVM-accelerated
virtual machines instead of using slower emulation.

This is useful for workloads that need to spin up VMs inside the sandbox,
such as testing operating systems or running nested virtualization.

Co-authored-by: openhands <openhands@all-hands.dev>
@gpothier gpothier force-pushed the feature/sandbox-kvm branch from 127e4ab to 3971771 Compare March 31, 2026 19:11
Copy link
Copy Markdown
Collaborator

@tofarr tofarr left a comment

Choose a reason for hiding this comment

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

🍰 - Nice!

@tofarr tofarr enabled auto-merge (squash) April 6, 2026 14:53
@tofarr tofarr merged commit 0c5e30a into OpenHands:main Apr 6, 2026
17 checks passed
@gpothier gpothier deleted the feature/sandbox-kvm branch April 6, 2026 18:46
@mamoodi mamoodi added the release:cloud-1.22.0 Cloud release 1.22.0 label Apr 13, 2026 — with OpenHands AI
aivong-openhands pushed a commit to aivong-openhands/OpenHands that referenced this pull request Apr 15, 2026
…ands#13618)

Co-authored-by: openhands <openhands@all-hands.dev>
Co-authored-by: Tim O'Farrell <tofarr@gmail.com>
devin-ai-integration Bot pushed a commit to OrpingtonClose/OpenHands that referenced this pull request Apr 26, 2026
…ands#13618)

Co-authored-by: openhands <openhands@all-hands.dev>
Co-authored-by: Tim O'Farrell <tofarr@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release:cloud-1.22.0 Cloud release 1.22.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants