Skip to content

Take care of writing boot parameters into memory #15

Closed
@bonzini

Description

@bonzini

The linux-loader crate does not handle writing in memory the setup header that it prepares, and there could also be extra parameters (e.g. kernel command line or, for PVH, the e820 map) that need to be written into memory. I am therefore proposing to add a "configurator" object that encapsulates all the logic needed to boot a kernel (later on this could include the CPU registers too). The basic structure would be:

pub struct E820MapEntry { ... |}
pub struct BootParameters {
    e820: Vec<E820MapEntry>, ...
};
...
pub trait BootConfigurator<M: GuestMemory> {
    pub fn write_boot_parameters(&self, result: &KernelLoaderResult, params: &BootParameters, dest: T);
}
pub struct PVHConfigurator; // implements BootConfigurator<T>
pub struct LinuxElfConfigurator; // implements BootConfigurator<T>
pub struct BzImageConfigurator; // implements BootConfigurator<T>

and probably an associated type on KernelLoader like

pub trait KernelLoader<M: GuestMemory> {
    type Configurator: Box<dyn BootConfigurator<M>>;
}

pub struct KernelLoaderResult<M: GuestMemory> {
    ...
    configurator: Box<dyn BootConfigurator<M>>
}

that can be used like

    let result = KernelLoaderType.load(guest_mem, ...)?;
    result.configurator.write_boot_parameters(result, guest_mem);

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions