devices/virtio/vhost/
mod.rs1use base::Error as SysError;
8use base::TubeError;
9use net_util::Error as TapError;
10use remain::sorted;
11use thiserror::Error;
12#[cfg(any(target_os = "android", target_os = "linux"))]
13use vhost::Error as VhostError;
14
15mod control_socket;
16
17pub use self::control_socket::*;
18
19cfg_if::cfg_if! {
20 if #[cfg(any(target_os = "android", target_os = "linux"))] {
21 #[cfg(target_arch = "aarch64")]
22 pub mod scmi;
23 pub mod worker;
24
25 #[cfg(target_arch = "aarch64")]
26 pub use self::scmi::Scmi;
27 } else if #[cfg(windows)] {}
28}
29
30#[sorted]
31#[derive(Error, Debug)]
32pub enum Error {
33 #[error("failed to clone kill event: {0}")]
35 CloneKillEvent(SysError),
36 #[error("failed to create kill event: {0}")]
38 CreateKillEvent(SysError),
39 #[error("failed to create tube: {0}")]
41 CreateTube(TubeError),
42 #[error("failed to create poll context: {0}")]
44 CreateWaitContext(SysError),
45 #[error("failed to enable tap interface: {0}")]
47 TapEnable(TapError),
48 #[error("failed to open tap device: {0}")]
50 TapOpen(TapError),
51 #[error("failed to set tap IP: {0}")]
53 TapSetIp(TapError),
54 #[error("failed to set tap mac address: {0}")]
56 TapSetMacAddress(TapError),
57 #[error("failed to set tap netmask: {0}")]
59 TapSetNetmask(TapError),
60 #[error("failed to set tap interface offload flags: {0}")]
62 TapSetOffload(TapError),
63 #[error("failed to set vnet header size: {0}")]
65 TapSetVnetHdrSize(TapError),
66 #[error("failed to read vhost error event: {0}")]
68 VhostErrorRead(SysError),
69 #[cfg(any(target_os = "android", target_os = "linux"))]
71 #[error("failed to get features: {0}")]
72 VhostGetFeatures(VhostError),
73 #[error("Vhost IOTLB required but not supported")]
75 VhostIotlbUnsupported,
76 #[error("failed to create vhost event: {0}")]
78 VhostIrqCreate(SysError),
79 #[error("failed to read vhost interrupt event: {0}")]
81 VhostIrqRead(SysError),
82 #[cfg(any(target_os = "android", target_os = "linux"))]
84 #[error("net set backend failed: {0}")]
85 VhostNetSetBackend(VhostError),
86 #[cfg(any(target_os = "android", target_os = "linux"))]
88 #[error("failed to open vhost device: {0}")]
89 VhostOpen(VhostError),
90 #[cfg(any(target_os = "android", target_os = "linux"))]
92 #[error("failed to set features: {0}")]
93 VhostSetFeatures(VhostError),
94 #[cfg(any(target_os = "android", target_os = "linux"))]
96 #[error("failed to set mem table: {0}")]
97 VhostSetMemTable(VhostError),
98 #[cfg(any(target_os = "android", target_os = "linux"))]
100 #[error("failed to set owner: {0}")]
101 VhostSetOwner(VhostError),
102 #[cfg(any(target_os = "android", target_os = "linux"))]
104 #[error("failed to set vring addr: {0}")]
105 VhostSetVringAddr(VhostError),
106 #[cfg(any(target_os = "android", target_os = "linux"))]
108 #[error("failed to set vring base: {0}")]
109 VhostSetVringBase(VhostError),
110 #[cfg(any(target_os = "android", target_os = "linux"))]
112 #[error("failed to set vring call: {0}")]
113 VhostSetVringCall(VhostError),
114 #[cfg(any(target_os = "android", target_os = "linux"))]
116 #[error("failed to set vring err: {0}")]
117 VhostSetVringErr(VhostError),
118 #[cfg(any(target_os = "android", target_os = "linux"))]
120 #[error("failed to set vring kick: {0}")]
121 VhostSetVringKick(VhostError),
122 #[cfg(any(target_os = "android", target_os = "linux"))]
124 #[error("failed to set vring num: {0}")]
125 VhostSetVringNum(VhostError),
126 #[cfg(any(target_os = "android", target_os = "linux"))]
128 #[error("failed to set CID for guest: {0}")]
129 VhostVsockSetCid(VhostError),
130 #[cfg(any(target_os = "android", target_os = "linux"))]
132 #[error("failed to start vhost-vsock driver: {0}")]
133 VhostVsockStart(VhostError),
134 #[error("queue missing vring base")]
135 VringBaseMissing,
136 #[error("failed waiting for events: {0}")]
138 WaitError(SysError),
139}
140
141pub type Result<T> = std::result::Result<T, Error>;