// There's no way to recover if error happens during processing a virtq, let the caller
// to handle it.
There's no way to recover if error happens during processing a virtq, let the caller
to handle it.
There ' s no way to recover if error happens during processing a virtq let the caller to handle it .
fn process_queue(
        &mut self,
        vring_state: &mut VringStateMutGuard<GuestMemoryAtomic<GuestMemoryMmap>>,
    ) -> Result<bool> {
        let mut used_any = false;
        let mem = self
            .mem
            .as_ref()
            .ok_or(DaemonError::NoMemoryConfigured)?
            .memory();
        let avail_chains: Vec<DescriptorChain<GuestMemoryAtomic<GuestMemoryMmap>>> = vring_state
            .get_queue_mut()
            .iter()
            .map_err(|_| DaemonError::IterateQueue)?
            .collect();
        for chain in avail_chains {
            used_any = true;
            let head_index = chain.head_index();
            let reader =
                Reader::new(&mem, chain.clone()).map_err(DaemonError::InvalidDescriptorChain)?;
            let writer =
                Writer::new(&mem, chain.clone()).map_err(DaemonError::InvalidDescriptorChain)?;
            self.server
                .handle_message(
                    reader,
                    writer,
                    self.vu_req
                        .as_mut()
                        .map(|x| x as &mut dyn FsCacheReqHandler),
                    None,
                )
                .map_err(DaemonError::ProcessQueue)?;
            if self.event_idx {
                if vring_state.add_used(head_index, 0).is_err() {
                    warn!("Couldn't return used descriptors to the ring");
                }
                match vring_state.needs_notification() {
                    Err(_) => {
                        warn!("Couldn't check if queue needs to be notified");
                        vring_state.signal_used_queue().unwrap();
                    }
                    Ok(needs_notification) => {
                        if needs_notification {
                            vring_state.signal_used_queue().unwrap();
                        }
                    }
                }
            } else {
                if vring_state.add_used(head_index, 0).is_err() {
                    warn!("Couldn't return used descriptors to the ring");
                }
                vring_state.signal_used_queue().unwrap();
            }
        }
        Ok(used_any)
    }
fn process_queue ( & mut self , vring_state : & mut VringStateMutGuard < GuestMemoryAtomic < GuestMemoryMmap > > , ) -> Result < bool > { let mut used_any = false ; let mem = self . mem . as_ref ( ) . ok_or ( DaemonError :: NoMemoryConfigured ) ? . memory ( ) ; let avail_chains : Vec < DescriptorChain < GuestMemoryAtomic < GuestMemoryMmap > > > = vring_state . get_queue_mut ( ) . iter ( ) . map_err ( | _ | DaemonError :: IterateQueue ) ? . collect ( ) ; for chain in avail_chains { used_any = true ; let head_index = chain . head_index ( ) ; let reader = Reader :: new ( & mem , chain . clone ( ) ) . map_err ( DaemonError :: InvalidDescriptorChain ) ? ; let writer = Writer :: new ( & mem , chain . clone ( ) ) . map_err ( DaemonError :: InvalidDescriptorChain ) ? ; self . server . handle_message ( reader , writer , self . vu_req . as_mut ( ) . map ( | x | x as & mut dyn FsCacheReqHandler ) , None , ) . map_err ( DaemonError :: ProcessQueue ) ? ; if self . event_idx { if vring_state . add_used ( head_index , 0 ) . is_err ( ) { warn ! ( " " ) ; } match vring_state . needs_notification ( ) { Err ( _ ) => { warn ! ( " " ) ; vring_state . signal_used_queue ( ) . unwrap ( ) ; } Ok ( needs_notification ) => { if needs_notification { vring_state . signal_used_queue ( ) . unwrap ( ) ; } } } } else { if vring_state . add_used ( head_index , 0 ) . is_err ( ) { warn ! ( " " ) ; } vring_state . signal_used_queue ( ) . unwrap ( ) ; } } Ok ( used_any ) }
There's no way to recover if error happens during processing a virtq, let the caller
to handle it.
There ' s no way to recover if error happens during processing a virtq let the caller to handle it .
&mut self
vring_state
&mut VringStateMutGuard<GuestMemoryAtomic<GuestMemoryMmap>>