vu.rs0.00%
1
// Copyright 2024 Google LLC2
//3
// Licensed under the Apache License, Version 2.0 (the "License");4
// you may not use this file except in compliance with the License.5
// You may obtain a copy of the License at6
//7
// https://www.apache.org/licenses/LICENSE-2.08
//9
// Unless required by applicable law or agreed to in writing, software10
// distributed under the License is distributed on an "AS IS" BASIS,11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.12
// See the License for the specific language governing permissions and13
// limitations under the License.14
15
pub mod backend;16
pub mod bindings;17
pub mod conn;18
pub mod frontend;19
20
use std::path::Path;21
22
use snafu::Snafu;23
24
use crate::errors::{DebugTrace, trace_error};25
use crate::virtio::vu::bindings::VuFeature;26
27
#[trace_error]28
#[derive(Snafu, DebugTrace)]29
#[snafu(module, visibility(pub(crate)), context(suffix(false)))]30
pub enum Error {31
#[snafu(display("Cannot access socket {path:?}"))]32
AccessSocket {33
path: Box<Path>,34
error: std::io::Error,35
},36
#[snafu(display("Error from OS"), context(false))]37
System { error: std::io::Error },38
#[snafu(display("vhost-user message ({req:#x}) missing fd"))]39
MissingFd { req: u32 },40
#[snafu(display("Unexpected vhost-user response, want {want}, got {got}"))]41
Response { want: u32, got: u32 },42
#[snafu(display("Unexpected vhost-user message size, want {want}, get {got}"))]43
MsgSize { want: usize, got: usize },44
#[snafu(display("Failed to send {want} bytes, only {done} bytes were sent"))]45
PartialWrite { want: usize, done: usize },46
#[snafu(display("Invalid vhost-user message payload size, want {want}, got {got}"))]47
PayloadSize { want: usize, got: u32 },48
#[snafu(display("vhost-user backend replied error code {ret:#x} to request {req:#x}"))]49
RequestErr { ret: u64, req: u32 },50
#[snafu(display("vhost-user backend signaled an error of queue {index:#x}"))]51
QueueErr { index: u16 },52
#[snafu(display("vhost-user backend is missing device feature {feature:#x}"))]53
DeviceFeature { feature: u128 },54
#[snafu(display("vhost-user backend is missing protocol feature {feature:x?}"))]55
ProtocolFeature { feature: VuFeature },56
}57
58
type Result<T, E = Error> = std::result::Result<T, E>;59