pub struct GuestRegionMmapExt {
pub inner: GuestRegionMmap,
pub region_type: GuestRegionType,
pub slot_from: u32,
pub slot_size: usize,
pub plugged: Mutex<BitVec>,
}Expand description
An extension to GuestMemoryRegion that can be split into multiple KVM slots of the same slot_size, and stores the type of region, and the starting KVM slot number.
Fields§
§inner: GuestRegionMmapthe wrapped GuestRegionMmap
region_type: GuestRegionTypethe type of region
slot_from: u32the starting KVM slot number assigned to this region
slot_size: usizethe size of the slots of this region
plugged: Mutex<BitVec>a bitvec indicating whether slot i is plugged into KVM (1) or not (0)
Implementations§
Source§impl GuestRegionMmapExt
impl GuestRegionMmapExt
Sourcepub fn slot_range(&self) -> Range<u32>
pub fn slot_range(&self) -> Range<u32>
Returns the slot range covered by this region.
Sourcepub fn slot_base(&self, slot: u32) -> Option<GuestAddress>
pub fn slot_base(&self, slot: u32) -> Option<GuestAddress>
Returns the base guest address for a specific slot, if it belongs to this region.
Methods from Deref<Target = MmapRegion<Option<AtomicBitmap>>>§
pub fn as_ptr(&self) -> *mut u8
pub fn as_ptr(&self) -> *mut u8
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.
pub fn file_offset(&self) -> Option<&FileOffset>
pub fn file_offset(&self) -> Option<&FileOffset>
Returns information regarding the offset into the file backing this region (if any).
pub fn prot(&self) -> i32
pub fn prot(&self) -> i32
Returns the value of the prot parameter passed to mmap when mapping this region.
pub fn flags(&self) -> i32
pub fn flags(&self) -> i32
Returns the value of the flags parameter passed to mmap when mapping this region.
pub fn fds_overlap<T>(&self, other: &MmapRegion<T>) -> boolwhere
T: Bitmap,
pub fn fds_overlap<T>(&self, other: &MmapRegion<T>) -> boolwhere
T: Bitmap,
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.
pub fn is_hugetlbfs(&self) -> Option<bool>
pub fn is_hugetlbfs(&self) -> Option<bool>
Returns true if the region is hugetlbfs
Trait Implementations§
Source§impl Debug for GuestRegionMmapExt
impl Debug for GuestRegionMmapExt
Source§impl Deref for GuestRegionMmapExt
impl Deref for GuestRegionMmapExt
Source§type Target = MmapRegion<Option<AtomicBitmap>>
type Target = MmapRegion<Option<AtomicBitmap>>
Source§fn deref(&self) -> &MmapRegion<Option<AtomicBitmap>>
fn deref(&self) -> &MmapRegion<Option<AtomicBitmap>>
Source§impl GuestMemoryRegion for GuestRegionMmapExt
impl GuestMemoryRegion for GuestRegionMmapExt
Source§type B = Option<AtomicBitmap>
type B = Option<AtomicBitmap>
Source§fn len(&self) -> GuestUsize
fn len(&self) -> GuestUsize
Source§fn start_addr(&self) -> GuestAddress
fn start_addr(&self) -> GuestAddress
Source§fn get_host_address(&self, addr: MemoryRegionAddress) -> Result<*mut u8>
fn get_host_address(&self, addr: MemoryRegionAddress) -> Result<*mut u8>
Source§fn file_offset(&self) -> Option<&FileOffset>
fn file_offset(&self) -> Option<&FileOffset>
Source§fn get_slice(
&self,
offset: MemoryRegionAddress,
count: usize,
) -> Result<VolatileSlice<'_, BS<'_, Self::B>>>
fn get_slice( &self, offset: MemoryRegionAddress, count: usize, ) -> Result<VolatileSlice<'_, BS<'_, Self::B>>>
§fn last_addr(&self) -> GuestAddress
fn last_addr(&self) -> GuestAddress
§fn check_address(
&self,
addr: MemoryRegionAddress,
) -> Option<MemoryRegionAddress>
fn check_address( &self, addr: MemoryRegionAddress, ) -> Option<MemoryRegionAddress>
§fn address_in_range(&self, addr: MemoryRegionAddress) -> bool
fn address_in_range(&self, addr: MemoryRegionAddress) -> bool
true if the given address is within this region.§fn checked_offset(
&self,
base: MemoryRegionAddress,
offset: usize,
) -> Option<MemoryRegionAddress>
fn checked_offset( &self, base: MemoryRegionAddress, offset: usize, ) -> Option<MemoryRegionAddress>
§fn to_region_addr(&self, addr: GuestAddress) -> Option<MemoryRegionAddress>
fn to_region_addr(&self, addr: GuestAddress) -> Option<MemoryRegionAddress>
§fn as_volatile_slice(
&self,
) -> Result<VolatileSlice<'_, <Self::B as WithBitmapSlice<'_>>::S>, Error>
fn as_volatile_slice( &self, ) -> Result<VolatileSlice<'_, <Self::B as WithBitmapSlice<'_>>::S>, Error>
§fn is_hugetlbfs(&self) -> Option<bool>
fn is_hugetlbfs(&self) -> Option<bool>
HugeTLBFS.
Returns Some(true) if the region is backed by hugetlbfs.
None represents that no information is available. Read moreimpl GuestMemoryRegionBytes for GuestRegionMmapExt
Auto Trait Implementations§
impl !Freeze for GuestRegionMmapExt
impl RefUnwindSafe for GuestRegionMmapExt
impl Send for GuestRegionMmapExt
impl Sync for GuestRegionMmapExt
impl Unpin for GuestRegionMmapExt
impl UnwindSafe for GuestRegionMmapExt
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
§impl<R> Bytes<MemoryRegionAddress> for Rwhere
R: GuestMemoryRegionBytes,
impl<R> Bytes<MemoryRegionAddress> for Rwhere
R: GuestMemoryRegionBytes,
§fn write(&self, buf: &[u8], addr: MemoryRegionAddress) -> Result<usize, Error>
fn write(&self, buf: &[u8], addr: MemoryRegionAddress) -> Result<usize, Error>
§Examples
- Write a slice at guest address 0x1200.
let res = gm
.write(&[1, 2, 3, 4, 5], GuestAddress(0x1200))
.expect("Could not write to guest memory");
assert_eq!(5, res);§fn read(
&self,
buf: &mut [u8],
addr: MemoryRegionAddress,
) -> Result<usize, Error>
fn read( &self, buf: &mut [u8], addr: MemoryRegionAddress, ) -> Result<usize, Error>
§Examples
- Read a slice of length 16 at guestaddress 0x1200.
let buf = &mut [0u8; 16];
let res = gm
.read(buf, GuestAddress(0x1200))
.expect("Could not read from guest memory");
assert_eq!(16, res);§fn write_slice(
&self,
buf: &[u8],
addr: MemoryRegionAddress,
) -> Result<(), Error>
fn write_slice( &self, buf: &[u8], addr: MemoryRegionAddress, ) -> Result<(), Error>
addr. Read more§fn read_slice(
&self,
buf: &mut [u8],
addr: MemoryRegionAddress,
) -> Result<(), Error>
fn read_slice( &self, buf: &mut [u8], addr: MemoryRegionAddress, ) -> Result<(), Error>
addr to fill an entire slice. Read more§fn read_volatile_from<F>(
&self,
addr: MemoryRegionAddress,
src: &mut F,
count: usize,
) -> Result<usize, Error>where
F: ReadVolatile,
fn read_volatile_from<F>(
&self,
addr: MemoryRegionAddress,
src: &mut F,
count: usize,
) -> Result<usize, Error>where
F: ReadVolatile,
count bytes from src and writes them into the container at addr.
Unlike VolatileRead::read_volatile, this function retries on EINTR being returned from
the underlying I/O read operation. Read more§fn read_exact_volatile_from<F>(
&self,
addr: MemoryRegionAddress,
src: &mut F,
count: usize,
) -> Result<(), Error>where
F: ReadVolatile,
fn read_exact_volatile_from<F>(
&self,
addr: MemoryRegionAddress,
src: &mut F,
count: usize,
) -> Result<(), Error>where
F: ReadVolatile,
§fn write_volatile_to<F>(
&self,
addr: MemoryRegionAddress,
dst: &mut F,
count: usize,
) -> Result<usize, Error>where
F: WriteVolatile,
fn write_volatile_to<F>(
&self,
addr: MemoryRegionAddress,
dst: &mut F,
count: usize,
) -> Result<usize, Error>where
F: WriteVolatile,
count bytes from the container at addr and writes them into dst.
Unlike VolatileWrite::write_volatile, this function retries on EINTR being returned by
the underlying I/O write operation. Read more§fn write_all_volatile_to<F>(
&self,
addr: MemoryRegionAddress,
dst: &mut F,
count: usize,
) -> Result<(), Error>where
F: WriteVolatile,
fn write_all_volatile_to<F>(
&self,
addr: MemoryRegionAddress,
dst: &mut F,
count: usize,
) -> Result<(), Error>where
F: WriteVolatile,
§fn store<T>(
&self,
val: T,
addr: MemoryRegionAddress,
order: Ordering,
) -> Result<(), Error>where
T: AtomicAccess,
fn store<T>(
&self,
val: T,
addr: MemoryRegionAddress,
order: Ordering,
) -> Result<(), Error>where
T: AtomicAccess,
§fn load<T>(
&self,
addr: MemoryRegionAddress,
order: Ordering,
) -> Result<T, Error>where
T: AtomicAccess,
fn load<T>(
&self,
addr: MemoryRegionAddress,
order: Ordering,
) -> Result<T, Error>where
T: AtomicAccess,
§impl<T> Conv for T
impl<T> Conv for T
§impl<T> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.