Struct AddressSpaceRegion

Source
pub struct AddressSpaceRegion {
    pub ty: AddressSpaceRegionType,
    pub base: GuestAddress,
    pub size: GuestUsize,
    pub host_numa_node_id: Option<u32>,
    /* private fields */
}
Expand description

Struct to maintain configuration information about a guest address region.

Fields§

§ty: AddressSpaceRegionType

Type of address space regions.

§base: GuestAddress

Base address of the region in virtual machine’s physical address space.

§size: GuestUsize

Size of the address space region.

§host_numa_node_id: Option<u32>

Host NUMA node ids assigned to this region.

Implementations§

Source§

impl AddressSpaceRegion

Source

pub fn new( ty: AddressSpaceRegionType, base: GuestAddress, size: GuestUsize, ) -> Self

Create an address space region with default configuration.

Source

pub fn build( ty: AddressSpaceRegionType, base: GuestAddress, size: GuestUsize, host_numa_node_id: Option<u32>, file_offset: Option<FileOffset>, perm_flags: i32, prot_flags: i32, is_hotplug: bool, ) -> Self

Create an address space region with all configurable information.

§Arguments
  • ty - Type of the address region
  • base - Base address in VM to map content
  • size - Length of content to map
  • numa_node_id - Optional NUMA node id to allocate memory from
  • file_offset - Optional file descriptor and offset to map content from
  • perm_flags - mmap permission flags
  • prot_flags - mmap protection flags
  • is_hotplug - Whether it’s a region for hotplug.
Source

pub fn create_default_memory_region( base: GuestAddress, size: GuestUsize, numa_node_id: Option<u32>, mem_type: &str, mem_file_path: &str, mem_prealloc: bool, is_hotplug: bool, ) -> Result<AddressSpaceRegion, AddressSpaceError>

Create an address space region to map memory into the virtual machine.

§Arguments
  • base - Base address in VM to map content
  • size - Length of content to map
  • numa_node_id - Optional NUMA node id to allocate memory from
  • mem_type - Memory mapping from, ‘shmem’ or ‘hugetlbfs’
  • mem_file_path - Memory file path
  • mem_prealloc - Whether to enable pre-allocation of guest memory
  • is_hotplug - Whether it’s a region for hotplug.
Source

pub fn create_memory_region( base: GuestAddress, size: GuestUsize, numa_node_id: Option<u32>, mem_type: &str, mem_file_path: &str, mem_prealloc: bool, prot_flags: i32, is_hotplug: bool, ) -> Result<AddressSpaceRegion, AddressSpaceError>

Create an address space region to map memory from memfd/hugetlbfs into the virtual machine.

§Arguments
  • base - Base address in VM to map content
  • size - Length of content to map
  • numa_node_id - Optional NUMA node id to allocate memory from
  • mem_type - Memory mapping from, ‘shmem’ or ‘hugetlbfs’
  • mem_file_path - Memory file path
  • mem_prealloc - Whether to enable pre-allocation of guest memory
  • is_hotplug - Whether it’s a region for hotplug.
  • prot_flags - mmap protection flags
Source

pub fn create_device_region( base: GuestAddress, size: GuestUsize, ) -> Result<AddressSpaceRegion, AddressSpaceError>

Create an address region for device MMIO.

§Arguments
  • base - Base address in VM to map content
  • size - Length of content to map
Source

pub fn region_type(&self) -> AddressSpaceRegionType

Get type of the address space region.

Source

pub fn len(&self) -> GuestUsize

Get size of region.

Source

pub fn start_addr(&self) -> GuestAddress

Get the inclusive start physical address of the region.

Source

pub fn last_addr(&self) -> GuestAddress

Get the inclusive end physical address of the region.

Source

pub fn perm_flags(&self) -> i32

Get mmap permission flags of the address space region.

Source

pub fn set_perm_flags(&mut self, perm_flags: i32)

Set mmap permission flags for the address space region.

Source

pub fn prot_flags(&self) -> i32

Get mmap protection flags of the address space region.

Source

pub fn set_prot_flags(&mut self, prot_flags: i32)

Set mmap protection flags for the address space region.

Source

pub fn host_numa_node_id(&self) -> Option<u32>

Get host_numa_node_id flags

Source

pub fn set_host_numa_node_id(&mut self, host_numa_node_id: Option<u32>)

Set associated NUMA node ID to allocate memory from for this region.

Source

pub fn has_file(&self) -> bool

Check whether the address space region is backed by a memory file.

Source

pub fn file_offset(&self) -> Option<&FileOffset>

Get optional file associated with the region.

Source

pub fn set_file_offset(&mut self, file_offset: Option<FileOffset>)

Set associated file/offset pair for the region.

Source

pub fn set_hotplug(&mut self)

Set the hotplug hint.

Source

pub fn is_hotplug(&self) -> bool

Get the hotplug hint.

Source

pub fn set_hugepage(&mut self)

Set hugepage hint for madvise(), only takes effect when the memory type is shmem.

Source

pub fn is_hugepage(&self) -> bool

Get the hugepage hint.

Source

pub fn set_anonpage(&mut self)

Set the anonymous memory hint.

Source

pub fn is_anonpage(&self) -> bool

Get the anonymous memory hint.

Source

pub fn is_valid(&self) -> bool

Check whether the address space region is valid.

Source

pub fn intersect_with(&self, other: &AddressSpaceRegion) -> bool

Check whether the address space region intersects with another one.

Trait Implementations§

Source§

impl Clone for AddressSpaceRegion

Source§

fn clone(&self) -> AddressSpaceRegion

Returns a duplicate of the value. Read more
1.0.0 · Source§

const fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for AddressSpaceRegion

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.