Skip to main content

KernelBuilder

Struct KernelBuilder 

Source
pub struct KernelBuilder { /* private fields */ }
Expand description

Builder for creating kernel images to embed in RVF files.

Implementations§

Source§

impl KernelBuilder

Source

pub fn new(arch: KernelArch) -> Self

Create a new KernelBuilder targeting the given architecture.

Source

pub fn kernel_type(self, kt: KernelType) -> Self

Set the kernel type.

Source

pub fn cmdline(self, cmdline: &str) -> Self

Set the kernel command line.

Source

pub fn with_initramfs(self, services: &[&str]) -> Self

Enable initramfs with the given services.

Source

pub fn kernel_version(self, version: &str) -> Self

Set the kernel version (for Docker builds).

Source

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).

Source

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.

Source

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
Source

pub fn kernel_flags(&self) -> u32

Get the kernel flags based on the current configuration.

Source

pub fn arch_byte(&self) -> u8

Get the architecture as a u8 for the KernelHeader.

Source

pub fn kernel_type_byte(&self) -> u8

Get the kernel type as a u8 for the KernelHeader.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.