virtio_driver/
lib.rs

1// SPDX-License-Identifier: (MIT OR Apache-2.0)
2
3#![deny(unsafe_op_in_unsafe_fn)]
4
5use bitflags::bitflags;
6use std::io::Error;
7
8mod devices;
9mod transports;
10mod util;
11pub mod virtqueue;
12
13pub use devices::*;
14pub use transports::*;
15pub use util::bytevalued::*;
16pub use util::endian::*;
17pub use util::eventfd::*;
18use util::iova::*;
19pub use util::sock_ctrl_msg::*;
20
21// Reexport `iovec` since it appear in public APIs.
22pub use libc::iovec;
23
24bitflags! {
25    pub struct VirtioFeatureFlags: u64 {
26        const RING_INDIRECT_DESC = 1 << 28;
27        const RING_EVENT_IDX = 1 << 29;
28        const VERSION_1 = 1 << 32;
29        const ACCESS_PLATFORM = 1 << 33;
30        const RING_PACKED = 1 << 34;
31        const IN_ORDER = 1 << 35;
32        const ORDER_PLATFORM = 1 << 36;
33        const SR_IOV = 1 << 37;
34        const NOTIFICATION_DATA = 1 << 38;
35        const NOTIF_CONFIG_DATA = 1 << 39;
36        const RING_RESET = 1 << 40;
37    }
38}
39
40/// The result of a completed request.
41///
42/// Type parameter `C` denotes the type of the "context" associated with the request.
43pub struct Completion<C> {
44    /// The user-defined "context" that was associated with the request.
45    pub context: C,
46
47    /// 0 on success, a negative `errno` value on error.
48    pub ret: i32,
49}