Skip to content

Commit caaac9a

Browse files
Dorinda Basseystefano-garzarella
authored andcommitted
chore(vhost-device-gpu): bump rutabaga_gfx to 0.1.71
- update RutabagaBuilder to accept fence handler at construction - replace query() with resource3d_info() - adjust tests for new fence + GuestMemory setup - drop removed fields (e.g. guest_cpu_mappable) Signed-off-by: Dorinda Bassey <[email protected]>
1 parent 8141da0 commit caaac9a

File tree

2 files changed

+26
-20
lines changed

2 files changed

+26
-20
lines changed

vhost-device-gpu/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ libc = "0.2"
2525
log = "0.4"
2626

2727
[target.'cfg(not(target_env = "musl"))'.dependencies]
28-
rutabaga_gfx = { version = "0.1.62", features = ["virgl_renderer"] }
28+
rutabaga_gfx = { version = "0.1.71", features = ["virgl_renderer"] }
2929
thiserror = "2.0.12"
3030
vhost = { version = "0.14.0", features = ["vhost-user-backend"] }
3131
vhost-user-backend = "0.20"

vhost-device-gpu/src/virtio_gpu.rs

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -395,16 +395,16 @@ impl RutabagaVirtioGpu {
395395

396396
fn configure_rutabaga_builder(
397397
gpu_config: &GpuConfig,
398+
fence: RutabagaFenceHandler,
398399
) -> (RutabagaBuilder, RutabagaComponentType) {
399400
let component = match gpu_config.gpu_mode() {
400401
GpuMode::VirglRenderer => RutabagaComponentType::VirglRenderer,
401402
#[cfg(feature = "gfxstream")]
402403
GpuMode::Gfxstream => RutabagaComponentType::Gfxstream,
403404
};
404405

405-
let builder = RutabagaBuilder::new(component, gpu_config.capsets().bits())
406+
let builder = RutabagaBuilder::new(gpu_config.capsets().bits(), fence)
406407
.set_use_egl(gpu_config.flags().use_egl)
407-
.set_use_glx(gpu_config.flags().use_glx)
408408
.set_use_gles(gpu_config.flags().use_gles)
409409
.set_use_surfaceless(gpu_config.flags().use_surfaceless)
410410
// Since vhost-user-gpu is out-of-process this is the only type of blob resource that
@@ -417,11 +417,9 @@ impl RutabagaVirtioGpu {
417417
pub fn new(queue_ctl: &VringRwLock, gpu_config: &GpuConfig, gpu_backend: GpuBackend) -> Self {
418418
let fence_state = Arc::new(Mutex::new(FenceState::default()));
419419
let fence = Self::create_fence_handler(queue_ctl.clone(), fence_state.clone());
420-
let (builder, component_type) = Self::configure_rutabaga_builder(gpu_config);
420+
let (builder, component_type) = Self::configure_rutabaga_builder(gpu_config, fence);
421421

422-
let rutabaga = builder
423-
.build(fence, None)
424-
.expect("Rutabaga initialization failed!");
422+
let rutabaga = builder.build().expect("Rutabaga initialization failed!");
425423

426424
Self {
427425
rutabaga,
@@ -434,7 +432,7 @@ impl RutabagaVirtioGpu {
434432
}
435433

436434
fn result_from_query(&self, resource_id: u32) -> GpuResponse {
437-
let Ok(query) = self.rutabaga.query(resource_id) else {
435+
let Ok(query) = self.rutabaga.resource3d_info(resource_id) else {
438436
return OkNoData;
439437
};
440438
let mut plane_info = Vec::with_capacity(4);
@@ -728,10 +726,10 @@ impl VirtioGpu for RutabagaVirtioGpu {
728726
let handle_opt: Option<Arc<RutabagaHandle>> =
729727
self.rutabaga.export_blob(resource_id).map(Arc::new).ok();
730728

731-
// Only trust query() when we have a DMABUF handle.
729+
// Only trust resource3d_info() when we have a DMABUF handle.
732730
let info_3d_opt: Option<Resource3DInfo> = if let Some(h) = handle_opt.as_ref() {
733731
if h.handle_type == RUTABAGA_HANDLE_TYPE_MEM_DMABUF {
734-
self.rutabaga.query(resource_id).ok()
732+
self.rutabaga.resource3d_info(resource_id).ok()
735733
} else {
736734
log::warn!(
737735
"export_blob for resource {} returned non-DMABUF handle type: {:?}",
@@ -1098,19 +1096,17 @@ impl VirtioGpu for RutabagaVirtioGpu {
10981096

10991097
#[cfg(test)]
11001098
mod tests {
1099+
#[cfg(feature = "gfxstream")]
1100+
use std::env::set_var;
11011101
use std::{
11021102
os::unix::net::UnixStream,
11031103
sync::{Arc, Mutex},
11041104
};
11051105

1106-
#[cfg(feature = "gfxstream")]
1107-
use std::env::set_var;
1108-
11091106
use assert_matches::assert_matches;
11101107
use rusty_fork::rusty_fork_test;
1111-
use rutabaga_gfx::{
1112-
RutabagaFence, RutabagaHandler, RUTABAGA_PIPE_BIND_RENDER_TARGET, RUTABAGA_PIPE_TEXTURE_2D,
1113-
};
1108+
use rutabaga_gfx::{RutabagaFence, RUTABAGA_PIPE_BIND_RENDER_TARGET, RUTABAGA_PIPE_TEXTURE_2D};
1109+
use vm_memory::{GuestAddress, GuestMemoryAtomic, GuestMemoryMmap};
11141110

11151111
use super::*;
11161112
use crate::{protocol::VIRTIO_GPU_FORMAT_R8G8B8A8_UNORM, GpuCapset, GpuFlags};
@@ -1161,9 +1157,21 @@ mod tests {
11611157

11621158
let config = GpuConfig::new(gpu_mode, capsets, GpuFlags::default()).unwrap();
11631159

1160+
// Mock memory
1161+
let mem = GuestMemoryAtomic::new(
1162+
GuestMemoryMmap::<()>::from_ranges(&[(GuestAddress(0), 0x10000)]).unwrap(),
1163+
);
1164+
let vring = VringRwLock::new(mem, 0x1000).unwrap();
1165+
vring.set_queue_info(0x100, 0x200, 0x300).unwrap();
1166+
vring.set_queue_ready(true);
1167+
1168+
let fence_state = Arc::new(Mutex::new(FenceState::default()));
1169+
let fence = RutabagaVirtioGpu::create_fence_handler(vring, fence_state);
1170+
// Test creating a fence with the `RutabagaFence` that can be used to determine
1171+
// when the previous command completed.
11641172
let (builder, actual_component_type) =
1165-
RutabagaVirtioGpu::configure_rutabaga_builder(&config);
1166-
let rutabaga = builder.build(RutabagaHandler::new(|_| {}), None).unwrap();
1173+
RutabagaVirtioGpu::configure_rutabaga_builder(&config, fence);
1174+
let rutabaga = builder.build().unwrap();
11671175
RutabagaVirtioGpu {
11681176
rutabaga,
11691177
gpu_backend: dummy_gpu_backend(),
@@ -1360,7 +1368,6 @@ mod tests {
13601368
offsets: [0, 0, 0, 0],
13611369
drm_fourcc: 0x34325241,
13621370
modifier: 0,
1363-
guest_cpu_mappable: true,
13641371
});
13651372
let result = virtio_gpu.set_scanout(VIRTIO_GPU_MAX_SCANOUTS + 1, 1, rect.clone());
13661373
assert_matches!(result, Err(ErrInvalidResourceId));
@@ -1405,7 +1412,6 @@ mod tests {
14051412
offsets: [0, 0, 0, 0],
14061413
drm_fourcc: 0x34325241, // 'AR24'
14071414
modifier: 0,
1408-
guest_cpu_mappable: false,
14091415
});
14101416
res
14111417
}

0 commit comments

Comments
 (0)