From 710394b87271d94034a7cf700ed9aa966f12390d Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Thu, 6 Feb 2020 11:32:00 +0000 Subject: [PATCH] vhost_user_block: Forward the error from unexpected event This is consistent with vhost-user-net and vhost-user-fs. Signed-off-by: Rob Bradford --- vhost_user_block/src/lib.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/vhost_user_block/src/lib.rs b/vhost_user_block/src/lib.rs index ce7827652..030feccc5 100644 --- a/vhost_user_block/src/lib.rs +++ b/vhost_user_block/src/lib.rs @@ -27,12 +27,12 @@ use std::process; use std::slice; use std::sync::{Arc, RwLock}; use std::vec::Vec; +use std::{convert, error, fmt, io}; use vhost_rs::vhost_user::message::*; 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; @@ -63,6 +63,8 @@ pub enum Error { ParseReadOnlyParam, /// Failed parsing fs number of queues parameter. ParseBlkNumQueuesParam(std::num::ParseIntError), + /// Failed to handle event other than input event. + HandleEventNotEpollIn, } impl fmt::Display for Error { @@ -214,8 +216,7 @@ impl VhostUserBackend for VhostUserBlkBackend { vrings: &[Arc>], ) -> VhostUserBackendResult { if evset != epoll::Events::EPOLLIN { - warn!("invalid events operation"); - return Ok(false); + return Err(Error::HandleEventNotEpollIn.into()); } debug!("event received: {:?}", device_event);