hyperlight-dev/hyperlight

Hyperlight is a lightweight Virtual Machine Manager (VMM) designed to be embedded within applications. It enables safe execution of untrusted code within micro virtual machines with very low latency and minimal overhead.

Rust

4,742

1,502 commits

updated Oct 19, 2026

See the code

README

Hyperlight

hyperlight logo

A lightweight VMM for running untrusted code in micro VMs with minimal overhead.
A Cloud Native Computing Foundation sandbox project.

Status: Hyperlight is pre-1.0. The API may change between releases, and upgrading will sometimes require code changes.

Hyperlight lets you safely run untrusted code inside hypervisor-isolated micro VMs that spin up in milliseconds, with guest function calls completing in microseconds. You embed it as a library in your Rust application, hand it a guest binary, and call functions across the VM boundary as naturally as calling a local function. To minimize startup time and memory footprint, there's no guest kernel or OS. Guests are purpose-built using the Hyperlight guest library.

  • Supports KVM, MSHV, and Windows Hypervisor Platform
  • No kernel or OS in the VM. Guests are regular ELF binaries written in no_std Rust or C
  • Host and guest communicate through typed function calls
  • Guests are sandboxed by default with no access to the host filesystem, network, etc.

Example

Host - create a sandbox, register a host function, and call into the guest:

// Build a sandbox from a guest binary, registering a host function the guest
// can call. In a real app that function might query a database, read a config,
// or call an external API. By default, guests can only print to the host.
let mut sandbox = SandboxBuilder::from_file(guest_path)
    .host_function("GetWeekday", || Ok("Monday".to_string()))
    .build()?;

// Call a function inside the VM
let greeting: String = sandbox.call("SayHello", "World".to_string())?;
println!("{greeting}"); // "Hello, World! Today is Monday."

Guest state persists across calls. Use snapshot() and restore() to save and reset VM memory. This avoids recreating the VM while ensuring each call starts from a clean state.

Guest (Rust) - declare host functions and expose guest functions with simple macros. Guests can also be written in C.

#[host_function("GetWeekday")]
fn get_weekday() -> Result<String>;

#[guest_function("SayHello")]
fn say_hello(name: String) -> Result<String> {
    let weekday = get_weekday()?;
    Ok(format!("Hello, {name}! Today is {weekday}."))
}

To get started, see the Getting Started guide. For more details on writing guests, see How to build a Hyperlight guest binary.

When to use Hyperlight

Hyperlight is a good fit when you need to:

  • Run untrusted or third-party code with hypervisor-level isolation
  • Create and tear down sandboxes in milliseconds
  • Make guest function calls in microseconds
  • Embed sandboxed execution directly in your application
  • Build functions-as-a-service with hypervisor-level isolation
  • Reuse sandboxes efficiently with snapshot and restore

Hyperlight is not designed for:

  • General-purpose virtualization (use a full VMM instead)
  • Running full-blown Linux guest workloads that need syscalls, networking, or filesystem access

Getting started

See docs/getting-started.md for detailed prerequisites and platform-specific setup for:

  • Running Hyperlight
  • Building guests

Or skip setup entirely with a codespace:

Open in GitHub Codespaces

Repository Structure

DirectoryDescription
src/hyperlight_hostHost library - creates and manages micro VMs
src/hyperlight_guestGuest platform primitives for paging, physical allocation, and host communication
src/hyperlight_guest_binDefault guest runtime with entry point, panic handler, heap, logging, and exceptions
src/hyperlight_guest_capiC API wrapper around hyperlight_guest_bin for use via FFI
src/hyperlight_libcC standard library for guests, built from picolibc
src/hyperlight_guest_macroMacros for registering guest and host functions
src/hyperlight_guest_tracingTracing support for guests
src/hyperlight_commonShared code used by both host and guest
src/hyperlight_component_macroProc macros for WIT-based host/guest bindings
src/hyperlight_component_utilShared implementation for WIT binding generation
src/hyperlight_testingShared test utilities
src/schemaFlatBuffer schema definitions
src/trace_dumpTool for dumping and visualizing trace data
src/testsTest guest programs (Rust and C)
  • cargo-hyperlight - Cargo subcommand for building and scaffolding Hyperlight guests
  • hyperlight-wasm - Run WebAssembly modules inside Hyperlight micro VMs
  • hyperlight-js - Run JavaScript inside Hyperlight micro VMs
  • hyperlight-sandbox - Multi-backend sandboxing framework for running untrusted code with controlled host capabilities, with Python, .NET, and Rust SDKs
  • hyperlight-unikraft - Run Linux applications (Python, Node.js, Go, Rust, C/C++) on Hyperlight micro VMs using Unikraft as the guest kernel

Contributing

See CONTRIBUTING.md.

Community


FOSSA Status

hyper-v
hypervisor
kvm
mshv
rust
vmm

hyperlight-dev/hyperlight

Hyperlight is a lightweight Virtual Machine Manager (VMM) designed to be embedded within applications. It enables safe execution of untrusted code within micro virtual machines with very low latency and minimal overhead.

Rust

4,742

1,502 commits

updated Oct 19, 2026

See the code

README

Hyperlight

hyperlight logo

A lightweight VMM for running untrusted code in micro VMs with minimal overhead.
A Cloud Native Computing Foundation sandbox project.

Status: Hyperlight is pre-1.0. The API may change between releases, and upgrading will sometimes require code changes.

Hyperlight lets you safely run untrusted code inside hypervisor-isolated micro VMs that spin up in milliseconds, with guest function calls completing in microseconds. You embed it as a library in your Rust application, hand it a guest binary, and call functions across the VM boundary as naturally as calling a local function. To minimize startup time and memory footprint, there's no guest kernel or OS. Guests are purpose-built using the Hyperlight guest library.

  • Supports KVM, MSHV, and Windows Hypervisor Platform
  • No kernel or OS in the VM. Guests are regular ELF binaries written in no_std Rust or C
  • Host and guest communicate through typed function calls
  • Guests are sandboxed by default with no access to the host filesystem, network, etc.

Example

Host - create a sandbox, register a host function, and call into the guest:

// Build a sandbox from a guest binary, registering a host function the guest
// can call. In a real app that function might query a database, read a config,
// or call an external API. By default, guests can only print to the host.
let mut sandbox = SandboxBuilder::from_file(guest_path)
    .host_function("GetWeekday", || Ok("Monday".to_string()))
    .build()?;

// Call a function inside the VM
let greeting: String = sandbox.call("SayHello", "World".to_string())?;
println!("{greeting}"); // "Hello, World! Today is Monday."

Guest state persists across calls. Use snapshot() and restore() to save and reset VM memory. This avoids recreating the VM while ensuring each call starts from a clean state.

Guest (Rust) - declare host functions and expose guest functions with simple macros. Guests can also be written in C.

#[host_function("GetWeekday")]
fn get_weekday() -> Result<String>;

#[guest_function("SayHello")]
fn say_hello(name: String) -> Result<String> {
    let weekday = get_weekday()?;
    Ok(format!("Hello, {name}! Today is {weekday}."))
}

To get started, see the Getting Started guide. For more details on writing guests, see How to build a Hyperlight guest binary.

When to use Hyperlight

Hyperlight is a good fit when you need to:

  • Run untrusted or third-party code with hypervisor-level isolation
  • Create and tear down sandboxes in milliseconds
  • Make guest function calls in microseconds
  • Embed sandboxed execution directly in your application
  • Build functions-as-a-service with hypervisor-level isolation
  • Reuse sandboxes efficiently with snapshot and restore

Hyperlight is not designed for:

  • General-purpose virtualization (use a full VMM instead)
  • Running full-blown Linux guest workloads that need syscalls, networking, or filesystem access

Getting started

See docs/getting-started.md for detailed prerequisites and platform-specific setup for:

  • Running Hyperlight
  • Building guests

Or skip setup entirely with a codespace:

Open in GitHub Codespaces

Repository Structure

DirectoryDescription
src/hyperlight_hostHost library - creates and manages micro VMs
src/hyperlight_guestGuest platform primitives for paging, physical allocation, and host communication
src/hyperlight_guest_binDefault guest runtime with entry point, panic handler, heap, logging, and exceptions
src/hyperlight_guest_capiC API wrapper around hyperlight_guest_bin for use via FFI
src/hyperlight_libcC standard library for guests, built from picolibc
src/hyperlight_guest_macroMacros for registering guest and host functions
src/hyperlight_guest_tracingTracing support for guests
src/hyperlight_commonShared code used by both host and guest
src/hyperlight_component_macroProc macros for WIT-based host/guest bindings
src/hyperlight_component_utilShared implementation for WIT binding generation
src/hyperlight_testingShared test utilities
src/schemaFlatBuffer schema definitions
src/trace_dumpTool for dumping and visualizing trace data
src/testsTest guest programs (Rust and C)
  • cargo-hyperlight - Cargo subcommand for building and scaffolding Hyperlight guests
  • hyperlight-wasm - Run WebAssembly modules inside Hyperlight micro VMs
  • hyperlight-js - Run JavaScript inside Hyperlight micro VMs
  • hyperlight-sandbox - Multi-backend sandboxing framework for running untrusted code with controlled host capabilities, with Python, .NET, and Rust SDKs
  • hyperlight-unikraft - Run Linux applications (Python, Node.js, Go, Rust, C/C++) on Hyperlight micro VMs using Unikraft as the guest kernel

Contributing

See CONTRIBUTING.md.

Community


FOSSA Status

hyper-v
hypervisor
kvm
mshv
rust
vmm

Project health

crates.io

Latest release

0.0.0 · Oct 8, 2024

Releases this year

0

Significant stargazers

(top 24 of 229)

Josh Soref

809 followers · starred Sep 2026

Matteo Collina

11,406 followers · starred Nov 2024

Luke Edwards

5,090 followers · starred Jun 2025

messense

2,198 followers · starred Nov 2024