pub struct MemoryRegion {
    mapping: MemoryMapping,
    guest_base: GuestAddress,
    shared_obj: BackingObject,
    obj_offset: u64,
    options: MemoryRegionOptions,
}
Expand description

A regions of memory mapped memory. Holds the memory mapping with its offset in guest memory. Also holds the backing object for the mapping and the offset in that object of the mapping.

Fields§

§mapping: MemoryMapping§guest_base: GuestAddress§shared_obj: BackingObject§obj_offset: u64§options: MemoryRegionOptions

Implementations§

source§

impl MemoryRegion

source

pub(crate) fn find_data_ranges(&self) -> Result<Vec<Range<usize>>>

Finds ranges of memory that might have non-zero data (i.e. not unallocated memory). The ranges are offsets into the region’s mmap, not offsets into the backing file.

For example, if there were three bytes and the second byte was a hole, the return would be [1..2] (in practice these are probably always at least page sized).

source

pub(crate) fn zero_range(&self, offset: usize, size: usize) -> Result<()>

source§

impl MemoryRegion

source

pub fn new_from_shm( size: u64, guest_base: GuestAddress, offset: u64, shm: Arc<SharedMemory> ) -> Result<Self>

Creates a new MemoryRegion using the given SharedMemory object to later be attached to a VM at guest_base address in the guest.

source

pub fn new_from_file( size: u64, guest_base: GuestAddress, offset: u64, file: Arc<File> ) -> Result<Self>

Creates a new MemoryRegion using the given file to get available later at guest_base address in the guest.

source

fn start(&self) -> GuestAddress

source

fn end(&self) -> GuestAddress

source

fn contains(&self, addr: GuestAddress) -> bool

Trait Implementations§

source§

impl Debug for MemoryRegion

source§

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

Formats the value using the given formatter. Read more

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.

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

§

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

§

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.