pub struct PagePool { /* private fields */ }
Expand description
A page allocator for memory.
This memory may be private memory, or shared visibility memory on isolated VMs. depending on the memory range passed into the corresponding new methods.
Pages are allocated via PagePoolAllocator
from Self::allocator
or
PagePoolAllocatorSpawner::allocator
.
This struct is considered the “owner” of the pool allowing for save/restore.
Implementations§
Source§impl PagePool
impl PagePool
Sourcepub fn new<T: PoolSource + 'static>(
ranges: &[MemoryRange],
source: T,
) -> Result<Self>
pub fn new<T: PoolSource + 'static>( ranges: &[MemoryRange], source: T, ) -> Result<Self>
Returns a new page pool managing the address ranges in ranges
,
using source
to access the memory.
Sourcepub fn allocator(&self, device_name: String) -> Result<PagePoolAllocator>
pub fn allocator(&self, device_name: String) -> Result<PagePoolAllocator>
Create an allocator instance that can be used to allocate pages. The
specified device_name
must be unique.
Users should create a new allocator for each device, as the device name is used to track allocations in the pool.
Sourcepub fn allocator_spawner(&self) -> PagePoolAllocatorSpawner
pub fn allocator_spawner(&self) -> PagePoolAllocatorSpawner
Create a spawner that allows creating multiple allocators.
Sourcepub fn validate_restore(
&self,
leak_unrestored: bool,
) -> Result<(), UnrestoredAllocations>
pub fn validate_restore( &self, leak_unrestored: bool, ) -> Result<(), UnrestoredAllocations>
Validate that all allocations have been restored. This should be called after all devices have been restored.
leak_unrestored
controls what to do if a matching allocation was not
restored. If true, the allocation is marked as leaked and the function
returns Ok. If false, the function returns an error if any are
unmatched.
Unmatched allocations are always logged via a tracing::warn!
log.