Skip to content

Commit

Permalink
vhost-device-gpu: Add Initial Implementation
Browse files Browse the repository at this point in the history
This program is a vhost-user backend daemon that provides
VIRTIO GPU device emulation as specified in the VIRTIO Spec v.1.2
https://docs.oasis-open.org/virtio/virtio/v1.2/csd01/virtio-v1.2-csd01.html
This crate utilizes the rutabaga crate from crosvm with some
minor modification to rutabaga crate to fix compilation.
This crate depends on this PR[rust-vmm/vhost#239]
that implements support for QEMU's vhost-user-gpu protocol.

This device uses the rutabaga_gfx crate to offer two rendering backends:
1. Virglrenderer:
   - Rutabaga translates OpenGL API and Vulkan calls to an intermediate
     representation and allows for OpenGL acceleration on the host.
2. Gfxstream:
   - GLES and Vulkan calls are forwarded to the host.

These backends can be used by simply changing the `--gpu-mode` command
line option.
This crate also includes some modifications from libkrun virtio-gpu device
https://github.com/containers/libkrun/tree/main/src/devices/src/virtio/gpu

Fixes: #598

Co-authored-by: Dorinda Bassey <dbassey@redhat.com>
Co-authored-by: Matej Hrica <mhrica@redhat.com>

Signed-off-by: Dorinda Bassey <dbassey@redhat.com>
Signed-off-by: Matej Hrica <mhrica@redhat.com>
  • Loading branch information
Dorinda Bassey committed Nov 20, 2024
1 parent b7321b7 commit e8856d7
Show file tree
Hide file tree
Showing 14 changed files with 4,652 additions and 2 deletions.
190 changes: 189 additions & 1 deletion staging/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions staging/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[workspace]
resolver = "2"
members = [
"vhost-device-gpu",
"vhost-device-video",
]
2 changes: 1 addition & 1 deletion staging/coverage_config_x86_64.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"coverage_score": 74.82,
"coverage_score": 79.80,
"exclude_path": "",
"crate_features": ""
}
10 changes: 10 additions & 0 deletions staging/vhost-device-gpu/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Changelog
## Unreleased

### Added

### Changed

### Fixed

### Deprecated
39 changes: 39 additions & 0 deletions staging/vhost-device-gpu/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
[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"
publish = false

[features]
xen = ["vm-memory/xen", "vhost/xen", "vhost-user-backend/xen"]

[dependencies]
clap = { version = "4.4", features = ["derive"] }
env_logger = "0.11.5"
libc = "0.2"
log = "0.4"

[target.'cfg(not(target_env = "musl"))'.dependencies]
rutabaga_gfx = { version = "0.1.4", features = ["gfxstream", "virgl_renderer"] }
thiserror = "2.0.3"
vhost = { version = "0.13.0", features = ["vhost-user-backend"] }
vhost-user-backend = "0.17"
virtio-bindings = "0.2.2"
virtio-queue = "0.14.0"
vm-memory = "0.16.1"
vmm-sys-util = "0.12.1"

[dev-dependencies]
assert_matches = "1.5"
tempfile = "3.13"
virtio-queue = { version = "0.14", features = ["test-utils"] }
vm-memory = { version = "0.16.1", features = ["backend-mmap", "backend-atomic"] }
mockall = "0.13.0"
rusty-fork = "0.3.0"
1 change: 1 addition & 0 deletions staging/vhost-device-gpu/LICENSE-APACHE
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
../../LICENSE-APACHE
1 change: 1 addition & 0 deletions staging/vhost-device-gpu/LICENSE-BSD-3-Clause
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
../../LICENSE-BSD-3-Clause
Loading

0 comments on commit e8856d7

Please sign in to comment.