Skip to content

Commit 902337e

Browse files
committed
refactor(aarch64): add #[from] to the arch error enum
Remove `map_err` calls by adding `#[from]` to error variants. Signed-off-by: Egor Lazarchuk <[email protected]>
1 parent 5359e2d commit 902337e

File tree

1 file changed

+9
-13
lines changed
  • src/vmm/src/arch/aarch64

1 file changed

+9
-13
lines changed

Diff for: src/vmm/src/arch/aarch64/mod.rs

+9-13
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,15 @@ pub enum ConfigurationError {
4040
/// Failed to create a Flattened Device Tree for this aarch64 microVM: {0}
4141
SetupFDT(#[from] fdt::FdtError),
4242
/// Failed to write to guest memory.
43-
MemoryError(GuestMemoryError),
43+
MemoryError(#[from] GuestMemoryError),
4444
/// Cannot copy kernel file fd
4545
KernelFile,
4646
/// Cannot load kernel due to invalid memory configuration or invalid kernel image: {0}
4747
KernelLoader(#[from] linux_loader::loader::Error),
4848
/// Error creating vcpu configuration: {0}
4949
VcpuConfig(#[from] CpuConfigurationError),
5050
/// Error configuring the vcpu: {0}
51-
VcpuConfigure(KvmVcpuError),
51+
VcpuConfigure(#[from] KvmVcpuError),
5252
}
5353

5454
/// The start of the memory area reserved for MMIO devices.
@@ -88,14 +88,12 @@ pub fn configure_system_for_boot(
8888
let optional_capabilities = vmm.kvm.optional_capabilities();
8989
// Configure vCPUs with normalizing and setting the generated CPU configuration.
9090
for vcpu in vcpus.iter_mut() {
91-
vcpu.kvm_vcpu
92-
.configure(
93-
&vmm.guest_memory,
94-
entry_point,
95-
&vcpu_config,
96-
&optional_capabilities,
97-
)
98-
.map_err(ConfigurationError::VcpuConfigure)?;
91+
vcpu.kvm_vcpu.configure(
92+
&vmm.guest_memory,
93+
entry_point,
94+
&vcpu_config,
95+
&optional_capabilities,
96+
)?;
9997
}
10098
let vcpu_mpidr = vcpus
10199
.iter_mut()
@@ -116,9 +114,7 @@ pub fn configure_system_for_boot(
116114
)?;
117115

118116
let fdt_address = GuestAddress(get_fdt_addr(&vmm.guest_memory));
119-
vmm.guest_memory
120-
.write_slice(fdt.as_slice(), fdt_address)
121-
.map_err(ConfigurationError::MemoryError)?;
117+
vmm.guest_memory.write_slice(fdt.as_slice(), fdt_address)?;
122118

123119
Ok(())
124120
}

0 commit comments

Comments
 (0)