mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-10-01 02:55:45 +00:00
arch: Improve arch::Error
Remove unused error enum entries, improve wording and derive thiserror::Error. Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
parent
1c786610b7
commit
47529796d0
@ -50,7 +50,7 @@ pub enum Error {
|
|||||||
|
|
||||||
impl From<Error> for super::Error {
|
impl From<Error> for super::Error {
|
||||||
fn from(e: Error) -> super::Error {
|
fn from(e: Error) -> super::Error {
|
||||||
super::Error::AArch64Setup(e)
|
super::Error::PlatformSpecific(e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -185,10 +185,10 @@ pub fn initramfs_load_addr(
|
|||||||
if guest_mem.address_in_range(offset) {
|
if guest_mem.address_in_range(offset) {
|
||||||
Ok(offset.raw_value())
|
Ok(offset.raw_value())
|
||||||
} else {
|
} else {
|
||||||
Err(super::Error::AArch64Setup(Error::InitramfsAddress))
|
Err(super::Error::PlatformSpecific(Error::InitramfsAddress))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
None => Err(super::Error::AArch64Setup(Error::InitramfsAddress)),
|
None => Err(super::Error::PlatformSpecific(Error::InitramfsAddress)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@ use std::collections::BTreeMap;
|
|||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::result;
|
use std::result;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
use thiserror::Error;
|
||||||
use versionize::{VersionMap, Versionize, VersionizeError, VersionizeResult};
|
use versionize::{VersionMap, Versionize, VersionizeError, VersionizeResult};
|
||||||
use versionize_derive::Versionize;
|
use versionize_derive::Versionize;
|
||||||
use vm_migration::VersionMapped;
|
use vm_migration::VersionMapped;
|
||||||
@ -26,31 +27,27 @@ type GuestMemoryMmap = vm_memory::GuestMemoryMmap<vm_memory::bitmap::AtomicBitma
|
|||||||
type GuestRegionMmap = vm_memory::GuestRegionMmap<vm_memory::bitmap::AtomicBitmap>;
|
type GuestRegionMmap = vm_memory::GuestRegionMmap<vm_memory::bitmap::AtomicBitmap>;
|
||||||
|
|
||||||
/// Type for returning error code.
|
/// Type for returning error code.
|
||||||
#[derive(Debug)]
|
#[derive(Debug, Error)]
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
#[cfg(target_arch = "x86_64")]
|
#[cfg(target_arch = "x86_64")]
|
||||||
/// X86_64 specific error triggered during system configuration.
|
#[error("Platform specific error (x86_64): {0:?}")]
|
||||||
X86_64Setup(x86_64::Error),
|
PlatformSpecific(x86_64::Error),
|
||||||
#[cfg(target_arch = "aarch64")]
|
#[cfg(target_arch = "aarch64")]
|
||||||
/// AArch64 specific error triggered during system configuration.
|
#[error("Platform specific error (aarch64): {0:?}")]
|
||||||
AArch64Setup(aarch64::Error),
|
PlatformSpecific(aarch64::Error),
|
||||||
/// The zero page extends past the end of guest_mem.
|
#[error("The memory map table extends past the end of guest memory")]
|
||||||
ZeroPagePastRamEnd,
|
|
||||||
/// Error writing the zero page of guest memory.
|
|
||||||
ZeroPageSetup(vm_memory::GuestMemoryError),
|
|
||||||
/// The memory map table extends past the end of guest memory.
|
|
||||||
MemmapTablePastRamEnd,
|
MemmapTablePastRamEnd,
|
||||||
/// Error writing memory map table to guest memory.
|
#[error("Error writing memory map table to guest memory")]
|
||||||
MemmapTableSetup,
|
MemmapTableSetup,
|
||||||
/// The hvm_start_info structure extends past the end of guest memory.
|
#[error("The hvm_start_info structure extends past the end of guest memory")]
|
||||||
StartInfoPastRamEnd,
|
StartInfoPastRamEnd,
|
||||||
/// Error writing hvm_start_info to guest memory.
|
#[error("Error writing hvm_start_info to guest memory")]
|
||||||
StartInfoSetup,
|
StartInfoSetup,
|
||||||
/// Failed to compute initramfs address.
|
#[error("Failed to compute initramfs address")]
|
||||||
InitramfsAddress,
|
InitramfsAddress,
|
||||||
/// Error writing module entry to guest memory.
|
#[error("Error writing module entry to guest memory: {0}")]
|
||||||
ModlistSetup(vm_memory::GuestMemoryError),
|
ModlistSetup(#[source] vm_memory::GuestMemoryError),
|
||||||
/// RSDP Beyond Guest Memory
|
#[error("RSDP extends past the end of guest memory")]
|
||||||
RsdpPastRamEnd,
|
RsdpPastRamEnd,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -197,7 +197,7 @@ pub enum Error {
|
|||||||
|
|
||||||
impl From<Error> for super::Error {
|
impl From<Error> for super::Error {
|
||||||
fn from(e: Error) -> super::Error {
|
fn from(e: Error) -> super::Error {
|
||||||
super::Error::X86_64Setup(e)
|
super::Error::PlatformSpecific(e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1180,7 +1180,9 @@ impl Vm {
|
|||||||
self.cpu_manager.lock().unwrap().boot_vcpus() as u64,
|
self.cpu_manager.lock().unwrap().boot_vcpus() as u64,
|
||||||
)
|
)
|
||||||
.map_err(|e| {
|
.map_err(|e| {
|
||||||
Error::ConfigureSystem(arch::Error::AArch64Setup(arch::aarch64::Error::SetupGic(e)))
|
Error::ConfigureSystem(arch::Error::PlatformSpecific(
|
||||||
|
arch::aarch64::Error::SetupGic(e),
|
||||||
|
))
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
// PMU interrupt sticks to PPI, so need to be added by 16 to get real irq number.
|
// PMU interrupt sticks to PPI, so need to be added by 16 to get real irq number.
|
||||||
@ -1190,7 +1192,9 @@ impl Vm {
|
|||||||
.unwrap()
|
.unwrap()
|
||||||
.init_pmu(arch::aarch64::fdt::AARCH64_PMU_IRQ + 16)
|
.init_pmu(arch::aarch64::fdt::AARCH64_PMU_IRQ + 16)
|
||||||
.map_err(|_| {
|
.map_err(|_| {
|
||||||
Error::ConfigureSystem(arch::Error::AArch64Setup(arch::aarch64::Error::VcpuInitPmu))
|
Error::ConfigureSystem(arch::Error::PlatformSpecific(
|
||||||
|
arch::aarch64::Error::VcpuInitPmu,
|
||||||
|
))
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
arch::configure_system(
|
arch::configure_system(
|
||||||
|
Loading…
Reference in New Issue
Block a user