virtio-devices: mem: Add constructor for BlocksState

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
Sebastien Boeuf 2021-09-22 17:34:59 +02:00 committed by Bo Chen
parent d7115ec656
commit af3a59aa33

View File

@ -392,6 +392,12 @@ pub struct 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 {
for state in self
.bitmap
@ -855,9 +861,7 @@ impl Mem {
seccomp_action,
hugepages,
dma_mapping_handlers: Arc::new(Mutex::new(BTreeMap::new())),
blocks_state: Arc::new(Mutex::new(BlocksState {
bitmap: vec![false; (config.region_size / config.block_size) as usize],
})),
blocks_state: Arc::new(Mutex::new(BlocksState::new(config.region_size))),
exit_evt,
})
}