Skip to content

Commit

Permalink
fix: avoid needless clone in build_microvm_from_snapshot
Browse files Browse the repository at this point in the history
There is no need to clone the GuestMemoryMmap here, as
create_vmm_and_vcpus returns it again (as part of the Vmm object), and
since later code in build_microvm_from_snapshot doesn't need to take
ownership of the GuestMemoryMmap, we can just use references to this
stored object, avoiding the clone.

Signed-off-by: Patrick Roy <[email protected]>
  • Loading branch information
roypat committed Jan 16, 2025
1 parent 9e011ba commit 3fb06e9
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/vmm/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ pub fn build_microvm_from_snapshot(
let (mut vmm, mut vcpus) = create_vmm_and_vcpus(
instance_info,
event_manager,
guest_memory.clone(),
guest_memory,
uffd,
vm_resources.machine_config.track_dirty_pages,
vm_resources.machine_config.vcpu_count,
Expand Down Expand Up @@ -517,7 +517,7 @@ pub fn build_microvm_from_snapshot(

// Restore devices states.
let mmio_ctor_args = MMIODevManagerConstructorArgs {
mem: &guest_memory,
mem: &vmm.guest_memory,
vm: vmm.vm.fd(),
event_manager,
resource_allocator: &mut vmm.resource_allocator,
Expand All @@ -532,7 +532,7 @@ pub fn build_microvm_from_snapshot(

{
let acpi_ctor_args = ACPIDeviceManagerConstructorArgs {
mem: &guest_memory,
mem: &vmm.guest_memory,
resource_allocator: &mut vmm.resource_allocator,
vm: vmm.vm.fd(),
};
Expand Down

0 comments on commit 3fb06e9

Please sign in to comment.