Struct devices::virtio::vhost_user_frontend::VhostUserFrontend
source · pub struct VhostUserFrontend {Show 13 fields
device_type: DeviceType,
worker_thread: Option<WorkerThread<Option<FrontendServer<BackendReqHandlerImpl>>>>,
backend_client: Arc<Mutex<BackendClient>>,
avail_features: u64,
acked_features: u64,
protocol_features: VhostUserProtocolFeatures,
backend_req_handler: Option<FrontendServer<BackendReqHandlerImpl>>,
shmem_region: RefCell<Option<Option<SharedMemoryRegion>>>,
queue_sizes: Vec<u16>,
cfg: Option<Vec<u8>>,
expose_shmem_descriptors_with_viommu: bool,
pci_address: Option<PciAddress>,
sent_queues: Option<BTreeMap<usize, Queue>>,
}
Fields§
§device_type: DeviceType
§worker_thread: Option<WorkerThread<Option<FrontendServer<BackendReqHandlerImpl>>>>
§backend_client: Arc<Mutex<BackendClient>>
§avail_features: u64
§acked_features: u64
§protocol_features: VhostUserProtocolFeatures
§backend_req_handler: Option<FrontendServer<BackendReqHandlerImpl>>
§shmem_region: RefCell<Option<Option<SharedMemoryRegion>>>
§queue_sizes: Vec<u16>
§cfg: Option<Vec<u8>>
§expose_shmem_descriptors_with_viommu: bool
§pci_address: Option<PciAddress>
§sent_queues: Option<BTreeMap<usize, Queue>>
Implementations§
source§impl VhostUserFrontend
impl VhostUserFrontend
pub fn new_fs( base_features: u64, connection: Connection<FrontendReq>, max_queue_size: Option<u16>, tag: Option<&str> ) -> Result<VhostUserFrontend, Error>
source§impl VhostUserFrontend
impl VhostUserFrontend
sourcepub fn new(
device_type: DeviceType,
base_features: u64,
connection: Connection<FrontendReq>,
max_queue_size: Option<u16>,
pci_address: Option<PciAddress>
) -> Result<VhostUserFrontend, Error>
pub fn new( device_type: DeviceType, base_features: u64, connection: Connection<FrontendReq>, max_queue_size: Option<u16>, pci_address: Option<PciAddress> ) -> Result<VhostUserFrontend, Error>
Create a new VirtioDevice for a vhost-user device frontend.
§Arguments
device_type
: virtio device typebase_features
: base virtio device features (e.g.VIRTIO_F_VERSION_1
)connection
: connection to the device backendmax_queue_size
: maximum number of entries in each queue (default:Queue::MAX_SIZE
)
sourcepub(crate) fn new_internal(
connection: Connection<FrontendReq>,
device_type: DeviceType,
max_queue_size: Option<u16>,
base_features: u64,
cfg: Option<&[u8]>,
pci_address: Option<PciAddress>
) -> Result<VhostUserFrontend, Error>
pub(crate) fn new_internal( connection: Connection<FrontendReq>, device_type: DeviceType, max_queue_size: Option<u16>, base_features: u64, cfg: Option<&[u8]>, pci_address: Option<PciAddress> ) -> Result<VhostUserFrontend, Error>
Create a new VirtioDevice for a vhost-user device frontend.
§Arguments
connection
: connection to the device backenddevice_type
: virtio device typemax_queue_size
: maximum number of entries in each queue (default:Queue::MAX_SIZE
)base_features
: base virtio device features (e.g.VIRTIO_F_VERSION_1
)cfg
: bytes to return for the virtio configuration space (queried from device if not specified)
fn set_mem_table(&mut self, mem: &GuestMemory) -> Result<(), Error>
sourcefn activate_vring(
&mut self,
mem: &GuestMemory,
queue_index: usize,
queue: &Queue,
irqfd: &Event
) -> Result<(), Error>
fn activate_vring( &mut self, mem: &GuestMemory, queue_index: usize, queue: &Queue, irqfd: &Event ) -> Result<(), Error>
Activates a vring for the given queue
.
sourcefn deactivate_vring(&self, queue_index: usize) -> Result<u16, Error>
fn deactivate_vring(&self, queue_index: usize) -> Result<u16, Error>
Stops the vring for the given queue
, returning its base index.
sourcefn start_worker(&mut self, interrupt: Interrupt, non_msix_evt: Event)
fn start_worker(&mut self, interrupt: Interrupt, non_msix_evt: Event)
Helper to start up the worker thread that will be used with handling interrupts and requests from the device process.
Trait Implementations§
source§impl VirtioDevice for VhostUserFrontend
impl VirtioDevice for VhostUserFrontend
source§fn debug_label(&self) -> String
fn debug_label(&self) -> String
Returns a label suitable for debug output.
source§fn keep_rds(&self) -> Vec<RawDescriptor>
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 device_type(&self) -> DeviceType
fn device_type(&self) -> DeviceType
The virtio device type.
source§fn queue_max_sizes(&self) -> &[u16]
fn queue_max_sizes(&self) -> &[u16]
The maximum size of each queue that this device supports.
source§fn features(&self) -> u64
fn features(&self) -> u64
The set of feature bits that this device supports in addition to the base features.
source§fn ack_features(&mut self, features: u64)
fn ack_features(&mut self, features: u64)
Acknowledges that this set of features should be enabled.
source§fn read_config(&self, offset: u64, data: &mut [u8])
fn read_config(&self, offset: u64, data: &mut [u8])
Reads this device configuration space at
offset
.source§fn write_config(&mut self, offset: u64, data: &[u8])
fn write_config(&mut self, offset: u64, data: &[u8])
Writes to this device configuration space at
offset
.source§fn activate(
&mut self,
mem: GuestMemory,
interrupt: Interrupt,
queues: BTreeMap<usize, Queue>
) -> Result<()>
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<()>
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 pci_address(&self) -> Option<PciAddress>
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.Returns the device’s shared memory region if present.
Provides the trait object used to map files into the device’s shared
memory region. Read more
source§fn expose_shmem_descriptors_with_viommu(&self) -> bool
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 virtio_sleep(&mut self) -> Result<Option<BTreeMap<usize, Queue>>>
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<()>
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>
fn virtio_snapshot(&mut self) -> Result<Value>
Snapshot current state. Device must be asleep.
source§fn virtio_restore(&mut self, data: Value) -> Result<()>
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 num_interrupts(&self) -> usize
fn num_interrupts(&self) -> usize
The number of interrupts used by this device.
source§fn get_device_bars(&mut self, _address: PciAddress) -> Vec<PciBarConfiguration>
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>>
fn get_device_caps(&self) -> Vec<Box<dyn PciCapability>>
Returns any additional capabiltiies required by the device.
source§fn on_device_sandboxed(&mut self)
fn on_device_sandboxed(&mut self)
Invoked when the device is sandboxed.
fn control_notify(&self, _behavior: MsixStatus)
fn generate_acpi( &mut self, _pci_address: &Option<PciAddress>, sdts: Vec<SDT> ) -> Option<Vec<SDT>>
source§fn read_bar(&mut self, _bar_index: PciBarIndex, _offset: u64, _data: &mut [u8])
fn read_bar(&mut self, _bar_index: PciBarIndex, _offset: u64, _data: &mut [u8])
Reads from a BAR region mapped in to the device. Read more
source§fn write_bar(&mut self, _bar_index: PciBarIndex, _offset: u64, _data: &[u8])
fn write_bar(&mut self, _bar_index: PciBarIndex, _offset: u64, _data: &[u8])
Writes to a BAR region mapped in to the device. Read more
source§fn transport_type(&self) -> VirtioTransportType
fn transport_type(&self) -> VirtioTransportType
Returns the Virtio transport type: PCI (default for crosvm) or MMIO.
Provides the base address of the shared memory region, if one is present. Will
be called before
activate
. Read moreQueries 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.
fn bootorder_fw_cfg(&self, _pci_address: u8) -> Option<(Vec<u8>, usize)>
Auto Trait Implementations§
impl !RefUnwindSafe for VhostUserFrontend
impl Send for VhostUserFrontend
impl !Sync for VhostUserFrontend
impl Unpin for VhostUserFrontend
impl !UnwindSafe for VhostUserFrontend
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
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn 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>
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)
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)
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.