MCPcopy Create free account
hub / github.com/cloud-hypervisor/cloud-hypervisor / handle_event

Method handle_event

virtio-devices/src/vhost_user/mod.rs:381–424  ·  view source on GitHub ↗
(
        &mut self,
        helper: &mut EpollHelper,
        event: &epoll::Event,
    )

Source from the content-addressed store, hash-verified

379
380impl<S: VhostUserFrontendReqHandler> EpollHelperHandler for VhostUserEpollHandler<S> {
381 fn handle_event(
382 &mut self,
383 helper: &mut EpollHelper,
384 event: &epoll::Event,
385 ) -> std::result::Result<(), EpollHelperError> {
386 let ev_type = event.data as u16;
387 let result = match ev_type {
388 HUP_CONNECTION_EVENT => {
389 info!(
390 "vhost-user backend for socket {} disconnected, attempting reconnection",
391 self.socket_path
392 );
393 self.reconnect(helper).map_err(|e| {
394 EpollHelperError::HandleEvent(anyhow!(
395 "failed to reconnect vhost-user backend for socket {}: {e:?}",
396 self.socket_path
397 ))
398 })
399 }
400 BACKEND_REQ_EVENT => {
401 if let Some(backend_req_handler) = self.backend_req_handler.as_mut() {
402 backend_req_handler
403 .handle_request()
404 .map(|_| ())
405 .map_err(|e| {
406 EpollHelperError::HandleEvent(anyhow!(
407 "Failed to handle request from vhost-user backend: {e:?}"
408 ))
409 })
410 } else {
411 Ok(())
412 }
413 }
414 _ => Err(EpollHelperError::HandleEvent(anyhow!(
415 "Unknown event for vhost-user thread"
416 ))),
417 };
418
419 // If the backend hits and error it is unusable from this point on.
420 if result.is_err() {
421 self.disconnected.store(true, Ordering::Relaxed);
422 }
423 result
424 }
425}
426
427/// Common snapshot state for all vhost-user device types.

Callers

nothing calls this directly

Calls 3

reconnectMethod · 0.80
mapMethod · 0.45
handle_requestMethod · 0.45

Tested by

no test coverage detected