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>,
deferred_snapshot_load: Option<VirtioGpuSnapshot>,
}
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>
§deferred_snapshot_load: Option<VirtioGpuSnapshot>
Implementations§
source§impl VirtioGpu
impl VirtioGpu
sourcepub 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>
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.
sourcepub fn import_event_device(
&mut self,
event_device: EventDevice
) -> Result<GpuResponse, GpuResponse>
pub fn import_event_device( &mut self, event_device: EventDevice ) -> Result<GpuResponse, GpuResponse>
Imports the event device
sourcepub fn display(&mut self) -> &Rc<RefCell<GpuDisplay>>
pub fn display(&mut self) -> &Rc<RefCell<GpuDisplay>>
Gets a reference to the display passed into new
.
sourcepub fn display_info(&self) -> Vec<(u32, u32, bool)>
pub fn display_info(&self) -> Vec<(u32, u32, bool)>
Gets the list of supported display resolutions as a slice of (width, height, enabled)
tuples.
fn add_displays(&mut self, displays: Vec<DisplayParameters>) -> GpuControlResult
sourcefn list_displays(&self) -> GpuControlResult
fn list_displays(&self) -> GpuControlResult
Returns the list of displays currently connected to the device.
sourcefn remove_displays(&mut self, display_ids: Vec<u32>) -> GpuControlResult
fn remove_displays(&mut self, display_ids: Vec<u32>) -> GpuControlResult
Removes the specified displays from the device.
fn set_display_mouse_mode( &mut self, display_id: u32, mouse_mode: MouseMode ) -> GpuControlResult
sourcepub fn process_gpu_control_command(
&mut self,
cmd: GpuControlCommand
) -> GpuControlResult
pub fn process_gpu_control_command( &mut self, cmd: GpuControlCommand ) -> GpuControlResult
Performs the given command to interact with or modify the device.
sourcepub fn process_display(&mut self) -> ProcessDisplayResult
pub fn process_display(&mut self) -> ProcessDisplayResult
Processes the internal display
events and returns true
if any display was closed.
sourcepub fn set_scanout(
&mut self,
scanout_id: u32,
resource_id: u32,
scanout_data: Option<VirtioScanoutBlobData>
) -> Result<GpuResponse, GpuResponse>
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.
sourcepub fn flush_resource(
&mut self,
resource_id: u32
) -> Result<GpuResponse, GpuResponse>
pub fn flush_resource( &mut self, resource_id: u32 ) -> Result<GpuResponse, GpuResponse>
If the resource is the scanout resource, flush it to the display.
sourcepub fn update_cursor(
&mut self,
resource_id: u32,
scanout_id: u32,
x: u32,
y: u32
) -> Result<GpuResponse, GpuResponse>
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.
sourcepub fn move_cursor(
&mut self,
_scanout_id: u32,
x: u32,
y: u32
) -> Result<GpuResponse, GpuResponse>
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.
sourcepub fn resource_assign_uuid(
&self,
resource_id: u32
) -> Result<GpuResponse, GpuResponse>
pub fn resource_assign_uuid( &self, resource_id: u32 ) -> Result<GpuResponse, GpuResponse>
Returns a uuid for the resource.
sourcepub fn export_resource(&mut self, resource_id: u32) -> ResourceResponse
pub fn export_resource(&mut self, resource_id: u32) -> ResourceResponse
If supported, export the resource with the given resource_id
to a file.
sourcepub fn export_fence(&mut self, fence_id: u64) -> ResourceResponse
pub fn export_fence(&mut self, fence_id: u64) -> ResourceResponse
If supported, export the fence with the given fence_id
to a file.
sourcepub fn get_capset_info(&self, index: u32) -> Result<GpuResponse, GpuResponse>
pub fn get_capset_info(&self, index: u32) -> Result<GpuResponse, GpuResponse>
Gets rutabaga’s capset information associated with index
.
sourcepub fn get_capset(
&self,
capset_id: u32,
version: u32
) -> Result<GpuResponse, GpuResponse>
pub fn get_capset( &self, capset_id: u32, version: u32 ) -> Result<GpuResponse, GpuResponse>
Gets a capset from rutabaga.
sourcepub fn force_ctx_0(&self)
pub fn force_ctx_0(&self)
Forces rutabaga to use it’s default context.
sourcepub fn create_fence(
&mut self,
rutabaga_fence: RutabagaFence
) -> Result<GpuResponse, GpuResponse>
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.
sourcepub fn event_poll(&self)
pub fn event_poll(&self)
Polls the Rutabaga backend.
sourcepub fn poll_descriptor(&self) -> Option<SafeDescriptor>
pub fn poll_descriptor(&self) -> Option<SafeDescriptor>
Gets a pollable eventfd that signals the device to wakeup and poll the Rutabaga backend.
sourcepub fn resource_create_3d(
&mut self,
resource_id: u32,
resource_create_3d: ResourceCreate3D
) -> Result<GpuResponse, GpuResponse>
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.
sourcepub fn attach_backing(
&mut self,
resource_id: u32,
mem: &GuestMemory,
vecs: Vec<(GuestAddress, usize)>
) -> Result<GpuResponse, GpuResponse>
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.
sourcepub fn detach_backing(
&mut self,
resource_id: u32
) -> Result<GpuResponse, GpuResponse>
pub fn detach_backing( &mut self, resource_id: u32 ) -> Result<GpuResponse, GpuResponse>
Detaches any previously attached iovecs from the resource.
sourcepub fn unref_resource(
&mut self,
resource_id: u32
) -> Result<GpuResponse, GpuResponse>
pub fn unref_resource( &mut self, resource_id: u32 ) -> Result<GpuResponse, GpuResponse>
Releases guest kernel reference on the resource.
sourcepub fn transfer_write(
&mut self,
ctx_id: u32,
resource_id: u32,
transfer: Transfer3D
) -> Result<GpuResponse, GpuResponse>
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.
sourcepub fn transfer_read(
&mut self,
ctx_id: u32,
resource_id: u32,
transfer: Transfer3D,
buf: Option<VolatileSlice<'_>>
) -> Result<GpuResponse, GpuResponse>
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:
- To the optional volatile slice
- To the host resource’s attached iovecs
Can also be used to invalidate caches.
sourcepub 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>
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.
sourcepub fn resource_map_blob(
&mut self,
resource_id: u32,
offset: u64
) -> Result<GpuResponse, GpuResponse>
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().
sourcepub fn resource_unmap_blob(
&mut self,
resource_id: u32
) -> Result<GpuResponse, GpuResponse>
pub fn resource_unmap_blob( &mut self, resource_id: u32 ) -> Result<GpuResponse, GpuResponse>
Uses the hypervisor to unmap the blob resource.
sourcepub fn get_edid(&self, scanout_id: u32) -> Result<GpuResponse, GpuResponse>
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.
sourcepub fn create_context(
&mut self,
ctx_id: u32,
context_init: u32,
context_name: Option<&str>
) -> Result<GpuResponse, GpuResponse>
pub fn create_context( &mut self, ctx_id: u32, context_init: u32, context_name: Option<&str> ) -> Result<GpuResponse, GpuResponse>
Creates a rutabaga context.
sourcepub fn destroy_context(
&mut self,
ctx_id: u32
) -> Result<GpuResponse, GpuResponse>
pub fn destroy_context( &mut self, ctx_id: u32 ) -> Result<GpuResponse, GpuResponse>
Destroys a rutabaga context.
sourcepub fn context_attach_resource(
&mut self,
ctx_id: u32,
resource_id: u32
) -> Result<GpuResponse, GpuResponse>
pub fn context_attach_resource( &mut self, ctx_id: u32, resource_id: u32 ) -> Result<GpuResponse, GpuResponse>
Attaches a resource to a rutabaga context.
sourcepub fn context_detach_resource(
&mut self,
ctx_id: u32,
resource_id: u32
) -> Result<GpuResponse, GpuResponse>
pub fn context_detach_resource( &mut self, ctx_id: u32, resource_id: u32 ) -> Result<GpuResponse, GpuResponse>
Detaches a resource from a rutabaga context.
sourcepub fn submit_command(
&mut self,
ctx_id: u32,
commands: &mut [u8],
fence_ids: &[u64]
) -> Result<GpuResponse, GpuResponse>
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.
fn result_from_query(&mut self, resource_id: u32) -> GpuResponse
fn update_scanout_resource( &mut self, scanout_type: SurfaceType, scanout_id: u32, scanout_data: Option<VirtioScanoutBlobData>, resource_id: u32 ) -> Result<GpuResponse, GpuResponse>
pub fn suspend(&self) -> Result<()>
pub fn snapshot(&self) -> Result<VirtioGpuSnapshot>
pub fn restore(&mut self, snapshot: VirtioGpuSnapshot) -> Result<()>
pub fn resume(&mut self, mem: &GuestMemory) -> Result<()>
Auto Trait Implementations§
impl !RefUnwindSafe for VirtioGpu
impl !Send for VirtioGpu
impl !Sync for VirtioGpu
impl Unpin for VirtioGpu
impl !UnwindSafe for VirtioGpu
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
§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>
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>
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)
&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)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.