Lines Matching +full:write +full:- +full:error
2 // SPDX-License-Identifier: Apache-2.0 or BSD-3-Clause
7 //! is a set of three different single-producer, single-consumer ring structures designed to store
8 //! generic scatter-gather I/O. The virtio specification 1.1 introduces an alternative compact
10 //! hardware implemented virtio devices. The packed virtqueue uses read-write memory, that means
25 //! Later Vhost-user protocol is introduced to complement the ioctl interface used to control the
35 #[cfg_attr(feature = "vhost-user", macro_use)]
37 #[cfg_attr(feature = "vhost-kern", macro_use)]
43 #[cfg(feature = "vhost-net")]
45 #[cfg(feature = "vhost-vdpa")]
47 #[cfg(feature = "vhost-kern")]
49 #[cfg(feature = "vhost-user")]
51 #[cfg(feature = "vhost-vsock")]
54 /// Error codes for vhost operations
56 pub enum Error { enum
75 #[cfg(feature = "vhost-kern")]
76 /// Error opening the vhost backend driver.
77 VhostOpen(std::io::Error),
78 #[cfg(feature = "vhost-kern")]
79 /// Error while running ioctl.
80 IoctlError(std::io::Error),
81 /// Error from IO subsystem.
82 IOError(std::io::Error),
83 #[cfg(feature = "vhost-user")]
84 /// Error from the vhost-user subsystem.
85 VhostUserProtocol(vhost_user::Error),
88 impl std::fmt::Display for Error { implementation
89 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { in fmt()
91 Error::InvalidOperation => write!(f, "invalid vhost operations"), in fmt()
92 Error::InvalidGuestMemory => write!(f, "invalid guest memory object"), in fmt()
93 Error::InvalidGuestMemoryRegion => write!(f, "invalid guest memory region"), in fmt()
94 Error::InvalidIotlbMsg => write!(f, "invalid IOTLB message"), in fmt()
95 Error::InvalidQueue => write!(f, "invalid virtqueue"), in fmt()
96 Error::DescriptorTableAddress => { in fmt()
97 write!(f, "invalid virtqueue descriptor table address") in fmt()
99 Error::UsedAddress => write!(f, "invalid virtqueue used table address"), in fmt()
100 Error::AvailAddress => write!(f, "invalid virtqueue available table address"), in fmt()
101 Error::LogAddress => write!(f, "invalid virtqueue log address"), in fmt()
102 Error::IOError(e) => write!(f, "IO error: {}", e), in fmt()
103 #[cfg(feature = "vhost-kern")] in fmt()
104 Error::VhostOpen(e) => write!(f, "failure in opening vhost file: {}", e), in fmt()
105 #[cfg(feature = "vhost-kern")] in fmt()
106 Error::IoctlError(e) => write!(f, "failure in vhost ioctl: {}", e), in fmt()
107 #[cfg(feature = "vhost-user")] in fmt()
108 Error::VhostUserProtocol(e) => write!(f, "vhost-user: {}", e), in fmt()
113 impl std::error::Error for Error {} implementation
115 #[cfg(feature = "vhost-user")]
116 impl std::convert::From<vhost_user::Error> for Error { implementation
117 fn from(err: vhost_user::Error) -> Self { in from()
118 Error::VhostUserProtocol(err) in from()
123 pub type Result<T> = std::result::Result<T, Error>;
132 format!("{}", Error::AvailAddress), in test_error()
136 format!("{}", Error::InvalidOperation), in test_error()
140 format!("{}", Error::InvalidGuestMemory), in test_error()
144 format!("{}", Error::InvalidGuestMemoryRegion), in test_error()
148 format!("{}", Error::InvalidIotlbMsg), in test_error()
151 assert_eq!(format!("{}", Error::InvalidQueue), "invalid virtqueue"); in test_error()
153 format!("{}", Error::DescriptorTableAddress), in test_error()
157 format!("{}", Error::UsedAddress), in test_error()
161 format!("{}", Error::LogAddress), in test_error()
165 assert_eq!(format!("{:?}", Error::AvailAddress), "AvailAddress"); in test_error()
168 #[cfg(feature = "vhost-user")]
171 let e: Error = vhost_user::Error::OversizedMsg.into(); in test_convert_from_vhost_user_error()
173 assert_eq!(format!("{}", e), "vhost-user: oversized message"); in test_convert_from_vhost_user_error()