Commit graph

531 commits

Author SHA1 Message Date
Alyssa Ross
34b75fdae5 vhost_user: don't take ownership of Listener
The vhost-device devices all call VhostUserDaemon::serve in a loop, to
handle reconnections.  This is not ideal, because a new listener is
created each loop iteration, which means that each time, the old
socket is unlinked and a new one is created.  This means that there's
a potential race where a frontend attempts to connect to the backend
before the new socket is created.

A more robust way to achieve this would be to have the devices create
their own listeners, and pass the same one to VhostUserDaemon::start
on each loop iteration, instead of letting VhostUserDaemon::serve
create it repeatedly.  This was not previously possible though,
because VhostUserDaemon::start consumed the listener, even though it
didn't need to.

Because it's now possible to call VhostUserDaemon::start multiple
times with the same socket, I've removed the TODO about handling
reconnection.

Signed-off-by: Alyssa Ross <hi@alyssa.is>
2025-09-10 09:09:29 +02:00
Alyssa Ross
e20a5a5bee vhost_user: fix mismatched lifetime warning
warning: hiding a lifetime that's elided elsewhere is confusing
   --> vhost/src/vhost_user/frontend.rs:131:13
    |
131 |     fn node(&self) -> MutexGuard<FrontendInternal> {
    |             ^^^^^     ---------------------------- the same lifetime is hidden here
    |             |
    |             the lifetime is elided here
    |
    = help: the same lifetime is referred to in inconsistent ways, making the signature confusing
    = note: `#[warn(mismatched_lifetime_syntaxes)]` on by default
help: use `'_` for type paths
    |
131 |     fn node(&self) -> MutexGuard<'_, FrontendInternal> {
    |                                  +++

Signed-off-by: Alyssa Ross <hi@alyssa.is>
2025-09-09 14:59:13 +03:00
dependabot[bot]
6a559e2aaf build(deps): bump rust-vmm-ci from 0b1cb86 to fc4584d
Bumps [rust-vmm-ci](https://github.com/rust-vmm/rust-vmm-ci) from `0b1cb86` to `fc4584d`.
- [Commits](0b1cb86353...fc4584d8b8)

---
updated-dependencies:
- dependency-name: rust-vmm-ci
  dependency-version: fc4584d8b805be4e8193d43d9ba6519f9a0f43a5
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-09-02 13:10:28 +02:00
dependabot[bot]
266854e492 build(deps): update userfaultfd requirement
---
updated-dependencies:
- dependency-name: userfaultfd
  dependency-version: 0.9.0
  dependency-type: direct:production
  dependency-group: vhost
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-08-28 09:28:01 +02:00
Wenyu Huang
18bf2a5613 Replace Eventfd with EventNotifier/EventConsumer
Eventfd is Linux-specific. To support more platforms, we replace it with
the EventNotifier/EventConsumer abstractions.
EventSender and EventReceiver are wrappers that encapsulate eventfd functionality
Use pipefd to replace eventfd in the test.

Signed-off-by: Wenyu Huang <huangwenyuu@outlook.com>
2025-08-27 10:18:07 +02:00
Wenyu Huang
e869735f3f chore: update the vmm-sys-util version
Update to v0.15.0 which supports sock_ctrl_msg on POSIX and adds
a cross platform event notification that uses EventFd when available
or pipe().

Because sock_ctrl_msg modifies the recv_with_fds, we need to modify the test
in vhost/src/vhost-user/connection.rs at the same time

Signed-off-by: Wenyu Huang <huangwenyuu@outlook.com>
2025-08-27 10:18:07 +02:00
German Maglione
580f19f16b Fix "mismatched lifetime syntaxes" warning
rust 1.89 made the "mismatched lifetime syntaxes" lint to show a warning
by default:
https://blog.rust-lang.org/2025/08/07/Rust-1.89.0/#mismatched-lifetime-syntaxes-lint

Add a placeholder lifetime to `vhost_user_backend::vring::VringStateMutGuard`
to be explicit.

Signed-off-by: German Maglione <gmaglione@redhat.com>
2025-08-27 10:10:08 +02:00
dependabot[bot]
cfff91eb0a build(deps): bump rust-vmm-ci from af54708 to 0b1cb86
Bumps [rust-vmm-ci](https://github.com/rust-vmm/rust-vmm-ci) from `af54708` to `0b1cb86`.
- [Commits](af54708293...0b1cb86353)

---
updated-dependencies:
- dependency-name: rust-vmm-ci
  dependency-version: 0b1cb86353cc093f2e17d7e9f6820de80a6c274d
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-08-13 11:35:52 +03:00
Alyssa Ross
c2dafc78c1 vhost: impl From<UnixListener> for Listener
It was already possible to do this as follows:

	unsafe { Listener::from_raw_fd(listener.into_raw_fd()) }

This just factors the From implementation out of the FromRawFd
implementation so it's possible to do the conversion without an
unnecessary unsafe in application code.

Signed-off-by: Alyssa Ross <hi@alyssa.is>
2025-07-30 14:09:59 +03:00
Manos Pitsidianakis
fce6393fca CODEOWNERS: add myself as reviewer
Help out with PR reviews and various maintenance tasks.

Signed-off-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
2025-07-24 13:09:49 +02:00
Stefano Garzarella
92b9df3bfd chore: fix new clippy warnings
clippy in the new rust toolchain (1.87) in our CI is highlighting
something to improve.
Mostly done with `cargo clippy --fix` + silence
`clippy::match_overlapping_arm` since EWOULDBLOCK equals to EGAIN on
linux.

Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
2025-07-17 13:12:15 +02:00
dependabot[bot]
55f5b29971 build(deps): bump rust-vmm-ci from aa2f8a9 to af54708
Bumps [rust-vmm-ci](https://github.com/rust-vmm/rust-vmm-ci) from `aa2f8a9` to `af54708`.
- [Commits](aa2f8a90e4...af54708293)

---
updated-dependencies:
- dependency-name: rust-vmm-ci
  dependency-version: af547082938b44b69b6f1bb44c1af8b405d7650c
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-07-17 13:12:15 +02:00
Jinank Jain
eae4f73778 vhost-user-backend: Prepare for new release v0.20.0
This release upgraded virtio-queue and virtio-bindings to latest
released version.

Signed-off-by: Jinank Jain <jinankjain@microsoft.com>
2025-07-03 12:42:25 +02:00
Jinank Jain
3db761bb85 build: Update virtio-queue and virtio-bindings
Bump virtio-queue from v0.16.0 to v0.16.0

Bump virtio-bindings from v0.2.5 to v0.2.6

Signed-off-by: Jinank Jain <jinankjain@microsoft.com>
2025-07-03 12:42:25 +02:00
Hengqi Chen
82e09ed2c4 vhost: Fix broken link in vhost/README.md
The link to vhost-user protocol is 404, replace it with
the latest one.

Signed-off-by: Hengqi Chen <hengqi.chen@gmail.com>
2025-06-27 08:55:59 +02:00
Christian Speich
f9b25c2498 vhost: Fix building docs
Building docs (as on docs.rs) has been broken since 8ee8739. This commit
introduces POSTCOPY and made this feature mutually exclusive with xen.

As docs are build for all features the corresponding check will be
triggered and the docs can not be built.

This patch extends the check to allow both "postcopy" and "xen" to be
enabled when building docs.

Signed-off-by: Christian Speich <christian@spei.ch>
2025-06-25 15:26:34 +02:00
Nelson Wong
03ba6ea92c vhost: correct 'trucate' to 'truncate'
There are several typos when using "truncate" on some messages and on the error type \`FileTruncateError\`.

Signed-off-by: Nelson Wong <wong.nel@protonmail.com>
2025-06-18 16:20:28 +03:00
Jinank Jain
9a744c22c8 vhost: Fix clippy warning from nightly compiler
There is a new warning reported by nightly compiler about mismatched
lifetime syntaxes. Add the missing lifetime where ever required.

Signed-off-by: Jinank Jain <jinankjain@microsoft.com>
2025-06-13 10:37:23 +02:00
Jinank Jain
49afe46e17 vhost-user-backend: Prepare for new release v0.19.0
This release upgraded virtio-queue and virtio-bindings to latest
released version.

Signed-off-by: Jinank Jain <jinankjain@microsoft.com>
2025-06-12 13:55:46 +02:00
Jinank Jain
ad7268f5e7 build: Update virtio-queue and virtio-bindings
Bump virtio-queue from v0.14.0 to v0.15.0

Bump virtio-bindings from v0.2.1 to v0.2.5

Signed-off-by: Jinank Jain <jinankjain@microsoft.com>
2025-06-12 13:55:46 +02:00
dependabot[bot]
77aed7480e build(deps): bump rust-vmm-ci from c3ef897 to aa2f8a9
Bumps [rust-vmm-ci](https://github.com/rust-vmm/rust-vmm-ci) from `c3ef897` to `aa2f8a9`.
- [Commits](c3ef897738...aa2f8a90e4)

---
updated-dependencies:
- dependency-name: rust-vmm-ci
  dependency-version: aa2f8a90e46533de8a58f19cd0c417de856d4437
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-06-10 10:47:50 +02:00
Babis Chalios
9c8dc0b749 vhost-user-backend: prepare v0.18.0 release
This release
1. Adds support for `VHOST_USER_GET_SHARED_OBJECT`
2. Updates to vhost to 0.14.0, vm-memory 0.16.2 and vmm-sys-util to
   0.14.0

Signed-off-by: Babis Chalios <bchalios@amazon.es>
2025-06-04 10:15:26 +02:00
Babis Chalios
31d323e293 vhost: Prepare v0.14.0 release
This release:
1. Adds support for `VHOST_USER_GET_SHARED_OBJECT`
2. Fixes the reply header for an error case in POSTCOPY_ADVISE
3. `VHOST_USER_PROTOCOL_F_REPLY_ACK` is now always supported by backends
4. Bumps vm-memory to 0.16.2 and vmm-sys-util to 0.14.0

Signed-off-by: Babis Chalios <bchalios@amazon.es>
2025-06-04 10:15:26 +02:00
Alyssa Ross
14db3cd165 vhost_user: fix replies without GET_PROTOCOL_FEATURES
I observed hangs in the following situation when using Cloud
Hypervisor with virtiofsd:

1. Start virtiofsd
2. Start Cloud Hypervisor instance 1, connected to virtiofsd.
3. Start Cloud Hypervisor instance 2, waiting for migration.
4. Migrate VM from Cloud Hypervisor instance 1 to 2.
5. Start virtiofsd again.

The hangs happened because Cloud Hypervisor remembered, as part of the
migration data, which vhost-user protocol features the backend for its
fs device supported.  Instance 2 therefore never sent
GET_PROTOCOL_FEATURES to the second invocation of virtiofsd.  This
should work, but it didn't, because update_reply_ack_flag() checked
whether self.protocol_features contained GET_PROTOCOL_FEATURES, but
self.protocol_features is only filled in when GET_PROTOCOL_FEATURES is
called.  As a result, Cloud Hypervisor expected a reply that virtiofsd
would never send.

Since REPLY_ACK is handled entirely by the vhost-user library, and not
by the backend, there's no need to ask the backend whether it supports
REPLY_ACK in the first place, so we can just drop the check for that
from update_reply_ack_flag().  We know that we always support it, so
we just need to check whether the backend has acked it.  This fixes
the hang described above.

Since we will now always reply if the backend acks the feature,
REPLY_ACK is now always included in the set of features returned by
GET_PROTOCOL_FEATURES, just like with XEN_MMAP (when enabled).

Signed-off-by: Alyssa Ross <hi@alyssa.is>
2025-06-03 15:56:15 +02:00
dependabot[bot]
8c7cc594ac build(deps): update nix requirement
Updates the requirements on [nix](https://github.com/nix-rust/nix) to permit the latest version.

Updates `nix` to 0.30.1
- [Changelog](https://github.com/nix-rust/nix/blob/master/CHANGELOG.md)
- [Commits](https://github.com/nix-rust/nix/compare/v0.29.0...v0.30.1)

---
updated-dependencies:
- dependency-name: nix
  dependency-version: 0.30.1
  dependency-type: direct:production
  dependency-group: vhost
...

Signed-off-by: dependabot[bot] <support@github.com>
[SG] adapted the memfd_create call to comply with the new nix v0.30
     interface
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
2025-06-03 13:40:14 +02:00
Babis Chalios
1e1ec87740 build: bump vmm-sys-util to 0.14.0
Update vm-sys-util crate from 0.12.1 to 0.14.0. Also, bump vm-memory to
latest 0.16.2 which uses that vmm-sys-util version.

Signed-off-by: Babis Chalios <bchalios@amazon.es>
2025-06-03 09:08:36 +02:00
Paolo Bonzini
888165bd8b set_log_base: use MmapRegion::bitmap() directly
For use in QEMU, I would like GuestMemoryRegion to return a BitmapSlice
instead of a &Bitmap.  This adds some flexibility that QEMU needs in
order to support a single global dirty bitmap that is sliced by the
various GuestMemoryRegions.

However, this removes access to the BitmapReplace trait, because it is of
course not possible to replace a slice of the bitmap only.  Fortunately,
vhost is built around the GM<> type alias, which has a pluggable bitmap
type but hardcodes the backend:

    type GM<B> = GuestMemoryAtomic<GuestMemoryMmap<B>>;

and therefore `region` is known to be a GuestRegionMmap.  Adding a
single dereference of the GuestRegionMmap returns the MmapRegion to
which the bitmap is attached, thus calling MmapRegion::bitmap() instead
of <GuestRegionMmap as GuestRegion>::bitmap().

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-05-21 13:57:16 +02:00
Alyssa Ross
cd05ac59b7 vhost: fix markdown formatting of docs heading
Signed-off-by: Alyssa Ross <hi@alyssa.is>
2025-03-27 17:45:18 +01:00
Alyssa Ross
c0f8a9f4f4 vhost_user: format links in docs correctly
This resolves a rustdoc warning, and makes the links appear as links
in the rendered documentation.

Signed-off-by: Alyssa Ross <hi@alyssa.is>
2025-03-27 13:55:01 +01:00
dependabot[bot]
1e444b5b19 build(deps): bump rust-vmm-ci from 8ae03e5 to c3ef897
Bumps [rust-vmm-ci](https://github.com/rust-vmm/rust-vmm-ci) from `8ae03e5` to `c3ef897`.
- [Commits](8ae03e5c36...c3ef897738)

---
updated-dependencies:
- dependency-name: rust-vmm-ci
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-03-27 09:03:28 +01:00
Stefano Garzarella
d539be999f vhost: fix clippy warnings on Rust 1.85
Our CI is being upgraded to Rust 1.85 and this will produce new warnings
from clippy like this one:

  error: this `map_or` can be simplified
    --> vhost/src/vhost_kern/mod.rs:79:12
     |
  79 |           if GuestAddress(config_data.desc_table_addr)
     |  ____________^
  80 | |             .checked_add(desc_table_size)
  81 | |             .map_or(true, |v| !m.address_in_range(v))
     | |_____________________________________________________^
     |
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_map_or
     = note: `-D clippy::unnecessary-map-or` implied by `-D warnings`
     = help: to override `-D warnings` add `#[allow(clippy::unnecessary_map_or)]`
  help: use is_none_or instead
     |
  79 ~         if GuestAddress(config_data.desc_table_addr)
  80 +             .checked_add(desc_table_size).is_none_or(|v| !m.address_in_range(v))
     |

Apply the advice using `cargo clippy --fix`.

Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
2025-03-25 14:30:22 +01:00
dependabot[bot]
425a3c0e86 build(deps): bump rust-vmm-ci from 2d733b0 to 8ae03e5
Bumps [rust-vmm-ci](https://github.com/rust-vmm/rust-vmm-ci) from `2d733b0` to `8ae03e5`.
- [Commits](2d733b05f0...8ae03e5c36)

---
updated-dependencies:
- dependency-name: rust-vmm-ci
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-03-11 09:26:28 +01:00
dependabot[bot]
6b13b83ec4 build(deps): bump rust-vmm-ci from 09aef99 to 2d733b0
Bumps [rust-vmm-ci](https://github.com/rust-vmm/rust-vmm-ci) from `09aef99` to `2d733b0`.
- [Commits](09aef997d8...2d733b05f0)

---
updated-dependencies:
- dependency-name: rust-vmm-ci
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-02-25 09:27:39 +01:00
dependabot[bot]
056e947be5 build(deps): bump rust-vmm-ci from c04433e to 09aef99
Bumps [rust-vmm-ci](https://github.com/rust-vmm/rust-vmm-ci) from `c04433e` to `09aef99`.
- [Commits](c04433e8d8...09aef997d8)

---
updated-dependencies:
- dependency-name: rust-vmm-ci
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-12-17 14:33:19 +01:00
Stefano Garzarella
f936944fd1 vhost-user-backend: fix clippy warnings
New clippy version in the CI highlighted some code to improve.
This patch is generated using `clippy --fix ...`.

Fixed 2 type of warnings:
1 - error: the following explicit lifetimes could be elided: 'a
       --> vhost-user-backend/src/bitmap.rs:109:6
        |
    109 | impl<'a> WithBitmapSlice<'a> for BitmapMmapRegion {

2 - error: unnecessary closure used to substitute value for `Option::None`
       --> vhost-user-backend/src/handler.rs:356:21
        |
    356 |           let vring = self
        |  _____________________^
    357 | |             .vrings
    358 | |             .get(index as usize)
    359 | |             .ok_or_else(|| VhostUserError::InvalidParam)?;

Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
2024-12-17 14:33:19 +01:00
dependabot[bot]
4f33b98a5d build(deps): bump rust-vmm-ci from 1150c47 to c04433e
Bumps [rust-vmm-ci](https://github.com/rust-vmm/rust-vmm-ci) from `1150c47` to `c04433e`.
- [Commits](1150c47872...c04433e8d8)

---
updated-dependencies:
- dependency-name: rust-vmm-ci
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-12-10 09:12:37 +01:00
Dorinda Bassey
176f44a256 CHANGELOG: VHOST_USER_SHARED_OBJECT support
Add VHOST_USER_SHARED_OBJECT support in CHANGELOG.md files

Signed-off-by: Dorinda Bassey <dbassey@redhat.com>
2024-11-19 13:51:47 +01:00
Dorinda Bassey
274d4dd062 Add test for VHOST_USER_SHARED_OBJECT
add test to trigger the VHOST_USER_SHARED_OBJECT message
on both frontend and backend.

Signed-off-by: Dorinda Bassey <dbassey@redhat.com>
2024-11-19 13:51:47 +01:00
Dorinda Bassey
23a4b43ac6 vhost_user: add VHOST_GET_SHARED_OBJECT frontend support
Add frontend support of `VHOST_GET_SHARED_OBJECT` message
to request a file descriptor from the backend.

Signed-off-by: Dorinda Bassey <dbassey@redhat.com>
2024-11-19 13:51:47 +01:00
Dorinda Bassey
83d0f48256 Forward VHOST_USER_GET_SHARED_OBJECT message
Add support for the `VHOST_USER_GET_SHARED_OBJECT` request
in the backend. The GET_SHARED_OBJECT message is only usable
when VhostUserProtocolFeatures::SHARED_OBJECT feature is
negotiated. This support involves implementing a new method
`get_shared_object` to enable the frontend to retrieve a fd
from the backend about shared objects.  When the frontend
sends this `GET_SHARED_OBJECT` message to the backend, the
backend opens a fd for use, and sends it's fd to the frontend.

The implementation of the `get_shared_object` method is
optional, and ensure that the function `get_shared_object`
returns an error if the backend does not implement it.
If the back-end supports shared objects, it should return
a `File` representing the fd.

Signed-off-by: Dorinda Bassey <dbassey@redhat.com>
2024-11-19 13:51:47 +01:00
Sergio Lopez
0b820e547f vhost: update uuid dep to 1.11.0
Signed-off-by: Sergio Lopez <slp@redhat.com>
2024-11-12 15:08:14 +01:00
Dorinda Bassey
c2b51047fd vhost: Fix reply header for error case in POSTCOPY_ADVISE
The reply header call is moved outside the match
statement to ensure consistent reply header usage
in both success and error cases of postcopy_advice.
This change fixes an issue where the reply header
was not being used in the error case of postcopy_advice.

Signed-off-by: Dorinda Bassey <dbassey@redhat.com>
2024-11-12 12:12:02 +01:00
Stefano Garzarella
3a49a22ffb CHANGELOGs: uniform and fix some inconsistencies
Every time I do a release I notice this difference between
changelogs in this workspace, so let's try to uniform them by using
the form used in vhost-user-backend: without square brackets in the
title of the release and the `v` as prefix (v0.0.0).

Also fixed some difference in how we link PRs, let's follow the
most used way: [[#000]](url)

Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
2024-11-05 09:54:44 +01:00
Stefano Garzarella
875f679ca8 vhost-user-backend: prepare v0.17.0 release
This release adds support for `VHOST_USER_RESET_DEVICE` and
updates vm-memory to 0.16.0 and virtio-queue to 0.13.0.

Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
2024-11-04 17:19:57 +01:00
Stefano Garzarella
972a8a5de6 vhost: prepare v0.13.0 release
This release adds support for `VHOST_USER_RESET_DEVICE` and
updates vm-memory to 0.16.0 and virtio-queue to 0.13.0.

Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
2024-11-04 17:19:57 +01:00
Stefano Garzarella
f107ee8f7a vhost-user-backend: yank v0.16.0 release
This version got yanked because the `gpu_socket` feature introduced
in this release was causing problems
(see [#265](https://github.com/rust-vmm/vhost/issues/265)).
Starting with the next version (v0.16.1), the `gpu_socket`
feature was removed.

Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
2024-11-04 09:51:44 +01:00
Stefano Garzarella
9f82b5c6c9 vhost: yank v0.12.0 release
This version got yanked because the `gpu_socket` feature introduced
in this release was causing problems
(see [#265](https://github.com/rust-vmm/vhost/issues/265)).
Starting with the next version (v0.12.1), the `gpu_socket`
feature was removed.

Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
2024-11-04 09:51:44 +01:00
Hanna Czenczek
d983ae07f7 CHANGELOG: VHOST_USER_RESET_DEVICE support
Announce VHOST_USER_RESET_DEVICE support in both CHANGELOG.md files.

Signed-off-by: Hanna Czenczek <hreitz@redhat.com>
2024-10-25 14:22:08 +02:00
Hanna Czenczek
86eb78875a vhost-user: Provide RESET_DEVICE front-end support
Added mostly for being able to add a reasonable test to
vhost-user-backend/tests/vhost-user-server.rs.

Signed-off-by: Hanna Czenczek <hreitz@redhat.com>
2024-10-25 14:22:08 +02:00
Hanna Czenczek
ff08ca095c vhost-user-server test: Use features constant
Add an associated const to MockVhostBackend that reflects the feature
bits it supports, so we can easily verify this value in other places.

Signed-off-by: Hanna Czenczek <hreitz@redhat.com>
2024-10-25 14:22:08 +02:00