Commit Graph

9 Commits

Author SHA1 Message Date
Dorinda Bassey
dff8efdd2b vhost-device-gpu: Fix format and lint issues
These are minor formatting and linter fixes

Signed-off-by: Dorinda Bassey <dbassey@redhat.com>
2025-11-13 14:48:04 +01:00
Dorinda Bassey
736c5d109d vhost-device-gpu: Add null backend and test
Add a no-op null backend that allows vhost-device-gpu
to compile with --no-default-features and update the
README, enabling testing of all feature combinations.
The null backend is automatically selected when
no-default features are enabled.

Signed-off-by: Dorinda Bassey <dbassey@redhat.com>
2025-11-13 14:48:04 +01:00
Dorinda Bassey
9f72a8187f vhost-device-gpu: Refactor vhost-device-gpu
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>
2025-11-13 14:48:04 +01:00
Dorinda Bassey
5931076436 vhost-device-gpu: Rename gfxstream feature
Rename the 'gfxstream' feature flag to
'backend-gfxstream' for consistency with
the new modular backend architecture and
update the README.

Signed-off-by: Dorinda Bassey <dbassey@redhat.com>
2025-11-13 14:48:04 +01:00
Manos Pitsidianakis
16bb710501 Remove redundant global deny/allow in crates
They are already defined in the workspace Cargo.toml

Signed-off-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
2025-11-10 10:39:03 +02:00
Alex Bennée
ac27ba3856 vhost-device-gpu: move assert_matches import
It is used by all the tests so don't gate it just by gfxstream. In
fact we don't need clap::ValueEnum either as the use super::* imports
it anyway so we can drop the whole feature stanza.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
2025-09-12 14:22:27 +03:00
Dorinda Bassey
d6d95a7208 vhost-device-gpu: fix typo in comment and code
correct typo in comment in device.rs and typo in
lib.rs

Signed-off-by: Dorinda Bassey <dbassey@redhat.com>
2025-09-02 12:09:54 +02:00
Manos Pitsidianakis
5f762349fb gpu: fix minor typos
Signed-off-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
2025-07-07 11:28:02 +03:00
Matej Hrica
02409f0a09 Move vhost-user-gpu from staging to main directory
The CLI interface should be stable now and coverage is good. Support
for more backends as described in the README is comming later.

Note that this decreases the test coverage in the staging directory from
82.43% to 74.62%.

Signed-off-by: Matej Hrica <mhrica@redhat.com>
2025-02-14 10:15:52 +02:00