mirror of
https://github.com/rust-vmm/vhost-device.git
synced 2026-01-05 00:39:40 +00:00
This commit refactors vhost-device-gpu by separating
virglrenderer from rutabaga, and using gfxstream via
rutabaga, Simplifying future backend development.
This commit introduces a significant refactor of the
virtio-gpu backend architecture:
- Transition `gfxstream` support to use `Rutabaga`
abstraction.
- Decouple `virglrenderer` from `Rutabaga`, allowing
it to be used as standalone.
- Unify backend handling using thread-local storage
and macro-based runtime dispatch.
Key Changes:
VirglRenderer Backend:
- `virgl.rs` is now a standalone backend that
directly calls `libvirglrenderer` functions.
- Removed reliance on `rutabaga` for virgl path.
Gfxstream Backend via Rutabaga:
- Introduced `gfxstream.rs` backend using `rutabaga`
- Thread-local `GfxstreamAdapter` manages its own
`Rutabaga` instance, initialized lazily.
- Preserved internal `GfxstreamResource` tracking
with scanout support and memory handling.
Renderer Selection Logic:
- In `device.rs`, `lazy_init_and_handle_event()` now:
- Dispatches `VirglRendererAdapter` and
`GfxstreamAdapter` using thread-local storage(TLS)
- Introduced `extract_backend_and_vring()` helper for
reusing backend setup logic.
Code Deduplication:
- Abstracted common logic for both backends to common.rs.
- Shared helpers reused between gfxstream and virgl.
- Improved modularity with fewer duplicated error
handling branches.
Testing and Validation:
- Replaced `virtio_gpu.rs` testing paths with new unit
tests for `gfxstream.rs` and `virgl.rs`.
- Added code coverage for the new refactored crate.
- Update coverage file to reflect the drop in coverage
due to exclusion of some gfxstream tests from CI
since they can't run in CI without GPU drivers.
Signed-off-by: Dorinda Bassey <dbassey@redhat.com>
47 lines
1.6 KiB
TOML
47 lines
1.6 KiB
TOML
[package]
|
|
name = "vhost-device-gpu"
|
|
version = "0.1.0"
|
|
authors = ["Dorinda Bassey <dbassey@redhat.com>", "Matej Hrica <mhrica@redhat.com>"]
|
|
description = "A virtio-gpu device using the vhost-user protocol."
|
|
repository = "https://github.com/rust-vmm/vhost-device"
|
|
readme = "README.md"
|
|
keywords = ["gpu", "vhost", "vhost-user", "virtio"]
|
|
categories = ["multimedia::video", "virtualization"]
|
|
license = "Apache-2.0 OR BSD-3-Clause"
|
|
edition = "2021"
|
|
# "Features enabled on platform-specific dependencies for target architectures not currently being built are ignored."
|
|
# See <https://doc.rust-lang.org/cargo/reference/features.html#feature-resolver-version-2>
|
|
resolver = "2"
|
|
|
|
[features]
|
|
default = ["backend-virgl", "backend-gfxstream"]
|
|
xen = ["vm-memory/xen", "vhost/xen", "vhost-user-backend/xen"]
|
|
backend-gfxstream = ["rutabaga_gfx/gfxstream"]
|
|
backend-virgl = ["dep:virglrenderer"]
|
|
|
|
[dependencies]
|
|
clap = { version = "4.5", features = ["derive"] }
|
|
env_logger = "0.11.6"
|
|
libc = "0.2"
|
|
log = "0.4"
|
|
|
|
[target.'cfg(not(target_env = "musl"))'.dependencies]
|
|
rutabaga_gfx = "0.1.75"
|
|
thiserror = "2.0.17"
|
|
virglrenderer = {version = "0.1.2", optional = true }
|
|
vhost = { version = "0.14.0", features = ["vhost-user-backend"] }
|
|
vhost-user-backend = "0.20"
|
|
virtio-bindings = "0.2.5"
|
|
virtio-queue = "0.16.0"
|
|
vm-memory = "0.16.1"
|
|
vmm-sys-util = "0.14.0"
|
|
bitflags = "2.10.0"
|
|
|
|
[dev-dependencies]
|
|
assert_matches = "1.5"
|
|
mockall = "0.13.0"
|
|
rusty-fork = "0.3.1"
|
|
tempfile = "3.23"
|
|
virtio-queue = { version = "0.16", features = ["test-utils"] }
|
|
vm-memory = { version = "0.16.1", features = ["backend-mmap", "backend-atomic"] }
|