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

@@ -2019,13 +2019,12 @@ impl Vm {
let mut table = MemoryRangeTable::default();
let guest_memory = self.memory_manager.lock().as_ref().unwrap().guest_memory();
guest_memory.memory().with_regions_mut(|_, region| {
for region in guest_memory.memory().iter() {
table.push(MemoryRange {
gpa: region.start_addr().raw_value(),
length: region.len() as u64,
});
Ok(())
})?;
}
Ok(table)
}
@@ -2520,7 +2519,7 @@ pub fn test_vm() {
let hv = hypervisor::new().unwrap();
let vm = hv.create_vm().expect("new VM creation failed");
mem.with_regions(|index, region| {
for (index, region) in mem.iter().enumerate() {
let mem_region = vm.make_user_memory_region(
index as u32,
region.start_addr().raw_value(),
@@ -2531,8 +2530,8 @@ pub fn test_vm() {
);
vm.set_user_memory_region(mem_region)
})
.expect("Cannot configure guest memory");
.expect("Cannot configure guest memory");
}
mem.write_slice(&code, load_addr)
.expect("Writing code to memory failed");