vmm: memory_manager: Replace 'ext_region' by 'saved_region'

Any occurrence of of a variable containing `ext_region` is replaced with
the less confusing name `saved_region`. The point is to clearly identify
the memory regions that might have been saved during a snapshot, while
the `ext` standing for `external` was pretty unclear.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
Sebastien Boeuf 2020-10-23 14:07:06 +02:00
parent c0e8e5b53f
commit 7e127df415

View File

@ -346,7 +346,7 @@ impl MemoryManager {
ram_regions: &[(GuestAddress, usize)], ram_regions: &[(GuestAddress, usize)],
zones: &[MemoryZoneConfig], zones: &[MemoryZoneConfig],
prefault: bool, prefault: bool,
ext_regions: Option<Vec<MemoryRegion>>, saved_regions: Option<Vec<MemoryRegion>>,
) -> Result<(Vec<Arc<GuestRegionMmap>>, MemoryZones), Error> { ) -> Result<(Vec<Arc<GuestRegionMmap>>, MemoryZones), Error> {
let mut zones = zones.to_owned(); let mut zones = zones.to_owned();
let mut mem_regions = Vec::new(); let mut mem_regions = Vec::new();
@ -398,7 +398,7 @@ impl MemoryManager {
zone.shared, zone.shared,
zone.hugepages, zone.hugepages,
zone.host_numa_node, zone.host_numa_node,
&ext_regions, &saved_regions,
)?; )?;
// Add region to the list of regions associated with the // Add region to the list of regions associated with the
@ -448,7 +448,7 @@ impl MemoryManager {
pub fn new( pub fn new(
vm: Arc<dyn hypervisor::Vm>, vm: Arc<dyn hypervisor::Vm>,
config: &MemoryConfig, config: &MemoryConfig,
ext_regions: Option<Vec<MemoryRegion>>, saved_regions: Option<Vec<MemoryRegion>>,
prefault: bool, prefault: bool,
phys_bits: u8, phys_bits: u8,
) -> Result<Arc<Mutex<MemoryManager>>, Error> { ) -> Result<Arc<Mutex<MemoryManager>>, Error> {
@ -581,7 +581,7 @@ impl MemoryManager {
.collect(); .collect();
let (mem_regions, mut memory_zones) = let (mem_regions, mut memory_zones) =
Self::create_memory_regions_from_zones(&ram_regions, &zones, prefault, ext_regions)?; Self::create_memory_regions_from_zones(&ram_regions, &zones, prefault, saved_regions)?;
let guest_memory = let guest_memory =
GuestMemoryMmap::from_arc_regions(mem_regions).map_err(Error::GuestMemory)?; GuestMemoryMmap::from_arc_regions(mem_regions).map_err(Error::GuestMemory)?;
@ -772,8 +772,8 @@ impl MemoryManager {
// no need for saving into a dedicated external file. For these // no need for saving into a dedicated external file. For these
// files, the VmConfig already contains the information on where to // files, the VmConfig already contains the information on where to
// find them. // find them.
let mut ext_regions = mem_snapshot.memory_regions; let mut saved_regions = mem_snapshot.memory_regions;
for region in ext_regions.iter_mut() { for region in saved_regions.iter_mut() {
if let Some(content) = &mut region.content { if let Some(content) = &mut region.content {
let mut memory_region_path = vm_snapshot_path.clone(); let mut memory_region_path = vm_snapshot_path.clone();
memory_region_path.push(content.clone()); memory_region_path.push(content.clone());
@ -781,7 +781,7 @@ impl MemoryManager {
} }
} }
MemoryManager::new(vm, config, Some(ext_regions), prefault, phys_bits) MemoryManager::new(vm, config, Some(saved_regions), prefault, phys_bits)
} else { } else {
Err(Error::Restore(MigratableError::Restore(anyhow!( Err(Error::Restore(MigratableError::Restore(anyhow!(
"Could not find {}-section from snapshot", "Could not find {}-section from snapshot",
@ -837,17 +837,17 @@ impl MemoryManager {
shared: bool, shared: bool,
hugepages: bool, hugepages: bool,
host_numa_node: Option<u32>, host_numa_node: Option<u32>,
ext_regions: &Option<Vec<MemoryRegion>>, saved_regions: &Option<Vec<MemoryRegion>>,
) -> Result<Arc<GuestRegionMmap>, Error> { ) -> Result<Arc<GuestRegionMmap>, Error> {
let mut copy_ext_region_content: Option<PathBuf> = None; let mut saved_region_content: Option<PathBuf> = None;
if let Some(ext_regions) = ext_regions { if let Some(saved_regions) = saved_regions {
for ext_region in ext_regions.iter() { for saved_region in saved_regions.iter() {
if ext_region.start_addr == start_addr && ext_region.size as usize == size { if saved_region.start_addr == start_addr && saved_region.size as usize == size {
copy_ext_region_content = ext_region.content.clone(); saved_region_content = saved_region.content.clone();
// No need to iterate further as we found the external // No need to iterate further as we found the saved region
// region matching the current region. // matching the current region.
break; break;
} }
} }
@ -922,11 +922,11 @@ impl MemoryManager {
.map_err(Error::GuestMemory)?; .map_err(Error::GuestMemory)?;
// Copy data to the region if needed // Copy data to the region if needed
if let Some(ext_region_content) = &copy_ext_region_content { if let Some(content) = &saved_region_content {
// Open (read only) the snapshot file for the given region. // Open (read only) the snapshot file for the given region.
let mut memory_region_file = OpenOptions::new() let mut memory_region_file = OpenOptions::new()
.read(true) .read(true)
.open(ext_region_content) .open(content)
.map_err(Error::SnapshotOpen)?; .map_err(Error::SnapshotOpen)?;
// Fill the region with the file content. // Fill the region with the file content.