@@ -33,6 +33,7 @@ use vmm_sys_util::epoll::EventSet;
33
33
use super :: VsockBackend ;
34
34
use super :: device:: { EVQ_INDEX , RXQ_INDEX , TXQ_INDEX , Vsock } ;
35
35
use crate :: devices:: virtio:: device:: VirtioDevice ;
36
+ use crate :: devices:: virtio:: queue:: InvalidAvailIdx ;
36
37
use crate :: devices:: virtio:: vsock:: metrics:: METRICS ;
37
38
use crate :: logger:: IncMetric ;
38
39
@@ -107,7 +108,7 @@ where
107
108
}
108
109
109
110
/// 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 > {
111
112
self . backend . notify ( evset) ;
112
113
// After the backend has been kicked, it might've freed up some resources, so we
113
114
// can attempt to send it more data to process.
@@ -116,11 +117,11 @@ where
116
117
// TX queue again.
117
118
// OK to unwrap: Only QueueError::InvalidAvailIdx is returned, and we explicitly
118
119
// want to panic on that one.
119
- let mut raise_irq = self . process_tx ( ) . unwrap ( ) ;
120
+ let mut raise_irq = self . process_tx ( ) ? ;
120
121
if self . backend . has_pending_rx ( ) {
121
- raise_irq |= self . process_rx ( ) . unwrap ( ) ;
122
+ raise_irq |= self . process_rx ( ) ? ;
122
123
}
123
- raise_irq
124
+ Ok ( raise_irq)
124
125
}
125
126
126
127
fn register_runtime_events ( & self , ops : & mut EventOps ) {
@@ -194,7 +195,7 @@ where
194
195
Self :: PROCESS_RXQ => raise_irq = self . handle_rxq_event ( evset) ,
195
196
Self :: PROCESS_TXQ => raise_irq = self . handle_txq_event ( evset) ,
196
197
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 ( ) ,
198
199
_ => warn ! ( "Unexpected vsock event received: {:?}" , source) ,
199
200
}
200
201
if raise_irq {
@@ -394,7 +395,7 @@ mod tests {
394
395
ctx. mock_activate ( test_ctx. mem . clone ( ) ) ;
395
396
396
397
ctx. device . backend . set_pending_rx ( true ) ;
397
- ctx. device . notify_backend ( EventSet :: IN ) ;
398
+ ctx. device . notify_backend ( EventSet :: IN ) . unwrap ( ) ;
398
399
399
400
// The backend should've received this event.
400
401
assert_eq ! ( ctx. device. backend. evset, Some ( EventSet :: IN ) ) ;
@@ -413,7 +414,7 @@ mod tests {
413
414
ctx. mock_activate ( test_ctx. mem . clone ( ) ) ;
414
415
415
416
ctx. device . backend . set_pending_rx ( false ) ;
416
- ctx. device . notify_backend ( EventSet :: IN ) ;
417
+ ctx. device . notify_backend ( EventSet :: IN ) . unwrap ( ) ;
417
418
418
419
// The backend should've received this event.
419
420
assert_eq ! ( ctx. device. backend. evset, Some ( EventSet :: IN ) ) ;
0 commit comments