Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 2 additions & 14 deletions crates/vm-bootloader/src/boot_loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,9 @@ pub enum Error {
#[error("Memory overlap")]
MemoryOverlap,
#[error("Layout error, reason: {0}")]
LayoutError(layout::Error),
LayoutError(#[from] layout::Error),
#[error("{0}")]
GenerateDtb(vm_fdt::Error),
}

impl From<layout::Error> for Error {
fn from(err: layout::Error) -> Self {
Error::LayoutError(err)
}
}

impl From<vm_fdt::Error> for Error {
fn from(err: vm_fdt::Error) -> Self {
Error::GenerateDtb(err)
}
GenerateDtb(#[from] vm_fdt::Error),
}

pub type Result<T> = core::result::Result<T, Error>;
Expand Down
6 changes: 0 additions & 6 deletions crates/vm-core/src/arch/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,6 @@ pub enum Error {
DtbAlreadySet,
}

impl From<Error> for crate::error::Error {
fn from(err: Error) -> Self {
crate::error::Error::LayoutError(err)
}
}

pub type Result<T> = core::result::Result<T, Error>;

pub trait MemoryLayout: Clone {
Expand Down
28 changes: 4 additions & 24 deletions crates/vm-core/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,38 +6,18 @@ pub enum Error {
InterruptControllerFailed(String),
#[cfg(feature = "kvm")]
#[error("{0}")]
KvmError(kvm_ioctls::Error),
KvmError(#[from] kvm_ioctls::Error),
#[cfg(feature = "hvp")]
#[error("{0}")]
ApplevisorError(applevisor::error::HypervisorError),
ApplevisorError(#[from] applevisor::error::HypervisorError),
#[error("{0}")]
MemoryError(vm_mm::error::Error),
MemoryError(#[from] vm_mm::error::Error),
#[error("{0}")]
LayoutError(crate::arch::layout::Error),
LayoutError(#[from] crate::arch::layout::Error),
#[error("{0}")]
Internal(String),
#[error("Unknown error: {0}")]
Unknown(String),
}

#[cfg(feature = "kvm")]
impl From<kvm_ioctls::Error> for Error {
fn from(err: kvm_ioctls::Error) -> Self {
Error::KvmError(err)
}
}

#[cfg(feature = "hvp")]
impl From<applevisor::error::HypervisorError> for Error {
fn from(err: applevisor::error::HypervisorError) -> Self {
Error::ApplevisorError(err)
}
}

impl From<vm_mm::error::Error> for Error {
fn from(err: vm_mm::error::Error) -> Self {
Error::MemoryError(err)
}
}

pub type Result<T> = std::result::Result<T, Error>;
32 changes: 4 additions & 28 deletions crates/vm-machine/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
#[derive(Debug, thiserror::Error)]
pub enum Error {
#[error("Platform error: {0}")]
Platform(vm_core::error::Error),
Platform(#[from] vm_core::error::Error),

#[error("No irq_chip is specified")]
NoIrqChipSpecified,

#[error("Device error: {0}")]
Device(vm_core::device::Error),
Device(#[from] vm_core::device::Error),

#[error("Pci device error: {0}")]
PciDevice(vm_pci::error::Error),
PciDevice(#[from] vm_pci::error::Error),

#[error("Failed to init memory, error: {0}")]
InitMemory(String),
Expand All @@ -19,34 +19,10 @@ pub enum Error {
InitIrqchip(String),

#[error("Failed to setup with bootloader, error: {0}")]
Bootloader(vm_bootloader::boot_loader::Error),
Bootloader(#[from] vm_bootloader::boot_loader::Error),

#[error("gdb_stub failed, error: {0}")]
GdbStub(String),
}

impl From<vm_core::error::Error> for Error {
fn from(err: vm_core::error::Error) -> Self {
Error::Platform(err)
}
}

impl From<vm_core::device::Error> for Error {
fn from(err: vm_core::device::Error) -> Self {
Error::Device(err)
}
}

impl From<vm_pci::error::Error> for Error {
fn from(err: vm_pci::error::Error) -> Self {
Error::PciDevice(err)
}
}

impl From<vm_bootloader::boot_loader::Error> for Error {
fn from(err: vm_bootloader::boot_loader::Error) -> Self {
Error::Bootloader(err)
}
}

pub type Result<T> = core::result::Result<T, Error>;
Loading