pub struct DeviceTestMemory { /* private fields */ }
Expand description
A wrapper around the [TestMapper
] that generates both [GuestMemory
] and [PagePoolAllocator
] backed
by the same underlying memory. Meant to provide shared memory for testing devices.
Implementations§
Source§impl DeviceTestMemory
impl DeviceTestMemory
Sourcepub fn new(num_pages: u64, allow_dma: bool, pool_name: &str) -> Self
pub fn new(num_pages: u64, allow_dma: bool, pool_name: &str) -> Self
Creates test memory that leverages the [TestMapper
] as the backing. It creates 3 accessors for the underlying memory:
guest_memory [GuestMemory
] - Has access to the entire range.
payload_memory [GuestMemory
] - Has access to the second half of the range.
dma_client [PagePoolAllocator
] - Has access to the first half of the range.
If the allow_dma
switch is enabled, both guest_memory and payload_memory will report a base_iova of 0.
Sourcepub fn guest_memory(&self) -> GuestMemory
pub fn guest_memory(&self) -> GuestMemory
Returns [GuestMemory
] accessor to the underlying memory. Reports base_iova as 0 if allow_dma
switch is enabled.
Sourcepub fn payload_mem(&self) -> GuestMemory
pub fn payload_mem(&self) -> GuestMemory
Returns [GuestMemory
] accessor to the second half of underlying memory. Reports base_iova as 0 if allow_dma
switch is enabled.
Sourcepub fn dma_client(&self) -> Arc<PagePoolAllocator>
pub fn dma_client(&self) -> Arc<PagePoolAllocator>
Returns [PagePoolAllocator
] with access to the first half of the underlying memory.