vmm/devices/virtio/block/
mod.rs

1// Copyright 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2// SPDX-License-Identifier: Apache-2.0
3use serde::{Deserialize, Serialize};
4
5use self::vhost_user::VhostUserBlockError;
6use self::virtio::VirtioBlockError;
7
8pub mod device;
9pub mod persist;
10pub mod vhost_user;
11pub mod virtio;
12
13/// Configuration options for disk caching.
14#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Deserialize, Serialize)]
15pub enum CacheType {
16    /// Flushing mechanic not will be advertised to the guest driver
17    #[default]
18    Unsafe,
19    /// Flushing mechanic will be advertised to the guest driver and
20    /// flush requests coming from the guest will be performed using
21    /// `fsync`.
22    Writeback,
23}
24
25/// Errors the block device can trigger.
26#[derive(Debug, thiserror::Error, displaydoc::Display)]
27pub enum BlockError {
28    /// Invalid block config.
29    InvalidBlockConfig,
30    /// Running method expected different backend.
31    InvalidBlockBackend,
32    /// Can not restore any backend.
33    BackendRestore,
34    /// Virtio backend error: {0}
35    VirtioBackend(VirtioBlockError),
36    /// Vhost user backend error: {0}
37    VhostUserBackend(VhostUserBlockError),
38}