(
&mut self,
device_event: u16,
evset: EventSet,
vrings: &[VringRwLock<GuestMemoryAtomic<GuestMemoryMmap>>],
thread_id: usize,
)
| 347 | } |
| 348 | |
| 349 | fn handle_event( |
| 350 | &mut self, |
| 351 | device_event: u16, |
| 352 | evset: EventSet, |
| 353 | vrings: &[VringRwLock<GuestMemoryAtomic<GuestMemoryMmap>>], |
| 354 | thread_id: usize, |
| 355 | ) -> VhostUserBackendResult<()> { |
| 356 | if evset != EventSet::IN { |
| 357 | return Err(Error::HandleEventNotEpollIn.into()); |
| 358 | } |
| 359 | |
| 360 | debug!("event received: {device_event:?}"); |
| 361 | |
| 362 | let thread = self.threads[thread_id].get_mut().unwrap(); |
| 363 | match device_event { |
| 364 | 0 => { |
| 365 | let mut vring = vrings[0].get_mut(); |
| 366 | |
| 367 | if self.poll_queue { |
| 368 | // Actively poll the queue until POLL_QUEUE_US has passed |
| 369 | // without seeing a new request. |
| 370 | let mut now = Instant::now(); |
| 371 | loop { |
| 372 | if thread.process_queue(&mut vring) { |
| 373 | now = Instant::now(); |
| 374 | } else if now.elapsed().as_micros() > POLL_QUEUE_US { |
| 375 | break; |
| 376 | } |
| 377 | } |
| 378 | } |
| 379 | |
| 380 | if thread.event_idx { |
| 381 | // vm-virtio's Queue implementation only checks avail_index |
| 382 | // once, so to properly support EVENT_IDX we need to keep |
| 383 | // calling process_queue() until it stops finding new |
| 384 | // requests on the queue. |
| 385 | loop { |
| 386 | vring |
| 387 | .get_queue_mut() |
| 388 | .enable_notification(self.mem.memory().deref()) |
| 389 | .unwrap(); |
| 390 | if !thread.process_queue(&mut vring) { |
| 391 | break; |
| 392 | } |
| 393 | } |
| 394 | } else { |
| 395 | // Without EVENT_IDX, a single call is enough. |
| 396 | thread.process_queue(&mut vring); |
| 397 | } |
| 398 | |
| 399 | Ok(()) |
| 400 | } |
| 401 | _ => Err(Error::HandleEventUnknownEvent.into()), |
| 402 | } |
| 403 | } |
| 404 | |
| 405 | fn get_config(&self, offset: u32, size: u32) -> Vec<u8> { |
| 406 | let subset = self |
nothing calls this directly
no test coverage detected