Skip to content

Commit 2b5ad8b

Browse files
committed
fix: Refactor vmm builder code to simplify logic
pass vm_config to eliminate two extra arguments derived from it Signed-off-by: tommady <[email protected]>
1 parent 5a23130 commit 2b5ad8b

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

src/vmm/src/builder.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,7 @@ fn create_vmm_and_vcpus(
154154
event_manager: &mut EventManager,
155155
guest_memory: GuestMemoryMmap,
156156
uffd: Option<Uffd>,
157-
track_dirty_pages: bool,
158-
vcpu_count: u8,
157+
vm_config: &VmConfig,
159158
kvm_capabilities: Vec<KvmCapability>,
160159
) -> Result<(Vmm, Vec<Vcpu>), StartMicrovmError> {
161160
use self::StartMicrovmError::*;
@@ -165,7 +164,7 @@ fn create_vmm_and_vcpus(
165164
let mut vm = Vm::new(kvm_capabilities)
166165
.map_err(VmmError::Vm)
167166
.map_err(StartMicrovmError::Internal)?;
168-
vm.memory_init(&guest_memory, track_dirty_pages)
167+
vm.memory_init(&guest_memory, vm_config.track_dirty_pages)
169168
.map_err(VmmError::Vm)
170169
.map_err(StartMicrovmError::Internal)?;
171170

@@ -186,7 +185,7 @@ fn create_vmm_and_vcpus(
186185
#[cfg(target_arch = "x86_64")]
187186
let (vcpus, pio_device_manager) = {
188187
setup_interrupt_controller(&mut vm)?;
189-
let vcpus = create_vcpus(&vm, vcpu_count, &vcpus_exit_evt).map_err(Internal)?;
188+
let vcpus = create_vcpus(&vm, vm_config.vcpu_count, &vcpus_exit_evt).map_err(Internal)?;
190189

191190
// Make stdout non blocking.
192191
set_stdout_nonblocking();
@@ -279,8 +278,7 @@ pub fn build_microvm_for_boot(
279278
event_manager,
280279
guest_memory,
281280
None,
282-
vm_resources.vm_config.track_dirty_pages,
283-
vm_resources.vm_config.vcpu_count,
281+
&vm_resources.vm_config,
284282
cpu_template.kvm_capabilities.clone(),
285283
)?;
286284

@@ -469,8 +467,7 @@ pub fn build_microvm_from_snapshot(
469467
event_manager,
470468
guest_memory.clone(),
471469
uffd,
472-
vm_resources.vm_config.track_dirty_pages,
473-
vm_resources.vm_config.vcpu_count,
470+
&vm_resources.vm_config,
474471
microvm_state.vm_state.kvm_cap_modifiers.clone(),
475472
)?;
476473

0 commit comments

Comments
 (0)