mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-08-21 15:31:15 +00:00
net_util: Use two two different enums for MQ error
Rather than use an embedded String inside the MultiQueueSupport error value use two different values to differentiate the two cases. Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
parent
3e807a19b7
commit
2efd307c4e
@ -13,8 +13,10 @@ use virtio_bindings::bindings::virtio_net::virtio_net_hdr_v1;
|
|||||||
pub enum Error {
|
pub enum Error {
|
||||||
/// Failed to convert an hexadecimal string into an integer.
|
/// Failed to convert an hexadecimal string into an integer.
|
||||||
ConvertHexStringToInt(std::num::ParseIntError),
|
ConvertHexStringToInt(std::num::ParseIntError),
|
||||||
/// Error related to the multiqueue support.
|
/// Error related to the multiqueue support (no support TAP side).
|
||||||
MultiQueueSupport(String),
|
MultiQueueNoTapSupport,
|
||||||
|
/// Error related to the multiqueue support (no support device side).
|
||||||
|
MultiQueueNoDeviceSupport,
|
||||||
/// Failed to read the TAP flags from sysfs.
|
/// Failed to read the TAP flags from sysfs.
|
||||||
ReadSysfsTunFlags(io::Error),
|
ReadSysfsTunFlags(io::Error),
|
||||||
/// Open tap device failed.
|
/// Open tap device failed.
|
||||||
@ -53,13 +55,9 @@ fn check_mq_support(if_name: &Option<&str>, queue_pairs: usize) -> Result<()> {
|
|||||||
let tun_flags = u32::from_str_radix(tun_flags_str.trim().trim_start_matches("0x"), 16)
|
let tun_flags = u32::from_str_radix(tun_flags_str.trim().trim_start_matches("0x"), 16)
|
||||||
.map_err(Error::ConvertHexStringToInt)?;
|
.map_err(Error::ConvertHexStringToInt)?;
|
||||||
if (tun_flags & net_gen::IFF_MULTI_QUEUE != 0) && !mq {
|
if (tun_flags & net_gen::IFF_MULTI_QUEUE != 0) && !mq {
|
||||||
return Err(Error::MultiQueueSupport(String::from(
|
return Err(Error::MultiQueueNoDeviceSupport);
|
||||||
"TAP interface supports MQ while device does not",
|
|
||||||
)));
|
|
||||||
} else if (tun_flags & net_gen::IFF_MULTI_QUEUE == 0) && mq {
|
} else if (tun_flags & net_gen::IFF_MULTI_QUEUE == 0) && mq {
|
||||||
return Err(Error::MultiQueueSupport(String::from(
|
return Err(Error::MultiQueueNoTapSupport);
|
||||||
"Device supports MQ while TAP interface does not",
|
|
||||||
)));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
|
Loading…
Reference in New Issue
Block a user