From ea6d5a04fa1d32afb2a75934dcfc734553752354 Mon Sep 17 00:00:00 2001 From: Philipp Schuster Date: Wed, 21 May 2025 13:32:58 +0200 Subject: [PATCH] misc: net_util: streamline #[source] and Error impl This streamlines the Error implementation in the Cloud Hypervisor code base to match the remaining parts so that everything follows the agreed conventions. These are leftovers missed in the previous commits. Signed-off-by: Philipp Schuster On-behalf-of: SAP philipp.schuster@sap.com --- net_util/src/ctrl_queue.rs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/net_util/src/ctrl_queue.rs b/net_util/src/ctrl_queue.rs index 46915b732..c9e2e366e 100644 --- a/net_util/src/ctrl_queue.rs +++ b/net_util/src/ctrl_queue.rs @@ -5,6 +5,7 @@ use std::sync::Arc; use libc::c_uint; +use thiserror::Error; use virtio_bindings::virtio_net::{ VIRTIO_NET_CTRL_GUEST_OFFLOADS, VIRTIO_NET_CTRL_GUEST_OFFLOADS_SET, VIRTIO_NET_CTRL_MQ, VIRTIO_NET_CTRL_MQ_VQ_PAIRS_MAX, VIRTIO_NET_CTRL_MQ_VQ_PAIRS_MIN, @@ -18,22 +19,29 @@ use vm_virtio::{AccessPlatform, Translatable}; use crate::{GuestMemoryMmap, Tap}; -#[derive(Debug)] +#[derive(Error, Debug)] pub enum Error { /// Read queue failed. - GuestMemory(GuestMemoryError), + #[error("Read queue failed")] + GuestMemory(#[source] GuestMemoryError), /// No control header descriptor + #[error("No control header descriptor")] NoControlHeaderDescriptor, /// Missing the data descriptor in the chain. + #[error("Missing the data descriptor in the chain")] NoDataDescriptor, /// No status descriptor + #[error("No status descriptor")] NoStatusDescriptor, /// Failed adding used index - QueueAddUsed(virtio_queue::Error), + #[error("Failed adding used index")] + QueueAddUsed(#[source] virtio_queue::Error), /// Failed creating an iterator over the queue - QueueIterator(virtio_queue::Error), + #[error("Failed creating an iterator over the queue")] + QueueIterator(#[source] virtio_queue::Error), /// Failed enabling notification for the queue - QueueEnableNotification(virtio_queue::Error), + #[error("Failed enabling notification for the queue")] + QueueEnableNotification(#[source] virtio_queue::Error), } type Result = std::result::Result;