Struct vm_topology::memory::MemoryLayout

source ·
pub struct MemoryLayout { /* private fields */ }
Expand description

Describes the memory layout of a guest.

Implementations§

source§

impl MemoryLayout

source

pub fn new( physical_address_size: u8, ram_size: u64, gaps: &[MemoryRange], vtl2_range: Option<MemoryRange>, ) -> Result<Self, Error>

Makes a new memory layout for a guest with ram_size bytes of memory and MMIO gaps at the locations specified by gaps.

ram_size must be a multiple of the page size. Each gap must be non-empty, and the gaps must be in order and non-overlapping.

vtl2_range describes a range of memory reserved for VTL2. It is not reported in ram.

All RAM is assigned to NUMA node 0.

source

pub fn new_from_ranges( physical_address_size: u8, memory: &[MemoryRangeWithNode], gaps: &[MemoryRange], ) -> Result<Self, Error>

Makes a new memory layout for a guest with the given mmio gaps and memory ranges.

memory and gaps ranges must be in sorted order and non-overlapping, and describe page aligned ranges.

source

pub fn mmio(&self) -> &[MemoryRange]

The MMIO gap ranges.

source

pub fn ram(&self) -> &[MemoryRangeWithNode]

The populated RAM ranges. This does not include the vtl2_range.

source

pub fn vtl2_range(&self) -> Option<MemoryRange>

A special memory range for VTL2, if any. This memory range is treated like RAM, but is only used to hold VTL2 and is located above ram and mmio.

source

pub fn physical_address_size(&self) -> u8

The bit width of a physical address for the VM.

source

pub fn ram_size(&self) -> u64

The total RAM size in bytes. This is not contiguous.

source

pub fn end_of_ram(&self) -> u64

One past the last byte of RAM.

source

pub fn ram_below_4gb(&self) -> u64

The bytes of RAM below 4GB.

source

pub fn ram_above_4gb(&self) -> u64

The bytes of RAM at or above 4GB.

source

pub fn ram_above_high_mmio(&self) -> Option<u64>

The bytes of RAM above the high MMIO gap.

Returns None if there aren’t exactly 2 MMIO gaps.

source

pub fn max_ram_below_4gb(&self) -> Option<u64>

The ending RAM address below 4GB.

Returns None if there is no RAM mapped below 4GB.

source

pub fn end_of_ram_or_mmio(&self) -> u64

One past the last byte of RAM, or the highest mmio range.

Trait Implementations§

source§

impl Clone for MemoryLayout

source§

fn clone(&self) -> MemoryLayout

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for MemoryLayout

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Inspect for MemoryLayout

source§

fn inspect(&self, req: Request<'_>)

Inspects the object.

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> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> ToOwned for T
where T: Clone,

source§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

impl<T, U> Upcast<U> for T
where U: Downcast<T>,