@@ -27,8 +27,6 @@ use linux_loader::loader::{Cmdline, KernelLoader};
27
27
use vm_memory:: GuestMemoryError ;
28
28
29
29
use self :: gic:: GICDevice ;
30
- use crate :: arch:: aarch64:: regs:: Aarch64RegisterVec ;
31
- use crate :: arch:: aarch64:: vcpu:: { VcpuArchError , get_registers} ;
32
30
use crate :: arch:: { BootProtocol , DeviceType , EntryPoint } ;
33
31
use crate :: cpu_config:: aarch64:: { CpuConfiguration , CpuConfigurationError } ;
34
32
use crate :: cpu_config:: templates:: CustomCpuTemplate ;
@@ -51,14 +49,12 @@ pub enum ConfigurationError {
51
49
KernelFile ,
52
50
/// Cannot load kernel due to invalid memory configuration or invalid kernel image: {0}
53
51
KernelLoader ( #[ from] linux_loader:: loader:: Error ) ,
54
- /// Error initializing the vcpu: {0}
55
- VcpuInit ( KvmVcpuError ) ,
56
- /// Error configuring the vcpu: {0}
57
- VcpuConfigure ( KvmVcpuError ) ,
58
- /// Error reading vcpu registers: {0}
59
- VcpuGetRegs ( VcpuArchError ) ,
52
+ /// Error creating vcpu configuration: {0}
53
+ VcpuConfig ( CpuConfigurationError ) ,
60
54
/// Error applying vcpu template: {0}
61
55
VcpuApplyTemplate ( CpuConfigurationError ) ,
56
+ /// Error configuring the vcpu: {0}
57
+ VcpuConfigure ( KvmVcpuError ) ,
62
58
}
63
59
64
60
/// The start of the memory area reserved for MMIO devices.
@@ -84,18 +80,8 @@ pub fn configure_system_for_boot(
84
80
boot_cmdline : Cmdline ,
85
81
) -> Result < ( ) , ConfigurationError > {
86
82
// Construct the base CpuConfiguration to apply CPU template onto.
87
- let cpu_config = {
88
- for vcpu in vcpus. iter_mut ( ) {
89
- vcpu. kvm_vcpu
90
- . init ( & cpu_template. vcpu_features )
91
- . map_err ( ConfigurationError :: VcpuInit ) ?;
92
- }
93
-
94
- let mut regs = Aarch64RegisterVec :: default ( ) ;
95
- get_registers ( & vcpus[ 0 ] . kvm_vcpu . fd , & cpu_template. reg_list ( ) , & mut regs)
96
- . map_err ( ConfigurationError :: VcpuGetRegs ) ?;
97
- CpuConfiguration { regs }
98
- } ;
83
+ let cpu_config =
84
+ CpuConfiguration :: new ( cpu_template, vcpus) . map_err ( ConfigurationError :: VcpuConfig ) ?;
99
85
100
86
// Apply CPU template to the base CpuConfiguration.
101
87
let cpu_config = CpuConfiguration :: apply_template ( cpu_config, cpu_template)
0 commit comments