Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion coverage_config_x86_64.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"coverage_score": 90.4,
"coverage_score": 83.6,
"exclude_path": "crates/virtio-queue/src/mock.rs",
"crate_features": "virtio-blk/backend-stdio"
}
18 changes: 12 additions & 6 deletions crates/devices/virtio-blk/src/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
//! approach.

use std::fmt::{self, Display};
use std::ops::Deref;
use std::result;

use crate::defs::{
Expand All @@ -32,9 +33,7 @@ use crate::defs::{
};

use virtio_queue::{Descriptor, DescriptorChain};
use vm_memory::{
ByteValued, Bytes, GuestAddress, GuestAddressSpace, GuestMemory, GuestMemoryError,
};
use vm_memory::{ByteValued, Bytes, GuestAddress, GuestMemory, GuestMemoryError};

/// Block request parsing errors.
#[derive(Debug)]
Expand Down Expand Up @@ -159,7 +158,10 @@ impl Request {
}

// Checks that a descriptor meets the minimal requirements for a valid status descriptor.
fn check_status_desc<M: GuestMemory>(mem: &M, desc: Descriptor) -> Result<()> {
fn check_status_desc<M>(mem: &M, desc: Descriptor) -> Result<()>
where
M: GuestMemory + ?Sized,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why special "?Sized" marker here?

{
// The status MUST always be writable.
if !desc.is_write_only() {
return Err(Error::UnexpectedReadOnlyDescriptor);
Expand Down Expand Up @@ -202,7 +204,11 @@ impl Request {
/// # Arguments
/// * `desc_chain` - A mutable reference to the descriptor chain that should point to the
/// buffers of a virtio block request.
pub fn parse<M: GuestAddressSpace>(desc_chain: &mut DescriptorChain<M>) -> Result<Request> {
pub fn parse<M>(desc_chain: &mut DescriptorChain<M>) -> Result<Request>
where
M: Deref,
M::Target: GuestMemory,
{
let chain_head = desc_chain.next().ok_or(Error::DescriptorChainTooShort)?;
// The head contains the request type which MUST be readable.
if chain_head.is_write_only() {
Expand Down Expand Up @@ -235,7 +241,7 @@ impl Request {
}
let status_desc = desc;

Request::check_status_desc::<<M>::M>(desc_chain.memory(), status_desc)?;
Request::check_status_desc(desc_chain.memory(), status_desc)?;

request.status_addr = status_desc.addr();
Ok(request)
Expand Down
Loading