@@ -274,8 +274,6 @@ pub mod aarch64 {
274
274
vcpus. push ( vcpu) ;
275
275
}
276
276
277
- setup_interrupt_controller ( vm, vcpu_count) ?;
278
-
279
277
Ok ( vcpus)
280
278
}
281
279
@@ -317,6 +315,9 @@ pub mod aarch64 {
317
315
let vcpus = create_vcpus ( & mut vmm. vm , vm_config. vcpu_count , & vmm. vcpus_exit_evt )
318
316
. map_err ( StartMicrovmError :: Internal ) ?;
319
317
318
+ setup_interrupt_controller ( & mut vmm. vm , vm_config. vcpu_count )
319
+ . map_err ( StartMicrovmError :: Internal ) ?;
320
+
320
321
Ok ( ( vmm, vcpus) )
321
322
}
322
323
}
@@ -459,6 +460,11 @@ pub mod x86_64 {
459
460
kvm_capabilities,
460
461
) ?;
461
462
463
+ setup_interrupt_controller ( & mut vmm. vm ) . map_err ( StartMicrovmError :: Internal ) ?;
464
+ vmm. pio_device_manager
465
+ . register_devices ( vmm. vm . fd ( ) )
466
+ . unwrap ( ) ;
467
+
462
468
let vcpus = create_vcpus ( & mut vmm. vm , vm_config. vcpu_count , & vmm. vcpus_exit_evt )
463
469
. map_err ( StartMicrovmError :: Internal ) ?;
464
470
@@ -477,10 +483,7 @@ fn build_vmm(
477
483
478
484
// Set up Kvm Vm and register memory regions.
479
485
// Build custom CPU config if a custom template is provided.
480
- //
481
- // allow unused_mut for the aarch64 platform.
482
- #[ allow( unused_mut) ]
483
- let mut vm = Vm :: new ( kvm_capabilities)
486
+ let vm = Vm :: new ( kvm_capabilities)
484
487
. map_err ( VmmError :: Vm )
485
488
. map_err ( Internal ) ?;
486
489
vm. memory_init ( & guest_memory, vm_config. track_dirty_pages )
@@ -499,8 +502,6 @@ fn build_vmm(
499
502
// Instantiate ACPI device manager.
500
503
let acpi_device_manager = ACPIDeviceManager :: new ( ) ;
501
504
502
- // For x86_64 we need to create the interrupt controller before calling `KVM_CREATE_VCPUS`
503
- // while on aarch64 we need to do it the other way around.
504
505
#[ cfg( target_arch = "x86_64" ) ]
505
506
let pio_device_manager = {
506
507
// Serial device setup.
@@ -513,17 +514,9 @@ fn build_vmm(
513
514
. map_err ( VmmError :: EventFd )
514
515
. map_err ( Internal ) ?;
515
516
516
- x86_64:: setup_interrupt_controller ( & mut vm) . map_err ( Internal ) ?;
517
-
518
517
// create pio dev manager with legacy devices
519
- let pio_device_manager = {
520
- // TODO Remove these unwraps.
521
- let mut pio_dev_mgr = PortIODeviceManager :: new ( serial_device, reset_evt) . unwrap ( ) ;
522
- pio_dev_mgr. register_devices ( vm. fd ( ) ) . unwrap ( ) ;
523
- pio_dev_mgr
524
- } ;
525
-
526
- pio_device_manager
518
+ // TODO: remove this unwrap
519
+ PortIODeviceManager :: new ( serial_device, reset_evt) . unwrap ( )
527
520
} ;
528
521
529
522
Ok ( Vmm {
0 commit comments