fn is_valid(
        &self,
        queue_max_size: u16,
        queue_size: u16,
        desc_addr: GuestAddress,
        avail_addr: GuestAddress,
        used_addr: GuestAddress,
    ) -> bool {
        let desc_table_size = 16 * queue_size as usize;
        let avail_ring_size = 6 + 2 * queue_size as usize;
        let used_ring_size = 6 + 8 * queue_size as usize;
        if queue_size > queue_max_size || queue_size == 0 || (queue_size & (queue_size - 1)) != 0 {
            false
        } else if desc_addr
            .checked_add(desc_table_size)
            .map_or(true, |v| !self.mem().address_in_range(v))
        {
            false
        } else if avail_addr
            .checked_add(avail_ring_size)
            .map_or(true, |v| !self.mem().address_in_range(v))
        {
            false
        } else if used_addr
            .checked_add(used_ring_size)
            .map_or(true, |v| !self.mem().address_in_range(v))
        {
            false
        } else {
            true
        }
    }
// TODO(dpopa): Investigate how we can call is_valid directly on the Queue struct
Investigate how we can call is_valid directly on the Queue struct
Investigate how we can call is_valid directly on the Queue struct
fn is_valid(
        &self,
        queue_max_size: u16,
        queue_size: u16,
        desc_addr: GuestAddress,
        avail_addr: GuestAddress,
        used_addr: GuestAddress,
    ) -> bool {
        let desc_table_size = 16 * queue_size as usize;
        let avail_ring_size = 6 + 2 * queue_size as usize;
        let used_ring_size = 6 + 8 * queue_size as usize;
        if queue_size > queue_max_size || queue_size == 0 || (queue_size & (queue_size - 1)) != 0 {
            false
        } else if desc_addr
            .checked_add(desc_table_size)
            .map_or(true, |v| !self.mem().address_in_range(v))
        {
            false
        } else if avail_addr
            .checked_add(avail_ring_size)
            .map_or(true, |v| !self.mem().address_in_range(v))
        {
            false
        } else if used_addr
            .checked_add(used_ring_size)
            .map_or(true, |v| !self.mem().address_in_range(v))
        {
            false
        } else {
            true
        }
    }
fn is_valid ( & self , queue_max_size : u16 , queue_size : u16 , desc_addr : GuestAddress , avail_addr : GuestAddress , used_addr : GuestAddress , ) -> bool { let desc_table_size = 16 * queue_size as usize ; let avail_ring_size = 6 + 2 * queue_size as usize ; let used_ring_size = 6 + 8 * queue_size as usize ; if queue_size > queue_max_size || queue_size == 0 || ( queue_size & ( queue_size - 1 ) ) != 0 { false } else if desc_addr . checked_add ( desc_table_size ) . map_or ( true , | v | ! self . mem ( ) . address_in_range ( v ) ) { false } else if avail_addr . checked_add ( avail_ring_size ) . map_or ( true , | v | ! self . mem ( ) . address_in_range ( v ) ) { false } else if used_addr . checked_add ( used_ring_size ) . map_or ( true , | v | ! self . mem ( ) . address_in_range ( v ) ) { false } else { true } }
TODO(dpopa): Investigate how we can call is_valid directly on the Queue struct
TODO ( dpopa ) : Investigate how we can call is_valid directly on the Queue struct
&self
queue_max_size
u16
queue_size
u16
desc_addr
GuestAddress
avail_addr
GuestAddress
used_addr
GuestAddress
&self
queue_max_size
u16
queue_size
u16
desc_addr
GuestAddress
avail_addr
GuestAddress
used_addr
GuestAddress