pub fn new(
        sys_mem: &Arc<AddressSpace>,
        desc_table: GuestAddress,
        queue_size: u16,
        index: u16,
    ) -> Result<Self> {
        if index >= queue_size {
            return Err(ErrorKind::QueueIndex(index, queue_size).into());
        }

        let desc =
            if let Some(desc_addr) = desc_table.checked_add(u64::from(index) * DESCRIPTOR_LEN) {
                sys_mem
                    .read_object::<SplitVringDesc>(desc_addr)
                    .chain_err(|| ErrorKind::ReadObjectErr("a descriptor", desc_addr.raw_value()))?
            } else {
                return Err(ErrorKind::AddressOverflow(
                    "creating a descriptor",
                    desc_table.raw_value(),
                    u64::from(index) * DESCRIPTOR_LEN,
                )
                .into());
            };
        if desc.is_valid(sys_mem, queue_size) {
            Ok(desc)
        } else {
            Err(ErrorKind::QueueDescInvalid.into())
        }
    }
/// Create a descriptor of split vring.
///
/// # Arguments
///
/// * `sys_mem` - Address space to which the vring belongs.
/// * `desc_table` - Guest address of virtqueue descriptor table.
/// * `queue_size` - Size of virtqueue.
/// * `index` - Index of descriptor in the virqueue descriptor table.
Create a descriptor of split vring.
Create a descriptor of split vring .
pub fn new(
        sys_mem: &Arc<AddressSpace>,
        desc_table: GuestAddress,
        queue_size: u16,
        index: u16,
    ) -> Result<Self> {
        if index >= queue_size {
            return Err(ErrorKind::QueueIndex(index, queue_size).into());
        }
        let desc =
            if let Some(desc_addr) = desc_table.checked_add(u64::from(index) * DESCRIPTOR_LEN) {
                sys_mem
                    .read_object::<SplitVringDesc>(desc_addr)
                    .chain_err(|| ErrorKind::ReadObjectErr("a descriptor", desc_addr.raw_value()))?
            } else {
                return Err(ErrorKind::AddressOverflow(
                    "creating a descriptor",
                    desc_table.raw_value(),
                    u64::from(index) * DESCRIPTOR_LEN,
                )
                .into());
            };
        if desc.is_valid(sys_mem, queue_size) {
            Ok(desc)
        } else {
            Err(ErrorKind::QueueDescInvalid.into())
        }
    }
pub fn new ( sys_mem : & Arc < AddressSpace > , desc_table : GuestAddress , queue_size : u16 , index : u16 , ) -> Result < Self > { if index >= queue_size { return Err ( ErrorKind :: QueueIndex ( index , queue_size ) . into ( ) ) ; } let desc = if let Some ( desc_addr ) = desc_table . checked_add ( u64 :: from ( index ) * DESCRIPTOR_LEN ) { sys_mem . read_object :: < SplitVringDesc > ( desc_addr ) . chain_err ( | | ErrorKind :: ReadObjectErr ( " " , desc_addr . raw_value ( ) ) ) ? } else { return Err ( ErrorKind :: AddressOverflow ( " " , desc_table . raw_value ( ) , u64 :: from ( index ) * DESCRIPTOR_LEN , ) . into ( ) ) ; } ; if desc . is_valid ( sys_mem , queue_size ) { Ok ( desc ) } else { Err ( ErrorKind :: QueueDescInvalid . into ( ) ) } }
Create a descriptor of split vring.
Create a descriptor of split vring .
sys_mem
&Arc<AddressSpace>
desc_table
GuestAddress
queue_size
u16
index
u16
sys_mem
&Arc<AddressSpace>
desc_table
GuestAddress
queue_size
u16
index
u16