Struct vm_memory::guest_memory::MemoryRegion
source · 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
§obj_offset: u64
§options: MemoryRegionOptions
Implementations§
source§impl MemoryRegion
impl MemoryRegion
sourcepub(crate) fn find_data_ranges(&self) -> Result<Vec<Range<usize>>>
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).
pub(crate) fn zero_range(&self, offset: usize, size: usize) -> Result<()>
source§impl MemoryRegion
impl MemoryRegion
sourcepub fn new_from_shm(
size: u64,
guest_base: GuestAddress,
offset: u64,
shm: Arc<SharedMemory>
) -> Result<Self>
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.
sourcepub fn new_from_file(
size: u64,
guest_base: GuestAddress,
offset: u64,
file: Arc<File>
) -> Result<Self>
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.
fn start(&self) -> GuestAddress
fn end(&self) -> GuestAddress
fn contains(&self, addr: GuestAddress) -> bool
Trait Implementations§
Auto Trait Implementations§
impl RefUnwindSafe for MemoryRegion
impl Send for MemoryRegion
impl Sync for MemoryRegion
impl Unpin for MemoryRegion
impl UnwindSafe for MemoryRegion
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more