pub struct MmapRegion<B = ()> { /* private fields */ }
Expand description

Helper structure for working with mmaped memory regions in Unix.

The structure is used for accessing the guest’s physical memory by mmapping it into the current process.

Limitations

When running a 64-bit virtual machine on a 32-bit hypervisor, only part of the guest’s physical memory may be mapped into the current process due to the limited virtual address space size of the process.

Implementations

Creates a shared anonymous mapping of size bytes.

Arguments
  • size - The size of the memory region in bytes.

Creates a shared file mapping of size bytes.

Arguments
  • file_offset - The mapping will be created at offset file_offset.start in the file referred to by file_offset.file.
  • size - The size of the memory region in bytes.

Creates a mapping based on the provided arguments.

Arguments
  • file_offset - if provided, the method will create a file mapping at offset file_offset.start in the file referred to by file_offset.file.
  • size - The size of the memory region in bytes.
  • prot - The desired memory protection of the mapping.
  • flags - This argument determines whether updates to the mapping are visible to other processes mapping the same region, and whether updates are carried through to the underlying file.

Creates a MmapRegion instance for an externally managed mapping.

This method is intended to be used exclusively in situations in which the mapping backing the region is provided by an entity outside the control of the caller (e.g. the dynamic linker).

Arguments
  • addr - Pointer to the start of the mapping. Must be page-aligned.
  • size - The size of the memory region in bytes.
  • prot - Must correspond to the memory protection attributes of the existing mapping.
  • flags - Must correspond to the flags that were passed to mmap for the creation of the existing mapping.
Safety

To use this safely, the caller must guarantee that addr and size define a region within a valid mapping that is already present in the process.

Returns a pointer to the beginning of the memory region. Mutable accesses performed using the resulting pointer are not automatically accounted for by the dirty bitmap tracking functionality.

Should only be used for passing this region to ioctls for setting guest memory.

Returns the size of this region.

Returns information regarding the offset into the file backing this region (if any).

Returns the value of the prot parameter passed to mmap when mapping this region.

Returns the value of the flags parameter passed to mmap when mapping this region.

Returns true if the mapping is owned by this MmapRegion instance.

Checks whether this region and other are backed by overlapping FileOffset objects.

This is mostly a sanity check available for convenience, as different file descriptors can alias the same file.

Set the hugetlbfs of the region

Returns true if the region is hugetlbfs

Returns a reference to the inner bitmap object.

Trait Implementations

Formats the value using the given formatter. Read more

Executes the destructor for this type. Read more

Type used for dirty memory tracking.

Gets the size of this slice.

Returns a VolatileSlice of count bytes starting at offset. Read more

Check whether the region is empty.

Gets a slice of memory for the entire region that supports volatile access.

Gets a VolatileRef at offset.

Returns a VolatileArrayRef of n elements starting at offset. Read more

Returns a reference to an instance of T at offset. Read more

Returns a mutable reference to an instance of T at offset. Mutable accesses performed using the resulting reference are not automatically accounted for by the dirty bitmap tracking functionality. Read more

Returns a reference to an instance of T at offset. Mutable accesses performed using the resulting reference are not automatically accounted for by the dirty bitmap tracking functionality. Read more

Returns the sum of base and offset if the resulting address is valid.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.