fn process_queue(&mut self, vring: &mut Vring) -> Result<()> {
        let mem = self.mem.as_ref().ok_or(Error::NoMemoryConfigured)?;

        while let Some(avail_desc) = vring.mut_queue().iter(mem).next() {
            let head_index = avail_desc.index();
            let reader =
                Reader::new(mem, avail_desc.clone()).map_err(Error::InvalidDescriptorChain)?;
            let writer = Writer::new(mem, avail_desc).map_err(Error::InvalidDescriptorChain)?;

            let total = self
                .server
                .handle_message(
                    reader,
                    writer,
                    self.vu_req
                        .as_mut()
                        .map(|x| x as &mut dyn FsCacheReqHandler),
                )
                .map_err(Error::ProcessQueue)?;

            self.used_descs.push((head_index, total as u32));
        }

        if !self.used_descs.is_empty() {
            for (desc_index, data_sz) in &self.used_descs {
                trace!(
                    "used desc index {} bytes {} total_used {}",
                    desc_index,
                    data_sz,
                    self.used_descs.len()
                );
                vring.mut_queue().add_used(mem, *desc_index, *data_sz);
            }
            self.used_descs.clear();
            vring.signal_used_queue().unwrap();
        }

        Ok(())
    }
// 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: &mut Vring) -> Result<()> {
        let mem = self.mem.as_ref().ok_or(Error::NoMemoryConfigured)?;
        while let Some(avail_desc) = vring.mut_queue().iter(mem).next() {
            let head_index = avail_desc.index();
            let reader =
                Reader::new(mem, avail_desc.clone()).map_err(Error::InvalidDescriptorChain)?;
            let writer = Writer::new(mem, avail_desc).map_err(Error::InvalidDescriptorChain)?;
            let total = self
                .server
                .handle_message(
                    reader,
                    writer,
                    self.vu_req
                        .as_mut()
                        .map(|x| x as &mut dyn FsCacheReqHandler),
                )
                .map_err(Error::ProcessQueue)?;
            self.used_descs.push((head_index, total as u32));
        }
        if !self.used_descs.is_empty() {
            for (desc_index, data_sz) in &self.used_descs {
                trace!(
                    "used desc index {} bytes {} total_used {}",
                    desc_index,
                    data_sz,
                    self.used_descs.len()
                );
                vring.mut_queue().add_used(mem, *desc_index, *data_sz);
            }
            self.used_descs.clear();
            vring.signal_used_queue().unwrap();
        }
        Ok(())
    }
fn process_queue ( & mut self , vring : & mut Vring ) -> Result < ( ) > { let mem = self . mem . as_ref ( ) . ok_or ( Error :: NoMemoryConfigured ) ? ; while let Some ( avail_desc ) = vring . mut_queue ( ) . iter ( mem ) . next ( ) { let head_index = avail_desc . index ( ) ; let reader = Reader :: new ( mem , avail_desc . clone ( ) ) . map_err ( Error :: InvalidDescriptorChain ) ? ; let writer = Writer :: new ( mem , avail_desc ) . map_err ( Error :: InvalidDescriptorChain ) ? ; let total = self . server . handle_message ( reader , writer , self . vu_req . as_mut ( ) . map ( | x | x as & mut dyn FsCacheReqHandler ) , ) . map_err ( Error :: ProcessQueue ) ? ; self . used_descs . push ( ( head_index , total as u32 ) ) ; } if ! self . used_descs . is_empty ( ) { for ( desc_index , data_sz ) in & self . used_descs { trace ! ( " " desc_index data_sz self used_descs len ( ) ) ; vring . mut_queue ( ) . add_used ( mem , * desc_index , * data_sz ) ; } self . used_descs . clear ( ) ; vring . signal_used_queue ( ) . unwrap ( ) ; } Ok ( ( ) ) }
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
&mut Vring
&mut self
vring
&mut Vring