Skip to content

Commit 6dde03e

Browse files
committed
Use mio to replace Epoll
Epoll is linux-specific. So we use mio, which is a cross-platform event notification, to replace Epoll. Signed-off-by: Wenyu Huang <huangwenyuu@outlook.com>
1 parent 2124694 commit 6dde03e

7 files changed

Lines changed: 153 additions & 109 deletions

File tree

vhost-user-backend/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
- [[#339]](https://github.com/rust-vmm/vhost/pull/339) Add support for `GET_SHMEM_CONFIG` message
77

88
### Changed
9+
- [[316](https://github.com/rust-vmm/vhost/pull/316)] Use mio to replace Epoll. Expose event_loop::EventSet.
10+
911
### Deprecated
1012
### Fixed
1113

vhost-user-backend/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ postcopy = ["vhost/postcopy", "userfaultfd"]
2020
libc = "0.2.39"
2121
log = "0.4.17"
2222
userfaultfd = { version = "0.9.0", optional = true }
23+
mio = { version = "1.0.4", features = ["os-poll", "os-ext"] }
2324
vhost = { path = "../vhost", version = "0.15.0", features = ["vhost-user-backend"] }
2425
virtio-bindings = { workspace = true }
2526
virtio-queue = { workspace = true }

vhost-user-backend/src/backend.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,15 @@ use vhost::vhost_user::message::{
2929
};
3030
use vhost::vhost_user::Backend;
3131
use vm_memory::bitmap::Bitmap;
32-
use vmm_sys_util::epoll::EventSet;
3332
use vmm_sys_util::event::{EventConsumer, EventNotifier};
3433

3534
use vhost::vhost_user::GpuBackend;
3635

3736
use super::vring::VringT;
3837
use super::GM;
3938

39+
use crate::EventSet;
40+
4041
/// Trait with interior mutability for vhost user backend servers to implement concrete services.
4142
///
4243
/// To support multi-threading and asynchronous IO, we enforce `Send + Sync` bound.
@@ -828,7 +829,7 @@ pub mod tests {
828829

829830
let vring = VringRwLock::new(mem, 0x1000).unwrap();
830831
backend
831-
.handle_event(0x1, EventSet::IN, &[vring], 0)
832+
.handle_event(0x1, EventSet::Readable, &[vring], 0)
832833
.unwrap();
833834

834835
backend.reset_device();

0 commit comments

Comments
 (0)