Skip to content

feat(machine): add Hyperlight platform support#2797

Open
danbugs wants to merge 5 commits intounikraft:stagingfrom
danbugs:hyperlight-platform
Open

feat(machine): add Hyperlight platform support#2797
danbugs wants to merge 5 commits intounikraft:stagingfrom
danbugs:hyperlight-platform

Conversation

@danbugs
Copy link
Copy Markdown

@danbugs danbugs commented Apr 20, 2026

Summary

Adds a new machine driver that runs Unikraft unikernels on Hyperlight micro-VMs. kraft run --plat hyperlight ... launches a unikernel in a KVM/MSHV-backed (Linux) or WHP-backed (Windows) Hyperlight micro-VM, tracked end-to-end by the same PID-lifecycle machinery the firecracker driver uses.

Fixes #2636.

What changed

  • machine/hyperlight/ — new package implementing the v1alpha1.MachineService interface: Create, Start, Stop, Delete, Get, List, Watch, Logs. Each machine corresponds to one detached hyperlight-unikraft child process whose stdout + stderr stream into <stateDir>/vmm.log.
  • machine/platform/register_linux.go + register_windows.go — wire the driver into the Linux (KVM/MSHV) and Windows (WHP) platform registries.
  • machine/platform/platform.go — add PlatformHyperlight and its hl alias.
  • unikraft/{app,lib}/* — small fix so libraries pulled into .unikraft/apps/<name> (app-elfloader style) resolve correctly when MakeArgs rebuilds. Needed because the canonical hyperlight workload depends on app-elfloader.

Addresses the pre-PR feedback raised in #2636.

Runtime dependency

The driver spawns a hyperlight-unikraft binary from danbugs/hyperlight-unikraft. One-line install:

cargo install --git https://github.com/danbugs/hyperlight-unikraft \
    --branch main hyperlight-unikraft-host --bin hyperlight-unikraft

The hyperlight-unikraft repo is currently under my personal alias (danbugs/). Once all required Hyperlight features land upstream, the plan is to move it under the hyperlight-dev org — this PR's install URL will be refreshed at that point.

Known limitations

  • kraft pause unsupported — Hyperlight has no pause semantic.
  • No networking — hyperlight-unikraft doesn't yet provide a paravirtualized NIC; follow-up work along the lines of Firecracker's PVH networking is tracked separately.
  • time.sleep and other interval-based timers don't block yet. The hyperlight-host hw-interrupts feature is enabled in hyperlight-unikraft (so vector 0x20 / IO port 107 plumbing is in place), but the Unikraft hyperlight-platform branch still needs the guest-side pvtimer bring-up (PIC remap + IDT vector + period configuration at the right point in boot) to complete the loop. Wall-clock reads (time.time(), datetime.now()) do work today — kraftkit injects a host-side timestamp via init-data at boot and the guest adds its own monotonic delta.

Tested

Ran the example workloads in danbugs/hyperlight-unikraft through this driver. kraft ps, kraft stop, kraft rm, kraft logs --follow all work across separate kraft invocations. Verified detached lifecycle — closing kraft leaves the VMM running until it exits on its own; kraft stop cleans it up afterwards.

Note for reviewers: this PR was assisted by an LLM, review w/ care.

danbugs added 5 commits April 20, 2026 19:30
Add a Hyperlight machine driver that runs Unikraft unikernels via
Hyperlight micro-VMs. Register 'hyperlight' and 'hl' as platform aliases
alongside firecracker/qemu/xen.

Each kraft machine corresponds to a hyperlight-unikraft child process:
Create prepares the config, Start spawns the process with stdout/stderr
redirected to vmm.log, and Stop/Delete terminate via SIGTERM using the
stored PID. This mirrors the firecracker driver's lifecycle so kraft ps,
logs, stop, and rm all work naturally across kraft invocations — the VM
handle doesn't need to survive in-process.

The driver is pure Go and has no cgo or compile-time link to
hyperlight-unikraft; it only requires the hyperlight-unikraft binary on
$PATH at runtime. Default memory is 16Mi (the median of the
hyperlight-unikraft example workloads); heavier guests override upward.

Signed-off-by: danbugs <danilochiarlone@gmail.com>
Some components are structurally libraries but hosted in 'app-*' repos
(notably app-elfloader). kraft pulls them to .unikraft/apps/<name>, yet
the library-path resolver expects them under .unikraft/libs/<name> and
fails with "cannot determine library path without component source".

Fall back to the apps/ location when the library's expected path is
missing and its name starts with 'app-'. Apply the same fallback during
schema transform so downstream callers see a valid path immediately, and
expose LibraryConfig.SetPath so MakeArgs can patch already-loaded
libraries before the final path check.

Signed-off-by: danbugs <danilochiarlone@gmail.com>
Previously the Hyperlight driver was only registered via register_linux.go;
on Windows hostSupportedStrategies() returned an empty map. Add the same
registration in register_windows.go so `kraft --plat hyperlight` works on
Windows hosts backed by Hyper-V / Windows Hypervisor Platform.

Also clarify DefaultMemory/DefaultStack comments and READMEs.

Signed-off-by: danbugs <danilochiarlone@gmail.com>
Switch Start from `os/exec` to `kraftkit.sh/exec` with
`WithDetach(true)`, matching the firecracker driver. The child
hyperlight-unikraft process is now placed in its own process group
on Linux (Setpgid) and survives the parent kraft exiting — so
`kraft run` backgrounded and then detached from the terminal
doesn't take the VM down with it.

Also call Process.Release right after Start so the go-runtime
doesn't need Wait() machinery against the child. Lifecycle is
PID-tracked in machine.Status, same as firecracker.

Addresses review feedback on unikraft#2636: 'the hyperlight
process isn't started in detached mode'.

Signed-off-by: danbugs <danilochiarlone@gmail.com>
- Point the hyperlight-unikraft install URL at the actual repo
  (danbugs/hyperlight-unikraft main) instead of the hypothetical
  hyperlight-dev/hyperlight-unikraft mirror.
- Replace the manual 'cargo build + cp to /usr/local/bin' recipe
  with `cargo install --git ... --bin hyperlight-unikraft` — one
  command, ends up on PATH automatically.
- Call out Windows support (the driver works on any host where
  hyperlight-unikraft can find a hypervisor: KVM on Linux, WHP on
  Windows).
- Mention that direct Rust FFI is a planned follow-up to the
  subprocess model.

Signed-off-by: danbugs <danilochiarlone@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 🧊 Icebox

Development

Successfully merging this pull request may close these issues.

Support Running on Hyperlight

1 participant