diff --git a/vhost_user_block/src/lib.rs b/vhost_user_block/src/lib.rs index e8b792fb8..ce7827652 100644 --- a/vhost_user_block/src/lib.rs +++ b/vhost_user_block/src/lib.rs @@ -32,6 +32,7 @@ use vhost_user_backend::{VhostUserBackend, VhostUserDaemon, Vring, VringWorker}; use virtio_bindings::bindings::virtio_blk::*; use vm_memory::{Bytes, GuestMemoryError, GuestMemoryMmap}; use vm_virtio::block::{build_disk_image_id, Request}; +use std::{fmt, error, convert,io}; const QUEUE_SIZE: usize = 1024; const SECTOR_SHIFT: u8 = 9; @@ -64,6 +65,20 @@ pub enum Error { 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 for io::Error { + fn from(e: Error) -> Self { + io::Error::new(io::ErrorKind::Other, e) + } +} + pub struct VhostUserBlkBackend { mem: Option, vring_worker: Option>,