Struct dbs_address_space::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: AddressSpaceRegionTypeType of address space regions.
base: GuestAddressBase address of the region in virtual machine’s physical address space.
size: GuestUsizeSize of the address space region.
host_numa_node_id: Option<u32>Host NUMA node ids assigned to this region.
Implementations
sourceimpl AddressSpaceRegion
impl AddressSpaceRegion
sourcepub fn new(
ty: AddressSpaceRegionType,
base: GuestAddress,
size: GuestUsize
) -> Self
pub fn new(
ty: AddressSpaceRegionType,
base: GuestAddress,
size: GuestUsize
) -> Self
Create an address space region with default configuration.
sourcepub fn build(
ty: AddressSpaceRegionType,
base: GuestAddress,
size: GuestUsize,
host_numa_node_id: Option<u32>,
file_offset: Option<FileOffset>,
perm_flags: i32,
is_hotplug: bool
) -> Self
pub fn build(
ty: AddressSpaceRegionType,
base: GuestAddress,
size: GuestUsize,
host_numa_node_id: Option<u32>,
file_offset: Option<FileOffset>,
perm_flags: i32,
is_hotplug: bool
) -> Self
Create an address space region with all configurable information.
Arguments
ty- Type of the address regionbase- Base address in VM to map contentsize- Length of content to mapnuma_node_id- Optional NUMA node id to allocate memory fromfile_offset- Optional file descriptor and offset to map content fromperm_flags- mmap permission flagsis_hotplug- Whether it’s a region for hotplug.
sourcepub 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>
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 contentsize- Length of content to mapnuma_node_id- Optional NUMA node id to allocate memory frommem_type- Memory mapping from, ‘shmem’ or ‘hugetlbfs’mem_file_path- Memory file pathmem_prealloc- Whether to enable pre-allocation of guest memoryis_hotplug- Whether it’s a region for hotplug.
sourcepub fn create_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>
pub fn create_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 from memfd/hugetlbfs into the virtual machine.
Arguments
base- Base address in VM to map contentsize- Length of content to mapnuma_node_id- Optional NUMA node id to allocate memory frommem_type- Memory mapping from, ‘shmem’ or ‘hugetlbfs’mem_file_path- Memory file pathmem_prealloc- Whether to enable pre-allocation of guest memoryis_hotplug- Whether it’s a region for hotplug.
sourcepub fn create_device_region(
base: GuestAddress,
size: GuestUsize
) -> Result<AddressSpaceRegion, AddressSpaceError>
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 contentsize- Length of content to map
sourcepub fn region_type(&self) -> AddressSpaceRegionType
pub fn region_type(&self) -> AddressSpaceRegionType
Get type of the address space region.
sourcepub fn len(&self) -> GuestUsize
pub fn len(&self) -> GuestUsize
Get size of region.
sourcepub fn start_addr(&self) -> GuestAddress
pub fn start_addr(&self) -> GuestAddress
Get the inclusive start physical address of the region.
sourcepub fn last_addr(&self) -> GuestAddress
pub fn last_addr(&self) -> GuestAddress
Get the inclusive end physical address of the region.
sourcepub fn perm_flags(&self) -> i32
pub fn perm_flags(&self) -> i32
Get mmap permission flags of the address space region.
sourcepub fn set_perm_flags(&mut self, perm_flags: i32)
pub fn set_perm_flags(&mut self, perm_flags: i32)
Set mmap permission flags for the address space region.
sourcepub fn host_numa_node_id(&self) -> Option<u32>
pub fn host_numa_node_id(&self) -> Option<u32>
Get host_numa_node_id flags
sourcepub fn set_host_numa_node_id(&mut self, host_numa_node_id: Option<u32>)
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.
sourcepub fn has_file(&self) -> bool
pub fn has_file(&self) -> bool
Check whether the address space region is backed by a memory file.
sourcepub fn file_offset(&self) -> Option<&FileOffset>
pub fn file_offset(&self) -> Option<&FileOffset>
Get optional file associated with the region.
sourcepub fn set_file_offset(&mut self, file_offset: Option<FileOffset>)
pub fn set_file_offset(&mut self, file_offset: Option<FileOffset>)
Set associated file/offset pair for the region.
sourcepub fn set_hotplug(&mut self)
pub fn set_hotplug(&mut self)
Set the hotplug hint.
sourcepub fn is_hotplug(&self) -> bool
pub fn is_hotplug(&self) -> bool
Get the hotplug hint.
sourcepub fn set_hugepage(&mut self)
pub fn set_hugepage(&mut self)
Set hugepage hint for madvise(), only takes effect when the memory type is shmem.
sourcepub fn is_hugepage(&self) -> bool
pub fn is_hugepage(&self) -> bool
Get the hugepage hint.
sourcepub fn set_anonpage(&mut self)
pub fn set_anonpage(&mut self)
Set the anonymous memory hint.
sourcepub fn is_anonpage(&self) -> bool
pub fn is_anonpage(&self) -> bool
Get the anonymous memory hint.
sourcepub fn intersect_with(&self, other: &AddressSpaceRegion) -> bool
pub fn intersect_with(&self, other: &AddressSpaceRegion) -> bool
Check whether the address space region intersects with another one.
Trait Implementations
sourceimpl Clone for AddressSpaceRegion
impl Clone for AddressSpaceRegion
sourcefn clone(&self) -> AddressSpaceRegion
fn clone(&self) -> AddressSpaceRegion
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more