misc: arch/riscv64: streamline #[source] and Error
This streamlines the code base to follow best practices for error handling in Rust: Each error struct implements std::error::Error (most due via thiserror::Error derive macro) and sets its source accordingly. This allows future work that nicely prints the error chains, for example. So far, the convention is that each error prints its sub error as part of its Display::fmt() impl. Signed-off-by: Philipp Schuster <philipp.schuster@cyberus-technology.de> On-behalf-of: SAP philipp.schuster@sap.com
This commit is contained in:
parent
d1a406143d
commit
a212343908
17 changed files with 179 additions and 174 deletions
|
|
@ -55,7 +55,7 @@ pub trait DeviceInfoForFdt {
|
|||
pub enum Error {
|
||||
/// Failure in writing FDT in memory.
|
||||
#[error("Failure in writing FDT in memory: {0}")]
|
||||
WriteFdtToMemory(GuestMemoryError),
|
||||
WriteFdtToMemory(#[source] GuestMemoryError),
|
||||
}
|
||||
type Result<T> = result::Result<T, Error>;
|
||||
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ pub enum Error {
|
|||
|
||||
/// Failed to write FDT to memory.
|
||||
#[error("Failed to write FDT to memory: {0}")]
|
||||
WriteFdtToMemory(fdt::Error),
|
||||
WriteFdtToMemory(#[source] fdt::Error),
|
||||
|
||||
/// Failed to create a AIA.
|
||||
#[error("Failed to create a AIA")]
|
||||
|
|
@ -43,7 +43,7 @@ pub enum Error {
|
|||
|
||||
/// Error configuring the general purpose registers
|
||||
#[error("Error configuring the general purpose registers: {0}")]
|
||||
RegsConfiguration(hypervisor::HypervisorCpuError),
|
||||
RegsConfiguration(#[source] hypervisor::HypervisorCpuError),
|
||||
}
|
||||
|
||||
impl From<Error> for super::Error {
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ use std::{io, result};
|
|||
|
||||
use byteorder::{ByteOrder, LittleEndian};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use thiserror::Error;
|
||||
use vm_device::interrupt::{
|
||||
InterruptIndex, InterruptSourceConfig, InterruptSourceGroup, MsiIrqSourceConfig,
|
||||
};
|
||||
|
|
@ -27,12 +28,14 @@ const MSIX_ENABLE_MASK: u16 = (1 << MSIX_ENABLE_BIT) as u16;
|
|||
pub const MSIX_TABLE_ENTRY_SIZE: usize = 16;
|
||||
pub const MSIX_CONFIG_ID: &str = "msix_config";
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Error, Debug)]
|
||||
pub enum Error {
|
||||
/// Failed enabling the interrupt route.
|
||||
EnableInterruptRoute(io::Error),
|
||||
#[error("Failed enabling the interrupt route: {0}")]
|
||||
EnableInterruptRoute(#[source] io::Error),
|
||||
/// Failed updating the interrupt route.
|
||||
UpdateInterruptRoute(io::Error),
|
||||
#[error("Failed updating the interrupt route: {0}")]
|
||||
UpdateInterruptRoute(#[source] io::Error),
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq)]
|
||||
|
|
|
|||
24
src/main.rs
24
src/main.rs
|
|
@ -52,23 +52,23 @@ enum Error {
|
|||
#[error("Failed to start the VMM thread: {0}")]
|
||||
StartVmmThread(#[source] vmm::Error),
|
||||
#[error("Error parsing config: {0}")]
|
||||
ParsingConfig(vmm::config::Error),
|
||||
ParsingConfig(#[source] vmm::config::Error),
|
||||
#[error("Error creating VM: {0:?}")]
|
||||
VmCreate(vmm::api::ApiError),
|
||||
VmCreate(#[source] vmm::api::ApiError),
|
||||
#[error("Error booting VM: {0:?}")]
|
||||
VmBoot(vmm::api::ApiError),
|
||||
VmBoot(#[source] vmm::api::ApiError),
|
||||
#[error("Error restoring VM: {0:?}")]
|
||||
VmRestore(vmm::api::ApiError),
|
||||
VmRestore(#[source] vmm::api::ApiError),
|
||||
#[error("Error parsing restore: {0}")]
|
||||
ParsingRestore(vmm::config::Error),
|
||||
ParsingRestore(#[source] vmm::config::Error),
|
||||
#[error("Failed to join on VMM thread: {0:?}")]
|
||||
ThreadJoin(std::boxed::Box<dyn std::any::Any + std::marker::Send>),
|
||||
#[error("VMM thread exited with error: {0}")]
|
||||
VmmThread(#[source] vmm::Error),
|
||||
#[error("Error parsing --api-socket: {0}")]
|
||||
ParsingApiSocket(std::num::ParseIntError),
|
||||
ParsingApiSocket(#[source] std::num::ParseIntError),
|
||||
#[error("Error parsing --event-monitor: {0}")]
|
||||
ParsingEventMonitor(option_parser::OptionParserError),
|
||||
ParsingEventMonitor(#[source] option_parser::OptionParserError),
|
||||
#[cfg(feature = "dbus_api")]
|
||||
#[error("`--dbus-object-path` option isn't provided")]
|
||||
MissingDBusObjectPath,
|
||||
|
|
@ -78,7 +78,7 @@ enum Error {
|
|||
#[error("Error parsing --event-monitor: path or fd required")]
|
||||
BareEventMonitor,
|
||||
#[error("Error doing event monitor I/O: {0}")]
|
||||
EventMonitorIo(std::io::Error),
|
||||
EventMonitorIo(#[source] std::io::Error),
|
||||
#[error("Event monitor thread failed: {0}")]
|
||||
EventMonitorThread(#[source] vmm::Error),
|
||||
#[cfg(feature = "guest_debug")]
|
||||
|
|
@ -102,13 +102,13 @@ enum Error {
|
|||
#[derive(Error, Debug)]
|
||||
enum FdTableError {
|
||||
#[error("Failed to create event fd: {0}")]
|
||||
CreateEventFd(std::io::Error),
|
||||
CreateEventFd(#[source] std::io::Error),
|
||||
#[error("Failed to obtain file limit: {0}")]
|
||||
GetRLimit(std::io::Error),
|
||||
GetRLimit(#[source] std::io::Error),
|
||||
#[error("Error calling fcntl with F_GETFD: {0}")]
|
||||
GetFd(std::io::Error),
|
||||
GetFd(#[source] std::io::Error),
|
||||
#[error("Failed to duplicate file handle: {0}")]
|
||||
Dup2(std::io::Error),
|
||||
Dup2(#[source] std::io::Error),
|
||||
}
|
||||
|
||||
struct Logger {
|
||||
|
|
|
|||
|
|
@ -62,25 +62,25 @@ pub const MINIMUM_BLOCK_QUEUE_SIZE: u16 = 2;
|
|||
#[derive(Error, Debug)]
|
||||
pub enum Error {
|
||||
#[error("Failed to parse the request: {0}")]
|
||||
RequestParsing(block::Error),
|
||||
RequestParsing(#[source] block::Error),
|
||||
#[error("Failed to execute the request: {0}")]
|
||||
RequestExecuting(block::ExecuteError),
|
||||
RequestExecuting(#[source] block::ExecuteError),
|
||||
#[error("Failed to complete the request: {0}")]
|
||||
RequestCompleting(block::Error),
|
||||
RequestCompleting(#[source] block::Error),
|
||||
#[error("Missing the expected entry in the list of requests")]
|
||||
MissingEntryRequestList,
|
||||
#[error("The asynchronous request returned with failure")]
|
||||
AsyncRequestFailure,
|
||||
#[error("Failed synchronizing the file: {0}")]
|
||||
Fsync(AsyncIoError),
|
||||
Fsync(#[source] AsyncIoError),
|
||||
#[error("Failed adding used index: {0}")]
|
||||
QueueAddUsed(virtio_queue::Error),
|
||||
QueueAddUsed(#[source] virtio_queue::Error),
|
||||
#[error("Failed creating an iterator over the queue: {0}")]
|
||||
QueueIterator(virtio_queue::Error),
|
||||
QueueIterator(#[source] virtio_queue::Error),
|
||||
#[error("Failed to update request status: {0}")]
|
||||
RequestStatus(GuestMemoryError),
|
||||
RequestStatus(#[source] GuestMemoryError),
|
||||
#[error("Failed to enable notification: {0}")]
|
||||
QueueEnableNotification(virtio_queue::Error),
|
||||
QueueEnableNotification(#[source] virtio_queue::Error),
|
||||
#[error("Failed to get {lock_type:?} lock for disk image {path}: {error}")]
|
||||
LockDiskImage {
|
||||
/// The underlying error.
|
||||
|
|
|
|||
|
|
@ -293,7 +293,7 @@ unsafe impl ByteValued for VirtioIommuFault {}
|
|||
#[derive(Error, Debug)]
|
||||
enum Error {
|
||||
#[error("Guest gave us bad memory addresses: {0}")]
|
||||
GuestMemory(GuestMemoryError),
|
||||
GuestMemory(#[source] GuestMemoryError),
|
||||
#[error("Guest gave us a write only descriptor that protocol says to read from")]
|
||||
UnexpectedWriteOnlyDescriptor,
|
||||
#[error("Guest gave us a read only descriptor that protocol says to write to")]
|
||||
|
|
@ -323,11 +323,11 @@ enum Error {
|
|||
#[error("Guest sent us invalid PROBE request")]
|
||||
InvalidProbeRequest,
|
||||
#[error("Failed to performing external mapping: {0}")]
|
||||
ExternalMapping(io::Error),
|
||||
ExternalMapping(#[source] io::Error),
|
||||
#[error("Failed to performing external unmapping: {0}")]
|
||||
ExternalUnmapping(io::Error),
|
||||
ExternalUnmapping(#[source] io::Error),
|
||||
#[error("Failed adding used index: {0}")]
|
||||
QueueAddUsed(virtio_queue::Error),
|
||||
QueueAddUsed(#[source] virtio_queue::Error),
|
||||
}
|
||||
|
||||
struct Request {}
|
||||
|
|
|
|||
|
|
@ -88,19 +88,19 @@ pub enum ActivateError {
|
|||
#[error("Failed to activate virtio device")]
|
||||
BadActivate,
|
||||
#[error("Failed to clone exit event fd: {0}")]
|
||||
CloneExitEventFd(std::io::Error),
|
||||
CloneExitEventFd(#[source] std::io::Error),
|
||||
#[error("Failed to spawn thread: {0}")]
|
||||
ThreadSpawn(std::io::Error),
|
||||
ThreadSpawn(#[source] std::io::Error),
|
||||
#[error("Failed to setup vhost-user-fs daemon: {0}")]
|
||||
VhostUserFsSetup(vhost_user::Error),
|
||||
VhostUserFsSetup(#[source] vhost_user::Error),
|
||||
#[error("Failed to setup vhost-user daemon: {0}")]
|
||||
VhostUserSetup(vhost_user::Error),
|
||||
VhostUserSetup(#[source] vhost_user::Error),
|
||||
#[error("Failed to create seccomp filter: {0}")]
|
||||
CreateSeccompFilter(seccompiler::Error),
|
||||
CreateSeccompFilter(#[source] seccompiler::Error),
|
||||
#[error("Failed to create rate limiter: {0}")]
|
||||
CreateRateLimiter(std::io::Error),
|
||||
CreateRateLimiter(#[source] std::io::Error),
|
||||
#[error("Failed to activate the vDPA device: {0}")]
|
||||
ActivateVdpa(vdpa::Error),
|
||||
ActivateVdpa(#[source] vdpa::Error),
|
||||
}
|
||||
|
||||
pub type ActivateResult = std::result::Result<(), ActivateError>;
|
||||
|
|
@ -110,21 +110,21 @@ pub type DeviceEventT = u16;
|
|||
#[derive(Error, Debug)]
|
||||
pub enum Error {
|
||||
#[error("Failed to single used queue: {0}")]
|
||||
FailedSignalingUsedQueue(io::Error),
|
||||
FailedSignalingUsedQueue(#[source] io::Error),
|
||||
#[error("I/O Error: {0}")]
|
||||
IoError(io::Error),
|
||||
IoError(#[source] io::Error),
|
||||
#[error("Failed to update memory vhost-user: {0}")]
|
||||
VhostUserUpdateMemory(vhost_user::Error),
|
||||
VhostUserUpdateMemory(#[source] vhost_user::Error),
|
||||
#[error("Failed to add memory region vhost-user: {0}")]
|
||||
VhostUserAddMemoryRegion(vhost_user::Error),
|
||||
VhostUserAddMemoryRegion(#[source] vhost_user::Error),
|
||||
#[error("Failed to set shared memory region")]
|
||||
SetShmRegionsNotSupported,
|
||||
#[error("Failed to process net queue: {0}")]
|
||||
NetQueuePair(::net_util::NetQueuePairError),
|
||||
NetQueuePair(#[source] ::net_util::NetQueuePairError),
|
||||
#[error("Failed to : {0}")]
|
||||
QueueAddUsed(virtio_queue::Error),
|
||||
QueueAddUsed(#[source] virtio_queue::Error),
|
||||
#[error("Failed to : {0}")]
|
||||
QueueIterator(virtio_queue::Error),
|
||||
QueueIterator(#[source] virtio_queue::Error),
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Default, Deserialize, Serialize, PartialEq, Eq)]
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@ const VIRTIO_MEM_F_ACPI_PXM: u8 = 0;
|
|||
#[derive(Error, Debug)]
|
||||
pub enum Error {
|
||||
#[error("Guest gave us bad memory addresses: {0}")]
|
||||
GuestMemory(GuestMemoryError),
|
||||
GuestMemory(#[source] GuestMemoryError),
|
||||
#[error("Guest gave us a write only descriptor that protocol says to read from")]
|
||||
UnexpectedWriteOnlyDescriptor,
|
||||
#[error("Guest gave us a read only descriptor that protocol says to write to")]
|
||||
|
|
@ -114,23 +114,23 @@ pub enum Error {
|
|||
#[error("Guest sent us invalid request")]
|
||||
InvalidRequest,
|
||||
#[error("Failed to EventFd write: {0}")]
|
||||
EventFdWriteFail(std::io::Error),
|
||||
EventFdWriteFail(#[source] std::io::Error),
|
||||
#[error("Failed to EventFd try_clone: {0}")]
|
||||
EventFdTryCloneFail(std::io::Error),
|
||||
EventFdTryCloneFail(#[source] std::io::Error),
|
||||
#[error("Failed to MpscRecv: {0}")]
|
||||
MpscRecvFail(mpsc::RecvError),
|
||||
MpscRecvFail(#[source] mpsc::RecvError),
|
||||
#[error("Resize invalid argument: {0}")]
|
||||
ResizeError(anyhow::Error),
|
||||
ResizeError(#[source] anyhow::Error),
|
||||
#[error("Fail to resize trigger: {0}")]
|
||||
ResizeTriggerFail(DeviceError),
|
||||
ResizeTriggerFail(#[source] DeviceError),
|
||||
#[error("Invalid configuration: {0}")]
|
||||
ValidateError(anyhow::Error),
|
||||
ValidateError(#[source] anyhow::Error),
|
||||
#[error("Failed discarding memory range: {0}")]
|
||||
DiscardMemoryRange(std::io::Error),
|
||||
DiscardMemoryRange(#[source] std::io::Error),
|
||||
#[error("Failed DMA mapping: {0}")]
|
||||
DmaMap(std::io::Error),
|
||||
DmaMap(#[source] std::io::Error),
|
||||
#[error("Failed DMA unmapping: {0}")]
|
||||
DmaUnmap(std::io::Error),
|
||||
DmaUnmap(#[source] std::io::Error),
|
||||
#[error("Invalid DMA mapping handler")]
|
||||
InvalidDmaMappingHandler,
|
||||
#[error("Not activated by the guest")]
|
||||
|
|
@ -138,7 +138,7 @@ pub enum Error {
|
|||
#[error("Unknown request type: {0}")]
|
||||
UnknownRequestType(u16),
|
||||
#[error("Failed adding used index: {0}")]
|
||||
QueueAddUsed(virtio_queue::Error),
|
||||
QueueAddUsed(#[source] virtio_queue::Error),
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
|
|
|
|||
|
|
@ -154,11 +154,11 @@ pub const TX_RATE_LIMITER_EVENT: u16 = EPOLL_HELPER_EVENT_LAST + 6;
|
|||
#[derive(Error, Debug)]
|
||||
pub enum Error {
|
||||
#[error("Failed to open taps: {0}")]
|
||||
OpenTap(OpenTapError),
|
||||
OpenTap(#[source] OpenTapError),
|
||||
#[error("Using existing tap: {0}")]
|
||||
TapError(TapError),
|
||||
TapError(#[source] TapError),
|
||||
#[error("Error calling dup() on tap fd: {0}")]
|
||||
DuplicateTapFd(std::io::Error),
|
||||
DuplicateTapFd(#[source] std::io::Error),
|
||||
}
|
||||
|
||||
pub type Result<T> = result::Result<T, Error>;
|
||||
|
|
|
|||
|
|
@ -32,59 +32,59 @@ use crate::{
|
|||
#[derive(Error, Debug)]
|
||||
pub enum Error {
|
||||
#[error("Failed to create vhost-vdpa: {0}")]
|
||||
CreateVhostVdpa(vhost::Error),
|
||||
CreateVhostVdpa(#[source] vhost::Error),
|
||||
#[error("Failed to map DMA range: {0}")]
|
||||
DmaMap(vhost::Error),
|
||||
DmaMap(#[source] vhost::Error),
|
||||
#[error("Failed to unmap DMA range: {0}")]
|
||||
DmaUnmap(vhost::Error),
|
||||
DmaUnmap(#[source] vhost::Error),
|
||||
#[error("Failed to get address range")]
|
||||
GetAddressRange,
|
||||
#[error("Failed to get the available index from the virtio queue: {0}")]
|
||||
GetAvailableIndex(virtio_queue::Error),
|
||||
GetAvailableIndex(#[source] virtio_queue::Error),
|
||||
#[error("Get virtio configuration size: {0}")]
|
||||
GetConfigSize(vhost::Error),
|
||||
GetConfigSize(#[source] vhost::Error),
|
||||
#[error("Get virtio device identifier: {0}")]
|
||||
GetDeviceId(vhost::Error),
|
||||
GetDeviceId(#[source] vhost::Error),
|
||||
#[error("Failed to get backend specific features: {0}")]
|
||||
GetBackendFeatures(vhost::Error),
|
||||
GetBackendFeatures(#[source] vhost::Error),
|
||||
#[error("Failed to get virtio features: {0}")]
|
||||
GetFeatures(vhost::Error),
|
||||
GetFeatures(#[source] vhost::Error),
|
||||
#[error("Failed to get the IOVA range: {0}")]
|
||||
GetIovaRange(vhost::Error),
|
||||
GetIovaRange(#[source] vhost::Error),
|
||||
#[error("Failed to get queue size: {0}")]
|
||||
GetVringNum(vhost::Error),
|
||||
GetVringNum(#[source] vhost::Error),
|
||||
#[error("Invalid IOVA range: {0}-{1}")]
|
||||
InvalidIovaRange(u64, u64),
|
||||
#[error("Missing VIRTIO_F_ACCESS_PLATFORM feature")]
|
||||
MissingAccessPlatformVirtioFeature,
|
||||
#[error("Failed to reset owner: {0}")]
|
||||
ResetOwner(vhost::Error),
|
||||
ResetOwner(#[source] vhost::Error),
|
||||
#[error("Failed to set backend specific features: {0}")]
|
||||
SetBackendFeatures(vhost::Error),
|
||||
SetBackendFeatures(#[source] vhost::Error),
|
||||
#[error("Failed to set backend configuration: {0}")]
|
||||
SetConfig(vhost::Error),
|
||||
SetConfig(#[source] vhost::Error),
|
||||
#[error("Failed to set eventfd notifying about a configuration change: {0}")]
|
||||
SetConfigCall(vhost::Error),
|
||||
SetConfigCall(#[source] vhost::Error),
|
||||
#[error("Failed to set virtio features: {0}")]
|
||||
SetFeatures(vhost::Error),
|
||||
SetFeatures(#[source] vhost::Error),
|
||||
#[error("Failed to set memory table: {0}")]
|
||||
SetMemTable(vhost::Error),
|
||||
SetMemTable(#[source] vhost::Error),
|
||||
#[error("Failed to set owner: {0}")]
|
||||
SetOwner(vhost::Error),
|
||||
SetOwner(#[source] vhost::Error),
|
||||
#[error("Failed to set virtio status: {0}")]
|
||||
SetStatus(vhost::Error),
|
||||
SetStatus(#[source] vhost::Error),
|
||||
#[error("Failed to set vring address: {0}")]
|
||||
SetVringAddr(vhost::Error),
|
||||
SetVringAddr(#[source] vhost::Error),
|
||||
#[error("Failed to set vring base: {0}")]
|
||||
SetVringBase(vhost::Error),
|
||||
SetVringBase(#[source] vhost::Error),
|
||||
#[error("Failed to set vring eventfd when buffer are used: {0}")]
|
||||
SetVringCall(vhost::Error),
|
||||
SetVringCall(#[source] vhost::Error),
|
||||
#[error("Failed to enable/disable vring: {0}")]
|
||||
SetVringEnable(vhost::Error),
|
||||
SetVringEnable(#[source] vhost::Error),
|
||||
#[error("Failed to set vring eventfd when new descriptors are available: {0}")]
|
||||
SetVringKick(vhost::Error),
|
||||
SetVringKick(#[source] vhost::Error),
|
||||
#[error("Failed to set vring size: {0}")]
|
||||
SetVringNum(vhost::Error),
|
||||
SetVringNum(#[source] vhost::Error),
|
||||
}
|
||||
|
||||
pub type Result<T> = std::result::Result<T, Error>;
|
||||
|
|
|
|||
|
|
@ -43,85 +43,85 @@ pub use self::vu_common_ctrl::VhostUserConfig;
|
|||
#[derive(Error, Debug)]
|
||||
pub enum Error {
|
||||
#[error("Failed accepting connection: {0}")]
|
||||
AcceptConnection(io::Error),
|
||||
AcceptConnection(#[source] io::Error),
|
||||
#[error("Invalid available address")]
|
||||
AvailAddress,
|
||||
#[error("Queue number is not correct")]
|
||||
BadQueueNum,
|
||||
#[error("Failed binding vhost-user socket: {0}")]
|
||||
BindSocket(io::Error),
|
||||
BindSocket(#[source] io::Error),
|
||||
#[error("Creating kill eventfd failed: {0}")]
|
||||
CreateKillEventFd(io::Error),
|
||||
CreateKillEventFd(#[source] io::Error),
|
||||
#[error("Cloning kill eventfd failed: {0}")]
|
||||
CloneKillEventFd(io::Error),
|
||||
CloneKillEventFd(#[source] io::Error),
|
||||
#[error("Invalid descriptor table address")]
|
||||
DescriptorTableAddress,
|
||||
#[error("Signal used queue failed: {0}")]
|
||||
FailedSignalingUsedQueue(io::Error),
|
||||
FailedSignalingUsedQueue(#[source] io::Error),
|
||||
#[error("Failed to read vhost eventfd: {0}")]
|
||||
MemoryRegions(MmapError),
|
||||
MemoryRegions(#[source] MmapError),
|
||||
#[error("Failed removing socket path: {0}")]
|
||||
RemoveSocketPath(io::Error),
|
||||
RemoveSocketPath(#[source] io::Error),
|
||||
#[error("Failed to create frontend: {0}")]
|
||||
VhostUserCreateFrontend(VhostError),
|
||||
VhostUserCreateFrontend(#[source] VhostError),
|
||||
#[error("Failed to open vhost device: {0}")]
|
||||
VhostUserOpen(VhostError),
|
||||
VhostUserOpen(#[source] VhostError),
|
||||
#[error("Connection to socket failed")]
|
||||
VhostUserConnect,
|
||||
#[error("Get features failed: {0}")]
|
||||
VhostUserGetFeatures(VhostError),
|
||||
VhostUserGetFeatures(#[source] VhostError),
|
||||
#[error("Get queue max number failed: {0}")]
|
||||
VhostUserGetQueueMaxNum(VhostError),
|
||||
VhostUserGetQueueMaxNum(#[source] VhostError),
|
||||
#[error("Get protocol features failed: {0}")]
|
||||
VhostUserGetProtocolFeatures(VhostError),
|
||||
VhostUserGetProtocolFeatures(#[source] VhostError),
|
||||
#[error("Get vring base failed: {0}")]
|
||||
VhostUserGetVringBase(VhostError),
|
||||
VhostUserGetVringBase(#[source] VhostError),
|
||||
#[error("Vhost-user Backend not support vhost-user protocol")]
|
||||
VhostUserProtocolNotSupport,
|
||||
#[error("Set owner failed: {0}")]
|
||||
VhostUserSetOwner(VhostError),
|
||||
VhostUserSetOwner(#[source] VhostError),
|
||||
#[error("Reset owner failed: {0}")]
|
||||
VhostUserResetOwner(VhostError),
|
||||
VhostUserResetOwner(#[source] VhostError),
|
||||
#[error("Set features failed: {0}")]
|
||||
VhostUserSetFeatures(VhostError),
|
||||
VhostUserSetFeatures(#[source] VhostError),
|
||||
#[error("Set protocol features failed: {0}")]
|
||||
VhostUserSetProtocolFeatures(VhostError),
|
||||
VhostUserSetProtocolFeatures(#[source] VhostError),
|
||||
#[error("Set mem table failed: {0}")]
|
||||
VhostUserSetMemTable(VhostError),
|
||||
VhostUserSetMemTable(#[source] VhostError),
|
||||
#[error("Set vring num failed: {0}")]
|
||||
VhostUserSetVringNum(VhostError),
|
||||
VhostUserSetVringNum(#[source] VhostError),
|
||||
#[error("Set vring addr failed: {0}")]
|
||||
VhostUserSetVringAddr(VhostError),
|
||||
VhostUserSetVringAddr(#[source] VhostError),
|
||||
#[error("Set vring base failed: {0}")]
|
||||
VhostUserSetVringBase(VhostError),
|
||||
VhostUserSetVringBase(#[source] VhostError),
|
||||
#[error("Set vring call failed: {0}")]
|
||||
VhostUserSetVringCall(VhostError),
|
||||
VhostUserSetVringCall(#[source] VhostError),
|
||||
#[error("Set vring kick failed: {0}")]
|
||||
VhostUserSetVringKick(VhostError),
|
||||
VhostUserSetVringKick(#[source] VhostError),
|
||||
#[error("Set vring enable failed: {0}")]
|
||||
VhostUserSetVringEnable(VhostError),
|
||||
VhostUserSetVringEnable(#[source] VhostError),
|
||||
#[error("Failed to create vhost eventfd: {0}")]
|
||||
VhostIrqCreate(io::Error),
|
||||
VhostIrqCreate(#[source] io::Error),
|
||||
#[error("Failed to read vhost eventfd: {0}")]
|
||||
VhostIrqRead(io::Error),
|
||||
VhostIrqRead(#[source] io::Error),
|
||||
#[error("Failed to read vhost eventfd: {0}")]
|
||||
VhostUserMemoryRegion(MmapError),
|
||||
VhostUserMemoryRegion(#[source] MmapError),
|
||||
#[error("Failed to create the frontend request handler from backend: {0}")]
|
||||
FrontendReqHandlerCreation(vhost::vhost_user::Error),
|
||||
FrontendReqHandlerCreation(#[source] vhost::vhost_user::Error),
|
||||
#[error("Set backend request fd failed: {0}")]
|
||||
VhostUserSetBackendRequestFd(vhost::Error),
|
||||
VhostUserSetBackendRequestFd(#[source] vhost::Error),
|
||||
#[error("Add memory region failed: {0}")]
|
||||
VhostUserAddMemReg(VhostError),
|
||||
VhostUserAddMemReg(#[source] VhostError),
|
||||
#[error("Failed getting the configuration: {0}")]
|
||||
VhostUserGetConfig(VhostError),
|
||||
VhostUserGetConfig(#[source] VhostError),
|
||||
#[error("Failed setting the configuration: {0}")]
|
||||
VhostUserSetConfig(VhostError),
|
||||
VhostUserSetConfig(#[source] VhostError),
|
||||
#[error("Failed getting inflight shm log: {0}")]
|
||||
VhostUserGetInflight(VhostError),
|
||||
VhostUserGetInflight(#[source] VhostError),
|
||||
#[error("Failed setting inflight shm log: {0}")]
|
||||
VhostUserSetInflight(VhostError),
|
||||
VhostUserSetInflight(#[source] VhostError),
|
||||
#[error("Failed setting the log base: {0}")]
|
||||
VhostUserSetLogBase(VhostError),
|
||||
VhostUserSetLogBase(#[source] VhostError),
|
||||
#[error("Invalid used address")]
|
||||
UsedAddress,
|
||||
#[error("Invalid features provided from vhost-user backend")]
|
||||
|
|
@ -131,17 +131,17 @@ pub enum Error {
|
|||
#[error("Missing IrqFd")]
|
||||
MissingIrqFd,
|
||||
#[error("Failed getting the available index: {0}")]
|
||||
GetAvailableIndex(QueueError),
|
||||
GetAvailableIndex(#[source] QueueError),
|
||||
#[error("Migration is not supported by this vhost-user device")]
|
||||
MigrationNotSupported,
|
||||
#[error("Failed creating memfd: {0}")]
|
||||
MemfdCreate(io::Error),
|
||||
MemfdCreate(#[source] io::Error),
|
||||
#[error("Failed truncating the file size to the expected size: {0}")]
|
||||
SetFileSize(io::Error),
|
||||
SetFileSize(#[source] io::Error),
|
||||
#[error("Failed to set the seals on the file: {0}")]
|
||||
SetSeals(io::Error),
|
||||
SetSeals(#[source] io::Error),
|
||||
#[error("Failed creating new mmap region: {0}")]
|
||||
NewMmapRegion(MmapRegionError),
|
||||
NewMmapRegion(#[source] MmapRegionError),
|
||||
#[error("Could not find the shm log region")]
|
||||
MissingShmLogRegion,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,15 +49,15 @@ const WATCHDOG_TIMEOUT: u64 = WATCHDOG_TIMER_INTERVAL as u64 + 5;
|
|||
#[derive(Error, Debug)]
|
||||
enum Error {
|
||||
#[error("Error programming timer fd: {0}")]
|
||||
TimerfdSetup(io::Error),
|
||||
TimerfdSetup(#[source] io::Error),
|
||||
#[error("Descriptor chain too short")]
|
||||
DescriptorChainTooShort,
|
||||
#[error("Failed adding used index: {0}")]
|
||||
QueueAddUsed(virtio_queue::Error),
|
||||
QueueAddUsed(#[source] virtio_queue::Error),
|
||||
#[error("Invalid descriptor")]
|
||||
InvalidDescriptor,
|
||||
#[error("Failed to write to guest memory: {0}")]
|
||||
GuestMemoryWrite(vm_memory::guest_memory::Error),
|
||||
GuestMemoryWrite(#[source] vm_memory::guest_memory::Error),
|
||||
}
|
||||
|
||||
struct WatchdogEpollHandler {
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ use std::sync::mpsc::{channel, RecvError, SendError, Sender};
|
|||
|
||||
use micro_http::Body;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use thiserror::Error;
|
||||
use vm_migration::MigratableError;
|
||||
use vmm_sys_util::eventfd::EventFd;
|
||||
|
||||
|
|
@ -56,10 +57,10 @@ use crate::vm_config::{
|
|||
use crate::Error as VmmError;
|
||||
|
||||
/// API errors are sent back from the VMM API server through the ApiResponse.
|
||||
#[derive(Debug)]
|
||||
#[derive(Error, Debug)]
|
||||
pub enum ApiError {
|
||||
/// Cannot write to EventFd.
|
||||
EventFdWrite(io::Error),
|
||||
EventFdWrite(#[source] io::Error),
|
||||
|
||||
/// API request send error
|
||||
RequestSend(SendError<ApiRequest>),
|
||||
|
|
|
|||
|
|
@ -41,81 +41,81 @@ pub enum Error {
|
|||
/// Missing restore source_url parameter.
|
||||
ParseRestoreSourceUrlMissing,
|
||||
/// Error parsing CPU options
|
||||
ParseCpus(OptionParserError),
|
||||
ParseCpus(#[source] OptionParserError),
|
||||
/// Invalid CPU features
|
||||
InvalidCpuFeatures(String),
|
||||
/// Error parsing memory options
|
||||
ParseMemory(OptionParserError),
|
||||
ParseMemory(#[source] OptionParserError),
|
||||
/// Error parsing memory zone options
|
||||
ParseMemoryZone(OptionParserError),
|
||||
ParseMemoryZone(#[source] OptionParserError),
|
||||
/// Missing 'id' from memory zone
|
||||
ParseMemoryZoneIdMissing,
|
||||
/// Error parsing rate-limiter group options
|
||||
ParseRateLimiterGroup(OptionParserError),
|
||||
ParseRateLimiterGroup(#[source] OptionParserError),
|
||||
/// Error parsing disk options
|
||||
ParseDisk(OptionParserError),
|
||||
ParseDisk(#[source] OptionParserError),
|
||||
/// Error parsing network options
|
||||
ParseNetwork(OptionParserError),
|
||||
ParseNetwork(#[source] OptionParserError),
|
||||
/// Error parsing RNG options
|
||||
ParseRng(OptionParserError),
|
||||
ParseRng(#[source] OptionParserError),
|
||||
/// Error parsing balloon options
|
||||
ParseBalloon(OptionParserError),
|
||||
ParseBalloon(#[source] OptionParserError),
|
||||
/// Error parsing filesystem parameters
|
||||
ParseFileSystem(OptionParserError),
|
||||
ParseFileSystem(#[source] OptionParserError),
|
||||
/// Error parsing persistent memory parameters
|
||||
ParsePersistentMemory(OptionParserError),
|
||||
ParsePersistentMemory(#[source] OptionParserError),
|
||||
/// Failed parsing console
|
||||
ParseConsole(OptionParserError),
|
||||
ParseConsole(#[source] OptionParserError),
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
/// Failed parsing debug-console
|
||||
ParseDebugConsole(OptionParserError),
|
||||
ParseDebugConsole(#[source] OptionParserError),
|
||||
/// No mode given for console
|
||||
ParseConsoleInvalidModeGiven,
|
||||
/// Failed parsing device parameters
|
||||
ParseDevice(OptionParserError),
|
||||
ParseDevice(#[source] OptionParserError),
|
||||
/// Missing path from device,
|
||||
ParseDevicePathMissing,
|
||||
/// Failed parsing vsock parameters
|
||||
ParseVsock(OptionParserError),
|
||||
ParseVsock(#[source] OptionParserError),
|
||||
/// Failed parsing restore parameters
|
||||
ParseRestore(OptionParserError),
|
||||
ParseRestore(#[source] OptionParserError),
|
||||
/// Failed parsing SGX EPC parameters
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
ParseSgxEpc(OptionParserError),
|
||||
ParseSgxEpc(#[source] OptionParserError),
|
||||
/// Missing 'id' from SGX EPC section
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
ParseSgxEpcIdMissing,
|
||||
/// Failed parsing NUMA parameters
|
||||
ParseNuma(OptionParserError),
|
||||
ParseNuma(#[source] OptionParserError),
|
||||
/// Failed validating configuration
|
||||
Validation(ValidationError),
|
||||
Validation(#[source] ValidationError),
|
||||
#[cfg(feature = "sev_snp")]
|
||||
/// Failed parsing SEV-SNP config
|
||||
ParseSevSnp(OptionParserError),
|
||||
ParseSevSnp(#[source] OptionParserError),
|
||||
#[cfg(feature = "tdx")]
|
||||
/// Failed parsing TDX config
|
||||
ParseTdx(OptionParserError),
|
||||
ParseTdx(#[source] OptionParserError),
|
||||
#[cfg(feature = "tdx")]
|
||||
/// No TDX firmware
|
||||
FirmwarePathMissing,
|
||||
/// Failed parsing userspace device
|
||||
ParseUserDevice(OptionParserError),
|
||||
ParseUserDevice(#[source] OptionParserError),
|
||||
/// Missing socket for userspace device
|
||||
ParseUserDeviceSocketMissing,
|
||||
/// Error parsing pci segment options
|
||||
ParsePciSegment(OptionParserError),
|
||||
ParsePciSegment(#[source] OptionParserError),
|
||||
/// Failed parsing platform parameters
|
||||
ParsePlatform(OptionParserError),
|
||||
ParsePlatform(#[source] OptionParserError),
|
||||
/// Failed parsing vDPA device
|
||||
ParseVdpa(OptionParserError),
|
||||
ParseVdpa(#[source] OptionParserError),
|
||||
/// Missing path for vDPA device
|
||||
ParseVdpaPathMissing,
|
||||
/// Failed parsing TPM device
|
||||
ParseTpm(OptionParserError),
|
||||
ParseTpm(#[source] OptionParserError),
|
||||
/// Missing path for TPM device
|
||||
ParseTpmPathMissing,
|
||||
/// Error parsing Landlock rules
|
||||
ParseLandlockRules(OptionParserError),
|
||||
ParseLandlockRules(#[source] OptionParserError),
|
||||
/// Missing fields in Landlock rules
|
||||
ParseLandlockMissingFields,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -204,7 +204,7 @@ pub enum Error {
|
|||
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
#[error("Failed to inject NMI")]
|
||||
NmiError(hypervisor::HypervisorCpuError),
|
||||
NmiError(#[source] hypervisor::HypervisorCpuError),
|
||||
}
|
||||
pub type Result<T> = result::Result<T, Error>;
|
||||
|
||||
|
|
|
|||
|
|
@ -145,15 +145,15 @@ pub enum Error {
|
|||
|
||||
/// Cannot handle the VM STDIN stream
|
||||
#[error("Error handling VM stdin: {0:?}")]
|
||||
Stdin(VmError),
|
||||
Stdin(#[source] VmError),
|
||||
|
||||
/// Cannot handle the VM pty stream
|
||||
#[error("Error handling VM pty: {0:?}")]
|
||||
Pty(VmError),
|
||||
Pty(#[source] VmError),
|
||||
|
||||
/// Cannot reboot the VM
|
||||
#[error("Error rebooting VM: {0:?}")]
|
||||
VmReboot(VmError),
|
||||
VmReboot(#[source] VmError),
|
||||
|
||||
/// Cannot create VMM thread
|
||||
#[error("Error spawning VMM thread {0:?}")]
|
||||
|
|
@ -161,22 +161,23 @@ pub enum Error {
|
|||
|
||||
/// Cannot shut the VMM down
|
||||
#[error("Error shutting down VMM: {0:?}")]
|
||||
VmmShutdown(VmError),
|
||||
VmmShutdown(#[source] VmError),
|
||||
|
||||
/// Cannot create seccomp filter
|
||||
#[error("Error creating seccomp filter: {0}")]
|
||||
CreateSeccompFilter(seccompiler::Error),
|
||||
CreateSeccompFilter(#[source] seccompiler::Error),
|
||||
|
||||
/// Cannot apply seccomp filter
|
||||
#[error("Error applying seccomp filter: {0}")]
|
||||
ApplySeccompFilter(seccompiler::Error),
|
||||
ApplySeccompFilter(#[source] seccompiler::Error),
|
||||
|
||||
/// Error activating virtio devices
|
||||
#[error("Error activating virtio devices: {0:?}")]
|
||||
ActivateVirtioDevices(VmError),
|
||||
ActivateVirtioDevices(#[source] VmError),
|
||||
|
||||
/// Error creating API server
|
||||
#[error("Error creating API server {0:?}")]
|
||||
// TODO #[source] once the type implements Error
|
||||
CreateApiServer(micro_http::ServerError),
|
||||
|
||||
/// Error binding API server socket
|
||||
|
|
@ -185,7 +186,7 @@ pub enum Error {
|
|||
|
||||
#[cfg(feature = "guest_debug")]
|
||||
#[error("Failed to start the GDB thread: {0}")]
|
||||
GdbThreadSpawn(io::Error),
|
||||
GdbThreadSpawn(#[source] io::Error),
|
||||
|
||||
/// GDB request receive error
|
||||
#[cfg(feature = "guest_debug")]
|
||||
|
|
@ -205,11 +206,11 @@ pub enum Error {
|
|||
|
||||
/// Cannot create Landlock object
|
||||
#[error("Error creating landlock object: {0}")]
|
||||
CreateLandlock(LandlockError),
|
||||
CreateLandlock(#[source] LandlockError),
|
||||
|
||||
/// Cannot apply landlock based sandboxing
|
||||
#[error("Error applying landlock: {0}")]
|
||||
ApplyLandlock(LandlockError),
|
||||
ApplyLandlock(#[source] LandlockError),
|
||||
}
|
||||
pub type Result<T> = result::Result<T, Error>;
|
||||
|
||||
|
|
|
|||
|
|
@ -142,10 +142,10 @@ pub enum Error {
|
|||
PoisonedState,
|
||||
|
||||
#[error("Error from device manager: {0:?}")]
|
||||
DeviceManager(DeviceManagerError),
|
||||
DeviceManager(#[source] DeviceManagerError),
|
||||
|
||||
#[error("Error initializing VM: {0:?}")]
|
||||
InitializeVm(hypervisor::HypervisorVmError),
|
||||
InitializeVm(#[source] hypervisor::HypervisorVmError),
|
||||
|
||||
#[error("No device with id {0:?} to remove")]
|
||||
NoDeviceToRemove(String),
|
||||
|
|
@ -196,7 +196,7 @@ pub enum Error {
|
|||
Resume(#[source] MigratableError),
|
||||
|
||||
#[error("Memory manager error: {0:?}")]
|
||||
MemoryManager(MemoryManagerError),
|
||||
MemoryManager(#[source] MemoryManagerError),
|
||||
|
||||
#[error("Eventfd write error: {0}")]
|
||||
EventfdError(#[source] std::io::Error),
|
||||
|
|
@ -235,16 +235,16 @@ pub enum Error {
|
|||
ResizeZone,
|
||||
|
||||
#[error("Cannot activate virtio devices: {0:?}")]
|
||||
ActivateVirtioDevices(DeviceManagerError),
|
||||
ActivateVirtioDevices(#[source] DeviceManagerError),
|
||||
|
||||
#[error("Error triggering power button: {0:?}")]
|
||||
PowerButton(DeviceManagerError),
|
||||
PowerButton(#[source] DeviceManagerError),
|
||||
|
||||
#[error("Kernel lacks PVH header")]
|
||||
KernelMissingPvhHeader,
|
||||
|
||||
#[error("Failed to allocate firmware RAM: {0:?}")]
|
||||
AllocateFirmwareMemory(MemoryManagerError),
|
||||
AllocateFirmwareMemory(#[source] MemoryManagerError),
|
||||
|
||||
#[error("Error manipulating firmware file: {0}")]
|
||||
FirmwareFile(#[source] std::io::Error),
|
||||
|
|
@ -304,7 +304,7 @@ pub enum Error {
|
|||
Debug(DebuggableError),
|
||||
|
||||
#[error("Error spawning kernel loading thread")]
|
||||
KernelLoadThreadSpawn(std::io::Error),
|
||||
KernelLoadThreadSpawn(#[source] std::io::Error),
|
||||
|
||||
#[error("Error joining kernel loading thread")]
|
||||
KernelLoadThreadJoin(std::boxed::Box<dyn std::any::Any + std::marker::Send>),
|
||||
|
|
@ -314,7 +314,7 @@ pub enum Error {
|
|||
|
||||
#[cfg(all(target_arch = "x86_64", feature = "guest_debug"))]
|
||||
#[error("Error coredumping VM: {0:?}")]
|
||||
Coredump(GuestDebuggableError),
|
||||
Coredump(#[source] GuestDebuggableError),
|
||||
|
||||
#[cfg(feature = "igvm")]
|
||||
#[error("Cannot open igvm file: {0}")]
|
||||
|
|
@ -331,10 +331,10 @@ pub enum Error {
|
|||
ResumeVm(#[source] hypervisor::HypervisorVmError),
|
||||
|
||||
#[error("Error creating console devices")]
|
||||
CreateConsoleDevices(ConsoleDeviceError),
|
||||
CreateConsoleDevices(#[source] ConsoleDeviceError),
|
||||
|
||||
#[error("Error locking disk images: Another instance likely holds a lock")]
|
||||
LockingError(DeviceManagerError),
|
||||
LockingError(#[source] DeviceManagerError),
|
||||
}
|
||||
pub type Result<T> = result::Result<T, Error>;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue