[−][src]Struct vm_memory::guest_memory::GuestAddress
Represents a guest physical address (GPA).
Notes:
On ARM64, a 32-bit hypervisor may be used to support a 64-bit guest. For simplicity,
u64
is used to store the the raw value no matter if the guest a 32-bit or 64-bit virtual
machine.
Trait Implementations
impl Address for GuestAddress
[src]
fn new(value: u64) -> GuestAddress
[src]
fn raw_value(&self) -> u64
[src]
fn checked_offset_from(&self, base: GuestAddress) -> Option<u64>
[src]
fn checked_add(&self, other: u64) -> Option<GuestAddress>
[src]
fn overflowing_add(&self, other: u64) -> (GuestAddress, bool)
[src]
fn unchecked_add(&self, offset: u64) -> GuestAddress
[src]
fn checked_sub(&self, other: u64) -> Option<GuestAddress>
[src]
fn overflowing_sub(&self, other: u64) -> (GuestAddress, bool)
[src]
fn unchecked_sub(&self, other: u64) -> GuestAddress
[src]
fn mask(&self, mask: Self::V) -> Self::V
[src]
fn unchecked_offset_from(&self, base: Self) -> Self::V
[src]
fn checked_align_up(&self, power_of_two: Self::V) -> Option<Self>
[src]
fn unchecked_align_up(&self, power_of_two: Self::V) -> Self
[src]
impl AddressValue for GuestAddress
[src]
impl BitAnd<u64> for GuestAddress
[src]
type Output = GuestAddress
The resulting type after applying the &
operator.
fn bitand(self, other: u64) -> GuestAddress
[src]
impl BitOr<u64> for GuestAddress
[src]
type Output = GuestAddress
The resulting type after applying the |
operator.
fn bitor(self, other: u64) -> GuestAddress
[src]
impl<T: GuestMemory> Bytes<GuestAddress> for T
[src]
type E = Error
Associated error codes
fn write(&self, buf: &[u8], addr: GuestAddress) -> Result<usize>
[src]
fn read(&self, buf: &mut [u8], addr: GuestAddress) -> Result<usize>
[src]
fn write_slice(&self, buf: &[u8], addr: GuestAddress) -> Result<()>
[src]
Examples
- Write a slice at guestaddress 0x200.
let start_addr = GuestAddress(0x1000); let mut gm = GuestMemoryMmap::from_ranges(&vec![(start_addr, 0x400)]) .expect("Could not create guest memory"); let res = gm.write_slice(&[1, 2, 3, 4, 5], start_addr); assert!(res.is_ok());
fn read_slice(&self, buf: &mut [u8], addr: GuestAddress) -> Result<()>
[src]
Examples
- Read a slice of length 16 at guestaddress 0x200.
let start_addr = GuestAddress(0x1000); let mut gm = GuestMemoryMmap::from_ranges(&vec![(start_addr, 0x400)]) .expect("Could not create guest memory"); let buf = &mut [0u8; 16]; let res = gm.read_slice(buf, start_addr); assert!(res.is_ok());
fn read_from<F>(
&self,
addr: GuestAddress,
src: &mut F,
count: usize
) -> Result<usize> where
F: Read,
[src]
&self,
addr: GuestAddress,
src: &mut F,
count: usize
) -> Result<usize> where
F: Read,
Examples
- Read bytes from /dev/urandom
let start_addr = GuestAddress(0x1000); let gm = GuestMemoryMmap::from_ranges(&vec![(start_addr, 0x400)]) .expect("Could not create guest memory"); let mut file = File::open(Path::new("/dev/urandom")) .expect("could not open /dev/urandom"); let addr = GuestAddress(0x1010); gm.read_from(addr, &mut file, 128) .expect("Could not read from /dev/urandom into guest memory"); let read_addr = addr.checked_add(8).expect("Could not compute read address"); let rand_val: u32 = gm .read_obj(read_addr) .expect("Could not read u32 val from /dev/urandom");
fn read_exact_from<F>(
&self,
addr: GuestAddress,
src: &mut F,
count: usize
) -> Result<()> where
F: Read,
[src]
&self,
addr: GuestAddress,
src: &mut F,
count: usize
) -> Result<()> where
F: Read,
fn write_to<F>(
&self,
addr: GuestAddress,
dst: &mut F,
count: usize
) -> Result<usize> where
F: Write,
[src]
&self,
addr: GuestAddress,
dst: &mut F,
count: usize
) -> Result<usize> where
F: Write,
Examples
- Write 128 bytes to /dev/null
let start_addr = GuestAddress(0x1000); let gm = GuestMemoryMmap::from_ranges(&vec![(start_addr, 1024)]) .expect("Could not create guest memory"); let mut file = OpenOptions::new() .write(true) .open("/dev/null") .expect("Could not open /dev/null"); gm.write_to(start_addr, &mut file, 128) .expect("Could not write 128 bytes to the provided address");
fn write_all_to<F>(
&self,
addr: GuestAddress,
dst: &mut F,
count: usize
) -> Result<()> where
F: Write,
[src]
&self,
addr: GuestAddress,
dst: &mut F,
count: usize
) -> Result<()> where
F: Write,
fn write_obj<T: ByteValued>(&self, val: T, addr: A) -> Result<(), Self::E>
[src]
fn read_obj<T: ByteValued>(&self, addr: A) -> Result<T, Self::E>
[src]
impl Clone for GuestAddress
[src]
fn clone(&self) -> GuestAddress
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Copy for GuestAddress
[src]
impl Debug for GuestAddress
[src]
impl Default for GuestAddress
[src]
fn default() -> GuestAddress
[src]
impl Eq for GuestAddress
[src]
impl Ord for GuestAddress
[src]
fn cmp(&self, other: &GuestAddress) -> Ordering
[src]
#[must_use]fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn clamp(self, min: Self, max: Self) -> Self
[src]
impl PartialEq<GuestAddress> for GuestAddress
[src]
fn eq(&self, other: &GuestAddress) -> bool
[src]
fn ne(&self, other: &GuestAddress) -> bool
[src]
impl PartialOrd<GuestAddress> for GuestAddress
[src]
fn partial_cmp(&self, other: &GuestAddress) -> Option<Ordering>
[src]
fn lt(&self, other: &GuestAddress) -> bool
[src]
fn le(&self, other: &GuestAddress) -> bool
[src]
fn gt(&self, other: &GuestAddress) -> bool
[src]
fn ge(&self, other: &GuestAddress) -> bool
[src]
impl StructuralEq for GuestAddress
[src]
impl StructuralPartialEq for GuestAddress
[src]
Auto Trait Implementations
impl RefUnwindSafe for GuestAddress
impl Send for GuestAddress
impl Sync for GuestAddress
impl Unpin for GuestAddress
impl UnwindSafe for GuestAddress
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,