Skip to content

Commit 8623eaa

Browse files
committed
refactor(aarch64): remove Result type from apply_template
On aarch64 `apply_template` cannot fail, so no reason for `Result` return type. Signed-off-by: Egor Lazarchuk <[email protected]>
1 parent 05f6912 commit 8623eaa

File tree

2 files changed

+5
-12
lines changed

2 files changed

+5
-12
lines changed

src/vmm/src/arch/aarch64/mod.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,7 @@ pub enum ConfigurationError {
5050
/// Cannot load kernel due to invalid memory configuration or invalid kernel image: {0}
5151
KernelLoader(#[from] linux_loader::loader::Error),
5252
/// Error creating vcpu configuration: {0}
53-
VcpuConfig(CpuConfigurationError),
54-
/// Error applying vcpu template: {0}
55-
VcpuApplyTemplate(CpuConfigurationError),
53+
VcpuConfig(#[from] CpuConfigurationError),
5654
/// Error configuring the vcpu: {0}
5755
VcpuConfigure(KvmVcpuError),
5856
}
@@ -80,12 +78,10 @@ pub fn configure_system_for_boot(
8078
boot_cmdline: Cmdline,
8179
) -> Result<(), ConfigurationError> {
8280
// Construct the base CpuConfiguration to apply CPU template onto.
83-
let cpu_config =
84-
CpuConfiguration::new(cpu_template, vcpus).map_err(ConfigurationError::VcpuConfig)?;
81+
let cpu_config = CpuConfiguration::new(cpu_template, vcpus)?;
8582

8683
// Apply CPU template to the base CpuConfiguration.
87-
let cpu_config = CpuConfiguration::apply_template(cpu_config, cpu_template)
88-
.map_err(ConfigurationError::VcpuApplyTemplate)?;
84+
let cpu_config = CpuConfiguration::apply_template(cpu_config, cpu_template);
8985

9086
let vcpu_config = VcpuConfig {
9187
vcpu_count: machine_config.vcpu_count,

src/vmm/src/cpu_config/aarch64/mod.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,7 @@ impl CpuConfiguration {
4949
}
5050

5151
/// Creates new guest CPU config based on the provided template
52-
pub fn apply_template(
53-
mut self,
54-
template: &CustomCpuTemplate,
55-
) -> Result<Self, CpuConfigurationError> {
52+
pub fn apply_template(mut self, template: &CustomCpuTemplate) -> Self {
5653
for (modifier, mut reg) in template.reg_modifiers.iter().zip(self.regs.iter_mut()) {
5754
match reg.size() {
5855
RegSize::U32 => {
@@ -73,7 +70,7 @@ impl CpuConfiguration {
7370
_ => unreachable!("Only 32, 64 and 128 bit wide registers are supported"),
7471
}
7572
}
76-
Ok(self)
73+
self
7774
}
7875

7976
/// Returns ids of registers that are changed

0 commit comments

Comments
 (0)