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(feature = "net")]
22 mod net;
23 pub mod vsock;
24 #[cfg(target_arch = "aarch64")]
25 pub mod scmi;
26 mod worker;
27
28 #[cfg(feature = "net")]
29 pub use self::net::Net;
30 pub use self::vsock::Vsock;
31 #[cfg(target_arch = "aarch64")]
32 pub use self::scmi::Scmi;
33 } else if #[cfg(windows)] {}
34}
35
36#[sorted]
37#[derive(Error, Debug)]
38pub enum Error {
39 #[error("failed to clone kill event: {0}")]
41 CloneKillEvent(SysError),
42 #[error("failed to create kill event: {0}")]
44 CreateKillEvent(SysError),
45 #[error("failed to create tube: {0}")]
47 CreateTube(TubeError),
48 #[error("failed to create poll context: {0}")]
50 CreateWaitContext(SysError),
51 #[error("failed to enable tap interface: {0}")]
53 TapEnable(TapError),
54 #[error("failed to open tap device: {0}")]
56 TapOpen(TapError),
57 #[error("failed to set tap IP: {0}")]
59 TapSetIp(TapError),
60 #[error("failed to set tap mac address: {0}")]
62 TapSetMacAddress(TapError),
63 #[error("failed to set tap netmask: {0}")]
65 TapSetNetmask(TapError),
66 #[error("failed to set tap interface offload flags: {0}")]
68 TapSetOffload(TapError),
69 #[error("failed to set vnet header size: {0}")]
71 TapSetVnetHdrSize(TapError),
72 #[error("failed to read vhost error event: {0}")]
74 VhostErrorRead(SysError),
75 #[cfg(any(target_os = "android", target_os = "linux"))]
77 #[error("failed to get features: {0}")]
78 VhostGetFeatures(VhostError),
79 #[error("Vhost IOTLB required but not supported")]
81 VhostIotlbUnsupported,
82 #[error("failed to create vhost event: {0}")]
84 VhostIrqCreate(SysError),
85 #[error("failed to read vhost interrupt event: {0}")]
87 VhostIrqRead(SysError),
88 #[cfg(any(target_os = "android", target_os = "linux"))]
90 #[error("net set backend failed: {0}")]
91 VhostNetSetBackend(VhostError),
92 #[cfg(any(target_os = "android", target_os = "linux"))]
94 #[error("failed to open vhost device: {0}")]
95 VhostOpen(VhostError),
96 #[cfg(any(target_os = "android", target_os = "linux"))]
98 #[error("failed to set features: {0}")]
99 VhostSetFeatures(VhostError),
100 #[cfg(any(target_os = "android", target_os = "linux"))]
102 #[error("failed to set mem table: {0}")]
103 VhostSetMemTable(VhostError),
104 #[cfg(any(target_os = "android", target_os = "linux"))]
106 #[error("failed to set owner: {0}")]
107 VhostSetOwner(VhostError),
108 #[cfg(any(target_os = "android", target_os = "linux"))]
110 #[error("failed to set vring addr: {0}")]
111 VhostSetVringAddr(VhostError),
112 #[cfg(any(target_os = "android", target_os = "linux"))]
114 #[error("failed to set vring base: {0}")]
115 VhostSetVringBase(VhostError),
116 #[cfg(any(target_os = "android", target_os = "linux"))]
118 #[error("failed to set vring call: {0}")]
119 VhostSetVringCall(VhostError),
120 #[cfg(any(target_os = "android", target_os = "linux"))]
122 #[error("failed to set vring err: {0}")]
123 VhostSetVringErr(VhostError),
124 #[cfg(any(target_os = "android", target_os = "linux"))]
126 #[error("failed to set vring kick: {0}")]
127 VhostSetVringKick(VhostError),
128 #[cfg(any(target_os = "android", target_os = "linux"))]
130 #[error("failed to set vring num: {0}")]
131 VhostSetVringNum(VhostError),
132 #[cfg(any(target_os = "android", target_os = "linux"))]
134 #[error("failed to set CID for guest: {0}")]
135 VhostVsockSetCid(VhostError),
136 #[cfg(any(target_os = "android", target_os = "linux"))]
138 #[error("failed to start vhost-vsock driver: {0}")]
139 VhostVsockStart(VhostError),
140 #[error("queue missing vring base")]
141 VringBaseMissing,
142 #[error("failed waiting for events: {0}")]
144 WaitError(SysError),
145}
146
147pub type Result<T> = std::result::Result<T, Error>;