mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-08-22 07:51:16 +00:00
vhost_user_block: Make Error behave like net and fs versions
Make the Error struct behave more like the net and fs equivalents. Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
parent
f1e19d6c96
commit
4f4c3d3ebe
@ -32,6 +32,7 @@ use vhost_user_backend::{VhostUserBackend, VhostUserDaemon, Vring, VringWorker};
|
|||||||
use virtio_bindings::bindings::virtio_blk::*;
|
use virtio_bindings::bindings::virtio_blk::*;
|
||||||
use vm_memory::{Bytes, GuestMemoryError, GuestMemoryMmap};
|
use vm_memory::{Bytes, GuestMemoryError, GuestMemoryMmap};
|
||||||
use vm_virtio::block::{build_disk_image_id, Request};
|
use vm_virtio::block::{build_disk_image_id, Request};
|
||||||
|
use std::{fmt, error, convert,io};
|
||||||
|
|
||||||
const QUEUE_SIZE: usize = 1024;
|
const QUEUE_SIZE: usize = 1024;
|
||||||
const SECTOR_SHIFT: u8 = 9;
|
const SECTOR_SHIFT: u8 = 9;
|
||||||
@ -64,6 +65,20 @@ pub enum Error {
|
|||||||
ParseBlkNumQueuesParam(std::num::ParseIntError),
|
ParseBlkNumQueuesParam(std::num::ParseIntError),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl fmt::Display for Error {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
|
write!(f, "vhost_user_block_error: {:?}", self)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl error::Error for Error {}
|
||||||
|
|
||||||
|
impl convert::From<Error> for io::Error {
|
||||||
|
fn from(e: Error) -> Self {
|
||||||
|
io::Error::new(io::ErrorKind::Other, e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub struct VhostUserBlkBackend {
|
pub struct VhostUserBlkBackend {
|
||||||
mem: Option<GuestMemoryMmap>,
|
mem: Option<GuestMemoryMmap>,
|
||||||
vring_worker: Option<Arc<VringWorker>>,
|
vring_worker: Option<Arc<VringWorker>>,
|
||||||
|
Loading…
Reference in New Issue
Block a user