pub fn process_rx(&mut self) -> bool {
        debug!("vsock: process_rx()");
        // This is safe since we checked in the event handler that the device is activated.
        let mem = self.device_state.mem().unwrap();

        let mut have_used = false;

        while let Some(head) = self.queues[RXQ_INDEX].pop(mem) {
            let used_len = match VsockPacket::from_rx_virtq_head(&head) {
                Ok(mut pkt) => {
                    if self.backend.recv_pkt(&mut pkt, mem).is_ok() {
                        match pkt.commit_hdr(mem) {
                            // This addition cannot overflow, because packet length
                            // is previously validated against `MAX_PKT_BUF_SIZE`
                            // bound as part of `commit_hdr()`.
                            Ok(()) => VSOCK_PKT_HDR_SIZE as u32 + pkt.len(),
                            Err(e) => {
                                warn!(
                                    "vsock: Error writing packet header to guest memory: {:?}.\
                                     Discarding the package.",
                                    e
                                );
                                0
                            }
                        }
                    } else {
                        // We are using a consuming iterator over the virtio buffers, so, if we can't
                        // fill in this buffer, we'll need to undo the last iterator step.
                        self.queues[RXQ_INDEX].undo_pop();
                        break;
                    }
                }
                Err(e) => {
                    warn!("vsock: RX queue error: {:?}. Discarding the package.", e);
                    0
                }
            };

            have_used = true;
            self.queues[RXQ_INDEX]
                .add_used(mem, head.index, used_len)
                .unwrap_or_else(|e| {
                    error!("Failed to add available descriptor {}: {}", head.index, e)
                });
        }

        have_used
    }
/// Walk the driver-provided RX queue buffers and attempt to fill them up with any data that we
/// have pending. Return `true` if descriptors have been added to the used ring, and `false`
/// otherwise.
Walk the driver-provided RX queue buffers and attempt to fill them up with any data that we
have pending. Return `true` if descriptors have been added to the used ring, and `false`
otherwise.
Walk the driver - provided RX queue buffers and attempt to fill them up with any data that we have pending . Return ` true ` if descriptors have been added to the used ring and ` false ` otherwise .
pub fn process_rx(&mut self) -> bool {
        debug!("vsock: process_rx()");
        // This is safe since we checked in the event handler that the device is activated.
        let mem = self.device_state.mem().unwrap();
        let mut have_used = false;
        while let Some(head) = self.queues[RXQ_INDEX].pop(mem) {
            let used_len = match VsockPacket::from_rx_virtq_head(&head) {
                Ok(mut pkt) => {
                    if self.backend.recv_pkt(&mut pkt, mem).is_ok() {
                        match pkt.commit_hdr(mem) {
                            // This addition cannot overflow, because packet length
                            // is previously validated against `MAX_PKT_BUF_SIZE`
                            // bound as part of `commit_hdr()`.
                            Ok(()) => VSOCK_PKT_HDR_SIZE as u32 + pkt.len(),
                            Err(e) => {
                                warn!(
                                    "vsock: Error writing packet header to guest memory: {:?}.\
                                     Discarding the package.",
                                    e
                                );
                                0
                            }
                        }
                    } else {
                        // We are using a consuming iterator over the virtio buffers, so, if we can't
                        // fill in this buffer, we'll need to undo the last iterator step.
                        self.queues[RXQ_INDEX].undo_pop();
                        break;
                    }
                }
                Err(e) => {
                    warn!("vsock: RX queue error: {:?}. Discarding the package.", e);
                    0
                }
            };
            have_used = true;
            self.queues[RXQ_INDEX]
                .add_used(mem, head.index, used_len)
                .unwrap_or_else(|e| {
                    error!("Failed to add available descriptor {}: {}", head.index, e)
                });
        }
        have_used
    }
pub fn process_rx ( & mut self ) -> bool { debug ! ( " " ) ; // This is safe since we checked in the event handler that the device is activated. let mem = self . device_state . mem ( ) . unwrap ( ) ; let mut have_used = false ; while let Some ( head ) = self . queues [ RXQ_INDEX ] . pop ( mem ) { let used_len = match VsockPacket :: from_rx_virtq_head ( & head ) { Ok ( mut pkt ) => { if self . backend . recv_pkt ( & mut pkt , mem ) . is_ok ( ) { match pkt . commit_hdr ( mem ) { // This addition cannot overflow, because packet length // is previously validated against `MAX_PKT_BUF_SIZE` // bound as part of `commit_hdr()`. Ok ( ( ) ) => VSOCK_PKT_HDR_SIZE as u32 + pkt . len ( ) , Err ( e ) => { warn ! ( " \
 " e ) ; 0 } } } else { // We are using a consuming iterator over the virtio buffers, so, if we can't // fill in this buffer, we'll need to undo the last iterator step. self . queues [ RXQ_INDEX ] . undo_pop ( ) ; break ; } } Err ( e ) => { warn ! ( " " e ) ; 0 } } ; have_used = true ; self . queues [ RXQ_INDEX ] . add_used ( mem , head . index , used_len ) . unwrap_or_else ( | e | { error ! ( " " head index e ) } ) ; } have_used }
Walk the driver-provided RX queue buffers and attempt to fill them up with any data that we
have pending.
Walk the driver - provided RX queue buffers and attempt to fill them up with any data that we have pending .
&mut self
&mut self