diff --git a/virtio-devices/src/vsock/unix/mod.rs b/virtio-devices/src/vsock/unix/mod.rs index b83d96c15..4f7bf2175 100644 --- a/virtio-devices/src/vsock/unix/mod.rs +++ b/virtio-devices/src/vsock/unix/mod.rs @@ -13,6 +13,7 @@ mod muxer; mod muxer_killq; mod muxer_rxq; +use thiserror::Error; pub use muxer::VsockMuxer as VsockUnixBackend; pub use Error as VsockUnixError; @@ -27,29 +28,40 @@ mod defs { pub const MUXER_KILLQ_SIZE: usize = 128; } -#[derive(Debug)] +#[derive(Error, Debug)] pub enum Error { /// Error converting from UTF-8 - ConvertFromUtf8(std::str::Utf8Error), + #[error("Error converting from UTF-8: {0}")] + ConvertFromUtf8(#[source] std::str::Utf8Error), /// Error registering a new epoll-listening FD. - EpollAdd(std::io::Error), + #[error("Error registering a new epoll-listening FD: {0}")] + EpollAdd(#[source] std::io::Error), /// Error creating an epoll FD. - EpollFdCreate(std::io::Error), + #[error("Error creating an epoll FD: {0}")] + EpollFdCreate(#[source] std::io::Error), /// The host made an invalid vsock port connection request. + #[error("The host made an invalid vsock port connection request")] InvalidPortRequest, /// Error parsing integer. - ParseInteger(std::num::ParseIntError), + #[error("Error parsing integer: {0}")] + ParseInteger(#[source] std::num::ParseIntError), /// Error reading stream port. - ReadStreamPort(Box), + #[error("Error reading stream port: {0}")] + ReadStreamPort(#[source] Box), /// Error accepting a new connection from the host-side Unix socket. - UnixAccept(std::io::Error), + #[error("Error accepting a new connection from the host-side Unix socket: {0}")] + UnixAccept(#[source] std::io::Error), /// Error binding to the host-side Unix socket. - UnixBind(std::io::Error), + #[error("Error binding to the host-side Unix socket: {0}")] + UnixBind(#[source] std::io::Error), /// Error connecting to a host-side Unix socket. - UnixConnect(std::io::Error), + #[error("Error connecting to a host-side Unix socket: {0}")] + UnixConnect(#[source] std::io::Error), /// Error reading from host-side Unix socket. - UnixRead(std::io::Error), + #[error("Error reading from host-side Unix socket: {0}")] + UnixRead(#[source] std::io::Error), /// Muxer connection limit reached. + #[error("Muxer connection limit reached")] TooManyConnections, } diff --git a/vmm/src/device_manager.rs b/vmm/src/device_manager.rs index cde0a004c..c60f2b33c 100644 --- a/vmm/src/device_manager.rs +++ b/vmm/src/device_manager.rs @@ -216,7 +216,7 @@ pub enum DeviceManagerError { /// Cannot create virtio-vsock backend #[error("Cannot create virtio-vsock backend")] - CreateVsockBackend(virtio_devices::vsock::VsockUnixError), + CreateVsockBackend(#[source] virtio_devices::vsock::VsockUnixError), /// Cannot create virtio-iommu device #[error("Cannot create virtio-iommu device: {0}")]