pub struct MemoryLayout { /* private fields */ }Expand description
Describes the memory layout of a guest.
Implementations§
Source§impl MemoryLayout
impl MemoryLayout
Sourcepub fn new(
ram_size: u64,
mmio_gaps: &[MemoryRange],
pci_ecam_gaps: &[MemoryRange],
pci_mmio_gaps: &[MemoryRange],
vtl2_range: Option<MemoryRange>,
) -> Result<Self, Error>
pub fn new( ram_size: u64, mmio_gaps: &[MemoryRange], pci_ecam_gaps: &[MemoryRange], pci_mmio_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 mmio and device
reserved 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.
Sourcepub fn new_with_numa(
numa_mem_sizes: &[u64],
mmio_gaps: &[MemoryRange],
pci_ecam_gaps: &[MemoryRange],
pci_mmio_gaps: &[MemoryRange],
vtl2_range: Option<MemoryRange>,
) -> Result<Self, Error>
pub fn new_with_numa( numa_mem_sizes: &[u64], mmio_gaps: &[MemoryRange], pci_ecam_gaps: &[MemoryRange], pci_mmio_gaps: &[MemoryRange], vtl2_range: Option<MemoryRange>, ) -> Result<Self, Error>
Like Self::new(), but distributes RAM across NUMA nodes according
to the per-node sizes in numa_mem_sizes.
numa_mem_sizes[i] is the number of RAM bytes for vnode i.
Each size must be page-aligned and non-zero. The sum of all sizes
is the total guest RAM.
RAM is placed sequentially around MMIO gaps, filling each node’s budget in order. When a node’s budget is exhausted mid-chunk, the chunk is split and the next node continues from that address.
Sourcepub fn new_from_ranges(
memory: &[MemoryRangeWithNode],
gaps: &[MemoryRange],
) -> Result<Self, Error>
pub fn new_from_ranges( 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.
Sourcepub fn new_from_resolved_ranges(
ram: Vec<MemoryRangeWithNode>,
mmio_gaps: Vec<MemoryRange>,
pci_ecam_gaps: Vec<MemoryRange>,
pci_mmio_gaps: Vec<MemoryRange>,
vtl2_range: Option<MemoryRange>,
) -> Result<Self, Error>
pub fn new_from_resolved_ranges( ram: Vec<MemoryRangeWithNode>, mmio_gaps: Vec<MemoryRange>, pci_ecam_gaps: Vec<MemoryRange>, pci_mmio_gaps: Vec<MemoryRange>, vtl2_range: Option<MemoryRange>, ) -> Result<Self, Error>
Makes a new memory layout from already-resolved RAM and fixed ranges.
Each individual range must be non-empty, but the lists themselves may
be empty (e.g. no PCIe root complexes means empty PCI ECAM/MMIO
vectors). Ranges within each list must be sorted and non-overlapping.
MMIO gaps may contain empty placeholder ranges to preserve positional
indexing (e.g. mmio()[0] = low, mmio()[1] = high); empty entries
are ignored during validation. The combined layout is also validated
for overlaps, including the optional VTL2 range.
Sourcepub fn ram(&self) -> &[MemoryRangeWithNode]
pub fn ram(&self) -> &[MemoryRangeWithNode]
The populated RAM ranges. This does not include the vtl2_range.
Sourcepub fn vtl2_range(&self) -> Option<MemoryRange>
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.
Sourcepub fn end_of_ram(&self) -> u64
pub fn end_of_ram(&self) -> u64
One past the last byte of RAM.
Sourcepub fn ram_below_4gb(&self) -> u64
pub fn ram_below_4gb(&self) -> u64
The bytes of RAM below 4GB.
Sourcepub fn ram_above_4gb(&self) -> u64
pub fn ram_above_4gb(&self) -> u64
The bytes of RAM at or above 4GB.
Sourcepub fn ram_above_high_mmio(&self) -> Option<u64>
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.
Sourcepub fn max_ram_below_4gb(&self) -> Option<u64>
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.
Sourcepub fn end_of_layout(&self) -> u64
pub fn end_of_layout(&self) -> u64
One past the last byte of RAM, MMIO, PCI ECAM, or PCI MMIO.
Sourcepub fn probe_address(&self, address: u64) -> Option<AddressType>
pub fn probe_address(&self, address: u64) -> Option<AddressType>
Probe a given address to see if it is in the memory layout described by
self. Returns the AddressType of the address if it is in the
layout.
This does not check the vtl2_range.
Trait Implementations§
Source§impl Clone for MemoryLayout
impl Clone for MemoryLayout
Source§fn clone(&self) -> MemoryLayout
fn clone(&self) -> MemoryLayout
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more