pub struct BootParams {
    pub header: Vec<u8>,
    pub header_start: GuestAddress,
    pub sections: Option<Vec<u8>>,
    pub sections_start: Option<GuestAddress>,
    pub modules: Option<Vec<u8>>,
    pub modules_start: Option<GuestAddress>,
}
Expand description

Boot parameters to be written in guest memory.

Fields

header: Vec<u8>

“Header section”, always written in guest memory irrespective of boot protocol.

header_start: GuestAddress

Header section address.

sections: Option<Vec<u8>>

Optional sections containing boot configurations (e.g. E820 map).

sections_start: Option<GuestAddress>

Sections starting address.

modules: Option<Vec<u8>>

Optional modules specified at boot configuration time.

modules_start: Option<GuestAddress>

Modules starting address.

Implementations

Creates a new BootParams struct with the specified header.

Arguments
  • header - ByteValued representation of mandatory boot parameters.
  • header_addr - address in guest memory where header will be written.
Examples
let boot_params = BootParams::new(&Header::default(), GuestAddress(0x1000));

Sets or overwrites the boot sections and associated memory address.

Unused on aarch64 and for the Linux boot protocol. For the PVH boot protocol, the sections specify the memory map table in hvm_memmap_table_entry structs.

Arguments
  • sections - vector of ByteValued boot configurations.
  • sections_addr - address where the sections will be written in guest memory.
Examples
let mut boot_params = BootParams::new(&Header::default(), GuestAddress(0x1000));
let mut sections: Vec<Section> = vec![Section::default()];
boot_params.set_sections(sections.as_slice(), GuestAddress(0x2000));
// Another call overwrites the sections.
sections.clear();
boot_params.set_sections(sections.as_slice(), GuestAddress(0x3000));
assert_eq!(boot_params.sections.unwrap().len(), 0);
assert_eq!(boot_params.sections_start.unwrap(), GuestAddress(0x3000));

Adds a boot section at the specified address (if specified and valid), or appends it.

It’s up to the caller to ensure that the section will not overlap with existing content or leave a gap past the current sections in the list.

Arguments
  • section - ByteValued boot section element.
  • section_addr - optional address for the section in guest memory.
Returns

Starting address of the section in guest memory, or an error.

Examples
let mut boot_params = BootParams::new(&Header::default(), GuestAddress(0x1000));
let section = Section::default();
// Sections start address needs to be configured first.
assert!(boot_params.add_section::<Section>(&section, None).is_err());
let sections_start = GuestAddress(0x2000);
assert!(boot_params
    .add_section::<Section>(&section, Some(sections_start))
    .is_ok());
// It can be overwritten...
assert_eq!(
    boot_params
        .add_section::<Section>(&section, Some(sections_start))
        .unwrap(),
    sections_start
);
// But only if the address is valid.
assert!(boot_params
    .add_section::<Section>(&section, Some(sections_start.unchecked_sub(0x100)))
    .is_err());
// Or appended...
assert_eq!(
    boot_params.add_section::<Section>(&section, None).unwrap(),
    sections_start.unchecked_add(size_of::<Section>() as u64)
);

Sets or overwrites the boot modules and associated memory address.

Unused on aarch64 and for the Linux boot protocol. For the PVH boot protocol, the modules are specified in hvm_modlist_entry structs.

Arguments
  • modules - vector of ByteValued boot configurations.
  • modules_addr - address where the modules will be written in guest memory.
Examples
let mut boot_params = BootParams::new(&Header::default(), GuestAddress(0x1000));
let mut modules: Vec<Module> = vec![Module::default()];
boot_params.set_modules(modules.as_slice(), GuestAddress(0x2000));
// Another call overwrites the sections.
modules.clear();
boot_params.set_modules(modules.as_slice(), GuestAddress(0x3000));
assert_eq!(boot_params.modules.unwrap().len(), 0);
assert_eq!(boot_params.modules_start.unwrap(), GuestAddress(0x3000));

Adds a boot module at the specified address (if specified and valid), or appends it.

It’s up to the caller to ensure that the module will not overlap with existing content or leave a gap past the current modules in the list.

Arguments
  • module - ByteValued boot module element.
  • module_addr - optional address for the module in guest memory.
Returns

Starting address of the module in guest memory, or an error.

Examples
let mut boot_params = BootParams::new(&Header::default(), GuestAddress(0x1000));
let module = Module::default();
// Modules start address needs to be configured first.
assert!(boot_params.add_module::<Module>(&module, None).is_err());
let modules_start = GuestAddress(0x2000);
assert!(boot_params
    .add_module::<Module>(&module, Some(modules_start))
    .is_ok());
// It can be overwritten...
assert_eq!(
    boot_params
        .add_module::<Module>(&module, Some(modules_start))
        .unwrap(),
    modules_start
);
// But only if the address is valid.
assert!(boot_params
    .add_module::<Module>(&module, Some(modules_start.unchecked_sub(0x100)))
    .is_err());
// Or appended...
assert_eq!(
    boot_params.add_module::<Module>(&module, None).unwrap(),
    modules_start.unchecked_add(size_of::<Module>() as u64)
);

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.