mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
virtio-devices: mem: Add constructor for BlocksState
Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
@@ -392,6 +392,12 @@ pub struct BlocksState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl BlocksState {
|
impl BlocksState {
|
||||||
|
fn new(region_size: u64) -> Self {
|
||||||
|
BlocksState {
|
||||||
|
bitmap: vec![false; (region_size / VIRTIO_MEM_DEFAULT_BLOCK_SIZE) as usize],
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn is_range_state(&self, first_block_index: usize, nb_blocks: u16, plug: bool) -> bool {
|
fn is_range_state(&self, first_block_index: usize, nb_blocks: u16, plug: bool) -> bool {
|
||||||
for state in self
|
for state in self
|
||||||
.bitmap
|
.bitmap
|
||||||
@@ -855,9 +861,7 @@ impl Mem {
|
|||||||
seccomp_action,
|
seccomp_action,
|
||||||
hugepages,
|
hugepages,
|
||||||
dma_mapping_handlers: Arc::new(Mutex::new(BTreeMap::new())),
|
dma_mapping_handlers: Arc::new(Mutex::new(BTreeMap::new())),
|
||||||
blocks_state: Arc::new(Mutex::new(BlocksState {
|
blocks_state: Arc::new(Mutex::new(BlocksState::new(config.region_size))),
|
||||||
bitmap: vec![false; (config.region_size / config.block_size) as usize],
|
|
||||||
})),
|
|
||||||
exit_evt,
|
exit_evt,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user