Skip to content

Commit 56b4979

Browse files
committed
refactor: avoid an unwrap in set_kvm_memory_regions
There's no need to use the GuestMemoryMmap to resolve the pointer to the start of the GuestMemoryRegion by resolving the guest physical address it starts at - because we literally store that pointer inside the GuestMemoryRegion, so can just use that. Signed-off-by: Patrick Roy <[email protected]>
1 parent 73e86de commit 56b4979

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

src/vmm/src/vstate/vm/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,7 @@ impl Vm {
9595
slot,
9696
guest_phys_addr: region.start_addr().raw_value(),
9797
memory_size: region.len(),
98-
// It's safe to unwrap because the guest address is valid.
99-
userspace_addr: guest_mem.get_host_address(region.start_addr()).unwrap() as u64,
98+
userspace_addr: region.as_ptr() as u64,
10099
flags,
101100
};
102101

0 commit comments

Comments
 (0)