[−][src]Struct linux_loader::configurator::BootParams
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
impl BootParams
[src]
pub fn new<T: ByteValued>(header: &T, header_addr: GuestAddress) -> Self
[src]
Creates a new BootParams
struct with the specified header.
Arguments
header
-ByteValued
representation of mandatory boot parameters.header_addr
- address in guest memory whereheader
will be written.
Examples
let boot_params = BootParams::new(&Header::default(), GuestAddress(0x1000));
pub fn set_sections<T: ByteValued>(
&mut self,
sections: &[T],
sections_addr: GuestAddress
)
[src]
&mut self,
sections: &[T],
sections_addr: GuestAddress
)
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 ofByteValued
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));
pub fn add_section<T: ByteValued>(
&mut self,
section: &T,
section_addr: Option<GuestAddress>
) -> Result<GuestAddress>
[src]
&mut self,
section: &T,
section_addr: Option<GuestAddress>
) -> Result<GuestAddress>
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>(§ion, None).is_err()); let sections_start = GuestAddress(0x2000); assert!(boot_params.add_section::<Section>( §ion, Some(sections_start) ).is_ok()); // It can be overwritten... assert_eq!(boot_params.add_section::<Section>( §ion, Some(sections_start) ).unwrap(), sections_start); // But only if the address is valid. assert!(boot_params.add_section::<Section>( §ion, Some(sections_start.unchecked_sub(0x100)) ).is_err()); // Or appended... assert_eq!( boot_params.add_section::<Section>(§ion, None).unwrap(), sections_start.unchecked_add(size_of::<Section>() as u64) );
pub fn set_modules<T: ByteValued>(
&mut self,
modules: &[T],
modules_addr: GuestAddress
)
[src]
&mut self,
modules: &[T],
modules_addr: GuestAddress
)
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 ofByteValued
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));
pub fn add_module<T: ByteValued>(
&mut self,
module: &T,
module_addr: Option<GuestAddress>
) -> Result<GuestAddress>
[src]
&mut self,
module: &T,
module_addr: Option<GuestAddress>
) -> Result<GuestAddress>
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
impl Clone for BootParams
[src]
fn clone(&self) -> BootParams
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Auto Trait Implementations
impl RefUnwindSafe for BootParams
impl Send for BootParams
impl Sync for BootParams
impl Unpin for BootParams
impl UnwindSafe for BootParams
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,