fn read(&mut self, data: &mut [u8], _base: GuestAddress, offset: u64) -> bool {
        match offset {
            0x00..=0xff if data.len() == 4 => {
                let value = match self.state.config_space.read_common_config(
                    &self.device,
                    &self.interrupt_status,
                    offset,
                ) {
                    Ok(v) => v,
                    Err(ref e) => {
                        error!(
                            "Failed to read mmio register {}, type: {}, {}",
                            offset,
                            self.device.lock().unwrap().device_type(),
                            error_chain::ChainedError::display_chain(e),
                        );
                        return false;
                    }
                };
                LittleEndian::write_u32(data, value);
            }
            0x100..=0xfff => {
                if let Err(ref e) = self
                    .device
                    .lock()
                    .unwrap()
                    .read_config(offset as u64 - 0x100, data)
                {
                    error!(
                        "Failed to read virtio-dev config space {} type: {} {}",
                        offset as u64 - 0x100,
                        self.device.lock().unwrap().device_type(),
                        error_chain::ChainedError::display_chain(e),
                    );
                    return false;
                }
            }
            _ => {
                warn!(
                    "Failed to read mmio register: overflows, offset is 0x{:x}, type: {}",
                    offset,
                    self.device.lock().unwrap().device_type(),
                );
            }
        };
        true
    }
/// Read data by virtio driver from VM.
Read data by virtio driver from VM.
Read data by virtio driver from VM .
fn read(&mut self, data: &mut [u8], _base: GuestAddress, offset: u64) -> bool {
        match offset {
            0x00..=0xff if data.len() == 4 => {
                let value = match self.state.config_space.read_common_config(
                    &self.device,
                    &self.interrupt_status,
                    offset,
                ) {
                    Ok(v) => v,
                    Err(ref e) => {
                        error!(
                            "Failed to read mmio register {}, type: {}, {}",
                            offset,
                            self.device.lock().unwrap().device_type(),
                            error_chain::ChainedError::display_chain(e),
                        );
                        return false;
                    }
                };
                LittleEndian::write_u32(data, value);
            }
            0x100..=0xfff => {
                if let Err(ref e) = self
                    .device
                    .lock()
                    .unwrap()
                    .read_config(offset as u64 - 0x100, data)
                {
                    error!(
                        "Failed to read virtio-dev config space {} type: {} {}",
                        offset as u64 - 0x100,
                        self.device.lock().unwrap().device_type(),
                        error_chain::ChainedError::display_chain(e),
                    );
                    return false;
                }
            }
            _ => {
                warn!(
                    "Failed to read mmio register: overflows, offset is 0x{:x}, type: {}",
                    offset,
                    self.device.lock().unwrap().device_type(),
                );
            }
        };
        true
    }
fn read ( & mut self , data : & mut [ u8 ] , _base : GuestAddress , offset : u64 ) -> bool { match offset { 0x00 ..= 0xff if data . len ( ) == 4 => { let value = match self . state . config_space . read_common_config ( & self . device , & self . interrupt_status , offset , ) { Ok ( v ) => v , Err ( ref e ) => { error ! ( " " offset self device lock ( ) unwrap ( ) device_type ( ) error_chain ChainedError display_chain ( e ) ) ; return false ; } } ; LittleEndian :: write_u32 ( data , value ) ; } 0x100 ..= 0xfff => { if let Err ( ref e ) = self . device . lock ( ) . unwrap ( ) . read_config ( offset as u64 - 0x100 , data ) { error ! ( " " offset as u64 0x100 self device lock ( ) unwrap ( ) device_type ( ) error_chain ChainedError display_chain ( e ) ) ; return false ; } } _ => { warn ! ( " " offset self device lock ( ) unwrap ( ) device_type ( ) ) ; } } ; true }
Read data by virtio driver from VM.
Read data by virtio driver from VM .
&mut self
data
&mut [u8]
_base
GuestAddress
offset
u64
&mut self
data
&mut [u8]
_base
GuestAddress
offset
u64