Skip to content

Commit

Permalink
refactor(vmm_builder): address comments
Browse files Browse the repository at this point in the history
move interrupt controller into create_vmm_and_vcpus
and fix aarm64 integration test

Signed-off-by: tommady <[email protected]>
  • Loading branch information
tommady committed Dec 7, 2024
1 parent 1ff7e17 commit e36a5f9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
25 changes: 11 additions & 14 deletions src/vmm/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -274,8 +274,6 @@ pub mod aarch64 {
vcpus.push(vcpu);
}

setup_interrupt_controller(vm, vcpu_count)?;

Ok(vcpus)
}

Expand Down Expand Up @@ -317,6 +315,9 @@ pub mod aarch64 {
let vcpus = create_vcpus(&mut vmm.vm, vm_config.vcpu_count, &vmm.vcpus_exit_evt)
.map_err(StartMicrovmError::Internal)?;

setup_interrupt_controller(&mut vmm.vm, vm_config.vcpu_count)
.map_err(StartMicrovmError::Internal)?;

Ok((vmm, vcpus))
}
}
Expand Down Expand Up @@ -459,6 +460,11 @@ pub mod x86_64 {
kvm_capabilities,
)?;

setup_interrupt_controller(&mut vmm.vm).map_err(StartMicrovmError::Internal)?;
vmm.pio_device_manager
.register_devices(vmm.vm.fd())
.unwrap();

let vcpus = create_vcpus(&mut vmm.vm, vm_config.vcpu_count, &vmm.vcpus_exit_evt)
.map_err(StartMicrovmError::Internal)?;

Expand All @@ -477,10 +483,7 @@ fn build_vmm(

// Set up Kvm Vm and register memory regions.
// Build custom CPU config if a custom template is provided.
//
// allow unused_mut for the aarch64 platform.
#[allow(unused_mut)]
let mut vm = Vm::new(kvm_capabilities)
let vm = Vm::new(kvm_capabilities)
.map_err(VmmError::Vm)
.map_err(Internal)?;
vm.memory_init(&guest_memory, vm_config.track_dirty_pages)
Expand Down Expand Up @@ -513,15 +516,9 @@ fn build_vmm(
.map_err(VmmError::EventFd)
.map_err(Internal)?;

x86_64::setup_interrupt_controller(&mut vm).map_err(Internal)?;

// create pio dev manager with legacy devices
let pio_device_manager = {
// TODO Remove these unwraps.
let mut pio_dev_mgr = PortIODeviceManager::new(serial_device, reset_evt).unwrap();
pio_dev_mgr.register_devices(vm.fd()).unwrap();
pio_dev_mgr
};
// TODO: remove this unwrap
let pio_device_manager = PortIODeviceManager::new(serial_device, reset_evt).unwrap();

pio_device_manager
};
Expand Down
3 changes: 3 additions & 0 deletions src/vmm/src/device_manager/persist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,9 @@ impl<'a> Persist<'a> for MMIODeviceManager {
for state in &state.legacy_devices {
if state.type_ == DeviceType::Serial {
let serial = setup_serial_device(std::io::stdin(), std::io::stdout())?;
constructor_args
.event_manager
.add_subscriber(serial.clone());

constructor_args
.resource_allocator
Expand Down

0 comments on commit e36a5f9

Please sign in to comment.