pub struct BlockAsync {
Show 17 fields boot_index: Option<usize>, disk_image: Option<Box<dyn DiskFile>>, disk_size: Arc<AtomicU64>, avail_features: u64, read_only: bool, sparse: bool, seg_max: u32, block_size: u32, id: Option<[u8; 20]>, control_tube: Option<Tube>, queue_sizes: Vec<u16>, pub(super) executor_kind: ExecutorKind, worker_threads: BTreeMap<usize, (WorkerThread<()>, UnboundedSender<WorkerCmd>)>, shared_state: Arc<RwLock<WorkerSharedState>>, worker_per_queue: bool, activated_queues: BTreeSet<usize>, pci_address: Option<PciAddress>,
}
Expand description

Virtio device for exposing block level read/write operations on a host file.

Fields§

§boot_index: Option<usize>§disk_image: Option<Box<dyn DiskFile>>§disk_size: Arc<AtomicU64>§avail_features: u64§read_only: bool§sparse: bool§seg_max: u32§block_size: u32§id: Option<[u8; 20]>§control_tube: Option<Tube>§queue_sizes: Vec<u16>§executor_kind: ExecutorKind§worker_threads: BTreeMap<usize, (WorkerThread<()>, UnboundedSender<WorkerCmd>)>§shared_state: Arc<RwLock<WorkerSharedState>>§worker_per_queue: bool§activated_queues: BTreeSet<usize>§pci_address: Option<PciAddress>

Implementations§

source§

impl BlockAsync

source

pub fn new( base_features: u64, disk_image: Box<dyn DiskFile>, disk_option: &DiskOption, control_tube: Option<Tube>, queue_size: Option<u16>, num_queues: Option<u16> ) -> SysResult<BlockAsync>

Create a new virtio block device that operates on the given AsyncDisk.

source

fn build_avail_features( base_features: u64, read_only: bool, sparse: bool, multi_queue: bool, packed_queue: bool ) -> u64

Returns the feature flags given the specified attributes.

source

async fn execute_request( reader: &mut Reader, writer: &mut Writer, disk_state: &AsyncRwLock<DiskState>, flush_timer: &RefCell<TimerAsync<Timer>>, flush_timer_armed: &RefCell<bool> ) -> Result<(), ExecuteError>

source

fn build_config_space( disk_size: u64, seg_max: u32, block_size: u32, num_queues: u16 ) -> virtio_blk_config

Builds and returns the config structure used to specify block features.

source

fn start_worker( &mut self, idx: usize ) -> Result<&(WorkerThread<()>, UnboundedSender<WorkerCmd>)>

Get the worker for a queue, starting it if necessary.

source

pub fn start_queue( &mut self, idx: usize, queue: Queue, _mem: GuestMemory ) -> Result<()>

source

pub fn stop_queue(&mut self, idx: usize) -> Result<Queue>

source§

impl BlockAsync

Trait Implementations§

source§

impl VhostUserDeviceBuilder for BlockAsync

source§

fn build(self: Box<Self>, _ex: &Executor) -> Result<Box<dyn Backend>>

Create the vhost-user device. Read more
source§

impl VirtioDevice for BlockAsync

source§

fn keep_rds(&self) -> Vec<RawDescriptor>

A vector of device-specific file descriptors that must be kept open after jailing. Must be called before the process is jailed.
source§

fn features(&self) -> u64

The set of feature bits that this device supports in addition to the base features.
source§

fn device_type(&self) -> DeviceType

The virtio device type.
source§

fn queue_max_sizes(&self) -> &[u16]

The maximum size of each queue that this device supports.
source§

fn read_config(&self, offset: u64, data: &mut [u8])

Reads this device configuration space at offset.
source§

fn activate( &mut self, mem: GuestMemory, _interrupt: Interrupt, queues: BTreeMap<usize, Queue> ) -> Result<()>

Activates this device for real usage.
source§

fn reset(&mut self) -> Result<()>

Optionally deactivates this device. If the reset method is not able to reset the virtio device, or the virtio device model doesn’t implement the reset method, an Err value is returned to indicate the reset is not successful. Otherwise Ok(()) should be returned.
source§

fn virtio_sleep(&mut self) -> Result<Option<BTreeMap<usize, Queue>>>

Pause all processing. Read more
source§

fn virtio_wake( &mut self, queues_state: Option<(GuestMemory, Interrupt, BTreeMap<usize, Queue>)> ) -> Result<()>

Resume all processing. Read more
source§

fn virtio_snapshot(&mut self) -> Result<Value>

Snapshot current state. Device must be asleep.
source§

fn virtio_restore(&mut self, data: Value) -> Result<()>

Restore device state from a snapshot. TODO(b/280607404): Vhost user will need fds passed to the device process.
source§

fn pci_address(&self) -> Option<PciAddress>

Returns the PCI address where the device will be allocated. Returns None if any address is good for the device.
source§

fn bootorder_fw_cfg(&self, pci_slot: u8) -> Option<(Vec<u8>, usize)>

source§

fn debug_label(&self) -> String

Returns a label suitable for debug output.
source§

fn num_interrupts(&self) -> usize

The number of interrupts used by this device.
source§

fn ack_features(&mut self, value: u64)

Acknowledges that this set of features should be enabled.
source§

fn write_config(&mut self, offset: u64, data: &[u8])

Writes to this device configuration space at offset.
source§

fn get_device_bars(&mut self, _address: PciAddress) -> Vec<PciBarConfiguration>

Returns any additional BAR configuration required by the device.
source§

fn get_device_caps(&self) -> Vec<Box<dyn PciCapability>>

Returns any additional capabiltiies required by the device.
source§

fn on_device_sandboxed(&mut self)

Invoked when the device is sandboxed.
source§

fn control_notify(&self, _behavior: MsixStatus)

source§

fn generate_acpi( &mut self, _pci_address: &Option<PciAddress>, sdts: Vec<SDT> ) -> Option<Vec<SDT>>

source§

fn transport_type(&self) -> VirtioTransportType

Returns the Virtio transport type: PCI (default for crosvm) or MMIO.
source§

fn get_shared_memory_region(&self) -> Option<SharedMemoryRegion>

Returns the device’s shared memory region if present.
source§

fn expose_shmem_descriptors_with_viommu(&self) -> bool

If true, VFIO passthrough devices can access descriptors mapped into this region by mapping the corresponding addresses from this device’s PCI bar into their IO address space with virtio-iommu. Read more
source§

fn set_shared_memory_mapper(&mut self, _mapper: Box<dyn SharedMemoryMapper>)

Provides the trait object used to map files into the device’s shared memory region. Read more
source§

fn set_shared_memory_region(&mut self, shmem_region: AddressRange)

Provides the guest address range of the shared memory region, if one is present. Will be called before activate.
source§

fn get_shared_memory_prepare_type(&mut self) -> SharedMemoryPrepareType

Queries the implementation whether a single prepared hypervisor memory mapping with explicit caching type should be setup lazily on first mapping request, or whether to dynamically setup a hypervisor mapping with every request’s caching type.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

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

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V