From 9040bcb7269f8f2b165d9fc4fc629ef54d6490dc Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 18 Nov 2025 17:06:55 +0000 Subject: [PATCH] build(deps): bump the rust-vmm group across 2 directories with 6 updates Bumps the rust-vmm group with 6 updates in the / directory: | Package | From | To | | --- | --- | --- | | [vhost](https://github.com/rust-vmm/vhost) | `0.14.0` | `0.15.0` | | [vhost-user-backend](https://github.com/rust-vmm/vhost) | `0.20.0` | `0.21.0` | | [virtio-queue](https://github.com/rust-vmm/vm-virtio) | `0.16.0` | `0.17.0` | | [vm-memory](https://github.com/rust-vmm/vm-memory) | `0.16.2` | `0.17.1` | | [vmm-sys-util](https://github.com/rust-vmm/vmm-sys-util) | `0.14.0` | `0.15.0` | | [virtio-vsock](https://github.com/rust-vmm/vm-virtio) | `0.10.0` | `0.11.0` | Bumps the rust-vmm group with 5 updates in the /staging directory: | Package | From | To | | --- | --- | --- | | [vhost](https://github.com/rust-vmm/vhost) | `0.14.0` | `0.15.0` | | [vhost-user-backend](https://github.com/rust-vmm/vhost) | `0.20.0` | `0.21.0` | | [virtio-queue](https://github.com/rust-vmm/vm-virtio) | `0.16.0` | `0.17.0` | | [vm-memory](https://github.com/rust-vmm/vm-memory) | `0.16.2` | `0.17.1` | | [vmm-sys-util](https://github.com/rust-vmm/vmm-sys-util) | `0.14.0` | `0.15.0` | Updates `vhost` from 0.14.0 to 0.15.0 - [Release notes](https://github.com/rust-vmm/vhost/releases) - [Commits](https://github.com/rust-vmm/vhost/compare/vhost-v0.14.0...vhost-v0.15.0) Updates `vhost-user-backend` from 0.20.0 to 0.21.0 - [Release notes](https://github.com/rust-vmm/vhost/releases) - [Commits](https://github.com/rust-vmm/vhost/compare/vhost-user-backend-v0.20.0...vhost-user-backend-v0.21.0) Updates `virtio-queue` from 0.16.0 to 0.17.0 - [Release notes](https://github.com/rust-vmm/vm-virtio/releases) - [Commits](https://github.com/rust-vmm/vm-virtio/compare/virtio-queue-v0.16.0...virtio-queue-v0.17.0) Updates `vm-memory` from 0.16.2 to 0.17.1 - [Release notes](https://github.com/rust-vmm/vm-memory/releases) - [Changelog](https://github.com/rust-vmm/vm-memory/blob/main/CHANGELOG.md) - [Commits](https://github.com/rust-vmm/vm-memory/compare/v0.16.2...v0.17.1) Updates `vmm-sys-util` from 0.14.0 to 0.15.0 - [Release notes](https://github.com/rust-vmm/vmm-sys-util/releases) - [Changelog](https://github.com/rust-vmm/vmm-sys-util/blob/main/CHANGELOG.md) - [Commits](https://github.com/rust-vmm/vmm-sys-util/compare/v0.14.0...v0.15.0) Updates `virtio-vsock` from 0.10.0 to 0.11.0 - [Release notes](https://github.com/rust-vmm/vm-virtio/releases) - [Commits](https://github.com/rust-vmm/vm-virtio/compare/virtio-vsock-v0.10.0...virtio-vsock-v0.11.0) Updates `vhost` from 0.14.0 to 0.15.0 - [Release notes](https://github.com/rust-vmm/vhost/releases) - [Commits](https://github.com/rust-vmm/vhost/compare/vhost-v0.14.0...vhost-v0.15.0) Updates `vhost-user-backend` from 0.20.0 to 0.21.0 - [Release notes](https://github.com/rust-vmm/vhost/releases) - [Commits](https://github.com/rust-vmm/vhost/compare/vhost-user-backend-v0.20.0...vhost-user-backend-v0.21.0) Updates `virtio-queue` from 0.16.0 to 0.17.0 - [Release notes](https://github.com/rust-vmm/vm-virtio/releases) - [Commits](https://github.com/rust-vmm/vm-virtio/compare/virtio-queue-v0.16.0...virtio-queue-v0.17.0) Updates `vm-memory` from 0.16.2 to 0.17.1 - [Release notes](https://github.com/rust-vmm/vm-memory/releases) - [Changelog](https://github.com/rust-vmm/vm-memory/blob/main/CHANGELOG.md) - [Commits](https://github.com/rust-vmm/vm-memory/compare/v0.16.2...v0.17.1) Updates `vmm-sys-util` from 0.14.0 to 0.15.0 - [Release notes](https://github.com/rust-vmm/vmm-sys-util/releases) - [Changelog](https://github.com/rust-vmm/vmm-sys-util/blob/main/CHANGELOG.md) - [Commits](https://github.com/rust-vmm/vmm-sys-util/compare/v0.14.0...v0.15.0) Updates `vhost` from 0.14.0 to 0.15.0 - [Release notes](https://github.com/rust-vmm/vhost/releases) - [Commits](https://github.com/rust-vmm/vhost/compare/vhost-v0.14.0...vhost-v0.15.0) Updates `vhost-user-backend` from 0.20.0 to 0.21.0 - [Release notes](https://github.com/rust-vmm/vhost/releases) - [Commits](https://github.com/rust-vmm/vhost/compare/vhost-user-backend-v0.20.0...vhost-user-backend-v0.21.0) Updates `virtio-queue` from 0.16.0 to 0.17.0 - [Release notes](https://github.com/rust-vmm/vm-virtio/releases) - [Commits](https://github.com/rust-vmm/vm-virtio/compare/virtio-queue-v0.16.0...virtio-queue-v0.17.0) Updates `vm-memory` from 0.16.2 to 0.17.1 - [Release notes](https://github.com/rust-vmm/vm-memory/releases) - [Changelog](https://github.com/rust-vmm/vm-memory/blob/main/CHANGELOG.md) - [Commits](https://github.com/rust-vmm/vm-memory/compare/v0.16.2...v0.17.1) Updates `vmm-sys-util` from 0.14.0 to 0.15.0 - [Release notes](https://github.com/rust-vmm/vmm-sys-util/releases) - [Changelog](https://github.com/rust-vmm/vmm-sys-util/blob/main/CHANGELOG.md) - [Commits](https://github.com/rust-vmm/vmm-sys-util/compare/v0.14.0...v0.15.0) Updates `vhost` from 0.14.0 to 0.15.0 - [Release notes](https://github.com/rust-vmm/vhost/releases) - [Commits](https://github.com/rust-vmm/vhost/compare/vhost-v0.14.0...vhost-v0.15.0) Updates `vhost-user-backend` from 0.20.0 to 0.21.0 - [Release notes](https://github.com/rust-vmm/vhost/releases) - [Commits](https://github.com/rust-vmm/vhost/compare/vhost-user-backend-v0.20.0...vhost-user-backend-v0.21.0) Updates `virtio-queue` from 0.16.0 to 0.17.0 - [Release notes](https://github.com/rust-vmm/vm-virtio/releases) - [Commits](https://github.com/rust-vmm/vm-virtio/compare/virtio-queue-v0.16.0...virtio-queue-v0.17.0) Updates `vm-memory` from 0.16.2 to 0.17.1 - [Release notes](https://github.com/rust-vmm/vm-memory/releases) - [Changelog](https://github.com/rust-vmm/vm-memory/blob/main/CHANGELOG.md) - [Commits](https://github.com/rust-vmm/vm-memory/compare/v0.16.2...v0.17.1) Updates `vmm-sys-util` from 0.14.0 to 0.15.0 - [Release notes](https://github.com/rust-vmm/vmm-sys-util/releases) - [Changelog](https://github.com/rust-vmm/vmm-sys-util/blob/main/CHANGELOG.md) - [Commits](https://github.com/rust-vmm/vmm-sys-util/compare/v0.14.0...v0.15.0) --- updated-dependencies: - dependency-name: vhost dependency-version: 0.15.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: rust-vmm - dependency-name: vhost-user-backend dependency-version: 0.21.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: rust-vmm - dependency-name: virtio-queue dependency-version: 0.17.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: rust-vmm - dependency-name: vm-memory dependency-version: 0.17.1 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: rust-vmm - dependency-name: vmm-sys-util dependency-version: 0.15.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: rust-vmm - dependency-name: virtio-vsock dependency-version: 0.11.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: rust-vmm - dependency-name: vhost dependency-version: 0.15.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: rust-vmm - dependency-name: vhost-user-backend dependency-version: 0.21.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: rust-vmm - dependency-name: virtio-queue dependency-version: 0.17.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: rust-vmm - dependency-name: vm-memory dependency-version: 0.17.1 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: rust-vmm - dependency-name: vmm-sys-util dependency-version: 0.15.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: rust-vmm - dependency-name: vhost dependency-version: 0.15.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: rust-vmm - dependency-name: vhost-user-backend dependency-version: 0.21.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: rust-vmm - dependency-name: virtio-queue dependency-version: 0.17.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: rust-vmm - dependency-name: vm-memory dependency-version: 0.17.1 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: rust-vmm - dependency-name: vmm-sys-util dependency-version: 0.15.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: rust-vmm - dependency-name: vhost dependency-version: 0.15.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: rust-vmm - dependency-name: vhost-user-backend dependency-version: 0.21.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: rust-vmm - dependency-name: virtio-queue dependency-version: 0.17.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: rust-vmm - dependency-name: vm-memory dependency-version: 0.17.1 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: rust-vmm - dependency-name: vmm-sys-util dependency-version: 0.15.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: rust-vmm ... Signed-off-by: dependabot[bot] SG: adapted code to the new changes in vhost-user-backend and vm-memory: - used EventConsumer & EventNotifier instead of EventFd for exit_event - removed vm_memory::Error::InvalidGuestRegion - included vm_memory::Bytes needed for read_volatile_from Signed-off-by: Stefano Garzarella --- Cargo.lock | 27 +++++++++++---------- staging/Cargo.lock | 23 +++++++++--------- staging/vhost-device-video/Cargo.toml | 14 +++++------ staging/vhost-device-video/src/vhu_video.rs | 19 ++++++++++----- vhost-device-can/Cargo.toml | 14 +++++------ vhost-device-can/src/vhu_can.rs | 17 +++++++++---- vhost-device-console/Cargo.toml | 14 +++++------ vhost-device-console/src/vhu_console.rs | 17 +++++++++---- vhost-device-gpio/Cargo.toml | 14 +++++------ vhost-device-gpio/src/vhu_gpio.rs | 16 ++++++++---- vhost-device-gpu/Cargo.toml | 14 +++++------ vhost-device-gpu/src/device.rs | 19 +++++++++++---- vhost-device-i2c/Cargo.toml | 14 +++++------ vhost-device-i2c/src/vhu_i2c.rs | 16 ++++++++---- vhost-device-input/Cargo.toml | 14 +++++------ vhost-device-input/src/vhu_input.rs | 16 ++++++++---- vhost-device-rng/Cargo.toml | 14 +++++------ vhost-device-rng/src/vhu_rng.rs | 18 +++++++++----- vhost-device-scmi/Cargo.toml | 12 ++++----- vhost-device-scmi/src/vhu_scmi.rs | 16 ++++++++---- vhost-device-scsi/Cargo.toml | 12 ++++----- vhost-device-scsi/src/vhu_scsi.rs | 17 +++++++++---- vhost-device-scsi/src/virtio.rs | 2 +- vhost-device-sound/Cargo.toml | 14 +++++------ vhost-device-sound/src/device.rs | 22 +++++++++++------ vhost-device-spi/Cargo.toml | 14 +++++------ vhost-device-spi/src/vhu_spi.rs | 16 ++++++++---- vhost-device-template/Cargo.toml | 14 +++++------ vhost-device-template/src/backend.rs | 17 +++++++++---- vhost-device-vsock/Cargo.toml | 14 +++++------ vhost-device-vsock/src/vhu_vsock.rs | 21 +++++++++++----- 31 files changed, 295 insertions(+), 196 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7a956dc..7d8ba14 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1994,9 +1994,9 @@ checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" [[package]] name = "vhost" -version = "0.14.0" +version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a4dcad85a129d97d5d4b2f3c47a4affdeedd76bdcd02094bcb5d9b76cac2d05" +checksum = "c76d90ce3c6b37d610a5304c9a445cfff580cf8b4b9fd02fb256aaf68552c28a" dependencies = [ "bitflags 2.10.0", "libc 0.2.177", @@ -2276,9 +2276,9 @@ dependencies = [ [[package]] name = "vhost-user-backend" -version = "0.20.0" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e183205a9ba7cb9c47fcb0fc0a07fc295a110efbb11ab78ad0d793b0a38a7bde" +checksum = "783587813a59c42c36519a6e12bb31eb2d7fa517377428252ba4cc2312584243" dependencies = [ "libc 0.2.177", "log", @@ -2319,10 +2319,11 @@ checksum = "804f498a26d5a63be7bbb8bdcd3869c3f286c4c4a17108905276454da0caf8cb" [[package]] name = "virtio-queue" -version = "0.16.0" +version = "0.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb0479158f863e59323771a1f684d843962f76960b86fecfec2bfa9c8f0f9180" +checksum = "e358084f32ed165fddb41d98ff1b7ff3c08b9611d8d6114a1b422e2e85688baf" dependencies = [ + "libc 0.2.177", "log", "virtio-bindings", "vm-memory", @@ -2331,9 +2332,9 @@ dependencies = [ [[package]] name = "virtio-vsock" -version = "0.10.0" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e49ff39d455ce92f01a910cb11b01e54b61c6f3b5d308a144c86044b39955b79" +checksum = "8e7822f0d005c2451d4cdbb42cc9581cabb42a0fb64347efe5492fa548e8931a" dependencies = [ "virtio-bindings", "virtio-queue", @@ -2342,23 +2343,23 @@ dependencies = [ [[package]] name = "vm-memory" -version = "0.16.2" +version = "0.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fd5e56d48353c5f54ef50bd158a0452fc82f5383da840f7b8efc31695dd3b9d" +checksum = "f39348a049689cabd3377cdd9182bf526ec76a6f823b79903896452e9d7a7380" dependencies = [ "arc-swap", "bitflags 2.10.0", "libc 0.2.177", - "thiserror 1.0.69", + "thiserror 2.0.17", "vmm-sys-util", "winapi", ] [[package]] name = "vmm-sys-util" -version = "0.14.0" +version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d21f366bf22bfba3e868349978766a965cbe628c323d58e026be80b8357ab789" +checksum = "506c62fdf617a5176827c2f9afbcf1be155b03a9b4bf9617a60dbc07e3a1642f" dependencies = [ "bitflags 1.3.2", "libc 0.2.177", diff --git a/staging/Cargo.lock b/staging/Cargo.lock index c948c75..a7ce15b 100644 --- a/staging/Cargo.lock +++ b/staging/Cargo.lock @@ -805,9 +805,9 @@ dependencies = [ [[package]] name = "vhost" -version = "0.14.0" +version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a4dcad85a129d97d5d4b2f3c47a4affdeedd76bdcd02094bcb5d9b76cac2d05" +checksum = "c76d90ce3c6b37d610a5304c9a445cfff580cf8b4b9fd02fb256aaf68552c28a" dependencies = [ "bitflags 2.10.0", "libc", @@ -843,9 +843,9 @@ dependencies = [ [[package]] name = "vhost-user-backend" -version = "0.20.0" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e183205a9ba7cb9c47fcb0fc0a07fc295a110efbb11ab78ad0d793b0a38a7bde" +checksum = "783587813a59c42c36519a6e12bb31eb2d7fa517377428252ba4cc2312584243" dependencies = [ "libc", "log", @@ -864,10 +864,11 @@ checksum = "804f498a26d5a63be7bbb8bdcd3869c3f286c4c4a17108905276454da0caf8cb" [[package]] name = "virtio-queue" -version = "0.16.0" +version = "0.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb0479158f863e59323771a1f684d843962f76960b86fecfec2bfa9c8f0f9180" +checksum = "e358084f32ed165fddb41d98ff1b7ff3c08b9611d8d6114a1b422e2e85688baf" dependencies = [ + "libc", "log", "virtio-bindings", "vm-memory", @@ -876,23 +877,23 @@ dependencies = [ [[package]] name = "vm-memory" -version = "0.16.2" +version = "0.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fd5e56d48353c5f54ef50bd158a0452fc82f5383da840f7b8efc31695dd3b9d" +checksum = "f39348a049689cabd3377cdd9182bf526ec76a6f823b79903896452e9d7a7380" dependencies = [ "arc-swap", "bitflags 2.10.0", "libc", - "thiserror 1.0.69", + "thiserror 2.0.17", "vmm-sys-util", "winapi", ] [[package]] name = "vmm-sys-util" -version = "0.14.0" +version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d21f366bf22bfba3e868349978766a965cbe628c323d58e026be80b8357ab789" +checksum = "506c62fdf617a5176827c2f9afbcf1be155b03a9b4bf9617a60dbc07e3a1642f" dependencies = [ "bitflags 1.3.2", "libc", diff --git a/staging/vhost-device-video/Cargo.toml b/staging/vhost-device-video/Cargo.toml index ca7b440..86983a4 100644 --- a/staging/vhost-device-video/Cargo.toml +++ b/staging/vhost-device-video/Cargo.toml @@ -26,17 +26,17 @@ log = "0.4" libc = "0.2.177" thiserror = "2.0" futures-executor = { version = "0.3", features = ["thread-pool"] } -vhost = { version = "0.14", features = ["vhost-user-backend"] } -vhost-user-backend = "0.20" +vhost = { version = "0.15", features = ["vhost-user-backend"] } +vhost-user-backend = "0.21" virtio-bindings = "0.2.5" -virtio-queue = "0.16" -vm-memory = "0.16.0" -vmm-sys-util = "0.14" +virtio-queue = "0.17" +vm-memory = "0.17.1" +vmm-sys-util = "0.15" v4l2r = { git = "https://github.com/Gnurou/v4l2r", rev = "110fd77", optional = true } [dev-dependencies] assert_matches = "1.5" rstest = "0.26.1" tempfile = "3.23.0" -virtio-queue = { version = "0.16", features = ["test-utils"] } -vm-memory = { version = "0.16.0", features = ["backend-mmap", "backend-atomic"] } +virtio-queue = { version = "0.17", features = ["test-utils"] } +vm-memory = { version = "0.17.1", features = ["backend-mmap", "backend-atomic"] } diff --git a/staging/vhost-device-video/src/vhu_video.rs b/staging/vhost-device-video/src/vhu_video.rs index 000d8dc..15123e5 100644 --- a/staging/vhost-device-video/src/vhu_video.rs +++ b/staging/vhost-device-video/src/vhu_video.rs @@ -20,7 +20,7 @@ use virtio_queue::DescriptorChain; use vm_memory::{ByteValued, GuestMemoryAtomic, GuestMemoryLoadGuard, GuestMemoryMmap, Le32}; use vmm_sys_util::{ epoll::EventSet, - eventfd::{EventFd, EFD_NONBLOCK}, + event::{new_event_consumer_and_notifier, EventConsumer, EventFlag, EventNotifier}, }; use crate::{vhu_video_thread::VhostUserVideoThread, video_backends}; @@ -127,7 +127,8 @@ unsafe impl ByteValued for VirtioVideoConfig {} pub(crate) struct VuVideoBackend { config: VirtioVideoConfig, pub threads: Vec>, - pub exit_event: EventFd, + pub exit_consumer: EventConsumer, + pub exit_notifier: EventNotifier, } impl VuVideoBackend { @@ -137,6 +138,8 @@ impl VuVideoBackend { video_backend, video_path, )?)); + let (exit_consumer, exit_notifier) = new_event_consumer_and_notifier(EventFlag::NONBLOCK) + .map_err(|_| VuVideoError::EventFdError)?; Ok(Self { config: VirtioVideoConfig { version: 0.into(), @@ -145,7 +148,8 @@ impl VuVideoBackend { device_name: [0; 32], }, threads: vec![Mutex::new(VhostUserVideoThread::new(backend.clone())?)], - exit_event: EventFd::new(EFD_NONBLOCK).map_err(|_| VuVideoError::EventFdError)?, + exit_consumer, + exit_notifier, }) } } @@ -259,8 +263,10 @@ impl VhostUserBackendMut for VuVideoBackend { buf[offset..offset + size].to_vec() } - fn exit_event(&self, _thread_index: usize) -> Option { - self.exit_event.try_clone().ok() + fn exit_event(&self, _thread_index: usize) -> Option<(EventConsumer, EventNotifier)> { + let consumer = self.exit_consumer.try_clone().ok()?; + let notifier = self.exit_notifier.try_clone().ok()?; + Some((consumer, notifier)) } } @@ -344,7 +350,8 @@ pub mod tests { let exit = backend.exit_event(0); assert!(exit.is_some()); - exit.unwrap().write(1).unwrap(); + let (_, notifier) = exit.unwrap(); + notifier.notify().unwrap(); for queue in COMMAND_Q..VIDEO_EVENT { // Skip exit event if queue == NUM_QUEUES as u16 { diff --git a/vhost-device-can/Cargo.toml b/vhost-device-can/Cargo.toml index dc0ce25..4e77920 100644 --- a/vhost-device-can/Cargo.toml +++ b/vhost-device-can/Cargo.toml @@ -21,14 +21,14 @@ log = "0.4" thiserror = "2.0" queues = "1.0.2" socketcan = "3.5.0" -vhost = { version = "0.14", features = ["vhost-user-backend"] } -vhost-user-backend = "0.20" +vhost = { version = "0.15", features = ["vhost-user-backend"] } +vhost-user-backend = "0.21" virtio-bindings = "0.2.5" -virtio-queue = "0.16" -vm-memory = "0.16.1" -vmm-sys-util = "0.14" +virtio-queue = "0.17" +vm-memory = "0.17.1" +vmm-sys-util = "0.15" [dev-dependencies] assert_matches = "1.5" -virtio-queue = { version = "0.16", features = ["test-utils"] } -vm-memory = { version = "0.16.1", features = ["backend-mmap", "backend-atomic"] } +virtio-queue = { version = "0.17", features = ["test-utils"] } +vm-memory = { version = "0.17.1", features = ["backend-mmap", "backend-atomic"] } diff --git a/vhost-device-can/src/vhu_can.rs b/vhost-device-can/src/vhu_can.rs index 8851f87..2505700 100644 --- a/vhost-device-can/src/vhu_can.rs +++ b/vhost-device-can/src/vhu_can.rs @@ -27,7 +27,7 @@ use vm_memory::{ }; use vmm_sys_util::{ epoll::EventSet, - eventfd::{EventFd, EFD_NONBLOCK}, + event::{new_event_consumer_and_notifier, EventConsumer, EventFlag, EventNotifier}, }; use crate::{ @@ -103,7 +103,8 @@ pub(crate) struct VhostUserCanBackend { controller: Arc>, acked_features: u64, event_idx: bool, - pub(crate) exit_event: EventFd, + exit_consumer: EventConsumer, + exit_notifier: EventNotifier, mem: Option>, } @@ -111,11 +112,15 @@ type CanDescriptorChain = DescriptorChain>) -> Result { + let (exit_consumer, exit_notifier) = new_event_consumer_and_notifier(EventFlag::NONBLOCK) + .map_err(|_| Error::EventFdFailed)?; + Ok(VhostUserCanBackend { controller, event_idx: false, acked_features: 0x0, - exit_event: EventFd::new(EFD_NONBLOCK).map_err(|_| Error::EventFdFailed)?, + exit_consumer, + exit_notifier, mem: None, }) } @@ -719,8 +724,10 @@ impl VhostUserBackendMut for VhostUserCanBackend { Ok(()) } - fn exit_event(&self, _thread_index: usize) -> Option { - self.exit_event.try_clone().ok() + fn exit_event(&self, _thread_index: usize) -> Option<(EventConsumer, EventNotifier)> { + let consumer = self.exit_consumer.try_clone().ok()?; + let notifier = self.exit_notifier.try_clone().ok()?; + Some((consumer, notifier)) } } diff --git a/vhost-device-console/Cargo.toml b/vhost-device-console/Cargo.toml index 50ca854..fd149b9 100644 --- a/vhost-device-console/Cargo.toml +++ b/vhost-device-console/Cargo.toml @@ -23,17 +23,17 @@ env_logger = "0.11" epoll = "4.4" log = "0.4" thiserror = "2.0" -vhost = { version = "0.14", features = ["vhost-user-backend"] } -vhost-user-backend = "0.20" +vhost = { version = "0.15", features = ["vhost-user-backend"] } +vhost-user-backend = "0.21" virtio-bindings = "0.2.5" -virtio-queue = "0.16" -vm-memory = "0.16.1" -vmm-sys-util = "0.14" +virtio-queue = "0.17" +vm-memory = "0.17.1" +vmm-sys-util = "0.15" [dev-dependencies] assert_matches = "1.5" -virtio-queue = { version = "0.16", features = ["test-utils"] } -vm-memory = { version = "0.16.1", features = ["backend-mmap", "backend-atomic"] } +virtio-queue = { version = "0.17", features = ["test-utils"] } +vm-memory = { version = "0.17.1", features = ["backend-mmap", "backend-atomic"] } [lints] workspace = true diff --git a/vhost-device-console/src/vhu_console.rs b/vhost-device-console/src/vhu_console.rs index 4b0fd3d..3fb311b 100644 --- a/vhost-device-console/src/vhu_console.rs +++ b/vhost-device-console/src/vhu_console.rs @@ -29,6 +29,7 @@ use vm_memory::{ }; use vmm_sys_util::{ epoll::EventSet, + event::{new_event_consumer_and_notifier, EventConsumer, EventFlag, EventNotifier}, eventfd::{EventFd, EFD_NONBLOCK}, }; @@ -140,7 +141,8 @@ pub struct VhostUserConsoleBackend { pub stream: Option>, pub rx_event: EventFd, pub rx_ctrl_event: EventFd, - pub exit_event: EventFd, + pub exit_consumer: EventConsumer, + pub exit_notifier: EventNotifier, mem: Option>, } @@ -151,6 +153,8 @@ impl VhostUserConsoleBackend { pub const NUM_QUEUES: u16 = 4; pub fn new(max_queue_size: usize, controller: Arc>) -> Result { + let (exit_consumer, exit_notifier) = new_event_consumer_and_notifier(EventFlag::NONBLOCK) + .map_err(|_| Error::EventFdFailed)?; Ok(Self { max_queue_size, controller, @@ -168,7 +172,8 @@ impl VhostUserConsoleBackend { listener: None, rx_event: EventFd::new(EFD_NONBLOCK).map_err(|_| Error::EventFdFailed)?, rx_ctrl_event: EventFd::new(EFD_NONBLOCK).map_err(|_| Error::EventFdFailed)?, - exit_event: EventFd::new(EFD_NONBLOCK).map_err(|_| Error::EventFdFailed)?, + exit_consumer, + exit_notifier, mem: None, }) } @@ -515,7 +520,7 @@ impl VhostUserConsoleBackend { ) .unwrap(); - let exit_event_fd = self.exit_event.as_raw_fd(); + let exit_event_fd = self.exit_consumer.as_raw_fd(); vring_worker .register_listener( exit_event_fd, @@ -850,8 +855,10 @@ impl VhostUserBackendMut for VhostUserConsoleBackend { Ok(()) } - fn exit_event(&self, _thread_index: usize) -> Option { - self.exit_event.try_clone().ok() + fn exit_event(&self, _thread_index: usize) -> Option<(EventConsumer, EventNotifier)> { + let consumer = self.exit_consumer.try_clone().ok()?; + let notifier = self.exit_notifier.try_clone().ok()?; + Some((consumer, notifier)) } } diff --git a/vhost-device-gpio/Cargo.toml b/vhost-device-gpio/Cargo.toml index 275af08..c58fa83 100644 --- a/vhost-device-gpio/Cargo.toml +++ b/vhost-device-gpio/Cargo.toml @@ -21,17 +21,17 @@ env_logger = "0.11" libc = "0.2" log = "0.4" thiserror = "2.0" -vhost = { version = "0.14", features = ["vhost-user-backend"] } -vhost-user-backend = "0.20" +vhost = { version = "0.15", features = ["vhost-user-backend"] } +vhost-user-backend = "0.21" virtio-bindings = "0.2.5" -virtio-queue = "0.16" -vm-memory = "0.16.1" -vmm-sys-util = "0.14" +virtio-queue = "0.17" +vm-memory = "0.17.1" +vmm-sys-util = "0.15" [target.'cfg(target_env = "gnu")'.dependencies] libgpiod = "1.0" [dev-dependencies] assert_matches = "1.5" -virtio-queue = { version = "0.16", features = ["test-utils"] } -vm-memory = { version = "0.16.1", features = ["backend-mmap", "backend-atomic"] } +virtio-queue = { version = "0.17", features = ["test-utils"] } +vm-memory = { version = "0.17.1", features = ["backend-mmap", "backend-atomic"] } diff --git a/vhost-device-gpio/src/vhu_gpio.rs b/vhost-device-gpio/src/vhu_gpio.rs index 6b6df58..dc40e6f 100644 --- a/vhost-device-gpio/src/vhu_gpio.rs +++ b/vhost-device-gpio/src/vhu_gpio.rs @@ -29,7 +29,7 @@ use vm_memory::{ }; use vmm_sys_util::{ epoll::EventSet, - eventfd::{EventFd, EFD_NONBLOCK}, + event::{new_event_consumer_and_notifier, EventConsumer, EventFlag, EventNotifier}, }; use crate::{ @@ -160,7 +160,8 @@ pub(crate) struct VhostUserGpioBackend { controller: Arc>, handles: Arc>>>>, event_idx: bool, - pub(crate) exit_event: EventFd, + pub(crate) exit_consumer: EventConsumer, + pub(crate) exit_notifier: EventNotifier, mem: Option>, } @@ -172,11 +173,14 @@ impl VhostUserGpioBackend { let mut handles: Vec>> = Vec::new(); handles.resize_with(controller.num_gpios() as usize, || None); + let (exit_consumer, exit_notifier) = new_event_consumer_and_notifier(EventFlag::NONBLOCK) + .map_err(|_| Error::EventFdFailed)?; Ok(VhostUserGpioBackend { controller: Arc::new(controller), handles: Arc::new(RwLock::new(handles)), event_idx: false, - exit_event: EventFd::new(EFD_NONBLOCK).map_err(|_| Error::EventFdFailed)?, + exit_consumer, + exit_notifier, mem: None, }) } @@ -499,8 +503,10 @@ impl VhostUserBackendMut for VhostUserGpi Ok(()) } - fn exit_event(&self, _thread_index: usize) -> Option { - self.exit_event.try_clone().ok() + fn exit_event(&self, _thread_index: usize) -> Option<(EventConsumer, EventNotifier)> { + let consumer = self.exit_consumer.try_clone().ok()?; + let notifier = self.exit_notifier.try_clone().ok()?; + Some((consumer, notifier)) } } diff --git a/vhost-device-gpu/Cargo.toml b/vhost-device-gpu/Cargo.toml index 00ebf49..f0319ac 100644 --- a/vhost-device-gpu/Cargo.toml +++ b/vhost-device-gpu/Cargo.toml @@ -29,12 +29,12 @@ log = "0.4" rutabaga_gfx = "0.1.75" thiserror = "2.0.17" virglrenderer = {version = "0.1.2", optional = true } -vhost = { version = "0.14.0", features = ["vhost-user-backend"] } -vhost-user-backend = "0.20" +vhost = { version = "0.15.0", features = ["vhost-user-backend"] } +vhost-user-backend = "0.21" virtio-bindings = "0.2.5" -virtio-queue = "0.16.0" -vm-memory = "0.16.1" -vmm-sys-util = "0.14.0" +virtio-queue = "0.17.0" +vm-memory = "0.17.1" +vmm-sys-util = "0.15.0" bitflags = "2.10.0" [dev-dependencies] @@ -42,5 +42,5 @@ assert_matches = "1.5" mockall = "0.13.0" rusty-fork = "0.3.1" tempfile = "3.23" -virtio-queue = { version = "0.16", features = ["test-utils"] } -vm-memory = { version = "0.16.1", features = ["backend-mmap", "backend-atomic"] } +virtio-queue = { version = "0.17", features = ["test-utils"] } +vm-memory = { version = "0.17.1", features = ["backend-mmap", "backend-atomic"] } diff --git a/vhost-device-gpu/src/device.rs b/vhost-device-gpu/src/device.rs index 1847310..c870e8f 100644 --- a/vhost-device-gpu/src/device.rs +++ b/vhost-device-gpu/src/device.rs @@ -69,7 +69,8 @@ use virtio_queue::{QueueOwnedT, Reader, Writer}; use vm_memory::{ByteValued, GuestAddressSpace, GuestMemoryAtomic, GuestMemoryMmap, Le32}; use vmm_sys_util::{ epoll::EventSet, - eventfd::{EventFd, EFD_NONBLOCK}, + event::{new_event_consumer_and_notifier, EventConsumer, EventFlag, EventNotifier}, + eventfd::EventFd, }; #[cfg(feature = "backend-gfxstream")] @@ -140,7 +141,8 @@ struct VhostUserGpuBackendInner { virtio_cfg: VirtioGpuConfig, event_idx_enabled: bool, gpu_backend: Option, - pub exit_event: EventFd, + pub exit_consumer: EventConsumer, + pub exit_notifier: EventNotifier, mem: Option>, gpu_config: GpuConfig, } @@ -160,6 +162,9 @@ impl VhostUserGpuBackend { gpu_config.capsets(), gpu_config.flags() ); + let (exit_consumer, exit_notifier) = new_event_consumer_and_notifier(EventFlag::NONBLOCK) + .map_err(|_| Error::EventFdFailed)?; + let inner = VhostUserGpuBackendInner { virtio_cfg: VirtioGpuConfig { events_read: 0.into(), @@ -169,7 +174,8 @@ impl VhostUserGpuBackend { }, event_idx_enabled: false, gpu_backend: None, - exit_event: EventFd::new(EFD_NONBLOCK).map_err(|_| Error::EventFdFailed)?, + exit_consumer, + exit_notifier, mem: None, gpu_config, }; @@ -712,8 +718,11 @@ impl VhostUserBackend for VhostUserGpuBackend { self.inner.lock().unwrap().get_config(offset, size) } - fn exit_event(&self, _thread_index: usize) -> Option { - self.inner.lock().unwrap().exit_event.try_clone().ok() + fn exit_event(&self, _thread_index: usize) -> Option<(EventConsumer, EventNotifier)> { + let inner = self.inner.lock().unwrap(); + let consumer = inner.exit_consumer.try_clone().ok()?; + let notifier = inner.exit_notifier.try_clone().ok()?; + Some((consumer, notifier)) } fn handle_event( diff --git a/vhost-device-i2c/Cargo.toml b/vhost-device-i2c/Cargo.toml index 1151a81..3945ca9 100644 --- a/vhost-device-i2c/Cargo.toml +++ b/vhost-device-i2c/Cargo.toml @@ -20,17 +20,17 @@ env_logger = "0.11" libc = "0.2" log = "0.4" thiserror = "2.0" -vhost = { version = "0.14", features = ["vhost-user-backend"] } -vhost-user-backend = "0.20" +vhost = { version = "0.15", features = ["vhost-user-backend"] } +vhost-user-backend = "0.21" virtio-bindings = "0.2.5" -virtio-queue = "0.16" -vm-memory = "0.16.1" -vmm-sys-util = "0.14" +virtio-queue = "0.17" +vm-memory = "0.17.1" +vmm-sys-util = "0.15" [dev-dependencies] assert_matches = "1.5" -virtio-queue = { version = "0.16", features = ["test-utils"] } -vm-memory = { version = "0.16.1", features = ["backend-mmap", "backend-atomic"] } +virtio-queue = { version = "0.17", features = ["test-utils"] } +vm-memory = { version = "0.17.1", features = ["backend-mmap", "backend-atomic"] } [lints] workspace = true diff --git a/vhost-device-i2c/src/vhu_i2c.rs b/vhost-device-i2c/src/vhu_i2c.rs index c4d7ffd..4089ace 100644 --- a/vhost-device-i2c/src/vhu_i2c.rs +++ b/vhost-device-i2c/src/vhu_i2c.rs @@ -27,7 +27,7 @@ use vm_memory::{ }; use vmm_sys_util::{ epoll::EventSet, - eventfd::{EventFd, EFD_NONBLOCK}, + event::{new_event_consumer_and_notifier, EventConsumer, EventFlag, EventNotifier}, }; use crate::i2c::*; @@ -105,7 +105,8 @@ unsafe impl ByteValued for VirtioI2cInHdr {} pub(crate) struct VhostUserI2cBackend { i2c_map: Arc>, event_idx: bool, - pub exit_event: EventFd, + pub exit_consumer: EventConsumer, + pub exit_notifier: EventNotifier, mem: Option>, } @@ -113,10 +114,13 @@ type I2cDescriptorChain = DescriptorChain VhostUserI2cBackend { pub fn new(i2c_map: Arc>) -> Result { + let (exit_consumer, exit_notifier) = new_event_consumer_and_notifier(EventFlag::NONBLOCK) + .map_err(|_| Error::EventFdFailed)?; Ok(VhostUserI2cBackend { i2c_map, event_idx: false, - exit_event: EventFd::new(EFD_NONBLOCK).map_err(|_| Error::EventFdFailed)?, + exit_consumer, + exit_notifier, mem: None, }) } @@ -355,8 +359,10 @@ impl VhostUserBackendMut for VhostUserI2cB Ok(()) } - fn exit_event(&self, _thread_index: usize) -> Option { - self.exit_event.try_clone().ok() + fn exit_event(&self, _thread_index: usize) -> Option<(EventConsumer, EventNotifier)> { + let consumer = self.exit_consumer.try_clone().ok()?; + let notifier = self.exit_notifier.try_clone().ok()?; + Some((consumer, notifier)) } } diff --git a/vhost-device-input/Cargo.toml b/vhost-device-input/Cargo.toml index d43a185..f495c1d 100644 --- a/vhost-device-input/Cargo.toml +++ b/vhost-device-input/Cargo.toml @@ -22,19 +22,19 @@ log = "0.4" rand = "0.9.2" tempfile = "3.23" thiserror = "2.0" -vhost = { version = "0.14", features = ["vhost-user-backend"] } -vhost-user-backend = "0.20" +vhost = { version = "0.15", features = ["vhost-user-backend"] } +vhost-user-backend = "0.21" virtio-bindings = "0.2.5" -virtio-queue = "0.16" -vm-memory = "0.16.1" -vmm-sys-util = "0.14" +virtio-queue = "0.17" +vm-memory = "0.17.1" +vmm-sys-util = "0.15" evdev = "0.13" nix = { version = "0.30", features = ["ioctl"] } [dev-dependencies] assert_matches = "1.5" -virtio-queue = { version = "0.16", features = ["test-utils"] } -vm-memory = { version = "0.16", features = ["backend-mmap", "backend-atomic"] } +virtio-queue = { version = "0.17", features = ["test-utils"] } +vm-memory = { version = "0.17", features = ["backend-mmap", "backend-atomic"] } [lints] workspace = true diff --git a/vhost-device-input/src/vhu_input.rs b/vhost-device-input/src/vhu_input.rs index 4456b65..115acbf 100644 --- a/vhost-device-input/src/vhu_input.rs +++ b/vhost-device-input/src/vhu_input.rs @@ -23,7 +23,7 @@ use virtio_queue::QueueT; use vm_memory::{ByteValued, Bytes, GuestAddressSpace, GuestMemoryAtomic, GuestMemoryMmap}; use vmm_sys_util::{ epoll::EventSet, - eventfd::{EventFd, EFD_NONBLOCK}, + event::{new_event_consumer_and_notifier, EventConsumer, EventFlag, EventNotifier}, }; use crate::input::*; @@ -124,7 +124,8 @@ impl From for io::Error { pub(crate) struct VuInputBackend { event_idx: bool, ev_dev: T, - pub exit_event: EventFd, + pub exit_consumer: EventConsumer, + pub exit_notifier: EventNotifier, select: u8, subsel: u8, mem: Option>, @@ -133,10 +134,13 @@ pub(crate) struct VuInputBackend { impl VuInputBackend { pub fn new(ev_dev: T) -> std::result::Result { + let (exit_consumer, exit_notifier) = new_event_consumer_and_notifier(EventFlag::NONBLOCK) + .map_err(|_| VuInputError::EventFdError)?; Ok(VuInputBackend { event_idx: false, ev_dev, - exit_event: EventFd::new(EFD_NONBLOCK).map_err(|_| VuInputError::EventFdError)?, + exit_consumer, + exit_notifier, select: 0, subsel: 0, mem: None, @@ -425,8 +429,10 @@ impl VhostUserBackendMut for VuInputBack Ok(()) } - fn exit_event(&self, _thread_index: usize) -> Option { - self.exit_event.try_clone().ok() + fn exit_event(&self, _thread_index: usize) -> Option<(EventConsumer, EventNotifier)> { + let consumer = self.exit_consumer.try_clone().ok()?; + let notifier = self.exit_notifier.try_clone().ok()?; + Some((consumer, notifier)) } } diff --git a/vhost-device-rng/Cargo.toml b/vhost-device-rng/Cargo.toml index bdc840b..be1d34d 100644 --- a/vhost-device-rng/Cargo.toml +++ b/vhost-device-rng/Cargo.toml @@ -21,17 +21,17 @@ log = "0.4" rand = "0.9.2" tempfile = "3.23" thiserror = "2.0" -vhost = { version = "0.14", features = ["vhost-user-backend"] } -vhost-user-backend = "0.20" +vhost = { version = "0.15", features = ["vhost-user-backend"] } +vhost-user-backend = "0.21" virtio-bindings = "0.2.5" -virtio-queue = "0.16" -vm-memory = "0.16.1" -vmm-sys-util = "0.14" +virtio-queue = "0.17" +vm-memory = "0.17.1" +vmm-sys-util = "0.15" [dev-dependencies] assert_matches = "1.5" -virtio-queue = { version = "0.16", features = ["test-utils"] } -vm-memory = { version = "0.16", features = ["backend-mmap", "backend-atomic"] } +virtio-queue = { version = "0.17", features = ["test-utils"] } +vm-memory = { version = "0.17", features = ["backend-mmap", "backend-atomic"] } [lints] workspace = true diff --git a/vhost-device-rng/src/vhu_rng.rs b/vhost-device-rng/src/vhu_rng.rs index 5d73cdf..63b87c4 100644 --- a/vhost-device-rng/src/vhu_rng.rs +++ b/vhost-device-rng/src/vhu_rng.rs @@ -22,12 +22,12 @@ use virtio_bindings::bindings::{ }; use virtio_queue::{DescriptorChain, QueueOwnedT}; use vm_memory::{ - GuestAddressSpace, GuestMemory, GuestMemoryAtomic, GuestMemoryLoadGuard, GuestMemoryMmap, + Bytes, GuestAddressSpace, GuestMemoryAtomic, GuestMemoryLoadGuard, GuestMemoryMmap, ReadVolatile, }; use vmm_sys_util::{ epoll::EventSet, - eventfd::{EventFd, EFD_NONBLOCK}, + event::{new_event_consumer_and_notifier, EventConsumer, EventFlag, EventNotifier}, }; const QUEUE_SIZE: usize = 1024; @@ -90,7 +90,8 @@ pub(crate) struct VuRngBackend { event_idx: bool, timer: VuRngTimerConfig, rng_source: Arc>, - pub exit_event: EventFd, + pub exit_consumer: EventConsumer, + pub exit_notifier: EventNotifier, mem: Option>, } @@ -101,11 +102,14 @@ impl VuRngBackend { period_ms: u128, max_bytes: usize, ) -> std::result::Result { + let (exit_consumer, exit_notifier) = new_event_consumer_and_notifier(EventFlag::NONBLOCK) + .map_err(|_| VuRngError::EventFdError)?; Ok(VuRngBackend { event_idx: false, rng_source, timer: VuRngTimerConfig::new(period_ms, max_bytes), - exit_event: EventFd::new(EFD_NONBLOCK).map_err(|_| VuRngError::EventFdError)?, + exit_consumer, + exit_notifier, mem: None, }) } @@ -284,8 +288,10 @@ impl VhostUserBackendMut for VuRngBacke Ok(()) } - fn exit_event(&self, _thread_index: usize) -> Option { - self.exit_event.try_clone().ok() + fn exit_event(&self, _thread_index: usize) -> Option<(EventConsumer, EventNotifier)> { + let consumer = self.exit_consumer.try_clone().ok()?; + let notifier = self.exit_notifier.try_clone().ok()?; + Some((consumer, notifier)) } } diff --git a/vhost-device-scmi/Cargo.toml b/vhost-device-scmi/Cargo.toml index e3f051d..44ff78c 100644 --- a/vhost-device-scmi/Cargo.toml +++ b/vhost-device-scmi/Cargo.toml @@ -15,16 +15,16 @@ env_logger = "0.11" itertools = "0.14" log = "0.4" thiserror = "2.0" -vhost = { version = "0.14", features = ["vhost-user-backend"] } -vhost-user-backend = "0.20" +vhost = { version = "0.15", features = ["vhost-user-backend"] } +vhost-user-backend = "0.21" virtio-bindings = "0.2" -virtio-queue = "0.16" -vm-memory = "0.16.1" -vmm-sys-util = "0.14" +virtio-queue = "0.17" +vm-memory = "0.17.1" +vmm-sys-util = "0.15" [dev-dependencies] assert_matches = "1.5" -virtio-queue = { version = "0.16", features = ["test-utils"] } +virtio-queue = { version = "0.17", features = ["test-utils"] } [lints] workspace = true diff --git a/vhost-device-scmi/src/vhu_scmi.rs b/vhost-device-scmi/src/vhu_scmi.rs index 73bf1ae..97cf539 100644 --- a/vhost-device-scmi/src/vhu_scmi.rs +++ b/vhost-device-scmi/src/vhu_scmi.rs @@ -26,7 +26,7 @@ use vm_memory::{ }; use vmm_sys_util::{ epoll::EventSet, - eventfd::{EventFd, EFD_NONBLOCK}, + event::{new_event_consumer_and_notifier, EventConsumer, EventFlag, EventNotifier}, }; use crate::{ @@ -96,7 +96,8 @@ type ScmiDescriptorChain = DescriptorChain>, /// Event vring and descriptors serve for asynchronous responses and /// notifications. They are obtained from the driver and we store them @@ -138,9 +139,12 @@ impl VuScmiBackend { None => return Result::Err(VuScmiError::UnknownDeviceRequested(name.clone())), }; } + let (exit_consumer, exit_notifier) = new_event_consumer_and_notifier(EventFlag::NONBLOCK) + .map_err(|_| VuScmiError::EventFdFailed)?; Ok(Self { event_idx: false, - exit_event: EventFd::new(EFD_NONBLOCK).map_err(|_| VuScmiError::EventFdFailed)?, + exit_consumer, + exit_notifier, mem: None, event_vring: None, event_descriptors: vec![], @@ -539,9 +543,11 @@ impl VhostUserBackendMut for VuScmiBackend { Ok(()) } - fn exit_event(&self, _thread_index: usize) -> Option { + fn exit_event(&self, _thread_index: usize) -> Option<(EventConsumer, EventNotifier)> { debug!("Exit event called"); - self.exit_event.try_clone().ok() + let consumer = self.exit_consumer.try_clone().ok()?; + let notifier = self.exit_notifier.try_clone().ok()?; + Some((consumer, notifier)) } } diff --git a/vhost-device-scsi/Cargo.toml b/vhost-device-scsi/Cargo.toml index bb5abea..2db2215 100644 --- a/vhost-device-scsi/Cargo.toml +++ b/vhost-device-scsi/Cargo.toml @@ -20,17 +20,17 @@ env_logger = "0.11" epoll = "4.4" log = "0.4" thiserror = "2.0" -vhost = { version = "0.14", features = ["vhost-user-backend"] } -vhost-user-backend = "0.20" +vhost = { version = "0.15", features = ["vhost-user-backend"] } +vhost-user-backend = "0.21" virtio-bindings = "0.2.5" -virtio-queue = "0.16" -vm-memory = "0.16.1" -vmm-sys-util = "0.14" +virtio-queue = "0.17" +vm-memory = "0.17.1" +vmm-sys-util = "0.15" [dev-dependencies] assert_matches = "1.5" tempfile = "3.23.0" -virtio-queue = { version = "0.16", features = ["test-utils"] } +virtio-queue = { version = "0.17", features = ["test-utils"] } [lints] workspace = true diff --git a/vhost-device-scsi/src/vhu_scsi.rs b/vhost-device-scsi/src/vhu_scsi.rs index fa0adf3..57a8baf 100644 --- a/vhost-device-scsi/src/vhu_scsi.rs +++ b/vhost-device-scsi/src/vhu_scsi.rs @@ -19,7 +19,7 @@ use virtio_queue::QueueOwnedT; use vm_memory::{GuestAddressSpace, GuestMemoryAtomic, GuestMemoryLoadGuard, GuestMemoryMmap}; use vmm_sys_util::{ epoll::EventSet, - eventfd::{EventFd, EFD_NONBLOCK}, + event::{new_event_consumer_and_notifier, EventConsumer, EventFlag, EventNotifier}, }; use crate::{ @@ -39,7 +39,8 @@ pub struct VhostUserScsiBackend { event_idx: bool, mem: Option>, targets: Vec>, - pub exit_event: EventFd, + pub exit_consumer: EventConsumer, + pub exit_notifier: EventNotifier, } impl Default for VhostUserScsiBackend { @@ -50,11 +51,15 @@ impl Default for VhostUserScsiBackend { impl VhostUserScsiBackend { pub fn new() -> Self { + let (exit_consumer, exit_notifier) = + new_event_consumer_and_notifier(EventFlag::NONBLOCK).expect("Creating exit event"); + Self { event_idx: false, mem: None, targets: Vec::new(), - exit_event: EventFd::new(EFD_NONBLOCK).expect("Creating exit eventfd"), + exit_consumer, + exit_notifier, } } @@ -322,8 +327,10 @@ impl VhostUserBackendMut for VhostUserScsiBackend { panic!("Access to configuration space is not supported."); } - fn exit_event(&self, _thread_index: usize) -> Option { - Some(self.exit_event.try_clone().expect("Cloning exit eventfd")) + fn exit_event(&self, _thread_index: usize) -> Option<(EventConsumer, EventNotifier)> { + let consumer = self.exit_consumer.try_clone().ok()?; + let notifier = self.exit_notifier.try_clone().ok()?; + Some((consumer, notifier)) } } diff --git a/vhost-device-scsi/src/virtio.rs b/vhost-device-scsi/src/virtio.rs index 2f0aa9e..6a4c9c2 100644 --- a/vhost-device-scsi/src/virtio.rs +++ b/vhost-device-scsi/src/virtio.rs @@ -228,7 +228,7 @@ where .addr() .0 .checked_add(u64::from(self.offset)) - .ok_or(io::Error::other(vm_memory::Error::InvalidGuestRegion))?, + .ok_or(io::Error::other("Guest address overflow"))?, ), ) .map_err(io::Error::other)?; diff --git a/vhost-device-sound/Cargo.toml b/vhost-device-sound/Cargo.toml index 4705215..1813a4c 100644 --- a/vhost-device-sound/Cargo.toml +++ b/vhost-device-sound/Cargo.toml @@ -22,12 +22,12 @@ clap = { version = "4.5", features = ["derive"] } env_logger = "0.11" log = "0.4" thiserror = "2.0" -vhost = { version = "0.14", features = ["vhost-user-backend"] } -vhost-user-backend = "0.20" +vhost = { version = "0.15", features = ["vhost-user-backend"] } +vhost-user-backend = "0.21" virtio-bindings = "0.2.5" -virtio-queue = "0.16" -vm-memory = "0.16.1" -vmm-sys-util = "0.14" +virtio-queue = "0.17" +vm-memory = "0.17.1" +vmm-sys-util = "0.15" # Make alsa and pipewire backends available only on gnu [target.'cfg(target_env = "gnu")'.dependencies] @@ -40,8 +40,8 @@ gst-audio = {package = "gstreamer-audio", version = "0.24.2", optional = true, f [dev-dependencies] rstest = "0.26.1" tempfile = "3.23" -virtio-queue = { version = "0.16", features = ["test-utils"] } -vm-memory = { version = "0.16.1", features = ["backend-mmap", "backend-atomic"] } +virtio-queue = { version = "0.17", features = ["test-utils"] } +vm-memory = { version = "0.17.1", features = ["backend-mmap", "backend-atomic"] } [target.'cfg(target_env = "gnu")'.dev-dependencies] rand = { version = "0.9.2" } diff --git a/vhost-device-sound/src/device.rs b/vhost-device-sound/src/device.rs index db09388..0ee7adf 100644 --- a/vhost-device-sound/src/device.rs +++ b/vhost-device-sound/src/device.rs @@ -22,7 +22,7 @@ use vm_memory::{ }; use vmm_sys_util::{ epoll::EventSet, - eventfd::{EventFd, EFD_NONBLOCK}, + event::{new_event_consumer_and_notifier, EventConsumer, EventFlag, EventNotifier}, }; use crate::{ @@ -486,7 +486,8 @@ impl VhostUserSoundThread { pub struct VhostUserSoundBackend { pub threads: Vec>, virtio_cfg: VirtioSoundConfig, - pub exit_event: EventFd, + pub exit_consumer: EventConsumer, + pub exit_notifier: EventNotifier, audio_backend: RwLock>, } @@ -567,6 +568,9 @@ impl VhostUserSoundBackend { let audio_backend = alloc_audio_backend(config.audio_backend, streams)?; + let (exit_consumer, exit_notifier) = + new_event_consumer_and_notifier(EventFlag::NONBLOCK).map_err(Error::EventFdCreate)?; + Ok(Self { threads, virtio_cfg: VirtioSoundConfig { @@ -575,13 +579,14 @@ impl VhostUserSoundBackend { chmaps: 1.into(), controls: 0.into(), }, - exit_event: EventFd::new(EFD_NONBLOCK).map_err(Error::EventFdCreate)?, + exit_consumer, + exit_notifier, audio_backend: RwLock::new(audio_backend), }) } pub fn send_exit_event(&self) { - self.exit_event.write(1).unwrap(); + self.exit_notifier.notify().unwrap(); } } @@ -668,8 +673,10 @@ impl VhostUserBackend for VhostUserSoundBackend { vec } - fn exit_event(&self, _thread_index: usize) -> Option { - self.exit_event.try_clone().ok() + fn exit_event(&self, _thread_index: usize) -> Option<(EventConsumer, EventNotifier)> { + let consumer = self.exit_consumer.try_clone().ok()?; + let notifier = self.exit_notifier.try_clone().ok()?; + Some((consumer, notifier)) } } @@ -982,7 +989,8 @@ mod tests { let exit = backend.exit_event(0); assert!(exit.is_some()); - exit.unwrap().write(1).unwrap(); + let (_, notifier) = exit.unwrap(); + notifier.notify().unwrap(); backend .handle_event(CONTROL_QUEUE_IDX, EventSet::IN, &vrings, 0) diff --git a/vhost-device-spi/Cargo.toml b/vhost-device-spi/Cargo.toml index c9d0816..452a2c5 100644 --- a/vhost-device-spi/Cargo.toml +++ b/vhost-device-spi/Cargo.toml @@ -21,18 +21,18 @@ env_logger = "0.11" libc = "0.2" log = "0.4" thiserror = "2.0" -vhost = { version = "0.14", features = ["vhost-user-backend"] } -vhost-user-backend = "0.20" +vhost = { version = "0.15", features = ["vhost-user-backend"] } +vhost-user-backend = "0.21" virtio-bindings = "0.2.5" -virtio-queue = "0.16" -vm-memory = "0.16.1" -vmm-sys-util = "0.14" +virtio-queue = "0.17" +vm-memory = "0.17.1" +vmm-sys-util = "0.15" bitflags = "2.10.0" [dev-dependencies] assert_matches = "1.5" -virtio-queue = { version = "0.16", features = ["test-utils"] } -vm-memory = { version = "0.16.1", features = ["backend-mmap", "backend-atomic"] } +virtio-queue = { version = "0.17", features = ["test-utils"] } +vm-memory = { version = "0.17.1", features = ["backend-mmap", "backend-atomic"] } [lints] workspace = true diff --git a/vhost-device-spi/src/vhu_spi.rs b/vhost-device-spi/src/vhu_spi.rs index a1ebdf3..fc14dc8 100644 --- a/vhost-device-spi/src/vhu_spi.rs +++ b/vhost-device-spi/src/vhu_spi.rs @@ -27,7 +27,7 @@ use vm_memory::{ }; use vmm_sys_util::{ epoll::EventSet, - eventfd::{EventFd, EFD_NONBLOCK}, + event::{new_event_consumer_and_notifier, EventConsumer, EventFlag, EventNotifier}, }; use crate::spi::*; @@ -137,7 +137,8 @@ unsafe impl ByteValued for VirtioSpiConfig {} pub(crate) struct VhostUserSpiBackend { spi_ctrl: Arc>, event_idx: bool, - pub exit_event: EventFd, + pub exit_consumer: EventConsumer, + pub exit_notifier: EventNotifier, mem: Option>, } @@ -145,10 +146,13 @@ type SpiDescriptorChain = DescriptorChain VhostUserSpiBackend { pub fn new(spi_ctrl: Arc>) -> Result { + let (exit_consumer, exit_notifier) = new_event_consumer_and_notifier(EventFlag::NONBLOCK) + .map_err(|_| Error::EventFdFailed)?; Ok(VhostUserSpiBackend { spi_ctrl, event_idx: false, - exit_event: EventFd::new(EFD_NONBLOCK).map_err(|_| Error::EventFdFailed)?, + exit_consumer, + exit_notifier, mem: None, }) } @@ -482,8 +486,10 @@ impl VhostUserBackendMut for VhostUserSpiB Ok(()) } - fn exit_event(&self, _thread_index: usize) -> Option { - self.exit_event.try_clone().ok() + fn exit_event(&self, _thread_index: usize) -> Option<(EventConsumer, EventNotifier)> { + let consumer = self.exit_consumer.try_clone().ok()?; + let notifier = self.exit_notifier.try_clone().ok()?; + Some((consumer, notifier)) } } diff --git a/vhost-device-template/Cargo.toml b/vhost-device-template/Cargo.toml index b767eb3..4c8b27f 100644 --- a/vhost-device-template/Cargo.toml +++ b/vhost-device-template/Cargo.toml @@ -20,17 +20,17 @@ env_logger = "0.11" libc = "0.2" log = "0.4" thiserror = "2.0" -vhost = { version = "0.14", features = ["vhost-user-backend"] } -vhost-user-backend = "0.20" +vhost = { version = "0.15", features = ["vhost-user-backend"] } +vhost-user-backend = "0.21" virtio-bindings = "0.2.5" -virtio-queue = "0.16" -vm-memory = "0.16.1" -vmm-sys-util = "0.14" +virtio-queue = "0.17" +vm-memory = "0.17.1" +vmm-sys-util = "0.15" [dev-dependencies] assert_matches = "1.5" -virtio-queue = { version = "0.16", features = ["test-utils"] } -vm-memory = { version = "0.16.1", features = ["backend-mmap", "backend-atomic"] } +virtio-queue = { version = "0.17", features = ["test-utils"] } +vm-memory = { version = "0.17.1", features = ["backend-mmap", "backend-atomic"] } [lints] workspace = true diff --git a/vhost-device-template/src/backend.rs b/vhost-device-template/src/backend.rs index 16f8264..a6ea331 100644 --- a/vhost-device-template/src/backend.rs +++ b/vhost-device-template/src/backend.rs @@ -19,7 +19,7 @@ use virtio_queue::{DescriptorChain, QueueOwnedT}; use vm_memory::{GuestAddressSpace, GuestMemoryAtomic, GuestMemoryLoadGuard, GuestMemoryMmap}; use vmm_sys_util::{ epoll::EventSet, - eventfd::{EventFd, EFD_NONBLOCK}, + event::{new_event_consumer_and_notifier, EventConsumer, EventFlag, EventNotifier}, }; use crate::FooInfo; @@ -53,7 +53,8 @@ impl From for std::io::Error { pub struct VhostUserFooBackend { info: FooInfo, event_idx: bool, - pub exit_event: EventFd, + pub exit_consumer: EventConsumer, + pub exit_notifier: EventNotifier, mem: Option>, } @@ -61,10 +62,14 @@ type FooDescriptorChain = DescriptorChain Result { + let (exit_consumer, exit_notifier) = new_event_consumer_and_notifier(EventFlag::NONBLOCK) + .map_err(|_| Error::EventFdFailed)?; + Ok(VhostUserFooBackend { info, event_idx: false, - exit_event: EventFd::new(EFD_NONBLOCK).map_err(|_| Error::EventFdFailed)?, + exit_consumer, + exit_notifier, mem: None, }) } @@ -214,8 +219,10 @@ impl VhostUserBackendMut for VhostUserFooBackend { Ok(()) } - fn exit_event(&self, _thread_index: usize) -> Option { - self.exit_event.try_clone().ok() + fn exit_event(&self, _thread_index: usize) -> Option<(EventConsumer, EventNotifier)> { + let consumer = self.exit_consumer.try_clone().ok()?; + let notifier = self.exit_notifier.try_clone().ok()?; + Some((consumer, notifier)) } } diff --git a/vhost-device-vsock/Cargo.toml b/vhost-device-vsock/Cargo.toml index e899dce..8a5671f 100644 --- a/vhost-device-vsock/Cargo.toml +++ b/vhost-device-vsock/Cargo.toml @@ -21,13 +21,13 @@ env_logger = "0.11" epoll = "4.4.0" log = "0.4" thiserror = "2.0" -vhost = { version = "0.14", features = ["vhost-user-backend"] } -vhost-user-backend = "0.20" +vhost = { version = "0.15", features = ["vhost-user-backend"] } +vhost-user-backend = "0.21" virtio-bindings = "0.2.5" -virtio-queue = "0.16" -virtio-vsock = "0.10" -vm-memory = "0.16.1" -vmm-sys-util = "0.14" +virtio-queue = "0.17" +virtio-vsock = "0.11" +vm-memory = "0.17.1" +vmm-sys-util = "0.15" figment = { version = "0.10.19", features = ["yaml"] } vsock = { version = "0.5.0", optional = true } libc = { version = "0.2.177", optional = true } @@ -35,7 +35,7 @@ serde = { version = "1", features = ["derive"] } [dev-dependencies] assert_matches = "1.5" -virtio-queue = { version = "0.16", features = ["test-utils"] } +virtio-queue = { version = "0.17", features = ["test-utils"] } tempfile = "3.23.0" [lints] diff --git a/vhost-device-vsock/src/vhu_vsock.rs b/vhost-device-vsock/src/vhu_vsock.rs index 00bc9d6..abe651b 100644 --- a/vhost-device-vsock/src/vhu_vsock.rs +++ b/vhost-device-vsock/src/vhu_vsock.rs @@ -18,7 +18,8 @@ use virtio_bindings::bindings::{ use vm_memory::{ByteValued, GuestMemoryAtomic, GuestMemoryMmap, Le64}; use vmm_sys_util::{ epoll::EventSet, - eventfd::{EventFd, EFD_NONBLOCK}, + event::{new_event_consumer_and_notifier, EventConsumer, EventFlag, EventNotifier}, + eventfd::EventFd, }; use crate::{thread_backend::RawPktsQ, vhu_vsock_thread::*}; @@ -258,7 +259,8 @@ pub(crate) struct VhostUserVsockBackend { queue_size: usize, pub threads: Vec>, queues_per_thread: Vec, - pub exit_event: EventFd, + pub exit_consumer: EventConsumer, + pub exit_notifier: EventNotifier, } impl VhostUserVsockBackend { @@ -272,6 +274,9 @@ impl VhostUserVsockBackend { )?); let queues_per_thread = vec![QUEUE_MASK]; + let (exit_consumer, exit_notifier) = + new_event_consumer_and_notifier(EventFlag::NONBLOCK).map_err(Error::EventFdCreate)?; + Ok(Self { config: VirtioVsockConfig { guest_cid: From::from(config.get_guest_cid()), @@ -279,7 +284,8 @@ impl VhostUserVsockBackend { queue_size: config.get_queue_size(), threads: vec![thread], queues_per_thread, - exit_event: EventFd::new(EFD_NONBLOCK).map_err(Error::EventFdCreate)?, + exit_consumer, + exit_notifier, }) } } @@ -390,8 +396,10 @@ impl VhostUserBackend for VhostUserVsockBackend { self.queues_per_thread.clone() } - fn exit_event(&self, _thread_index: usize) -> Option { - self.exit_event.try_clone().ok() + fn exit_event(&self, _thread_index: usize) -> Option<(EventConsumer, EventNotifier)> { + let consumer = self.exit_consumer.try_clone().ok()?; + let notifier = self.exit_notifier.try_clone().ok()?; + Some((consumer, notifier)) } } @@ -447,7 +455,8 @@ mod tests { let exit = backend.exit_event(0); assert!(exit.is_some()); - exit.unwrap().write(1).unwrap(); + let (_, notifier) = exit.unwrap(); + notifier.notify().unwrap(); let ret = backend.handle_event(RX_QUEUE_EVENT, EventSet::IN, &vrings, 0); ret.unwrap();