mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
vmm: hypervisor: split set_user_memory_region to two functions
Previously the same function was used to both create and remove regions.
This worked on KVM because it uses size 0 to indicate removal.
MSHV has two calls -- one for creation and one for removal. It also
requires having the size field available because it is not slot based.
Split set_user_memory_region to {create/remove}_user_memory_region. For
KVM they still use set_user_memory_region underneath, but for MSHV they
map to different functions.
This fixes user memory region removal on MSHV.
Signed-off-by: Wei Liu <liuwe@microsoft.com>
This commit is contained in:
@@ -679,7 +679,7 @@ impl VfioPciDevice {
|
||||
false,
|
||||
);
|
||||
|
||||
vm.set_user_memory_region(mem_region)
|
||||
vm.create_user_memory_region(mem_region)
|
||||
.map_err(|e| VfioPciError::MapRegionGuest(e.into()))?;
|
||||
|
||||
// Update the region with memory mapped info.
|
||||
@@ -703,13 +703,13 @@ impl VfioPciDevice {
|
||||
let r = self.vm.make_user_memory_region(
|
||||
mem_slot,
|
||||
region.start.raw_value() + mmap_offset,
|
||||
0,
|
||||
mmap_size as u64,
|
||||
host_addr as u64,
|
||||
false,
|
||||
false,
|
||||
);
|
||||
|
||||
if let Err(e) = self.vm.set_user_memory_region(r) {
|
||||
if let Err(e) = self.vm.remove_user_memory_region(r) {
|
||||
error!("Could not remove the userspace memory region: {}", e);
|
||||
}
|
||||
|
||||
@@ -1137,14 +1137,14 @@ impl PciDevice for VfioPciDevice {
|
||||
let old_mem_region = self.vm.make_user_memory_region(
|
||||
mem_slot,
|
||||
old_base + mmap_offset,
|
||||
0,
|
||||
mmap_size as u64,
|
||||
host_addr as u64,
|
||||
false,
|
||||
false,
|
||||
);
|
||||
|
||||
self.vm
|
||||
.set_user_memory_region(old_mem_region)
|
||||
.remove_user_memory_region(old_mem_region)
|
||||
.map_err(|e| io::Error::new(io::ErrorKind::Other, e))?;
|
||||
|
||||
// Insert new region
|
||||
@@ -1158,7 +1158,7 @@ impl PciDevice for VfioPciDevice {
|
||||
);
|
||||
|
||||
self.vm
|
||||
.set_user_memory_region(new_mem_region)
|
||||
.create_user_memory_region(new_mem_region)
|
||||
.map_err(|e| io::Error::new(io::ErrorKind::Other, e))?;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user