Skip to content

Adding unix support for vhost-device-vsock#965

Open
eric-14 wants to merge 1 commit into
rust-vmm:mainfrom
eric-14:macos
Open

Adding unix support for vhost-device-vsock#965
eric-14 wants to merge 1 commit into
rust-vmm:mainfrom
eric-14:macos

Conversation

@eric-14

@eric-14 eric-14 commented May 25, 2026

Copy link
Copy Markdown

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:

  • All commits in this PR have Signed-Off-By trailers (with
    git commit -s), and the commit message has max 60 characters for the
    summary and max 75 characters for each description line.
  • All added/changed functionality has a corresponding unit/integration
    test.
  • All added/changed public-facing functionality has entries in the "Upcoming
    Release" section of CHANGELOG.md (if no such section exists, please create one).
  • Any newly added unsafe code is properly documented.

@luigix25 luigix25 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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"] }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The git dependencies have been migrated to mio and work on unix.
Splitting the commit results in errors due to difference in API.

Comment on lines +24 to +29
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"] }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

Comment thread vhost-device-vsock/src/main.rs Outdated
Comment on lines 5 to 46
//! 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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All these changes seems to be unrelated. Please discard them

Comment thread vhost-device-vsock/src/.codex Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is unintentional

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was local cargo nightly. I will remove the changes

// .map_err(Error::EpollAdd)?;

// Ok(())
// }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

development leftover?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolved

Comment on lines +270 to +280
// 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(())
// }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolved

Comment thread vhost-device-vsock/src/vhu_vsock_thread.rs Outdated
@eric-14

eric-14 commented Jun 1, 2026

Copy link
Copy Markdown
Author

@luigix25 apologies for the oversight. I will make the recommended changes.

@eric-14 eric-14 force-pushed the macos branch 2 times, most recently from 9e2ff5b to 8d424b0 Compare June 17, 2026 16:37
@eric-14 eric-14 closed this Jun 17, 2026
@eric-14 eric-14 reopened this Jun 17, 2026
@eric-14 eric-14 force-pushed the macos branch 4 times, most recently from 4c794a7 to e8c571f Compare June 17, 2026 18:13
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants