Use mio to replace Epoll#316
Conversation
cbb223d to
138400e
Compare
2b19107 to
e53a34c
Compare
be19e30 to
158ca1d
Compare
44e7bb3 to
77ba627
Compare
|
this LGTM |
|
@stefano-garzarella @germag any problems about this? |
|
Hi @uran0sH , I'm trying to build the vhost crate on macOS and came across this PR. It seems this PR hasn't been updated for a while, are you still working on it? If not, I'd be happy to take over and continue the work to help get it merged. Let me know what you think. Thanks! |
Yeah I will update this pr as soon as possible |
6dde03e to
fbc40ce
Compare
When register_event we pass in the value of u32/u64, so we don't need to convert it to u16 and then pass it to handle_event. Signed-off-by: Wenyu Huang <huangwenyuu@outlook.com>
We can safely use usize instead of u64, because normally we will not register a data that exceeds the size of usize Signed-off-by: Wenyu Huang <huangwenyuu@outlook.com>
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>
|
Hi, this LGTM @name1e5s can you try to build it again? |
The `VhostBackend` and `VhostBackendMut` traits in `vhost/src/backend.rs`
take `&EventFd` in `set_vring_call`, `set_vring_kick`, and
`set_vring_err`. The implementations of these traits are all Linux-only
consumers — kernel vhost drivers (`vhost_kern/`, gated on the
`vhost-kern` feature) and the vhost-user frontend (gated on
`vhost-user-frontend`). No macOS consumer ever calls these methods.
Until now, the unconditional `use vmm_sys_util::eventfd::EventFd;` at
the top of `backend.rs` forced every dependent crate (including
`vhost-user-backend` consumers like virtiofsd) to compile against
`vmm_sys_util::eventfd` even when nothing in the build path called these
methods. On macOS that meant requiring an `eventfd` shim inside
vmm-sys-util just for the type to resolve.
Gate the import, the six trait method signatures, the corresponding
methods in `impl<T: VhostBackendMut> VhostBackend for {RwLock,RefCell}<T>`,
and the test mock + test on `#[cfg(target_os = "linux")]`. The trait
becomes a smaller surface on macOS — exactly the surface that has
working consumers there. Linux behaviour is unchanged.
This unblocks dropping the macOS `eventfd` shim from vmm-sys-util
(rust-vmm/vmm-sys-util#268), and combined with the mio rewrite of
`vhost-user-backend`'s event loop (rust-vmm#316), removes the last hard
dependency between the macOS build path and `vmm_sys_util::eventfd`.
Tested: full virtiofsd → vhost-user-backend → vhost → vmm-sys-util
stack builds and tests pass on aarch64-apple-darwin with no eventfd
shim in vmm-sys-util.
Signed-off-by: Chris Thomas <chris.thomas@antimatter-studios.com>
|
@uran0sH building vhost backend on my macOs still fails due to eventfd in vhost/backend.rs. I am porting Vhostbackend trait methods to eventconsumer and eventNotifier. Are you considering taking this approach ? |
Yeah, but the changes still are in my own repo: uran0sH@54d673a, not submitted to the upstream. If you want to test, you can use this branch: https://github.com/uran0sH/vhost/tree/macos. And I also change the vhost-device. These changes in uran0sH/vhost-device#2 |
@uran0sH what is missing to submit it here? |
I think nothing major is missing. I am not sure whether uran0sH@54d673a should be submitted in this pr or as a sperate one. What do you think? |
I think better a separate PR if they are not depending on each other. |
@uran0sH I found the following issue with https://github.com/uran0sH/vhost/tree/macos I have fixed it on my branch https://github.com/eric-14/rust_vhost_/tree/experimental_mac |
|
@eric-14 Thanks! After looking at it (honestly, just skimming) again, there are some minor issues that should be fixed and a couple not so minor:
Less important:
|
|
@germag Thank you for the latest review. I will make the necessary changes and ping you. |
|
@germag, I have completed the changes. Do you prefer I create a new PR or commit to this PR? |
I'd suggest to start a new PR, I'm not sure if you have rights to push on this. |
Summary of the PR
Epoll is linux-specific. So we use mio, which is a cross-platform event notification, to replace Epoll.
Requirements
Before submitting your PR, please make sure you addressed the following
requirements:
git commit -s), and the commit message has max 60 characters for thesummary and max 75 characters for each description line.
test.
Release" section of CHANGELOG.md (if no such section exists, please create one).
unsafecode is properly documented.