virtio-devices, vmm: Deprecate "GuestMemory::with_regions(_mut)"

Function "GuestMemory::with_regions(_mut)" were mainly temporary methods
to access the regions in `GuestMemory` as the lack of iterator-based
access, and hence they are deprecated in the upstream vm-memory crate [1].

[1] https://github.com/rust-vmm/vm-memory/issues/133

Signed-off-by: Bo Chen <chen.bo@intel.com>
This commit is contained in:
Bo Chen
2021-05-24 12:23:25 -07:00
committed by Rob Bradford
parent 0e0159db0c
commit 2c4fa258a6
3 changed files with 12 additions and 20 deletions

View File

@@ -773,7 +773,7 @@ impl MemoryManager {
log_dirty,
}));
guest_memory.memory().with_regions(|_, region| {
for region in guest_memory.memory().iter() {
let mut mm = memory_manager.lock().unwrap();
let slot = mm.create_userspace_mapping(
region.start_addr().raw_value(),
@@ -788,9 +788,7 @@ impl MemoryManager {
size: region.len(),
slot,
});
Ok(())
})?;
}
for region in virtio_mem_regions.drain(..) {
let mut mm = memory_manager.lock().unwrap();
@@ -1942,7 +1940,7 @@ impl Snapshottable for MemoryManager {
let mut memory_regions: Vec<MemoryRegion> = Vec::new();
guest_memory.with_regions_mut(|index, region| {
for (index, region) in guest_memory.iter().enumerate() {
if region.len() == 0 {
return Err(MigratableError::Snapshot(anyhow!("Zero length region")));
}
@@ -1970,9 +1968,7 @@ impl Snapshottable for MemoryManager {
start_addr: region.start_addr().0,
size: region.len(),
});
Ok(())
})?;
}
// Store locally this list of regions as it will be used through the
// Transportable::send() implementation. The point is to avoid the