Skip to content

Commit 81ab3ba

Browse files
authored
Merge branch 'main' into semver
2 parents cca888f + a93e9f2 commit 81ab3ba

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/vmm/src/devices/virtio/vsock/event_handler.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ use vmm_sys_util::epoll::EventSet;
3333
use super::VsockBackend;
3434
use super::device::{EVQ_INDEX, RXQ_INDEX, TXQ_INDEX, Vsock};
3535
use crate::devices::virtio::device::VirtioDevice;
36+
use crate::devices::virtio::queue::InvalidAvailIdx;
3637
use crate::devices::virtio::vsock::metrics::METRICS;
3738
use crate::logger::IncMetric;
3839

@@ -107,7 +108,7 @@ where
107108
}
108109

109110
/// Notify backend of new events.
110-
pub fn notify_backend(&mut self, evset: EventSet) -> bool {
111+
pub fn notify_backend(&mut self, evset: EventSet) -> Result<bool, InvalidAvailIdx> {
111112
self.backend.notify(evset);
112113
// After the backend has been kicked, it might've freed up some resources, so we
113114
// can attempt to send it more data to process.
@@ -116,11 +117,11 @@ where
116117
// TX queue again.
117118
// OK to unwrap: Only QueueError::InvalidAvailIdx is returned, and we explicitly
118119
// want to panic on that one.
119-
let mut raise_irq = self.process_tx().unwrap();
120+
let mut raise_irq = self.process_tx()?;
120121
if self.backend.has_pending_rx() {
121-
raise_irq |= self.process_rx().unwrap();
122+
raise_irq |= self.process_rx()?;
122123
}
123-
raise_irq
124+
Ok(raise_irq)
124125
}
125126

126127
fn register_runtime_events(&self, ops: &mut EventOps) {
@@ -194,7 +195,7 @@ where
194195
Self::PROCESS_RXQ => raise_irq = self.handle_rxq_event(evset),
195196
Self::PROCESS_TXQ => raise_irq = self.handle_txq_event(evset),
196197
Self::PROCESS_EVQ => raise_irq = self.handle_evq_event(evset),
197-
Self::PROCESS_NOTIFY_BACKEND => raise_irq = self.notify_backend(evset),
198+
Self::PROCESS_NOTIFY_BACKEND => raise_irq = self.notify_backend(evset).unwrap(),
198199
_ => warn!("Unexpected vsock event received: {:?}", source),
199200
}
200201
if raise_irq {
@@ -394,7 +395,7 @@ mod tests {
394395
ctx.mock_activate(test_ctx.mem.clone());
395396

396397
ctx.device.backend.set_pending_rx(true);
397-
ctx.device.notify_backend(EventSet::IN);
398+
ctx.device.notify_backend(EventSet::IN).unwrap();
398399

399400
// The backend should've received this event.
400401
assert_eq!(ctx.device.backend.evset, Some(EventSet::IN));
@@ -413,7 +414,7 @@ mod tests {
413414
ctx.mock_activate(test_ctx.mem.clone());
414415

415416
ctx.device.backend.set_pending_rx(false);
416-
ctx.device.notify_backend(EventSet::IN);
417+
ctx.device.notify_backend(EventSet::IN).unwrap();
417418

418419
// The backend should've received this event.
419420
assert_eq!(ctx.device.backend.evset, Some(EventSet::IN));

0 commit comments

Comments
 (0)