mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2025-01-03 11:25:20 +00:00
hypervisor: add safety statement in set_user_memory_region
When set_user_memory_region was moved to hypervisor crate, it was turned into a safe function that wrapped around an unsafe call. All but one call site had the safety statements removed. But safety statement was not moved inside the wrapper function. Add the safety statement back to help reasoning in the future. Also remove that one last instance where the safety statement is not needed . No functional change. Signed-off-by: Wei Liu <liuwe@microsoft.com>
This commit is contained in:
parent
b27439b6ed
commit
1741af74ed
@ -170,6 +170,7 @@ impl vm::Vm for KvmVm {
|
||||
/// Creates/modifies a guest physical memory slot.
|
||||
///
|
||||
fn set_user_memory_region(&self, user_memory_region: MemoryRegion) -> vm::Result<()> {
|
||||
// Safe because guest regions are guaranteed not to overlap.
|
||||
unsafe {
|
||||
self.fd
|
||||
.set_user_memory_region(user_memory_region)
|
||||
|
@ -1459,7 +1459,6 @@ pub fn test_vm() {
|
||||
flags: 0,
|
||||
};
|
||||
|
||||
// Safe because the guest regions are guaranteed not to overlap.
|
||||
vm_fd.set_user_memory_region(mem_region)
|
||||
})
|
||||
.expect("Cannot configure guest memory");
|
||||
|
Loading…
Reference in New Issue
Block a user