Skip to content

Commit 1ab08b7

Browse files
stefano-garzarellaslp
authored andcommitted
vhost-user-backend: remove return value from handle_event
The return value of VhostUserBackend::handle_event() is undocumented and difficult to interpret. The current implementation used it to interrupt the event loop as it does when we receive an exit event. All current implementations checked (rust-vmm/vhost-device, virtiofsd) return an error or always false, effectively not using this feature. Since we already have a mechanism for breaking the event loop, we can avoid this ambiguous and redundant feature. Closes #144 Signed-off-by: Stefano Garzarella <[email protected]>
1 parent 5278cb5 commit 1ab08b7

File tree

4 files changed

+13
-10
lines changed

4 files changed

+13
-10
lines changed

crates/vhost-user-backend/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
### Changed
88
- Change uses of master/slave for frontend/backend in the codebase.
9+
- [[#192]](https://github.com/rust-vmm/vhost/pull/192) vhost-user-backend: remove return value from handle_event
910

1011
### Fixed
1112

crates/vhost-user-backend/src/backend.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ where
110110
evset: EventSet,
111111
vrings: &[V],
112112
thread_id: usize,
113-
) -> Result<bool>;
113+
) -> Result<()>;
114114
}
115115

116116
/// Trait without interior mutability for vhost user backend servers to implement concrete services.
@@ -191,7 +191,7 @@ where
191191
evset: EventSet,
192192
vrings: &[V],
193193
thread_id: usize,
194-
) -> Result<bool>;
194+
) -> Result<()>;
195195
}
196196

197197
impl<T: VhostUserBackend<V, B>, V, B> VhostUserBackend<V, B> for Arc<T>
@@ -253,7 +253,7 @@ where
253253
evset: EventSet,
254254
vrings: &[V],
255255
thread_id: usize,
256-
) -> Result<bool> {
256+
) -> Result<()> {
257257
self.deref()
258258
.handle_event(device_event, evset, vrings, thread_id)
259259
}
@@ -318,7 +318,7 @@ where
318318
evset: EventSet,
319319
vrings: &[V],
320320
thread_id: usize,
321-
) -> Result<bool> {
321+
) -> Result<()> {
322322
self.lock()
323323
.unwrap()
324324
.handle_event(device_event, evset, vrings, thread_id)
@@ -384,7 +384,7 @@ where
384384
evset: EventSet,
385385
vrings: &[V],
386386
thread_id: usize,
387-
) -> Result<bool> {
387+
) -> Result<()> {
388388
self.write()
389389
.unwrap()
390390
.handle_event(device_event, evset, vrings, thread_id)
@@ -491,10 +491,10 @@ pub mod tests {
491491
_evset: EventSet,
492492
_vrings: &[VringRwLock],
493493
_thread_id: usize,
494-
) -> Result<bool> {
494+
) -> Result<()> {
495495
self.events += 1;
496496

497-
Ok(false)
497+
Ok(())
498498
}
499499
}
500500

crates/vhost-user-backend/src/event_loop.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,9 @@ where
211211

212212
self.backend
213213
.handle_event(device_event, evset, &self.vrings, self.thread_id)
214-
.map_err(VringEpollError::HandleEventBackendHandling)
214+
.map_err(VringEpollError::HandleEventBackendHandling)?;
215+
216+
Ok(false)
215217
}
216218
}
217219

crates/vhost-user-backend/tests/vhost-user-server.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,10 @@ impl VhostUserBackendMut<VringRwLock, ()> for MockVhostBackend {
9999
_evset: EventSet,
100100
_vrings: &[VringRwLock],
101101
_thread_id: usize,
102-
) -> Result<bool> {
102+
) -> Result<()> {
103103
self.events += 1;
104104

105-
Ok(false)
105+
Ok(())
106106
}
107107
}
108108

0 commit comments

Comments
 (0)