• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2021 The Chromium OS Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 mod block;
6 mod console;
7 mod fs;
8 #[cfg(feature = "gpu")]
9 mod gpu;
10 mod handler;
11 mod mac80211_hwsim;
12 mod net;
13 #[cfg(feature = "audio")]
14 mod snd;
15 mod vsock;
16 mod wl;
17 mod worker;
18 
19 pub use self::block::*;
20 pub use self::console::*;
21 pub use self::fs::*;
22 #[cfg(feature = "gpu")]
23 pub use self::gpu::*;
24 pub use self::handler::VhostUserHandler;
25 pub use self::mac80211_hwsim::*;
26 pub use self::net::*;
27 #[cfg(feature = "audio")]
28 pub use self::snd::*;
29 pub use self::vsock::*;
30 pub use self::wl::*;
31 
32 use remain::sorted;
33 use thiserror::Error as ThisError;
34 use vm_memory::GuestMemoryError;
35 use vmm_vhost::Error as VhostError;
36 
37 #[sorted]
38 #[derive(ThisError, Debug)]
39 pub enum Error {
40     /// Failed to copy config to a buffer.
41     #[error("failed to copy config to a buffer: {0}")]
42     CopyConfig(std::io::Error),
43     /// Failed to create `base::Event`.
44     #[error("failed to create Event: {0}")]
45     CreateEvent(base::Error),
46     /// Failed to get config.
47     #[error("failed to get config: {0}")]
48     GetConfig(VhostError),
49     /// Failed to get features.
50     #[error("failed to get features: {0}")]
51     GetFeatures(VhostError),
52     /// Failed to get host address.
53     #[error("failed to get host address: {0}")]
54     GetHostAddress(GuestMemoryError),
55     /// Failed to get protocol features.
56     #[error("failed to get protocol features: {0}")]
57     GetProtocolFeatures(VhostError),
58     /// Failed to get number of queues.
59     #[error("failed to get number of queues: {0}")]
60     GetQueueNum(VhostError),
61     /// Failed to get vring base offset.
62     #[error("failed to get vring base offset: {0}")]
63     GetVringBase(VhostError),
64     /// Invalid config offset is given.
65     #[error("invalid config offset is given: {data_len} + {offset} > {config_len}")]
66     InvalidConfigOffset {
67         data_len: u64,
68         offset: u64,
69         config_len: u64,
70     },
71     /// MSI-X config is unavailable.
72     #[error("MSI-X config is unavailable")]
73     MsixConfigUnavailable,
74     /// MSI-X irqfd is unavailable.
75     #[error("MSI-X irqfd is unavailable")]
76     MsixIrqfdUnavailable,
77     /// Failed to reset owner.
78     #[error("failed to reset owner: {0}")]
79     ResetOwner(VhostError),
80     /// Failed to set config.
81     #[error("failed to set config: {0}")]
82     SetConfig(VhostError),
83     /// Failed to set device request channel.
84     #[error("failed to set device request channel: {0}")]
85     SetDeviceRequestChannel(VhostError),
86     /// Failed to set features.
87     #[error("failed to set features: {0}")]
88     SetFeatures(VhostError),
89     /// Failed to set memory map regions.
90     #[error("failed to set memory map regions: {0}")]
91     SetMemTable(VhostError),
92     /// Failed to set owner.
93     #[error("failed to set owner: {0}")]
94     SetOwner(VhostError),
95     /// Failed to set protocol features.
96     #[error("failed to set protocol features: {0}")]
97     SetProtocolFeatures(VhostError),
98     /// Failed to set vring address.
99     #[error("failed to set vring address: {0}")]
100     SetVringAddr(VhostError),
101     /// Failed to set vring base offset.
102     #[error("failed to set vring base offset: {0}")]
103     SetVringBase(VhostError),
104     /// Failed to set eventfd to signal used vring buffers.
105     #[error("failed to set eventfd to signal used vring buffers: {0}")]
106     SetVringCall(VhostError),
107     /// Failed to enable or disable vring.
108     #[error("failed to enable or disable vring: {0}")]
109     SetVringEnable(VhostError),
110     /// Failed to set eventfd for adding buffers to vring.
111     #[error("failed to set eventfd for adding buffers to vring: {0}")]
112     SetVringKick(VhostError),
113     /// Failed to set the size of the queue.
114     #[error("failed to set the size of the queue: {0}")]
115     SetVringNum(VhostError),
116     /// Failed to connect socket.
117     #[error("failed to connect socket: {0}")]
118     SocketConnect(std::io::Error),
119     /// Failed to create Master from a UDS path.
120     #[error("failed to connect to device socket while creating instance: {0}")]
121     SocketConnectOnMasterCreate(VhostError),
122     /// The tag for the Fs device was too long to fit in the config space.
123     #[error("tag is too long: {len} > {max}")]
124     TagTooLong { len: usize, max: usize },
125 }
126 
127 pub type Result<T> = std::result::Result<T, Error>;
128