diff --git a/vmm/src/memory_manager.rs b/vmm/src/memory_manager.rs index 819c74c37..2041880b2 100644 --- a/vmm/src/memory_manager.rs +++ b/vmm/src/memory_manager.rs @@ -823,8 +823,8 @@ impl MemoryManager { #[allow(clippy::too_many_arguments)] fn create_ram_region( - file: &Option, - mut file_offset: u64, + backing_file: &Option, + file_offset: u64, start_addr: GuestAddress, size: usize, prefault: bool, @@ -833,27 +833,12 @@ impl MemoryManager { host_numa_node: Option, ext_regions: &Option>, ) -> Result, Error> { - let mut backing_file: Option = file.clone(); let mut copy_ext_region_content: Option = None; if let Some(ext_regions) = ext_regions { for ext_region in ext_regions.iter() { if ext_region.start_addr == start_addr && ext_region.size as usize == size { - if ext_region.backing_file.is_some() { - // If the region is memory mapped as "shared", then we - // don't replace the backing file, but expect to copy - // the content from the external backing file after the - // region has been created. - if shared { - copy_ext_region_content = ext_region.backing_file.clone(); - } else { - backing_file = ext_region.backing_file.clone(); - // We must override the file offset as in this case - // we're restoring an existing region, which means - // it will fit perfectly the calculated region. - file_offset = 0; - } - } + copy_ext_region_content = ext_region.backing_file.clone(); // No need to iterate further as we found the external // region matching the current region.