This document explains how to build a binary to be used as a Hyperlight guest.
When building a guest, one needs to follow some rules so that the resulting binary can be used with Hyperlight:
- the binary must not use the standard library
- the expected entrypoint function signature is
void hyperlight_main(void)orpub fn hyperlight_main() - Hyperlight expects
hl_Vec* c_guest_dispatch_function(const hl_FunctionCall *functioncall)orpub fn guest_dispatch_function(function_call: FunctionCall) -> Result<Vec<u8>>to be defined in the binary so that in case the host calls a function that is not registered by the guest, this function is called instead. - to be callable by the host, a function needs to be registered by the guest in
the
hyperlight_mainfunction.
In the case of a binary that is written in Rust, one needs to make use of the
Hyperlight crate, hyperlight_guest and hyperlight_guest_bin that contains the types and APIs that enable
the guest to:
- register functions that can be called by the host application
- call host functions that have been registered by the host.
guest_time(enabled by default): Provides time-related functionality via a paravirtualized clock. This includesSystemTime,Instant, andUNIX_EPOCHinhyperlight_guest_bin::timethat mirror thestd::timeAPI. See Guest Time API for details.
For the binary written in C, the generated C bindings can be downloaded from the
latest release page that contain: the hyperlight_guest.h header and the
C API library.
The hyperlight_guest.h header contains the corresponding APIs to register
guest functions and call host functions from within the guest.
When built with the guest_time feature (enabled by default), the C API provides
POSIX-compatible time functions: gettimeofday(), clock_gettime(), and time().
See Guest Time API for details.