misc: arch: streamline error Display::fmt()

The changes were mostly automatically applied using the Python
script mentioned in the first commit of this series.

Signed-off-by: Philipp Schuster <philipp.schuster@cyberus-technology.de>
On-behalf-of: SAP philipp.schuster@sap.com
This commit is contained in:
Philipp Schuster
2025-05-21 12:32:23 +02:00
committed by Rob Bradford
parent 3f3489e38e
commit 06a868cb85
11 changed files with 68 additions and 61 deletions
+1 -1
View File
@@ -81,7 +81,7 @@ pub trait DeviceInfoForFdt {
#[derive(Debug, Error)] #[derive(Debug, Error)]
pub enum Error { pub enum Error {
/// Failure in writing FDT in memory. /// Failure in writing FDT in memory.
#[error("Failure in writing FDT in memory: {0}")] #[error("Failure in writing FDT in memory")]
WriteFdtToMemory(#[source] GuestMemoryError), WriteFdtToMemory(#[source] GuestMemoryError),
} }
type Result<T> = result::Result<T, Error>; type Result<T> = result::Result<T, Error>;
+3 -3
View File
@@ -32,7 +32,7 @@ pub enum Error {
SetupFdt, SetupFdt,
/// Failed to write FDT to memory. /// Failed to write FDT to memory.
#[error("Failed to write FDT to memory: {0}")] #[error("Failed to write FDT to memory")]
WriteFdtToMemory(#[source] fdt::Error), WriteFdtToMemory(#[source] fdt::Error),
/// Failed to create a GIC. /// Failed to create a GIC.
@@ -44,11 +44,11 @@ pub enum Error {
InitramfsAddress, InitramfsAddress,
/// Error configuring the general purpose registers /// Error configuring the general purpose registers
#[error("Error configuring the general purpose registers: {0}")] #[error("Error configuring the general purpose registers")]
RegsConfiguration(#[source] hypervisor::HypervisorCpuError), RegsConfiguration(#[source] hypervisor::HypervisorCpuError),
/// Error configuring the MPIDR register /// Error configuring the MPIDR register
#[error("Error configuring the MPIDR register: {0}")] #[error("Error configuring the MPIDR register")]
VcpuRegMpidr(#[source] hypervisor::HypervisorCpuError), VcpuRegMpidr(#[source] hypervisor::HypervisorCpuError),
/// Error initializing PMU for vcpu /// Error initializing PMU for vcpu
+4 -4
View File
@@ -28,13 +28,13 @@ type GuestRegionMmap = vm_memory::GuestRegionMmap<vm_memory::bitmap::AtomicBitma
#[derive(Debug, Error)] #[derive(Debug, Error)]
pub enum Error { pub enum Error {
#[cfg(target_arch = "x86_64")] #[cfg(target_arch = "x86_64")]
#[error("Platform specific error (x86_64): {0}")] #[error("Platform specific error (x86_64)")]
PlatformSpecific(#[from] x86_64::Error), PlatformSpecific(#[from] x86_64::Error),
#[cfg(target_arch = "aarch64")] #[cfg(target_arch = "aarch64")]
#[error("Platform specific error (aarch64): {0:?}")] #[error("Platform specific error (aarch64)")]
PlatformSpecific(#[from] aarch64::Error), PlatformSpecific(#[from] aarch64::Error),
#[cfg(target_arch = "riscv64")] #[cfg(target_arch = "riscv64")]
#[error("Platform specific error (riscv64): {0:?}")] #[error("Platform specific error (riscv64)")]
PlatformSpecific(#[from] riscv64::Error), PlatformSpecific(#[from] riscv64::Error),
#[error("The memory map table extends past the end of guest memory")] #[error("The memory map table extends past the end of guest memory")]
MemmapTablePastRamEnd, MemmapTablePastRamEnd,
@@ -46,7 +46,7 @@ pub enum Error {
StartInfoSetup, StartInfoSetup,
#[error("Failed to compute initramfs address")] #[error("Failed to compute initramfs address")]
InitramfsAddress, InitramfsAddress,
#[error("Error writing module entry to guest memory: {0}")] #[error("Error writing module entry to guest memory")]
ModlistSetup(#[source] vm_memory::GuestMemoryError), ModlistSetup(#[source] vm_memory::GuestMemoryError),
#[error("RSDP extends past the end of guest memory")] #[error("RSDP extends past the end of guest memory")]
RsdpPastRamEnd, RsdpPastRamEnd,
+1 -1
View File
@@ -54,7 +54,7 @@ pub trait DeviceInfoForFdt {
#[derive(Debug, Error)] #[derive(Debug, Error)]
pub enum Error { pub enum Error {
/// Failure in writing FDT in memory. /// Failure in writing FDT in memory.
#[error("Failure in writing FDT in memory: {0}")] #[error("Failure in writing FDT in memory")]
WriteFdtToMemory(#[source] GuestMemoryError), WriteFdtToMemory(#[source] GuestMemoryError),
} }
type Result<T> = result::Result<T, Error>; type Result<T> = result::Result<T, Error>;
+2 -2
View File
@@ -30,7 +30,7 @@ pub enum Error {
SetupFdt, SetupFdt,
/// Failed to write FDT to memory. /// Failed to write FDT to memory.
#[error("Failed to write FDT to memory: {0}")] #[error("Failed to write FDT to memory")]
WriteFdtToMemory(#[source] fdt::Error), WriteFdtToMemory(#[source] fdt::Error),
/// Failed to create a AIA. /// Failed to create a AIA.
@@ -42,7 +42,7 @@ pub enum Error {
InitramfsAddress, InitramfsAddress,
/// Error configuring the general purpose registers /// Error configuring the general purpose registers
#[error("Error configuring the general purpose registers: {0}")] #[error("Error configuring the general purpose registers")]
RegsConfiguration(#[source] hypervisor::HypervisorCpuError), RegsConfiguration(#[source] hypervisor::HypervisorCpuError),
} }
+14 -14
View File
@@ -132,35 +132,35 @@ pub struct CpuidConfig {
#[derive(Debug, Error)] #[derive(Debug, Error)]
pub enum Error { pub enum Error {
/// Error writing MP table to memory. /// Error writing MP table to memory.
#[error("Error writing MP table to memory: {0}")] #[error("Error writing MP table to memory")]
MpTableSetup(#[source] mptable::Error), MpTableSetup(#[source] mptable::Error),
/// Error configuring the general purpose registers /// Error configuring the general purpose registers
#[error("Error configuring the general purpose registers: {0}")] #[error("Error configuring the general purpose registers")]
RegsConfiguration(#[source] regs::Error), RegsConfiguration(#[source] regs::Error),
/// Error configuring the special registers /// Error configuring the special registers
#[error("Error configuring the special registers: {0}")] #[error("Error configuring the special registers")]
SregsConfiguration(#[source] regs::Error), SregsConfiguration(#[source] regs::Error),
/// Error configuring the floating point related registers /// Error configuring the floating point related registers
#[error("Error configuring the floating point related registers: {0}")] #[error("Error configuring the floating point related registers")]
FpuConfiguration(#[source] regs::Error), FpuConfiguration(#[source] regs::Error),
/// Error configuring the MSR registers /// Error configuring the MSR registers
#[error("Error configuring the MSR registers: {0}")] #[error("Error configuring the MSR registers")]
MsrsConfiguration(#[source] regs::Error), MsrsConfiguration(#[source] regs::Error),
/// Failed to set supported CPUs. /// Failed to set supported CPUs.
#[error("Failed to set supported CPUs: {0}")] #[error("Failed to set supported CPUs")]
SetSupportedCpusFailed(#[source] anyhow::Error), SetSupportedCpusFailed(#[source] anyhow::Error),
/// Cannot set the local interruption due to bad configuration. /// Cannot set the local interruption due to bad configuration.
#[error("Cannot set the local interruption due to bad configuration: {0}")] #[error("Cannot set the local interruption due to bad configuration")]
LocalIntConfiguration(#[source] anyhow::Error), LocalIntConfiguration(#[source] anyhow::Error),
/// Error setting up SMBIOS table /// Error setting up SMBIOS table
#[error("Error setting up SMBIOS table: {0}")] #[error("Error setting up SMBIOS table")]
SmbiosSetup(#[source] smbios::Error), SmbiosSetup(#[source] smbios::Error),
/// Could not find any SGX EPC section /// Could not find any SGX EPC section
@@ -176,15 +176,15 @@ pub enum Error {
MissingSgxLaunchControlFeature, MissingSgxLaunchControlFeature,
/// Error getting supported CPUID through the hypervisor (kvm/mshv) API /// Error getting supported CPUID through the hypervisor (kvm/mshv) API
#[error("Error getting supported CPUID through the hypervisor API: {0}")] #[error("Error getting supported CPUID through the hypervisor API")]
CpuidGetSupported(#[source] HypervisorError), CpuidGetSupported(#[source] HypervisorError),
/// Error populating CPUID with KVM HyperV emulation details /// Error populating CPUID with KVM HyperV emulation details
#[error("Error populating CPUID with KVM HyperV emulation details: {0}")] #[error("Error populating CPUID with KVM HyperV emulation details")]
CpuidKvmHyperV(#[source] vmm_sys_util::fam::Error), CpuidKvmHyperV(#[source] vmm_sys_util::fam::Error),
/// Error populating CPUID with CPU identification /// Error populating CPUID with CPU identification
#[error("Error populating CPUID with CPU identification: {0}")] #[error("Error populating CPUID with CPU identification")]
CpuidIdentification(#[source] vmm_sys_util::fam::Error), CpuidIdentification(#[source] vmm_sys_util::fam::Error),
/// Error checking CPUID compatibility /// Error checking CPUID compatibility
@@ -192,16 +192,16 @@ pub enum Error {
CpuidCheckCompatibility, CpuidCheckCompatibility,
// Error writing EBDA address // Error writing EBDA address
#[error("Error writing EBDA address: {0}")] #[error("Error writing EBDA address")]
EbdaSetup(#[source] vm_memory::GuestMemoryError), EbdaSetup(#[source] vm_memory::GuestMemoryError),
// Error getting CPU TSC frequency // Error getting CPU TSC frequency
#[error("Error getting CPU TSC frequency: {0}")] #[error("Error getting CPU TSC frequency")]
GetTscFrequency(#[source] HypervisorCpuError), GetTscFrequency(#[source] HypervisorCpuError),
/// Error retrieving TDX capabilities through the hypervisor (kvm/mshv) API /// Error retrieving TDX capabilities through the hypervisor (kvm/mshv) API
#[cfg(feature = "tdx")] #[cfg(feature = "tdx")]
#[error("Error retrieving TDX capabilities through the hypervisor API: {0}")] #[error("Error retrieving TDX capabilities through the hypervisor API")]
TdxCapabilities(#[source] HypervisorError), TdxCapabilities(#[source] HypervisorError),
/// Failed to configure E820 map for bzImage /// Failed to configure E820 map for bzImage
+8 -8
View File
@@ -59,31 +59,31 @@ pub enum Error {
#[error("The MP table has too little address space to be stored")] #[error("The MP table has too little address space to be stored")]
AddressOverflow, AddressOverflow,
/// Failure while zeroing out the memory for the MP table. /// Failure while zeroing out the memory for the MP table.
#[error("Failure while zeroing out the memory for the MP table: {0}")] #[error("Failure while zeroing out the memory for the MP table")]
Clear(#[source] GuestMemoryError), Clear(#[source] GuestMemoryError),
/// Number of CPUs exceeds the maximum supported CPUs /// Number of CPUs exceeds the maximum supported CPUs
#[error("Number of CPUs exceeds the maximum supported CPUs")] #[error("Number of CPUs exceeds the maximum supported CPUs")]
TooManyCpus, TooManyCpus,
/// Failure to write the MP floating pointer. /// Failure to write the MP floating pointer.
#[error("Failure to write the MP floating pointer: {0}")] #[error("Failure to write the MP floating pointer")]
WriteMpfIntel(#[source] GuestMemoryError), WriteMpfIntel(#[source] GuestMemoryError),
/// Failure to write MP CPU entry. /// Failure to write MP CPU entry.
#[error("Failure to write MP CPU entry: {0}")] #[error("Failure to write MP CPU entry")]
WriteMpcCpu(#[source] GuestMemoryError), WriteMpcCpu(#[source] GuestMemoryError),
/// Failure to write MP ioapic entry. /// Failure to write MP ioapic entry.
#[error("Failure to write MP ioapic entry: {0}")] #[error("Failure to write MP ioapic entry")]
WriteMpcIoapic(#[source] GuestMemoryError), WriteMpcIoapic(#[source] GuestMemoryError),
/// Failure to write MP bus entry. /// Failure to write MP bus entry.
#[error("Failure to write MP bus entry: {0}")] #[error("Failure to write MP bus entry")]
WriteMpcBus(#[source] GuestMemoryError), WriteMpcBus(#[source] GuestMemoryError),
/// Failure to write MP interrupt source entry. /// Failure to write MP interrupt source entry.
#[error("Failure to write MP interrupt source entry: {0}")] #[error("Failure to write MP interrupt source entry")]
WriteMpcIntsrc(#[source] GuestMemoryError), WriteMpcIntsrc(#[source] GuestMemoryError),
/// Failure to write MP local interrupt source entry. /// Failure to write MP local interrupt source entry.
#[error("Failure to write MP local interrupt source entry: {0}")] #[error("Failure to write MP local interrupt source entry")]
WriteMpcLintsrc(#[source] GuestMemoryError), WriteMpcLintsrc(#[source] GuestMemoryError),
/// Failure to write MP table header. /// Failure to write MP table header.
#[error("Failure to write MP table header: {0}")] #[error("Failure to write MP table header")]
WriteMpcTable(#[source] GuestMemoryError), WriteMpcTable(#[source] GuestMemoryError),
} }
+11 -11
View File
@@ -23,40 +23,40 @@ use crate::{EntryPoint, GuestMemoryMmap};
#[derive(Debug, Error)] #[derive(Debug, Error)]
pub enum Error { pub enum Error {
/// Failed to get SREGs for this CPU. /// Failed to get SREGs for this CPU.
#[error("Failed to get SREGs for this CPU: {0}")] #[error("Failed to get SREGs for this CPU")]
GetStatusRegisters(#[source] hypervisor::HypervisorCpuError), GetStatusRegisters(#[source] hypervisor::HypervisorCpuError),
/// Failed to set base registers for this CPU. /// Failed to set base registers for this CPU.
#[error("Failed to set base registers for this CPU: {0}")] #[error("Failed to set base registers for this CPU")]
SetBaseRegisters(#[source] hypervisor::HypervisorCpuError), SetBaseRegisters(#[source] hypervisor::HypervisorCpuError),
/// Failed to configure the FPU. /// Failed to configure the FPU.
#[error("Failed to configure the FPU: {0}")] #[error("Failed to configure the FPU")]
SetFpuRegisters(#[source] hypervisor::HypervisorCpuError), SetFpuRegisters(#[source] hypervisor::HypervisorCpuError),
/// Setting up MSRs failed. /// Setting up MSRs failed.
#[error("Setting up MSRs failed: {0}")] #[error("Setting up MSRs failed")]
SetModelSpecificRegisters(#[source] hypervisor::HypervisorCpuError), SetModelSpecificRegisters(#[source] hypervisor::HypervisorCpuError),
/// Failed to set SREGs for this CPU. /// Failed to set SREGs for this CPU.
#[error("Failed to set SREGs for this CPU: {0}")] #[error("Failed to set SREGs for this CPU")]
SetStatusRegisters(#[source] hypervisor::HypervisorCpuError), SetStatusRegisters(#[source] hypervisor::HypervisorCpuError),
/// Checking the GDT address failed. /// Checking the GDT address failed.
#[error("Checking the GDT address failed")] #[error("Checking the GDT address failed")]
CheckGdtAddr, CheckGdtAddr,
/// Writing the GDT to RAM failed. /// Writing the GDT to RAM failed.
#[error("Writing the GDT to RAM failed: {0}")] #[error("Writing the GDT to RAM failed")]
WriteGdt(#[source] GuestMemoryError), WriteGdt(#[source] GuestMemoryError),
/// Writing the IDT to RAM failed. /// Writing the IDT to RAM failed.
#[error("Writing the IDT to RAM failed: {0}")] #[error("Writing the IDT to RAM failed")]
WriteIdt(#[source] GuestMemoryError), WriteIdt(#[source] GuestMemoryError),
/// Writing PDPTE to RAM failed. /// Writing PDPTE to RAM failed.
#[error("Writing PDPTE to RAM failed: {0}")] #[error("Writing PDPTE to RAM failed")]
WritePdpteAddress(#[source] GuestMemoryError), WritePdpteAddress(#[source] GuestMemoryError),
/// Writing PDE to RAM failed. /// Writing PDE to RAM failed.
#[error("Writing PDE to RAM failed: {0}")] #[error("Writing PDE to RAM failed")]
WritePdeAddress(#[source] GuestMemoryError), WritePdeAddress(#[source] GuestMemoryError),
/// Writing PML4 to RAM failed. /// Writing PML4 to RAM failed.
#[error("Writing PML4 to RAM failed: {0}")] #[error("Writing PML4 to RAM failed")]
WritePml4Address(#[source] GuestMemoryError), WritePml4Address(#[source] GuestMemoryError),
/// Writing PML5 to RAM failed. /// Writing PML5 to RAM failed.
#[error("Writing PML5 to RAM failed: {0}")] #[error("Writing PML5 to RAM failed")]
WritePml5Address(#[source] GuestMemoryError), WritePml5Address(#[source] GuestMemoryError),
} }
+1 -1
View File
@@ -33,7 +33,7 @@ pub enum Error {
#[error("Failure to write additional data to memory")] #[error("Failure to write additional data to memory")]
WriteData, WriteData,
/// Failure to parse uuid, uuid format may be error /// Failure to parse uuid, uuid format may be error
#[error("Failure to parse uuid: {0}")] #[error("Failure to parse uuid")]
ParseUuid(#[source] uuid::Error), ParseUuid(#[source] uuid::Error),
} }
+5 -5
View File
@@ -13,11 +13,11 @@ use crate::GuestMemoryMmap;
#[derive(Error, Debug)] #[derive(Error, Debug)]
pub enum TdvfError { pub enum TdvfError {
#[error("Failed read TDVF descriptor: {0}")] #[error("Failed read TDVF descriptor")]
ReadDescriptor(#[source] std::io::Error), ReadDescriptor(#[source] std::io::Error),
#[error("Failed read TDVF descriptor offset: {0}")] #[error("Failed read TDVF descriptor offset")]
ReadDescriptorOffset(#[source] std::io::Error), ReadDescriptorOffset(#[source] std::io::Error),
#[error("Failed read GUID table: {0}")] #[error("Failed read GUID table")]
ReadGuidTable(#[source] std::io::Error), ReadGuidTable(#[source] std::io::Error),
#[error("Invalid descriptor signature")] #[error("Invalid descriptor signature")]
InvalidDescriptorSignature, InvalidDescriptorSignature,
@@ -25,9 +25,9 @@ pub enum TdvfError {
InvalidDescriptorSize, InvalidDescriptorSize,
#[error("Invalid descriptor version")] #[error("Invalid descriptor version")]
InvalidDescriptorVersion, InvalidDescriptorVersion,
#[error("Failed to write HOB details to guest memory: {0}")] #[error("Failed to write HOB details to guest memory")]
GuestMemoryWriteHob(#[source] GuestMemoryError), GuestMemoryWriteHob(#[source] GuestMemoryError),
#[error("Failed to create Uuid: {0}")] #[error("Failed to create Uuid")]
UuidCreation(#[source] uuid::Error), UuidCreation(#[source] uuid::Error),
} }
+18 -11
View File
@@ -442,14 +442,14 @@ dependencies = [
[[package]] [[package]]
name = "getrandom" name = "getrandom"
version = "0.3.1" version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "43a49c392881ce6d5c3b8cb70f98717b7c07aabbdff06687b9030dbfbe2725f8" checksum = "26145e563e54f2cadc477553f1ec5ee650b00862f0a58bcd12cbdc5f0ea2d2f4"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"libc", "libc",
"wasi 0.13.3+wasi-0.2.2", "r-efi",
"windows-targets", "wasi 0.14.2+wasi-0.2.4",
] ]
[[package]] [[package]]
@@ -678,7 +678,7 @@ name = "net_util"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"epoll", "epoll",
"getrandom 0.3.1", "getrandom 0.3.3",
"libc", "libc",
"log", "log",
"net_gen", "net_gen",
@@ -818,6 +818,12 @@ dependencies = [
"proc-macro2", "proc-macro2",
] ]
[[package]]
name = "r-efi"
version = "5.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "74765f6d916ee2faa39bc8e68e4f3ed8949b48cccdac59983d287a7cb71ce9c5"
[[package]] [[package]]
name = "rand" name = "rand"
version = "0.9.0" version = "0.9.0"
@@ -845,7 +851,7 @@ version = "0.9.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "99d9a13982dcf210057a8a78572b2217b667c3beacbf3a0d8b454f6f82837d38" checksum = "99d9a13982dcf210057a8a78572b2217b667c3beacbf3a0d8b454f6f82837d38"
dependencies = [ dependencies = [
"getrandom 0.3.1", "getrandom 0.3.3",
] ]
[[package]] [[package]]
@@ -1106,7 +1112,7 @@ version = "1.15.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e0f540e3240398cce6128b64ba83fdbdd86129c16a3aa1a3a252efd66eb3d587" checksum = "e0f540e3240398cce6128b64ba83fdbdd86129c16a3aa1a3a252efd66eb3d587"
dependencies = [ dependencies = [
"getrandom 0.3.1", "getrandom 0.3.3",
"rand", "rand",
"uuid-macro-internal", "uuid-macro-internal",
] ]
@@ -1324,6 +1330,7 @@ dependencies = [
"uuid", "uuid",
"vfio-ioctls", "vfio-ioctls",
"vfio_user", "vfio_user",
"virtio-bindings",
"virtio-devices", "virtio-devices",
"virtio-queue", "virtio-queue",
"vm-allocator", "vm-allocator",
@@ -1355,9 +1362,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
[[package]] [[package]]
name = "wasi" name = "wasi"
version = "0.13.3+wasi-0.2.2" version = "0.14.2+wasi-0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "26816d2e1a4a36a2940b96c5296ce403917633dff8f3440e9b236ed6f6bacad2" checksum = "9683f9a5a998d873c0d21fcbe3c083009670149a8fab228644b8bd36b2c48cb3"
dependencies = [ dependencies = [
"wit-bindgen-rt", "wit-bindgen-rt",
] ]
@@ -1523,9 +1530,9 @@ dependencies = [
[[package]] [[package]]
name = "wit-bindgen-rt" name = "wit-bindgen-rt"
version = "0.33.0" version = "0.39.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3268f3d866458b787f390cf61f4bbb563b922d091359f9608842999eaee3943c" checksum = "6f42320e61fe2cfd34354ecb597f86f413484a798ba44a8ca1165c58d42da6c1"
dependencies = [ dependencies = [
"bitflags 2.9.0", "bitflags 2.9.0",
] ]