Commit Graph

21 Commits

Author SHA1 Message Date
Stefano Garzarella
9191a0c1de chore: remove pub visibility from exit event fields
The `exit_consumer` and `exit_notifier` fields are only used internally
by the exit_event() method implementation or by send_exit_event() in the
sound device. So, they do not need to be exposed in the public API of
backend structures.

Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
2025-11-19 12:09:37 +02:00
dependabot[bot]
9040bcb726 build(deps): bump the rust-vmm group across 2 directories with 6 updates
Bumps the rust-vmm group with 6 updates in the / directory:

| Package | From | To |
| --- | --- | --- |
| [vhost](https://github.com/rust-vmm/vhost) | `0.14.0` | `0.15.0` |
| [vhost-user-backend](https://github.com/rust-vmm/vhost) | `0.20.0` | `0.21.0` |
| [virtio-queue](https://github.com/rust-vmm/vm-virtio) | `0.16.0` | `0.17.0` |
| [vm-memory](https://github.com/rust-vmm/vm-memory) | `0.16.2` | `0.17.1` |
| [vmm-sys-util](https://github.com/rust-vmm/vmm-sys-util) | `0.14.0` | `0.15.0` |
| [virtio-vsock](https://github.com/rust-vmm/vm-virtio) | `0.10.0` | `0.11.0` |

Bumps the rust-vmm group with 5 updates in the /staging directory:

| Package | From | To |
| --- | --- | --- |
| [vhost](https://github.com/rust-vmm/vhost) | `0.14.0` | `0.15.0` |
| [vhost-user-backend](https://github.com/rust-vmm/vhost) | `0.20.0` | `0.21.0` |
| [virtio-queue](https://github.com/rust-vmm/vm-virtio) | `0.16.0` | `0.17.0` |
| [vm-memory](https://github.com/rust-vmm/vm-memory) | `0.16.2` | `0.17.1` |
| [vmm-sys-util](https://github.com/rust-vmm/vmm-sys-util) | `0.14.0` | `0.15.0` |

Updates `vhost` from 0.14.0 to 0.15.0
- [Release notes](https://github.com/rust-vmm/vhost/releases)
- [Commits](https://github.com/rust-vmm/vhost/compare/vhost-v0.14.0...vhost-v0.15.0)

Updates `vhost-user-backend` from 0.20.0 to 0.21.0
- [Release notes](https://github.com/rust-vmm/vhost/releases)
- [Commits](https://github.com/rust-vmm/vhost/compare/vhost-user-backend-v0.20.0...vhost-user-backend-v0.21.0)

Updates `virtio-queue` from 0.16.0 to 0.17.0
- [Release notes](https://github.com/rust-vmm/vm-virtio/releases)
- [Commits](https://github.com/rust-vmm/vm-virtio/compare/virtio-queue-v0.16.0...virtio-queue-v0.17.0)

Updates `vm-memory` from 0.16.2 to 0.17.1
- [Release notes](https://github.com/rust-vmm/vm-memory/releases)
- [Changelog](https://github.com/rust-vmm/vm-memory/blob/main/CHANGELOG.md)
- [Commits](https://github.com/rust-vmm/vm-memory/compare/v0.16.2...v0.17.1)

Updates `vmm-sys-util` from 0.14.0 to 0.15.0
- [Release notes](https://github.com/rust-vmm/vmm-sys-util/releases)
- [Changelog](https://github.com/rust-vmm/vmm-sys-util/blob/main/CHANGELOG.md)
- [Commits](https://github.com/rust-vmm/vmm-sys-util/compare/v0.14.0...v0.15.0)

Updates `virtio-vsock` from 0.10.0 to 0.11.0
- [Release notes](https://github.com/rust-vmm/vm-virtio/releases)
- [Commits](https://github.com/rust-vmm/vm-virtio/compare/virtio-vsock-v0.10.0...virtio-vsock-v0.11.0)

Updates `vhost` from 0.14.0 to 0.15.0
- [Release notes](https://github.com/rust-vmm/vhost/releases)
- [Commits](https://github.com/rust-vmm/vhost/compare/vhost-v0.14.0...vhost-v0.15.0)

Updates `vhost-user-backend` from 0.20.0 to 0.21.0
- [Release notes](https://github.com/rust-vmm/vhost/releases)
- [Commits](https://github.com/rust-vmm/vhost/compare/vhost-user-backend-v0.20.0...vhost-user-backend-v0.21.0)

Updates `virtio-queue` from 0.16.0 to 0.17.0
- [Release notes](https://github.com/rust-vmm/vm-virtio/releases)
- [Commits](https://github.com/rust-vmm/vm-virtio/compare/virtio-queue-v0.16.0...virtio-queue-v0.17.0)

Updates `vm-memory` from 0.16.2 to 0.17.1
- [Release notes](https://github.com/rust-vmm/vm-memory/releases)
- [Changelog](https://github.com/rust-vmm/vm-memory/blob/main/CHANGELOG.md)
- [Commits](https://github.com/rust-vmm/vm-memory/compare/v0.16.2...v0.17.1)

Updates `vmm-sys-util` from 0.14.0 to 0.15.0
- [Release notes](https://github.com/rust-vmm/vmm-sys-util/releases)
- [Changelog](https://github.com/rust-vmm/vmm-sys-util/blob/main/CHANGELOG.md)
- [Commits](https://github.com/rust-vmm/vmm-sys-util/compare/v0.14.0...v0.15.0)

Updates `vhost` from 0.14.0 to 0.15.0
- [Release notes](https://github.com/rust-vmm/vhost/releases)
- [Commits](https://github.com/rust-vmm/vhost/compare/vhost-v0.14.0...vhost-v0.15.0)

Updates `vhost-user-backend` from 0.20.0 to 0.21.0
- [Release notes](https://github.com/rust-vmm/vhost/releases)
- [Commits](https://github.com/rust-vmm/vhost/compare/vhost-user-backend-v0.20.0...vhost-user-backend-v0.21.0)

Updates `virtio-queue` from 0.16.0 to 0.17.0
- [Release notes](https://github.com/rust-vmm/vm-virtio/releases)
- [Commits](https://github.com/rust-vmm/vm-virtio/compare/virtio-queue-v0.16.0...virtio-queue-v0.17.0)

Updates `vm-memory` from 0.16.2 to 0.17.1
- [Release notes](https://github.com/rust-vmm/vm-memory/releases)
- [Changelog](https://github.com/rust-vmm/vm-memory/blob/main/CHANGELOG.md)
- [Commits](https://github.com/rust-vmm/vm-memory/compare/v0.16.2...v0.17.1)

Updates `vmm-sys-util` from 0.14.0 to 0.15.0
- [Release notes](https://github.com/rust-vmm/vmm-sys-util/releases)
- [Changelog](https://github.com/rust-vmm/vmm-sys-util/blob/main/CHANGELOG.md)
- [Commits](https://github.com/rust-vmm/vmm-sys-util/compare/v0.14.0...v0.15.0)

Updates `vhost` from 0.14.0 to 0.15.0
- [Release notes](https://github.com/rust-vmm/vhost/releases)
- [Commits](https://github.com/rust-vmm/vhost/compare/vhost-v0.14.0...vhost-v0.15.0)

Updates `vhost-user-backend` from 0.20.0 to 0.21.0
- [Release notes](https://github.com/rust-vmm/vhost/releases)
- [Commits](https://github.com/rust-vmm/vhost/compare/vhost-user-backend-v0.20.0...vhost-user-backend-v0.21.0)

Updates `virtio-queue` from 0.16.0 to 0.17.0
- [Release notes](https://github.com/rust-vmm/vm-virtio/releases)
- [Commits](https://github.com/rust-vmm/vm-virtio/compare/virtio-queue-v0.16.0...virtio-queue-v0.17.0)

Updates `vm-memory` from 0.16.2 to 0.17.1
- [Release notes](https://github.com/rust-vmm/vm-memory/releases)
- [Changelog](https://github.com/rust-vmm/vm-memory/blob/main/CHANGELOG.md)
- [Commits](https://github.com/rust-vmm/vm-memory/compare/v0.16.2...v0.17.1)

Updates `vmm-sys-util` from 0.14.0 to 0.15.0
- [Release notes](https://github.com/rust-vmm/vmm-sys-util/releases)
- [Changelog](https://github.com/rust-vmm/vmm-sys-util/blob/main/CHANGELOG.md)
- [Commits](https://github.com/rust-vmm/vmm-sys-util/compare/v0.14.0...v0.15.0)

---
updated-dependencies:
- dependency-name: vhost
  dependency-version: 0.15.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: rust-vmm
- dependency-name: vhost-user-backend
  dependency-version: 0.21.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: rust-vmm
- dependency-name: virtio-queue
  dependency-version: 0.17.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: rust-vmm
- dependency-name: vm-memory
  dependency-version: 0.17.1
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: rust-vmm
- dependency-name: vmm-sys-util
  dependency-version: 0.15.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: rust-vmm
- dependency-name: virtio-vsock
  dependency-version: 0.11.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: rust-vmm
- dependency-name: vhost
  dependency-version: 0.15.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: rust-vmm
- dependency-name: vhost-user-backend
  dependency-version: 0.21.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: rust-vmm
- dependency-name: virtio-queue
  dependency-version: 0.17.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: rust-vmm
- dependency-name: vm-memory
  dependency-version: 0.17.1
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: rust-vmm
- dependency-name: vmm-sys-util
  dependency-version: 0.15.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: rust-vmm
- dependency-name: vhost
  dependency-version: 0.15.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: rust-vmm
- dependency-name: vhost-user-backend
  dependency-version: 0.21.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: rust-vmm
- dependency-name: virtio-queue
  dependency-version: 0.17.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: rust-vmm
- dependency-name: vm-memory
  dependency-version: 0.17.1
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: rust-vmm
- dependency-name: vmm-sys-util
  dependency-version: 0.15.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: rust-vmm
- dependency-name: vhost
  dependency-version: 0.15.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: rust-vmm
- dependency-name: vhost-user-backend
  dependency-version: 0.21.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: rust-vmm
- dependency-name: virtio-queue
  dependency-version: 0.17.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: rust-vmm
- dependency-name: vm-memory
  dependency-version: 0.17.1
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: rust-vmm
- dependency-name: vmm-sys-util
  dependency-version: 0.15.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: rust-vmm
...

Signed-off-by: dependabot[bot] <support@github.com>
SG: adapted code to the new changes in vhost-user-backend and vm-memory:
  - used EventConsumer & EventNotifier instead of EventFd for exit_event
  - removed vm_memory::Error::InvalidGuestRegion
  - included vm_memory::Bytes needed for read_volatile_from
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
2025-11-19 11:28:08 +02:00
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
Dorinda Bassey
caaac9a6fd 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 <dbassey@redhat.com>
2025-09-18 09:18:57 +02:00
Alex Bennée
e6caab8bb0 vhost-device-gpu: gate env::set_var test usage
Only used with gfxstream tests.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
2025-09-12 14:22:27 +03: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
Alex Bennée
9dcb98387a vhost-device-gpu: clean-up includes for gfxstream
Keep the compiler output clean for a --no-default-features build.

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
Dorinda Bassey
066c4f7651 vhost-device-gpu: support VHOST_USER_GPU_DMABUF_SCANOUT
Refactored the set_scanout implementation to send
VHOST_USER_GPU_DMABUF_SCANOUT or DMABUF_SCANOUT2 messages when
using the VirglRenderer backend. This enables proper support
for exporting resources via DMABUF and passing the relevant
metadata (width, height, stride, format, modifier) to the
frontend.

Updated VirtioGpuResource to store optional handle and 3D info
required for DMABUF scanout, and added validation for these
fields.

Extended test coverage to include validation for invalid scanout
IDs, missing resources, and backend-specific behavior for both
VirglRenderer and Gfxstream.

Signed-off-by: Dorinda Bassey <dbassey@redhat.com>
2025-09-02 12:09:54 +02:00
Dorinda Bassey
8e3e8a918c virtio_gpu.rs: expose component_type for specific backend
- Added `component_type` field to `RutabagaVirtioGpu` to retain the
  selected backend type (e.g., VirglRenderer, Gfxstream).
- Refactored `configure_rutabaga_builder` to return both the builder
  and the selected component type.
- Updated `new_gpu` test helper to accept a `RutabagaComponentType`
  argument, allowing tests to be parameterized by GPU backend.

This prepares the codebase for backend-specific logic, such as
validating behavior based on the component used.

Signed-off-by: Dorinda Bassey <dbassey@redhat.com>
2025-09-02 12:09:54 +02:00
Dorinda Bassey
852751b76a virtio_gpu.rs: Allow mutation in AssociatedScanouts methods
Corrected the AssociatedScanouts methods to remove the
const keyword and allow them to be mutable functions

Signed-off-by: Dorinda Bassey <dbassey@redhat.com>
2025-09-02 12:09:54 +02:00
Dorinda Bassey
1a1d1e2685 vhost-device-gpu: update rutabaga_gfx, CI and README
- Updated rutabaga_gfx to 0.1.62, which now requires env vars to
use system-provided virglrenderer and minigbm libraries for both
gfxstream and virglrenderer GPU backends.

- Updated README with new build instructions using
  CROSVM_USE_SYSTEM_* env vars.
- Update transfer_read to use the latest rutabaga_gfx changes

- The GNU CI builds and tests for vhost-device-gpu currently fail
because they try to build against the vendored virglrenderer tree.
Locally we already build with CROSVM_USE_SYSTEM_* env vars, so
mirror that setup in CI as well.

Signed-off-by: Dorinda Bassey <dbassey@redhat.com>
2025-09-02 12:09:54 +02:00
Manos Pitsidianakis
8077199d82 Fix more clippy lints
Signed-off-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
2025-07-18 13:02:46 +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
Wenyu Huang
91a625603f chore: bump virtio-queue and some related dependencies
virtio-queue v0.15 introduces a new Descriptor API supporting both
split and packed virtqueue.
Update our dependencies and code to work with the new version
of the crate, including updating vhost-user-backend and virtio-vsock.

Updates `vhost-user-backend` from 0.18.0 to 0.19.0
- [Release notes](https://github.com/rust-vmm/vhost/releases)
- [Commits](rust-vmm/vhost@vhost-user-backend-v0.18.0...vhost-user-backend-v0.19.0)

Updates `virtio-queue` from 0.14.0 to 0.15.0
- [Release notes](https://github.com/rust-vmm/vm-virtio/releases)
- [Commits](rust-vmm/vm-virtio@virtio-queue-v0.14.0...virtio-queue-v0.15.0)

Updates `virtio-vsock` from 0.8.0 to 0.9.0
- [Release notes](https://github.com/rust-vmm/vm-virtio/releases)
- [Commits](rust-vmm/vm-virtio@virtio-vsock-v0.8.0...virtio-vsock-v0.9.0)

Signed-off-by: Wenyu Huang <huangwenyuu@outlook.com>
2025-06-23 21:36:11 +02:00
Ruoqing He
d43fd79bb7 clippy: Fix clippy::precedence
Fix `clippy::precedence` warnings reported by clippy 0.1.85 (4d91de4e48
2025-02-17).

```console
error: operator precedence can trip the unwary
   --> vhost-device-template/src/vhu_foo.rs:152:9
    |
152 | /         1 << VIRTIO_F_VERSION_1
153 | |             | 1 << VIRTIO_F_NOTIFY_ON_EMPTY
154 | |             | 1 << VIRTIO_RING_F_INDIRECT_DESC
155 | |             | 1 << VIRTIO_RING_F_EVENT_IDX
    | |__________________________________________^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#precedence
    = note: `-D clippy::precedence` implied by `-D warnings`
    = help: to override `-D warnings` add `#[allow(clippy::precedence)]`
help: consider parenthesizing your expression
    |
152 ~         1 << VIRTIO_F_VERSION_1
153 +             | 1 << VIRTIO_F_NOTIFY_ON_EMPTY
154 +             | 1 << VIRTIO_RING_F_INDIRECT_DESC | (1 << VIRTIO_RING_F_EVENT_IDX)
    |
```

Signed-off-by: Ruoqing He <heruoqing@iscas.ac.cn>
2025-03-31 13:45:27 +02: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