Skip to main content

RegionManager

Struct RegionManager 

Source
pub struct RegionManager<const MAX: usize> { /* private fields */ }
Expand description

Manages a fixed-capacity table of owned memory regions.

MAX is the compile-time upper bound on the number of regions.

Implementations§

Source§

impl<const MAX: usize> RegionManager<MAX>

Source

pub const fn new() -> Self

Create a new empty region manager.

Source

pub const fn count(&self) -> usize

Return the number of active regions.

Source

pub const fn capacity(&self) -> usize

Return the maximum capacity.

Source

pub fn create(&mut self, config: RegionConfig) -> RvmResult<OwnedRegionId>

Create a new memory region from the given configuration.

Validates alignment, non-zero page count, and overlap with existing regions in the same partition.

§Errors

Returns RvmError::AlignmentError if addresses are not page-aligned. Returns RvmError::ResourceLimitExceeded if page count is zero or the manager is at capacity. Returns RvmError::MemoryOverlap if the region overlaps an existing region in the same partition.

Source

pub fn create_auto_id( &mut self, owner: PartitionId, guest_base: GuestPhysAddr, host_base: PhysAddr, page_count: u32, tier: Tier, permissions: MemoryPermissions, ) -> RvmResult<OwnedRegionId>

Allocate a fresh OwnedRegionId and create the region.

§Errors

See RegionManager::create for error conditions.

Source

pub fn destroy(&mut self, region_id: OwnedRegionId) -> RvmResult<OwnedRegion>

Destroy a region, freeing its slot.

§Errors

Returns RvmError::PartitionNotFound if the region does not exist.

Source

pub fn transfer( &mut self, region_id: OwnedRegionId, new_owner: PartitionId, ) -> RvmResult<()>

Transfer ownership of a region to a new partition.

This conceptually moves the region: the old owner loses access and the new owner gains it. The guest-physical mapping remains the same (the new partition sees the region at the same guest address).

§Errors

Returns RvmError::PartitionNotFound if the region does not exist. Returns RvmError::MemoryOverlap if the new owner already has a region at the same guest address range.

Source

pub fn get(&self, region_id: OwnedRegionId) -> Option<&OwnedRegion>

Look up a region by its identifier.

Source

pub fn get_mut(&mut self, region_id: OwnedRegionId) -> Option<&mut OwnedRegion>

Look up a region by its identifier (mutable).

Source

pub fn translate( &self, owner: PartitionId, guest: GuestPhysAddr, ) -> Option<AddressMapping>

Translate a guest physical address to a host physical address within the given partition.

Source

pub fn count_for_partition(&self, owner: PartitionId) -> usize

Count how many regions are owned by a given partition.

Source

pub fn regions_for_partition( &self, owner: PartitionId, out: &mut [OwnedRegionId], ) -> usize

Iterate over the region IDs owned by a given partition. Writes matching IDs into out and returns the count written.

Trait Implementations§

Source§

impl<const MAX: usize> Default for RegionManager<MAX>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<const MAX: usize> Freeze for RegionManager<MAX>

§

impl<const MAX: usize> RefUnwindSafe for RegionManager<MAX>

§

impl<const MAX: usize> Send for RegionManager<MAX>
where [OwnedRegion; MAX]: Send,

§

impl<const MAX: usize> Sync for RegionManager<MAX>
where [OwnedRegion; MAX]: Sync,

§

impl<const MAX: usize> Unpin for RegionManager<MAX>
where [OwnedRegion; MAX]: Unpin,

§

impl<const MAX: usize> UnsafeUnpin for RegionManager<MAX>

§

impl<const MAX: usize> UnwindSafe for RegionManager<MAX>

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.

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, 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.