pub struct KernelBuilder { /* private fields */ }Expand description
Builder for creating kernel images to embed in RVF files.
Implementations§
Source§impl KernelBuilder
impl KernelBuilder
Sourcepub fn new(arch: KernelArch) -> Self
pub fn new(arch: KernelArch) -> Self
Create a new KernelBuilder targeting the given architecture.
Sourcepub fn kernel_type(self, kt: KernelType) -> Self
pub fn kernel_type(self, kt: KernelType) -> Self
Set the kernel type.
Sourcepub fn with_initramfs(self, services: &[&str]) -> Self
pub fn with_initramfs(self, services: &[&str]) -> Self
Enable initramfs with the given services.
Sourcepub fn kernel_version(self, version: &str) -> Self
pub fn kernel_version(self, version: &str) -> Self
Set the kernel version (for Docker builds).
Sourcepub fn from_prebuilt(path: &Path) -> Result<BuiltKernel, KernelError>
pub fn from_prebuilt(path: &Path) -> Result<BuiltKernel, KernelError>
Build a kernel from a prebuilt image file on disk.
Supports:
- Linux bzImage (starts with boot sector magic or bzImage signature)
- ELF executables (starts with \x7FELF)
- Raw binary images
The file must be at least 512 bytes (minimum boot sector size).
Sourcepub fn build_docker(
&self,
context_dir: &Path,
) -> Result<BuiltKernel, KernelError>
pub fn build_docker( &self, context_dir: &Path, ) -> Result<BuiltKernel, KernelError>
Build a kernel using Docker (requires Docker installed).
This downloads the Linux kernel source, applies the RVF microVM config, and builds a bzImage inside a Docker container. The result is a real, bootable kernel image.
Set docker_context to a directory where the Dockerfile and config
will be written. If None, a temporary directory is used.
Sourcepub fn build_initramfs(
&self,
services: &[&str],
extra_binaries: &[(&str, &[u8])],
) -> Result<Vec<u8>, KernelError>
pub fn build_initramfs( &self, services: &[&str], extra_binaries: &[(&str, &[u8])], ) -> Result<Vec<u8>, KernelError>
Build an initramfs (gzipped cpio archive) with the configured services.
The initramfs contains:
- Standard directory structure (/bin, /sbin, /etc, /dev, /proc, /sys, …)
- Device nodes (console, ttyS0, null, zero, urandom)
- /init script that mounts filesystems and starts services
- Any extra binaries passed in
extra_binaries
Sourcepub fn kernel_flags(&self) -> u32
pub fn kernel_flags(&self) -> u32
Get the kernel flags based on the current configuration.
Sourcepub fn kernel_type_byte(&self) -> u8
pub fn kernel_type_byte(&self) -> u8
Get the kernel type as a u8 for the KernelHeader.