pub struct BlockDevice { /* private fields */ }Expand description
virtio-block frontend.
Implementations§
Source§impl BlockDevice
impl BlockDevice
Sourcepub fn new(config: BlockConfig, backend: Arc<dyn BlockBackend>) -> Self
pub fn new(config: BlockConfig, backend: Arc<dyn BlockBackend>) -> Self
Build a virtio-block from a validated BlockConfig and a
concrete backend.
Sourcepub fn capacity_sectors(&self) -> u64
pub fn capacity_sectors(&self) -> u64
Backing-store size in 512-byte sectors (virtio-block config layout).
Trait Implementations§
Source§impl Debug for BlockDevice
impl Debug for BlockDevice
Source§impl VirtioDevice for BlockDevice
impl VirtioDevice for BlockDevice
Source§fn device_type(&self) -> VirtioDeviceType
fn device_type(&self) -> VirtioDeviceType
Device-type discriminant for the MMIO
DeviceID register.Source§fn avail_features(&self) -> u64
fn avail_features(&self) -> u64
Bitmap of features the device offers. The transport ANDs this with
the driver’s
acked_features and surfaces the negotiated set.Source§fn acked_features(&self) -> u64
fn acked_features(&self) -> u64
Bitmap of features the driver has acknowledged.
Source§fn set_acked_features(&mut self, value: u64)
fn set_acked_features(&mut self, value: u64)
Set the driver-acked feature set. The transport calls this once per
MMIO
DriverFeatures write; implementors typically just store the
value.Source§fn queue_max_sizes(&self) -> &[u16]
fn queue_max_sizes(&self) -> &[u16]
Per-queue maximum descriptor counts. The vector length determines how
many vrings the device exposes; the value at each index becomes
QueueNumMax for that queue.Source§fn queues_mut(&mut self) -> &mut [Queue]
fn queues_mut(&mut self) -> &mut [Queue]
Borrow the device’s queue state mutably (transport uses this when the
driver writes queue-config registers).
Source§fn read_config(&self, offset: u64, data: &mut [u8])
fn read_config(&self, offset: u64, data: &mut [u8])
Read a slice of the device’s config space at
offset.Source§fn write_config(&mut self, _offset: u64, _data: &[u8])
fn write_config(&mut self, _offset: u64, _data: &[u8])
Write a slice into the device’s config space at
offset. Per the
virtio spec § 2.4.2, drivers SHOULD not write config-space after
DRIVER_OK; the transport gates on this and silently drops post-OK
writes via crate::transport::VirtioMmioTransport::accept_config_write.Source§fn activate(
&mut self,
mem: Arc<dyn GuestMemory>,
irq: IrqLine,
) -> Result<(), ActivateError>
fn activate( &mut self, mem: Arc<dyn GuestMemory>, irq: IrqLine, ) -> Result<(), ActivateError>
Take ownership of the resources needed to drive the device live.
Called exactly once on the driver’s
DRIVER_OK transition. Read moreSource§fn is_activated(&self) -> bool
fn is_activated(&self) -> bool
true once activate has succeeded.Source§fn process_queue(&mut self, queue_index: u16)
fn process_queue(&mut self, queue_index: u16)
Handler invoked on a guest write to the MMIO
QueueNotify register. Read moreAuto Trait Implementations§
impl Freeze for BlockDevice
impl !RefUnwindSafe for BlockDevice
impl Send for BlockDevice
impl Sync for BlockDevice
impl Unpin for BlockDevice
impl UnsafeUnpin for BlockDevice
impl !UnwindSafe for BlockDevice
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more