fn check_status_desc<M: GuestMemory>(mem: &M, desc: Descriptor) -> Result<()> {
        // The status MUST always be writable.
        if !desc.is_write_only() {
            return Err(Error::UnexpectedReadOnlyDescriptor);
        }
        // It makes sense to check the data length from descriptor, since we're going to
        // keep from now on only the address of the status buffer in the `Request` object
        // so we won't be able to validate this at some other point.
        if desc.len() < 1 {
            return Err(Error::DescriptorLengthTooSmall);
        }

        // Check that the address of the status is valid in guest memory.
        // We will write an u8 status here after executing the request.
        let _ = mem.check_address(desc.addr()).ok_or_else(|| {
            Error::GuestMemory(GuestMemoryError::InvalidGuestAddress(desc.addr()))
        })?;
        Ok(())
    }
// Checks that a descriptor meets the minimal requirements for a valid status descriptor.
Checks that a descriptor meets the minimal requirements for a valid status descriptor.
Checks that a descriptor meets the minimal requirements for a valid status descriptor .
fn check_status_desc<M: GuestMemory>(mem: &M, desc: Descriptor) -> Result<()> {
        // The status MUST always be writable.
        if !desc.is_write_only() {
            return Err(Error::UnexpectedReadOnlyDescriptor);
        }
        // It makes sense to check the data length from descriptor, since we're going to
        // keep from now on only the address of the status buffer in the `Request` object
        // so we won't be able to validate this at some other point.
        if desc.len() < 1 {
            return Err(Error::DescriptorLengthTooSmall);
        }
        // Check that the address of the status is valid in guest memory.
        // We will write an u8 status here after executing the request.
        let _ = mem.check_address(desc.addr()).ok_or_else(|| {
            Error::GuestMemory(GuestMemoryError::InvalidGuestAddress(desc.addr()))
        })?;
        Ok(())
    }
fn check_status_desc < M : GuestMemory > ( mem : & M , desc : Descriptor ) -> Result < ( ) > { // The status MUST always be writable. if ! desc . is_write_only ( ) { return Err ( Error :: UnexpectedReadOnlyDescriptor ) ; } // It makes sense to check the data length from descriptor, since we're going to // keep from now on only the address of the status buffer in the `Request` object // so we won't be able to validate this at some other point. if desc . len ( ) < 1 { return Err ( Error :: DescriptorLengthTooSmall ) ; } // Check that the address of the status is valid in guest memory. // We will write an u8 status here after executing the request. let _ = mem . check_address ( desc . addr ( ) ) . ok_or_else ( | | { Error :: GuestMemory ( GuestMemoryError :: InvalidGuestAddress ( desc . addr ( ) ) ) } ) ? ; Ok ( ( ) ) }
Checks that a descriptor meets the minimal requirements for a valid status descriptor.
Checks that a descriptor meets the minimal requirements for a valid status descriptor .
mem
&M
desc
Descriptor
mem
&M
desc
Descriptor