File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -405,6 +405,28 @@ pub trait GuestMemory {
405
405
/// Note: the underline guest memory is not protected from memory aliasing, which breaks the
406
406
/// rust memory safety model. It's the caller's responsibility to ensure that there's no
407
407
/// concurrent accesses to the underline guest memory.
408
+ ///
409
+ /// # Arguments
410
+ /// * `guest_addr` - Guest address to convert.
411
+ ///
412
+ /// # Examples
413
+ ///
414
+ /// ```
415
+ /// # #[cfg(feature = "backend-mmap")]
416
+ /// # use vm_memory::{GuestAddress, GuestMemory, GuestMemoryMmap};
417
+ ///
418
+ /// # #[cfg(feature = "backend-mmap")]
419
+ /// # fn test_get_host_address() -> Result<(), ()> {
420
+ /// let start_addr = GuestAddress(0x1000);
421
+ /// let mut gm = GuestMemoryMmap::new(&vec![(start_addr, 0x500)]).map_err(|_| ())?;
422
+ /// let addr = gm.get_host_address(GuestAddress(0x1200)).unwrap();
423
+ /// println!("Host address is {:p}", addr);
424
+ /// Ok(())
425
+ /// # }
426
+ ///
427
+ /// # #[cfg(feature = "backend-mmap")]
428
+ /// test_get_host_address();
429
+ /// ```
408
430
fn get_host_address ( & self , addr : GuestAddress ) -> Result < * mut u8 > {
409
431
self . to_region_addr ( addr)
410
432
. ok_or_else ( || Error :: InvalidGuestAddress ( addr) )
You can’t perform that action at this time.
0 commit comments