Adding unix support for vhost-device-vsock#965
Conversation
57ffcd3 to
116abd2
Compare
luigix25
left a comment
There was a problem hiding this comment.
thank you for your contribution.
I did a very quick review of your changes, please try to write better commit messages (see https://www.kernel.org/doc/html/latest/process/submitting-patches.html#describe-your-changes) and avoid all unrelated changes.
Look at the history of commit messages, and try do to something similar.
Please make sure that every commit compiles, and cargo fmt and clippy are happy.
For example, currently, commit 1 does not compile.
|
|
||
| [dev-dependencies] | ||
| assert_matches = "1.5" | ||
| virtio-queue = { workspace = true, features = ["test-utils"] } |
There was a problem hiding this comment.
why this change? if you need it, please put it in a different commit explaining why you need this change. And make it clear that it's a WIP commit.
There was a problem hiding this comment.
The git dependencies have been migrated to mio and work on unix.
Splitting the commit results in errors due to difference in API.
| vhost = { git="https://github.com/eric-14/rust_vhost_.git", branch="experimental_mac" } | ||
| vhost-user-backend = { git="https://github.com/eric-14/rust_vhost_.git", branch="experimental_mac" } | ||
| virtio-bindings = { workspace = true } | ||
| virtio-queue = { workspace = true } | ||
| virtio-vsock = "0.11" | ||
| vm-memory = { workspace = true } | ||
| virtio-queue = { git = "https://github.com/uran0sh/vm-virtio.git", branch = "update-vm-memory" } | ||
| virtio-vsock = { git = "https://github.com/uran0sh/vm-virtio.git", branch = "update-vm-memory" } | ||
| vm-memory = { git = "https://github.com/rust-vmm/vm-memory.git", rev = "b2eaf989de2c3b9146ea7625250472501cd793fd", features = ["backend-mmap", "backend-atomic", "backend-bitmap"] } |
| //! The crate introduces a vhost-device-vsock device that enables communication | ||
| //! between an application running in the guest (inside a VM) and an application | ||
| //! running on the host (outside the VM). | ||
| //! | ||
| //! The application running in the guest communicates over VM sockets (AF_VSOCK sockets). | ||
| //! On the host side, the communication mechanism depends on the backend: | ||
| //! - With the Unix domain socket backend (`--uds-path`), the host application communicates over AF_UNIX sockets | ||
| //! - With the vsock backend (`--forward-cid`, `--forward-listen`), the host application communicates over AF_VSOCK sockets | ||
| //! The application running in the guest communicates over VM sockets (AF_VSOCK | ||
| //! sockets). On the host side, the communication mechanism depends on the | ||
| //! backend: | ||
| //! - With the Unix domain socket backend (`--uds-path`), the host application | ||
| //! communicates over AF_UNIX sockets | ||
| //! - With the vsock backend (`--forward-cid`, `--forward-listen`), the host | ||
| //! application communicates over AF_VSOCK sockets | ||
| //! | ||
| //! The main components of the crate are split into various files as described below: | ||
| //! The main components of the crate are split into various files as described | ||
| //! below: | ||
| //! | ||
| //! - [`rxops`] | ||
| //! - Introduces various vsock operations that are enqueued into the rxqueue to be sent to the | ||
| //! guest. Exposes a **RxOps** structure. | ||
| //! - Introduces various vsock operations that are enqueued into the rxqueue | ||
| //! to be sent to the guest. Exposes a **RxOps** structure. | ||
| //! - [`rxqueue`] | ||
| //! - rxqueue contains the pending rx operations corresponding to that connection. The queue is | ||
| //! represented as a bitmap as we handle connection-oriented connections. The module contains | ||
| //! various queue manipulation methods. Exposes a **RxQueue** structure. | ||
| //! - rxqueue contains the pending rx operations corresponding to that | ||
| //! connection. The queue is represented as a bitmap as we handle | ||
| //! connection-oriented connections. The module contains various queue | ||
| //! manipulation methods. Exposes a **RxQueue** structure. | ||
| //! - [`thread_backend`] | ||
| //! - Multiplexes connections between host and guest and calls into per connection methods that | ||
| //! are responsible for processing data and packets corresponding to the connection. Exposes a | ||
| //! **VsockThreadBackend** structure. | ||
| //! - [`txbuf`] | ||
| //! - Module to buffer data that is sent from the guest to the host. The module exposes a **LocalTxBuf** | ||
| //! - Multiplexes connections between host and guest and calls into per | ||
| //! connection methods that are responsible for processing data and packets | ||
| //! corresponding to the connection. Exposes a **VsockThreadBackend** | ||
| //! structure. | ||
| //! - [`txbuf`] | ||
| //! - Module to buffer data that is sent from the guest to the host. The | ||
| //! module exposes a **LocalTxBuf** structure. | ||
| //! - [`vhu_vsock_thread`] | ||
| //! - Module exposes a **VhostUserVsockThread** structure. It also handles new host-initiated | ||
| //! connections and provides interfaces for registering host connections with the epoll fd. Also | ||
| //! provides interfaces for iterating through the rx and tx queues. | ||
| //! - Module exposes a **VhostUserVsockThread** structure. It also handles new | ||
| //! host-initiated connections and provides interfaces for registering host | ||
| //! connections with the epoll fd. Also provides interfaces for iterating | ||
| //! through the rx and tx queues. | ||
| //! - [`vsock_conn`] | ||
| //! - Module introduces a **VsockConnection** structure that represents a single vsock connection | ||
| //! between the guest and the host. It also processes packets according to their type. | ||
| //! - Module introduces a **VsockConnection** structure that represents a | ||
| //! single vsock connection between the guest and the host. It also | ||
| //! processes packets according to their type. | ||
| //! - [`vhu_vsock`] | ||
| //! - Exposes the main vhost-user vsock backend interface. |
There was a problem hiding this comment.
All these changes seems to be unrelated. Please discard them
There was a problem hiding this comment.
I think this is unintentional
There was a problem hiding this comment.
this was local cargo nightly. I will remove the changes
| // .map_err(Error::EpollAdd)?; | ||
|
|
||
| // Ok(()) | ||
| // } |
| // pub fn epoll_unregister(epoll_fd: RawFd, fd: RawFd) -> Result<()> { | ||
| // epoll::ctl( | ||
| // epoll_fd, | ||
| // epoll::ControlOptions::EPOLL_CTL_DEL, | ||
| // fd, | ||
| // epoll::Event::new(epoll::Events::empty(), 0), | ||
| // ) | ||
| // .map_err(Error::EpollRemove)?; | ||
|
|
||
| // Ok(()) | ||
| // } |
|
@luigix25 apologies for the oversight. I will make the recommended changes. |
9e2ff5b to
8d424b0
Compare
4c794a7 to
e8c571f
Compare
Replace epoll with mio to eliminate platform-specific dependencies and allow the vsock to run on both Linux and unix systems. Signed-off-by: EricMwangi <ericmwas01@gmail.com>
Summary of the PR
The PR updates vhost-device-vsock from epoll to mio to support unix systems
In this PR, I have changed the epoll naming to poller for struct vhostdevice. I found retaining epoll would be misleading.
However, I could maintain the naming of epoll to avoid any confusion.
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.