pub fn region_write(&self, index: u32, buf: &[u8], addr: u64) {
        let stub: &VfioRegion = match self.regions.get(index as usize) {
            Some(v) => v,
            None => {
                warn!("region write with invalid index: {}", index);
                return;
            }
        };

        let size = buf.len() as u64;
        if size > stub.size
            || addr + size > stub.size
            || (stub.flags & VFIO_REGION_INFO_FLAG_WRITE) == 0
        {
            warn!(
                "region write with invalid parameter, add: {}, size: {}",
                addr, size
            );
            return;
        }

        if let Err(e) = self.device.write_all_at(buf, stub.offset + addr) {
            warn!(
                "Failed to write region in index: {}, addr: {}, error: {}",
                index, addr, e
            );
        }
    }
/// Write the data from buf into a vfio device region
///
/// # Arguments
/// * `index`: region num
/// * `buf`: data src and buf length is write size
/// * `addr`: offset in the region
Write the data from buf into a vfio device region
Write the data from buf into a vfio device region
pub fn region_write(&self, index: u32, buf: &[u8], addr: u64) {
        let stub: &VfioRegion = match self.regions.get(index as usize) {
            Some(v) => v,
            None => {
                warn!("region write with invalid index: {}", index);
                return;
            }
        };
        let size = buf.len() as u64;
        if size > stub.size
            || addr + size > stub.size
            || (stub.flags & VFIO_REGION_INFO_FLAG_WRITE) == 0
        {
            warn!(
                "region write with invalid parameter, add: {}, size: {}",
                addr, size
            );
            return;
        }
        if let Err(e) = self.device.write_all_at(buf, stub.offset + addr) {
            warn!(
                "Failed to write region in index: {}, addr: {}, error: {}",
                index, addr, e
            );
        }
    }
pub fn region_write ( & self , index : u32 , buf : & [ u8 ] , addr : u64 ) { let stub : & VfioRegion = match self . regions . get ( index as usize ) { Some ( v ) => v , None => { warn ! ( " " index ) ; return ; } } ; let size = buf . len ( ) as u64 ; if size > stub . size || addr + size > stub . size || ( stub . flags & VFIO_REGION_INFO_FLAG_WRITE ) == 0 { warn ! ( " " addr size ) ; return ; } if let Err ( e ) = self . device . write_all_at ( buf , stub . offset + addr ) { warn ! ( " " index addr e ) ; } }
Write the data from buf into a vfio device region
Write the data from buf into a vfio device region
&self
index
u32
buf
&[u8]
addr
u64