page_pool_alloc

Struct PagePool

Source
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

Source

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.

Source

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.

Source

pub fn allocator_spawner(&self) -> PagePoolAllocatorSpawner

Create a spawner that allows creating multiple allocators.

Source

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.

Trait Implementations§

Source§

impl Inspect for PagePool

Source§

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

Inspects the object.
Source§

impl SaveRestore for PagePool

Source§

type SavedState = PagePoolState

The concrete saved state type.
Source§

fn save(&mut self) -> Result<Self::SavedState, SaveError>

Saves the object’s state.
Source§

fn restore(&mut self, state: Self::SavedState) -> Result<(), RestoreError>

Restores the object’s state.

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

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

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

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.

§

impl<T> ProtobufSaveRestore for T
where T: SaveRestore, <T as SaveRestore>::SavedState: 'static + Send + SavedStateRoot,

§

fn save(&mut self) -> Result<SavedStateBlob, SaveError>

Save the object.
§

fn restore(&mut self, state: SavedStateBlob) -> Result<(), RestoreError>

Restore the object.
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.
§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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