pub struct VirtIOBlk<'a> { /* private fields */ }
Expand description

The virtio block device is a simple virtual block device (ie. disk).

Read and write requests (and other exotic requests) are placed in the queue, and serviced (probably out of order) by the device except where noted.

Implementations

Create a new VirtIO-Blk driver.

Acknowledge interrupt.

Read a block.

Read a block in a non-blocking way which means that it returns immediately.

Arguments
  • block_id - The identifier of the block to read.
  • buf - The buffer in the memory which the block is read into.
  • resp - A mutable reference to a variable provided by the caller which contains the status of the requests. The caller can safely read the variable only after the request is ready.
Usage

It will submit request to the virtio block device and return a token identifying the position of the first Descriptor in the chain. If there are not enough Descriptors to allocate, then it returns Error::BufferTooSmall.

After the request is ready, resp will be updated and the caller can get the status of the request(e.g. succeed or failed) through it. However, the caller must not spin on resp to wait for it to change. A safe way is to read it after the same token as this method returns is fetched through VirtIOBlk::pop_used(), which means that the request has been ready.

Safety

buf is still borrowed by the underlying virtio block device even if this method returns. Thus, it is the caller’s responsibility to guarantee that buf is not accessed before the request is completed in order to avoid data races.

Write a block.

Arguments
  • block_id - The identifier of the block to write.
  • buf - The buffer in the memory containing the data to write to the block.
  • resp - A mutable reference to a variable provided by the caller which contains the status of the requests. The caller can safely read the variable only after the request is ready.
Usage

See also VirtIOBlk::read_block_nb().

Safety

See also VirtIOBlk::read_block_nb().

During an interrupt, it fetches a token of a completed request from the used ring and return it. If all completed requests have already been fetched, return Err(Error::NotReady).

Return size of its VirtQueue. It can be used to tell the caller how many channels he should monitor on.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.