2019-08-28 09:50:48 +00:00
|
|
|
// Copyright 2019 Intel Corporation. All Rights Reserved.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
|
|
|
extern crate epoll;
|
|
|
|
extern crate net_util;
|
2021-02-25 09:46:27 +00:00
|
|
|
extern crate vhost;
|
2019-08-28 09:50:48 +00:00
|
|
|
extern crate virtio_bindings;
|
|
|
|
extern crate vm_memory;
|
|
|
|
|
|
|
|
use std::io;
|
2021-02-25 09:46:27 +00:00
|
|
|
use vhost::Error as VhostError;
|
2019-08-28 09:50:48 +00:00
|
|
|
use vm_memory::Error as MmapError;
|
|
|
|
|
2019-09-02 11:00:35 +00:00
|
|
|
pub mod blk;
|
2019-08-30 16:16:32 +00:00
|
|
|
pub mod fs;
|
2019-08-28 09:50:48 +00:00
|
|
|
mod handler;
|
|
|
|
pub mod net;
|
|
|
|
pub mod vu_common_ctrl;
|
|
|
|
|
2019-09-02 11:00:35 +00:00
|
|
|
pub use self::blk::Blk;
|
2019-08-30 16:16:32 +00:00
|
|
|
pub use self::fs::*;
|
2019-08-28 09:50:48 +00:00
|
|
|
pub use self::net::Net;
|
|
|
|
pub use self::vu_common_ctrl::VhostUserConfig;
|
|
|
|
|
|
|
|
#[derive(Debug)]
|
|
|
|
pub enum Error {
|
|
|
|
/// Invalid available address.
|
|
|
|
AvailAddress,
|
|
|
|
/// Queue number is not correct
|
|
|
|
BadQueueNum,
|
|
|
|
/// Creating kill eventfd failed.
|
|
|
|
CreateKillEventFd(io::Error),
|
|
|
|
/// Cloning kill eventfd failed.
|
|
|
|
CloneKillEventFd(io::Error),
|
|
|
|
/// Invalid descriptor table address.
|
|
|
|
DescriptorTableAddress,
|
|
|
|
/// Signal used queue failed.
|
|
|
|
FailedSignalingUsedQueue(io::Error),
|
|
|
|
/// Failed to read vhost eventfd.
|
|
|
|
MemoryRegions(MmapError),
|
|
|
|
/// Failed to create master.
|
|
|
|
VhostUserCreateMaster(VhostError),
|
|
|
|
/// Failed to open vhost device.
|
|
|
|
VhostUserOpen(VhostError),
|
2019-08-30 17:40:33 +00:00
|
|
|
/// Connection to socket failed.
|
2021-02-25 09:46:27 +00:00
|
|
|
VhostUserConnect(vhost::Error),
|
2019-08-28 09:50:48 +00:00
|
|
|
/// Get features failed.
|
|
|
|
VhostUserGetFeatures(VhostError),
|
2020-02-03 06:24:41 +00:00
|
|
|
/// Get queue max number failed.
|
|
|
|
VhostUserGetQueueMaxNum(VhostError),
|
2019-08-28 09:50:48 +00:00
|
|
|
/// Get protocol features failed.
|
|
|
|
VhostUserGetProtocolFeatures(VhostError),
|
|
|
|
/// Vhost-user Backend not support vhost-user protocol.
|
|
|
|
VhostUserProtocolNotSupport,
|
|
|
|
/// Set owner failed.
|
|
|
|
VhostUserSetOwner(VhostError),
|
2019-09-19 16:14:55 +00:00
|
|
|
/// Reset owner failed.
|
|
|
|
VhostUserResetOwner(VhostError),
|
2019-08-28 09:50:48 +00:00
|
|
|
/// Set features failed.
|
|
|
|
VhostUserSetFeatures(VhostError),
|
|
|
|
/// Set protocol features failed.
|
|
|
|
VhostUserSetProtocolFeatures(VhostError),
|
|
|
|
/// Set mem table failed.
|
|
|
|
VhostUserSetMemTable(VhostError),
|
|
|
|
/// Set vring num failed.
|
|
|
|
VhostUserSetVringNum(VhostError),
|
|
|
|
/// Set vring addr failed.
|
|
|
|
VhostUserSetVringAddr(VhostError),
|
|
|
|
/// Set vring base failed.
|
|
|
|
VhostUserSetVringBase(VhostError),
|
|
|
|
/// Set vring call failed.
|
|
|
|
VhostUserSetVringCall(VhostError),
|
|
|
|
/// Set vring kick failed.
|
|
|
|
VhostUserSetVringKick(VhostError),
|
|
|
|
/// Set vring enable failed.
|
|
|
|
VhostUserSetVringEnable(VhostError),
|
|
|
|
/// Failed to create vhost eventfd.
|
|
|
|
VhostIrqCreate(io::Error),
|
|
|
|
/// Failed to read vhost eventfd.
|
|
|
|
VhostIrqRead(io::Error),
|
|
|
|
/// Failed to read vhost eventfd.
|
|
|
|
VhostUserMemoryRegion(MmapError),
|
2019-08-30 17:40:33 +00:00
|
|
|
/// Failed to create the master request handler from slave.
|
2021-02-25 09:46:27 +00:00
|
|
|
MasterReqHandlerCreation(vhost::vhost_user::Error),
|
2019-08-30 17:40:33 +00:00
|
|
|
/// Set slave request fd failed.
|
2021-02-25 09:46:27 +00:00
|
|
|
VhostUserSetSlaveRequestFd(vhost::Error),
|
2019-08-28 09:50:48 +00:00
|
|
|
/// Invalid used address.
|
|
|
|
UsedAddress,
|
2019-09-02 11:00:35 +00:00
|
|
|
/// Invalid features provided from vhost-user backend
|
|
|
|
InvalidFeatures,
|
2019-08-28 09:50:48 +00:00
|
|
|
}
|
|
|
|
type Result<T> = std::result::Result<T, Error>;
|