• 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 fs;
7 mod handler;
8 mod net;
9 mod worker;
10 
11 pub use self::block::*;
12 pub use self::fs::*;
13 pub use self::net::*;
14 
15 use remain::sorted;
16 use thiserror::Error as ThisError;
17 use vm_memory::GuestMemoryError;
18 use vmm_vhost::Error as VhostError;
19 
20 #[sorted]
21 #[derive(ThisError, Debug)]
22 pub enum Error {
23     /// Failed to copy config to a buffer.
24     #[error("failed to copy config to a buffer: {0}")]
25     CopyConfig(std::io::Error),
26     /// Failed to create `base::Event`.
27     #[error("failed to create Event: {0}")]
28     CreateEvent(base::Error),
29     /// Failed to get config.
30     #[error("failed to get config: {0}")]
31     GetConfig(VhostError),
32     /// Failed to get features.
33     #[error("failed to get features: {0}")]
34     GetFeatures(VhostError),
35     /// Failed to get host address.
36     #[error("failed to get host address: {0}")]
37     GetHostAddress(GuestMemoryError),
38     /// Failed to get protocol features.
39     #[error("failed to get protocol features: {0}")]
40     GetProtocolFeatures(VhostError),
41     /// Failed to get number of queues.
42     #[error("failed to get number of queues: {0}")]
43     GetQueueNum(VhostError),
44     /// Failed to get vring base offset.
45     #[error("failed to get vring base offset: {0}")]
46     GetVringBase(VhostError),
47     /// Invalid config offset is given.
48     #[error("invalid config offset is given: {data_len} + {offset} > {config_len}")]
49     InvalidConfigOffset {
50         data_len: u64,
51         offset: u64,
52         config_len: u64,
53     },
54     /// MSI-X config is unavailable.
55     #[error("MSI-X config is unavailable")]
56     MsixConfigUnavailable,
57     /// MSI-X irqfd is unavailable.
58     #[error("MSI-X irqfd is unavailable")]
59     MsixIrqfdUnavailable,
60     /// Failed to reset owner.
61     #[error("failed to reset owner: {0}")]
62     ResetOwner(VhostError),
63     /// Failed to set features.
64     #[error("failed to set features: {0}")]
65     SetFeatures(VhostError),
66     /// Failed to set memory map regions.
67     #[error("failed to set memory map regions: {0}")]
68     SetMemTable(VhostError),
69     /// Failed to set owner.
70     #[error("failed to set owner: {0}")]
71     SetOwner(VhostError),
72     /// Failed to set protocol features.
73     #[error("failed to set protocol features: {0}")]
74     SetProtocolFeatures(VhostError),
75     /// Failed to set vring address.
76     #[error("failed to set vring address: {0}")]
77     SetVringAddr(VhostError),
78     /// Failed to set vring base offset.
79     #[error("failed to set vring base offset: {0}")]
80     SetVringBase(VhostError),
81     /// Failed to set eventfd to signal used vring buffers.
82     #[error("failed to set eventfd to signal used vring buffers: {0}")]
83     SetVringCall(VhostError),
84     /// Failed to enable or disable vring.
85     #[error("failed to enable or disable vring: {0}")]
86     SetVringEnable(VhostError),
87     /// Failed to set eventfd for adding buffers to vring.
88     #[error("failed to set eventfd for adding buffers to vring: {0}")]
89     SetVringKick(VhostError),
90     /// Failed to set the size of the queue.
91     #[error("failed to set the size of the queue: {0}")]
92     SetVringNum(VhostError),
93     /// Failed to connect socket.
94     #[error("failed to connect socket: {0}")]
95     SocketConnect(std::io::Error),
96     /// The tag for the Fs device was too long to fit in the config space.
97     #[error("tag is too long: {len} > {max}")]
98     TagTooLong { len: usize, max: usize },
99 }
100 
101 pub type Result<T> = std::result::Result<T, Error>;
102