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:
@@ -176,8 +176,11 @@ pub enum Error {
|
||||
/// The requested hotplug memory addition is not a valid size
|
||||
InvalidSize,
|
||||
|
||||
/// Failed to set the user memory region.
|
||||
SetUserMemoryRegion(hypervisor::HypervisorVmError),
|
||||
/// Failed to create the user memory region.
|
||||
CreateUserMemoryRegion(hypervisor::HypervisorVmError),
|
||||
|
||||
/// Failed to remove the user memory region.
|
||||
RemoveUserMemoryRegion(hypervisor::HypervisorVmError),
|
||||
|
||||
/// Failed to EventFd.
|
||||
EventFdFail(io::Error),
|
||||
@@ -1212,8 +1215,8 @@ impl MemoryManager {
|
||||
);
|
||||
|
||||
self.vm
|
||||
.set_user_memory_region(mem_region)
|
||||
.map_err(Error::SetUserMemoryRegion)?;
|
||||
.create_user_memory_region(mem_region)
|
||||
.map_err(Error::CreateUserMemoryRegion)?;
|
||||
|
||||
// Mark the pages as mergeable if explicitly asked for.
|
||||
if mergeable {
|
||||
@@ -1259,15 +1262,15 @@ impl MemoryManager {
|
||||
let mem_region = self.vm.make_user_memory_region(
|
||||
slot,
|
||||
guest_phys_addr,
|
||||
0, /* memory_size -- using 0 removes this slot */
|
||||
memory_size,
|
||||
userspace_addr,
|
||||
false, /* readonly -- don't care */
|
||||
false, /* log dirty */
|
||||
);
|
||||
|
||||
self.vm
|
||||
.set_user_memory_region(mem_region)
|
||||
.map_err(Error::SetUserMemoryRegion)?;
|
||||
.remove_user_memory_region(mem_region)
|
||||
.map_err(Error::RemoveUserMemoryRegion)?;
|
||||
|
||||
// Mark the pages as unmergeable if there were previously marked as
|
||||
// mergeable.
|
||||
|
||||
Reference in New Issue
Block a user