Path: blob/main/devices/src/virtio/vhost_user_frontend/error.rs
5394 views
// Copyright 2021 The ChromiumOS Authors1// Use of this source code is governed by a BSD-style license that can be2// found in the LICENSE file.34use remain::sorted;5use thiserror::Error as ThisError;6use vm_memory::GuestMemoryError;7use vmm_vhost::message::VhostUserProtocolFeatures;8use vmm_vhost::Error as VhostError;910#[sorted]11#[derive(ThisError, Debug)]12pub enum Error {13/// Failed to copy config to a buffer.14#[error("failed to copy config to a buffer: {0}")]15CopyConfig(std::io::Error),16/// Failed to create backend request handler17#[error("could not create backend req handler: {0}")]18CreateBackendReqHandler(VhostError),19/// Failed to create `base::Event`.20#[error("failed to create Event: {0}")]21CreateEvent(base::Error),22/// Failed to get config.23#[error("failed to get config: {0}")]24GetConfig(VhostError),25/// Failed to get features.26#[error("failed to get features: {0}")]27GetFeatures(VhostError),28/// Failed to get host address.29#[error("failed to get host address: {0}")]30GetHostAddress(GuestMemoryError),31/// Failed to get protocol features.32#[error("failed to get protocol features: {0}")]33GetProtocolFeatures(VhostError),34/// Failed to get number of queues.35#[error("failed to get number of queues: {0}")]36GetQueueNum(VhostError),37/// Failed to get vring base offset.38#[error("failed to get vring base offset: {0}")]39GetVringBase(VhostError),40/// MSI-X config is unavailable.41#[error("MSI-X config is unavailable")]42MsixConfigUnavailable,43/// MSI-X irqfd is unavailable.44#[error("MSI-X irqfd is unavailable")]45MsixIrqfdUnavailable,46#[error("protocol feature is not negotiated: {0:?}")]47ProtocolFeatureNotNegoiated(VhostUserProtocolFeatures),48/// Failed to reset owner.49#[error("failed to reset owner: {0}")]50ResetOwner(VhostError),51/// Failed to restore.52#[error("failed to restore: {0}")]53Restore(VhostError),54/// Failed to convert serde Value to a slice.55#[error("failed to convert a serde Value to slice {0}")]56SerdeValueToSlice(anyhow::Error),57/// Failed to set config.58#[error("failed to set config: {0}")]59SetConfig(VhostError),60/// Failed to set device request channel.61#[error("failed to set device request channel: {0}")]62SetDeviceRequestChannel(VhostError),63/// Failed to set features.64#[error("failed to set features: {0}")]65SetFeatures(VhostError),66/// Failed to set memory map regions.67#[error("failed to set memory map regions: {0}")]68SetMemTable(VhostError),69/// Failed to set owner.70#[error("failed to set owner: {0}")]71SetOwner(VhostError),72/// Failed to set protocol features.73#[error("failed to set protocol features: {0}")]74SetProtocolFeatures(VhostError),75/// Failed to set vring address.76#[error("failed to set vring address: {0}")]77SetVringAddr(VhostError),78/// Failed to set vring base offset.79#[error("failed to set vring base offset: {0}")]80SetVringBase(VhostError),81/// Failed to set eventfd to signal used vring buffers.82#[error("failed to set eventfd to signal used vring buffers: {0}")]83SetVringCall(VhostError),84/// Failed to enable or disable vring.85#[error("failed to enable or disable vring: {0}")]86SetVringEnable(VhostError),87/// Failed to set eventfd for adding buffers to vring.88#[error("failed to set eventfd for adding buffers to vring: {0}")]89SetVringKick(VhostError),90/// Failed to set the size of the queue.91#[error("failed to set the size of the queue: {0}")]92SetVringNum(VhostError),93/// Error getting the shmem regions.94#[error("failed to enumerate shmem regions {0}")]95ShmemRegions(VhostError),96/// Failed to sleep the device.97#[error("failed to sleep the device {0}")]98Sleep(VhostError),99/// Failed to convert a slice to a serde Value.100#[error("Failed to convert a slice to a serde Value: {0}")]101SliceToSerdeValue(anyhow::Error),102/// Failed to snapshot.103#[error("failed to snapshot: {0}")]104Snapshot(VhostError),105/// Failed to connect socket.106#[error("failed to connect socket: {0}")]107SocketConnect(std::io::Error),108/// Failed to spawn worker thread.109#[error("failed to spawn worker: {0}")]110SpawnWorker(std::io::Error),111/// The tag for the Fs device was too long to fit in the config space.112#[error("tag is too long: {len} > {max}")]113TagTooLong { len: usize, max: usize },114/// Too many shmem regions.115#[error("too many shmem regions: {0} > 1")]116TooManyShmemRegions(usize),117/// vring base from vhost-user backend is too big.118#[error("vring base returned by vhost-user backend is too big: {0}")]119VringBaseTooBig(u32),120/// failed to wake the vhost user device.121#[error("failed to wake the vhost user device.")]122Wake(VhostError),123/// failed to wake the worker.124#[error("failed to wake the worker.")]125WakeWorker,126}127128pub type Result<T> = std::result::Result<T, Error>;129130131