Skip to main content

axvirtio_common/
error.rs

1//! VirtIO Error Types
2//!
3//! This module defines common error types used across all VirtIO device implementations.
4
5/// VirtIO specific error types
6#[derive(Debug, Clone, Copy, PartialEq, Eq)]
7pub enum VirtioError {
8    /// Invalid queue configuration
9    InvalidQueue,
10    /// Queue not ready for operation (not configured yet)
11    QueueNotReady,
12    /// Invalid descriptor
13    InvalidDescriptor,
14    /// Invalid access width for MMIO operation
15    InvalidAccessWidth,
16    /// Device not ready
17    DeviceNotReady,
18    /// Invalid device index
19    InvalidDeviceIndex,
20    /// Backend operation failed
21    BackendError,
22    /// Memory access error
23    MemoryError,
24    /// Invalid configuration
25    InvalidConfig,
26    /// Feature negotiation failed
27    FeatureNegotiationFailed,
28    /// Invalid request
29    InvalidRequest,
30    /// Operation not supported
31    NotSupported,
32    /// Invalid buffer size
33    InvalidBufferSize,
34    /// Invalid sector
35    InvalidSector,
36    /// Invalid register
37    InvalidRegister,
38    /// Invalid address or address translation failed
39    InvalidAddress,
40    /// One or more virtqueue rings are misaligned (desc 16B, avail 2B, used 4B)
41    RingMisaligned,
42    /// The virtqueue ring regions overlap each other
43    RingOverlap,
44    /// The virtqueue ring layout is invalid (zero address, region overflow, or
45    /// a ring region lies outside the guest address space)
46    InvalidRingLayout,
47    /// The queue is faulted after a runtime ring/descriptor failure and must be
48    /// reset before further use. Unlike [`QueueNotReady`](Self::QueueNotReady),
49    /// which is a normal pre-configuration state, a faulted queue has served
50    /// requests and hit a runtime failure; its guest-serving data paths
51    /// (`pop`/`complete`, chain walks and data access) reject with this error
52    /// and write no guest memory until `reset`, while the configuration
53    /// setters remain usable.
54    QueueFaulted,
55    /// Resource not found
56    NotFound,
57    /// The operation is valid but cannot complete until asynchronous backend
58    /// work makes progress.
59    WouldBlock,
60    /// Invalid input
61    InvalidInput,
62}
63
64/// Result type for VirtIO operations
65pub type VirtioResult<T> = Result<T, VirtioError>;