/// Check whether the ring configuration is valid.
Check whether the ring configuration is valid.
Check whether the ring configuration is valid .
fn is_valid(&self, config_data: &VringConfigData) -> bool {
        let queue_size = config_data.queue_size;
        if queue_size > config_data.queue_max_size
            || queue_size == 0
            || (queue_size & (queue_size - 1)) != 0
        {
            return false;
        }
        let m = self.mem().memory();
        let desc_table_size = 16 * u64::from(queue_size) as GuestUsize;
        let avail_ring_size = 6 + 2 * u64::from(queue_size) as GuestUsize;
        let used_ring_size = 6 + 8 * u64::from(queue_size) as GuestUsize;
        if GuestAddress(config_data.desc_table_addr)
            .checked_add(desc_table_size)
            .map_or(true, |v| !m.address_in_range(v))
        {
            return false;
        }
        if GuestAddress(config_data.avail_ring_addr)
            .checked_add(avail_ring_size)
            .map_or(true, |v| !m.address_in_range(v))
        {
            return false;
        }
        if GuestAddress(config_data.used_ring_addr)
            .checked_add(used_ring_size)
            .map_or(true, |v| !m.address_in_range(v))
        {
            return false;
        }
        config_data.is_log_addr_valid()
    }
fn is_valid ( & self , config_data : & VringConfigData ) -> bool { let queue_size = config_data . queue_size ; if queue_size > config_data . queue_max_size || queue_size == 0 || ( queue_size & ( queue_size - 1 ) ) != 0 { return false ; } let m = self . mem ( ) . memory ( ) ; let desc_table_size = 16 * u64 :: from ( queue_size ) as GuestUsize ; let avail_ring_size = 6 + 2 * u64 :: from ( queue_size ) as GuestUsize ; let used_ring_size = 6 + 8 * u64 :: from ( queue_size ) as GuestUsize ; if GuestAddress ( config_data . desc_table_addr ) . checked_add ( desc_table_size ) . map_or ( true , | v | ! m . address_in_range ( v ) ) { return false ; } if GuestAddress ( config_data . avail_ring_addr ) . checked_add ( avail_ring_size ) . map_or ( true , | v | ! m . address_in_range ( v ) ) { return false ; } if GuestAddress ( config_data . used_ring_addr ) . checked_add ( used_ring_size ) . map_or ( true , | v | ! m . address_in_range ( v ) ) { return false ; } config_data . is_log_addr_valid ( ) }
Check whether the ring configuration is valid.
Check whether the ring configuration is valid .
&self
config_data
&VringConfigData