mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
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:
committed by
Rob Bradford
parent
d1a406143d
commit
a212343908
@@ -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,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user