pub struct VirtioGpu {
    display: Rc<RefCell<GpuDisplay>>,
    scanouts: BTreeMap<u32, VirtioGpuScanout>,
    scanouts_updated: Arc<AtomicBool>,
    cursor_scanout: VirtioGpuScanout,
    mapper: Arc<Mutex<Option<Box<dyn SharedMemoryMapper>>>>,
    rutabaga: Rutabaga,
    resources: BTreeMap<u32, VirtioGpuResource>,
    external_blob: bool,
    fixed_blob_mapping: bool,
    udmabuf_driver: Option<UdmabufDriver>,
}
Expand description

Handles functionality related to displays, input events and hypervisor memory management.

Fields§

§display: Rc<RefCell<GpuDisplay>>§scanouts: BTreeMap<u32, VirtioGpuScanout>§scanouts_updated: Arc<AtomicBool>§cursor_scanout: VirtioGpuScanout§mapper: Arc<Mutex<Option<Box<dyn SharedMemoryMapper>>>>§rutabaga: Rutabaga§resources: BTreeMap<u32, VirtioGpuResource>§external_blob: bool§fixed_blob_mapping: bool§udmabuf_driver: Option<UdmabufDriver>

Implementations§

source§

impl VirtioGpu

source

pub fn new( display: GpuDisplay, display_params: Vec<GpuDisplayParameters>, display_event: Arc<AtomicBool>, rutabaga: Rutabaga, mapper: Arc<Mutex<Option<Box<dyn SharedMemoryMapper>>>>, external_blob: bool, fixed_blob_mapping: bool, udmabuf: bool ) -> Option<VirtioGpu>

Creates a new instance of the VirtioGpu state tracker.

source

pub fn import_event_device( &mut self, event_device: EventDevice ) -> Result<GpuResponse, GpuResponse>

Imports the event device

source

pub fn display(&mut self) -> &Rc<RefCell<GpuDisplay>>

Gets a reference to the display passed into new.

source

pub fn display_info(&self) -> Vec<(u32, u32, bool)>

Gets the list of supported display resolutions as a slice of (width, height, enabled) tuples.

source

fn add_displays(&mut self, displays: Vec<DisplayParameters>) -> GpuControlResult

source

fn list_displays(&self) -> GpuControlResult

Returns the list of displays currently connected to the device.

source

fn remove_displays(&mut self, display_ids: Vec<u32>) -> GpuControlResult

Removes the specified displays from the device.

source

fn set_display_mouse_mode( &mut self, display_id: u32, mouse_mode: MouseMode ) -> GpuControlResult

source

pub fn process_gpu_control_command( &mut self, cmd: GpuControlCommand ) -> GpuControlResult

Performs the given command to interact with or modify the device.

source

pub fn process_display(&mut self) -> ProcessDisplayResult

Processes the internal display events and returns true if any display was closed.

source

pub fn set_scanout( &mut self, scanout_id: u32, resource_id: u32, scanout_data: Option<VirtioScanoutBlobData> ) -> Result<GpuResponse, GpuResponse>

Sets the given resource id as the source of scanout to the display.

source

pub fn flush_resource( &mut self, resource_id: u32 ) -> Result<GpuResponse, GpuResponse>

If the resource is the scanout resource, flush it to the display.

source

pub fn update_cursor( &mut self, resource_id: u32, scanout_id: u32, x: u32, y: u32 ) -> Result<GpuResponse, GpuResponse>

Updates the cursor’s memory to the given resource_id, and sets its position to the given coordinates.

source

pub fn move_cursor( &mut self, _scanout_id: u32, x: u32, y: u32 ) -> Result<GpuResponse, GpuResponse>

Moves the cursor’s position to the given coordinates.

source

pub fn resource_assign_uuid( &self, resource_id: u32 ) -> Result<GpuResponse, GpuResponse>

Returns a uuid for the resource.

source

pub fn export_resource(&mut self, resource_id: u32) -> ResourceResponse

If supported, export the resource with the given resource_id to a file.

source

pub fn export_fence(&self, fence_id: u64) -> ResourceResponse

If supported, export the fence with the given fence_id to a file.

source

pub fn get_capset_info(&self, index: u32) -> Result<GpuResponse, GpuResponse>

Gets rutabaga’s capset information associated with index.

source

pub fn get_capset( &self, capset_id: u32, version: u32 ) -> Result<GpuResponse, GpuResponse>

Gets a capset from rutabaga.

source

pub fn force_ctx_0(&self)

Forces rutabaga to use it’s default context.

source

pub fn create_fence( &mut self, rutabaga_fence: RutabagaFence ) -> Result<GpuResponse, GpuResponse>

Creates a fence with the RutabagaFence that can be used to determine when the previous command completed.

source

pub fn event_poll(&self)

Polls the Rutabaga backend.

source

pub fn poll_descriptor(&self) -> Option<SafeDescriptor>

Gets a pollable eventfd that signals the device to wakeup and poll the Rutabaga backend.

source

pub fn resource_create_3d( &mut self, resource_id: u32, resource_create_3d: ResourceCreate3D ) -> Result<GpuResponse, GpuResponse>

Creates a 3D resource with the given properties and resource_id.

source

pub fn attach_backing( &mut self, resource_id: u32, mem: &GuestMemory, vecs: Vec<(GuestAddress, usize)> ) -> Result<GpuResponse, GpuResponse>

Attaches backing memory to the given resource, represented by a Vec of (address, size) tuples in the guest’s physical address space. Converts to RutabagaIovec from the memory mapping.

source

pub fn detach_backing( &mut self, resource_id: u32 ) -> Result<GpuResponse, GpuResponse>

Detaches any previously attached iovecs from the resource.

source

pub fn unref_resource( &mut self, resource_id: u32 ) -> Result<GpuResponse, GpuResponse>

Releases guest kernel reference on the resource.

source

pub fn transfer_write( &mut self, ctx_id: u32, resource_id: u32, transfer: Transfer3D ) -> Result<GpuResponse, GpuResponse>

Copies data to host resource from the attached iovecs. Can also be used to flush caches.

source

pub fn transfer_read( &mut self, ctx_id: u32, resource_id: u32, transfer: Transfer3D, buf: Option<VolatileSlice<'_>> ) -> Result<GpuResponse, GpuResponse>

Copies data from the host resource to:

  1. To the optional volatile slice
  2. To the host resource’s attached iovecs

Can also be used to invalidate caches.

source

pub fn resource_create_blob( &mut self, ctx_id: u32, resource_id: u32, resource_create_blob: ResourceCreateBlob, vecs: Vec<(GuestAddress, usize)>, mem: &GuestMemory ) -> Result<GpuResponse, GpuResponse>

Creates a blob resource using rutabaga.

source

pub fn resource_map_blob( &mut self, resource_id: u32, offset: u64 ) -> Result<GpuResponse, GpuResponse>

Uses the hypervisor to map the rutabaga blob resource.

When sandboxing is disabled, external_blob is unset and opaque fds are mapped by rutabaga as ExternalMapping. When sandboxing is enabled, external_blob is set and opaque fds must be mapped in the hypervisor process by Vulkano using metadata provided by Rutabaga::vulkan_info().

source

pub fn resource_unmap_blob( &mut self, resource_id: u32 ) -> Result<GpuResponse, GpuResponse>

Uses the hypervisor to unmap the blob resource.

source

pub fn get_edid(&self, scanout_id: u32) -> Result<GpuResponse, GpuResponse>

Gets the EDID for the specified scanout ID. If that scanout is not enabled, it would return the EDID of a default display.

source

pub fn create_context( &mut self, ctx_id: u32, context_init: u32, context_name: Option<&str> ) -> Result<GpuResponse, GpuResponse>

Creates a rutabaga context.

source

pub fn destroy_context( &mut self, ctx_id: u32 ) -> Result<GpuResponse, GpuResponse>

Destroys a rutabaga context.

source

pub fn context_attach_resource( &mut self, ctx_id: u32, resource_id: u32 ) -> Result<GpuResponse, GpuResponse>

Attaches a resource to a rutabaga context.

source

pub fn context_detach_resource( &mut self, ctx_id: u32, resource_id: u32 ) -> Result<GpuResponse, GpuResponse>

Detaches a resource from a rutabaga context.

source

pub fn submit_command( &mut self, ctx_id: u32, commands: &mut [u8], fence_ids: &[u64] ) -> Result<GpuResponse, GpuResponse>

Submits a command buffer to a rutabaga context.

source

fn result_from_query(&mut self, resource_id: u32) -> GpuResponse

source

fn update_scanout_resource( &mut self, scanout_type: SurfaceType, scanout_id: u32, scanout_data: Option<VirtioScanoutBlobData>, resource_id: u32 ) -> Result<GpuResponse, GpuResponse>

source

pub fn snapshot(&self) -> Result<VirtioGpuSnapshot>

source

pub fn restore( &mut self, snapshot: VirtioGpuSnapshot, mem: &GuestMemory ) -> Result<()>

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
§

impl<T> Downcast for Twhere T: Any,

§

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

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, Global>) -> Rc<dyn Any, Global>

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 Twhere 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 Twhere 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 Twhere 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 Twhere V: MultiLane<T>,

§

fn vzip(self) -> V