misc: net_util: streamline error Display::fmt()

The changes were mostly automatically applied using the Python
script mentioned in the first commit of this series.

Signed-off-by: Philipp Schuster <philipp.schuster@cyberus-technology.de>
On-behalf-of: SAP philipp.schuster@sap.com
This commit is contained in:
Philipp Schuster
2025-05-21 12:32:04 +02:00
committed by Rob Bradford
parent 72c8178335
commit 67896333e3
4 changed files with 24 additions and 24 deletions
+1 -1
View File
@@ -40,7 +40,7 @@ pub use tap::{Error as TapError, Tap};
#[derive(Error, Debug)] #[derive(Error, Debug)]
pub enum Error { pub enum Error {
#[error("Failed to create a socket: {0}")] #[error("Failed to create a socket")]
CreateSocket(#[source] IoError), CreateSocket(#[source] IoError),
} }
+9 -9
View File
@@ -12,27 +12,27 @@ use super::{vnet_hdr_len, MacAddr, Tap, TapError};
#[derive(Error, Debug)] #[derive(Error, Debug)]
pub enum Error { pub enum Error {
#[error("Failed to convert an hexadecimal string into an integer: {0}")] #[error("Failed to convert an hexadecimal string into an integer")]
ConvertHexStringToInt(#[source] std::num::ParseIntError), ConvertHexStringToInt(#[source] std::num::ParseIntError),
#[error("Error related to the multiqueue support (no support TAP side)")] #[error("Error related to the multiqueue support (no support TAP side)")]
MultiQueueNoTapSupport, MultiQueueNoTapSupport,
#[error("Error related to the multiqueue support (no support device side)")] #[error("Error related to the multiqueue support (no support device side)")]
MultiQueueNoDeviceSupport, MultiQueueNoDeviceSupport,
#[error("Failed to read the TAP flags from sysfs: {0}")] #[error("Failed to read the TAP flags from sysfs")]
ReadSysfsTunFlags(#[source] io::Error), ReadSysfsTunFlags(#[source] io::Error),
#[error("Open tap device failed: {0}")] #[error("Open tap device failed")]
TapOpen(#[source] TapError), TapOpen(#[source] TapError),
#[error("Setting tap IP and/or netmask failed: {0}")] #[error("Setting tap IP and/or netmask failed")]
TapSetIpNetmask(#[source] TapError), TapSetIpNetmask(#[source] TapError),
#[error("Setting MAC address failed: {0}")] #[error("Setting MAC address failed")]
TapSetMac(#[source] TapError), TapSetMac(#[source] TapError),
#[error("Getting MAC address failed: {0}")] #[error("Getting MAC address failed")]
TapGetMac(#[source] TapError), TapGetMac(#[source] TapError),
#[error("Setting vnet header size failed: {0}")] #[error("Setting vnet header size failed")]
TapSetVnetHdrSize(#[source] TapError), TapSetVnetHdrSize(#[source] TapError),
#[error("Setting MTU failed: {0}")] #[error("Setting MTU failed")]
TapSetMtu(#[source] TapError), TapSetMtu(#[source] TapError),
#[error("Enabling tap interface failed: {0}")] #[error("Enabling tap interface failed")]
TapEnable(#[source] TapError), TapEnable(#[source] TapError),
} }
+9 -9
View File
@@ -353,27 +353,27 @@ pub struct NetCounters {
pub enum NetQueuePairError { pub enum NetQueuePairError {
#[error("No memory configured")] #[error("No memory configured")]
NoMemoryConfigured, NoMemoryConfigured,
#[error("Error registering listener: {0}")] #[error("Error registering listener")]
RegisterListener(#[source] io::Error), RegisterListener(#[source] io::Error),
#[error("Error unregistering listener: {0}")] #[error("Error unregistering listener")]
UnregisterListener(#[source] io::Error), UnregisterListener(#[source] io::Error),
#[error("Error writing to the TAP device: {0}")] #[error("Error writing to the TAP device")]
WriteTap(#[source] io::Error), WriteTap(#[source] io::Error),
#[error("Error reading from the TAP device: {0}")] #[error("Error reading from the TAP device")]
ReadTap(#[source] io::Error), ReadTap(#[source] io::Error),
#[error("Error related to guest memory: {0}")] #[error("Error related to guest memory")]
GuestMemory(#[source] vm_memory::GuestMemoryError), GuestMemory(#[source] vm_memory::GuestMemoryError),
#[error("Returned an error while iterating through the queue: {0}")] #[error("Returned an error while iterating through the queue")]
QueueIteratorFailed(#[source] virtio_queue::Error), QueueIteratorFailed(#[source] virtio_queue::Error),
#[error("Descriptor chain is too short")] #[error("Descriptor chain is too short")]
DescriptorChainTooShort, DescriptorChainTooShort,
#[error("Descriptor chain does not contain valid descriptors")] #[error("Descriptor chain does not contain valid descriptors")]
DescriptorChainInvalid, DescriptorChainInvalid,
#[error("Failed to determine if queue needed notification: {0}")] #[error("Failed to determine if queue needed notification")]
QueueNeedsNotification(#[source] virtio_queue::Error), QueueNeedsNotification(#[source] virtio_queue::Error),
#[error("Failed to enable notification on the queue: {0}")] #[error("Failed to enable notification on the queue")]
QueueEnableNotification(#[source] virtio_queue::Error), QueueEnableNotification(#[source] virtio_queue::Error),
#[error("Failed to add used index to the queue: {0}")] #[error("Failed to add used index to the queue")]
QueueAddUsed(#[source] virtio_queue::Error), QueueAddUsed(#[source] virtio_queue::Error),
#[error("Descriptor with invalid virtio-net header")] #[error("Descriptor with invalid virtio-net header")]
DescriptorInvalidHeader, DescriptorInvalidHeader,
+5 -5
View File
@@ -22,21 +22,21 @@ use crate::mac::MAC_ADDR_LEN;
#[derive(Error, Debug)] #[derive(Error, Debug)]
pub enum Error { pub enum Error {
#[error("Couldn't open /dev/net/tun: {0}")] #[error("Couldn't open /dev/net/tun")]
OpenTun(#[source] IoError), OpenTun(#[source] IoError),
#[error("Unable to configure tap interface: {0}")] #[error("Unable to configure tap interface")]
ConfigureTap(#[source] IoError), ConfigureTap(#[source] IoError),
#[error("Unable to retrieve features: {0}")] #[error("Unable to retrieve features")]
GetFeatures(#[source] IoError), GetFeatures(#[source] IoError),
#[error("Missing multiqueue support in the kernel")] #[error("Missing multiqueue support in the kernel")]
MultiQueueKernelSupport, MultiQueueKernelSupport,
#[error("ioctl ({0}) failed: {1}")] #[error("ioctl ({0}) failed: {1}")]
IoctlError(c_ulong, #[source] IoError), IoctlError(c_ulong, #[source] IoError),
#[error("Failed to create a socket: {0}")] #[error("Failed to create a socket")]
NetUtil(#[source] NetUtilError), NetUtil(#[source] NetUtilError),
#[error("Invalid interface name")] #[error("Invalid interface name")]
InvalidIfname, InvalidIfname,
#[error("Error parsing MAC data: {0}")] #[error("Error parsing MAC data")]
MacParsing(#[source] IoError), MacParsing(#[source] IoError),
#[error("Invalid netmask")] #[error("Invalid netmask")]
InvalidNetmask, InvalidNetmask,