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 copy of the value. Read more
1.0.0 · source§

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 Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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 Twhere T: Clone,

§

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 Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.