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 <robert.bradford@intel.com>
This commit is contained in:
Rob Bradford 2020-02-06 11:32:00 +00:00 committed by Sebastien Boeuf
parent 4f4c3d3ebe
commit 710394b872

View File

@ -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<RwLock<Vring>>],
) -> VhostUserBackendResult<bool> {
if evset != epoll::Events::EPOLLIN {
warn!("invalid events operation");
return Ok(false);
return Err(Error::HandleEventNotEpollIn.into());
}
debug!("event received: {:?}", device_event);