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>
This commit is contained in:
Dorinda Bassey 2025-11-04 13:25:52 +01:00
parent 4fd2add85c
commit ef571bb8f3
5 changed files with 31 additions and 31 deletions

View File

@ -14,9 +14,9 @@ edition = "2021"
resolver = "2"
[features]
default = ["gfxstream"]
default = ["backend-gfxstream"]
xen = ["vm-memory/xen", "vhost/xen", "vhost-user-backend/xen"]
gfxstream = ["rutabaga_gfx/gfxstream"]
backend-gfxstream = ["rutabaga_gfx/gfxstream"]
[dependencies]
clap = { version = "4.5", features = ["derive"] }

View File

@ -64,7 +64,7 @@ A virtio-gpu device using the vhost-user protocol.
```
_NOTE_: Option `-g, --gpu-mode` can only accept the `gfxstream` value if the
crate has been built with the `gfxstream` feature, which is the default.
crate has been built with the `backend-gfxstream` feature, which is the default.
## Limitations
@ -101,7 +101,7 @@ CROSVM_USE_SYSTEM_MINIGBM=1 \
cargo build
```
gfxstream support is compiled by default, it can be disabled by not building with the `gfxstream` feature flag, for example:
gfxstream support is compiled by default, it can be disabled by not building with the `backend-gfxstream` feature flag, for example:
```session
CROSVM_USE_SYSTEM_VIRGLRENDERER=1 \
@ -120,7 +120,7 @@ host with minimal modification.
First start the daemon on the host machine using either of the 2 gpu modes:
1) `virglrenderer`
2) `gfxstream` (if the crate has been compiled with the feature `gfxstream`)
2) `gfxstream` (if the crate has been compiled with the feature `backend-gfxstream`)
```shell
host# vhost-device-gpu --socket-path /tmp/gpu.socket --gpu-mode virglrenderer

View File

@ -21,7 +21,7 @@ use std::{
use bitflags::bitflags;
use clap::ValueEnum;
use log::info;
#[cfg(feature = "gfxstream")]
#[cfg(feature = "backend-gfxstream")]
use rutabaga_gfx::{RUTABAGA_CAPSET_GFXSTREAM_GLES, RUTABAGA_CAPSET_GFXSTREAM_VULKAN};
use rutabaga_gfx::{RUTABAGA_CAPSET_VIRGL, RUTABAGA_CAPSET_VIRGL2};
use thiserror::Error as ThisError;
@ -34,7 +34,7 @@ use crate::device::VhostUserGpuBackend;
pub enum GpuMode {
#[value(name = "virglrenderer", alias("virgl-renderer"))]
VirglRenderer,
#[cfg(feature = "gfxstream")]
#[cfg(feature = "backend-gfxstream")]
Gfxstream,
}
@ -42,7 +42,7 @@ impl Display for GpuMode {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
match self {
Self::VirglRenderer => write!(f, "virglrenderer"),
#[cfg(feature = "gfxstream")]
#[cfg(feature = "backend-gfxstream")]
Self::Gfxstream => write!(f, "gfxstream"),
}
}
@ -56,11 +56,11 @@ bitflags! {
const VIRGL2 = 1 << RUTABAGA_CAPSET_VIRGL2 as u64;
const ALL_VIRGLRENDERER_CAPSETS = Self::VIRGL.bits() | Self::VIRGL2.bits();
#[cfg(feature = "gfxstream")]
#[cfg(feature = "backend-gfxstream")]
const GFXSTREAM_VULKAN = 1 << RUTABAGA_CAPSET_GFXSTREAM_VULKAN as u64;
#[cfg(feature = "gfxstream")]
#[cfg(feature = "backend-gfxstream")]
const GFXSTREAM_GLES = 1 << RUTABAGA_CAPSET_GFXSTREAM_GLES as u64;
#[cfg(feature = "gfxstream")]
#[cfg(feature = "backend-gfxstream")]
const ALL_GFXSTREAM_CAPSETS = Self::GFXSTREAM_VULKAN.bits() | Self::GFXSTREAM_GLES.bits();
}
}
@ -77,9 +77,9 @@ impl Display for GpuCapset {
match capset {
Self::VIRGL => write!(f, "virgl"),
Self::VIRGL2 => write!(f, "virgl2"),
#[cfg(feature = "gfxstream")]
#[cfg(feature = "backend-gfxstream")]
Self::GFXSTREAM_VULKAN => write!(f, "gfxstream-vulkan"),
#[cfg(feature = "gfxstream")]
#[cfg(feature = "backend-gfxstream")]
Self::GFXSTREAM_GLES => write!(f, "gfxstream-gles"),
_ => panic!("Unknown capset {:#x}", self.bits()),
}?;
@ -141,13 +141,13 @@ pub enum GpuConfigError {
impl GpuConfig {
pub const DEFAULT_VIRGLRENDER_CAPSET_MASK: GpuCapset = GpuCapset::ALL_VIRGLRENDERER_CAPSETS;
#[cfg(feature = "gfxstream")]
#[cfg(feature = "backend-gfxstream")]
pub const DEFAULT_GFXSTREAM_CAPSET_MASK: GpuCapset = GpuCapset::ALL_GFXSTREAM_CAPSETS;
pub const fn get_default_capset_for_mode(gpu_mode: GpuMode) -> GpuCapset {
match gpu_mode {
GpuMode::VirglRenderer => Self::DEFAULT_VIRGLRENDER_CAPSET_MASK,
#[cfg(feature = "gfxstream")]
#[cfg(feature = "backend-gfxstream")]
GpuMode::Gfxstream => Self::DEFAULT_GFXSTREAM_CAPSET_MASK,
}
}
@ -155,7 +155,7 @@ impl GpuConfig {
fn validate_capset(gpu_mode: GpuMode, capset: GpuCapset) -> Result<(), GpuConfigError> {
let supported_capset_mask = match gpu_mode {
GpuMode::VirglRenderer => GpuCapset::ALL_VIRGLRENDERER_CAPSETS,
#[cfg(feature = "gfxstream")]
#[cfg(feature = "backend-gfxstream")]
GpuMode::Gfxstream => GpuCapset::ALL_GFXSTREAM_CAPSETS,
};
for capset in capset.iter() {
@ -177,7 +177,7 @@ impl GpuConfig {
let capset = capset.unwrap_or_else(|| Self::get_default_capset_for_mode(gpu_mode));
Self::validate_capset(gpu_mode, capset)?;
#[cfg(feature = "gfxstream")]
#[cfg(feature = "backend-gfxstream")]
if capset.contains(GpuCapset::GFXSTREAM_GLES) && !flags.use_gles {
return Err(GpuConfigError::GlesRequiredByGfxstream);
}
@ -244,14 +244,14 @@ mod tests {
}
#[test]
#[cfg(feature = "gfxstream")]
#[cfg(feature = "backend-gfxstream")]
fn test_gpu_config_create_default_gfxstream() {
let config = GpuConfig::new(GpuMode::Gfxstream, None, GpuFlags::default()).unwrap();
assert_eq!(config.gpu_mode(), GpuMode::Gfxstream);
assert_eq!(config.capsets(), GpuConfig::DEFAULT_GFXSTREAM_CAPSET_MASK);
}
#[cfg(feature = "gfxstream")]
#[cfg(feature = "backend-gfxstream")]
fn assert_invalid_gpu_config(mode: GpuMode, capset: GpuCapset, expected_capset: GpuCapset) {
let result = GpuConfig::new(mode, Some(capset), GpuFlags::new_default());
assert_matches!(
@ -275,7 +275,7 @@ mod tests {
}
#[test]
#[cfg(feature = "gfxstream")]
#[cfg(feature = "backend-gfxstream")]
fn test_gpu_config_invalid_combinations() {
assert_invalid_gpu_config(
GpuMode::VirglRenderer,
@ -291,7 +291,7 @@ mod tests {
}
#[test]
#[cfg(feature = "gfxstream")]
#[cfg(feature = "backend-gfxstream")]
fn test_gles_required_by_gfxstream() {
let capset = GpuCapset::GFXSTREAM_VULKAN | GpuCapset::GFXSTREAM_GLES;
let flags = GpuFlags {
@ -305,7 +305,7 @@ mod tests {
#[test]
fn test_default_num_capsets() {
assert_eq!(GpuConfig::DEFAULT_VIRGLRENDER_CAPSET_MASK.num_capsets(), 2);
#[cfg(feature = "gfxstream")]
#[cfg(feature = "backend-gfxstream")]
assert_eq!(GpuConfig::DEFAULT_GFXSTREAM_CAPSET_MASK.num_capsets(), 2);
}

View File

@ -22,13 +22,13 @@ pub enum CapsetName {
/// [gfxstream] Vulkan implementation (partial support only){n}
/// NOTE: Can only be used for 2D display output for now, there is no
/// hardware acceleration yet
#[cfg(feature = "gfxstream")]
#[cfg(feature = "backend-gfxstream")]
GfxstreamVulkan = GpuCapset::GFXSTREAM_VULKAN.bits(),
/// [gfxstream] OpenGL ES implementation (partial support only){n}
/// NOTE: Can only be used for 2D display output for now, there is no
/// hardware acceleration yet
#[cfg(feature = "gfxstream")]
#[cfg(feature = "backend-gfxstream")]
GfxstreamGles = GpuCapset::GFXSTREAM_GLES.bits(),
}

View File

@ -18,7 +18,7 @@ use rutabaga_gfx::{
RutabagaComponentType, RutabagaFence, RutabagaFenceHandler, RutabagaHandle,
RutabagaIntoRawDescriptor, RutabagaIovec, Transfer3D, RUTABAGA_HANDLE_TYPE_MEM_DMABUF,
};
#[cfg(feature = "gfxstream")]
#[cfg(feature = "backend-gfxstream")]
use vhost::vhost_user::gpu_message::VhostUserGpuScanout;
use vhost::vhost_user::{
gpu_message::{
@ -399,7 +399,7 @@ impl RutabagaVirtioGpu {
) -> (RutabagaBuilder, RutabagaComponentType) {
let component = match gpu_config.gpu_mode() {
GpuMode::VirglRenderer => RutabagaComponentType::VirglRenderer,
#[cfg(feature = "gfxstream")]
#[cfg(feature = "backend-gfxstream")]
GpuMode::Gfxstream => RutabagaComponentType::Gfxstream,
};
@ -662,7 +662,7 @@ impl VirtioGpu for RutabagaVirtioGpu {
self.scanouts[scanout_idx] = Some(VirtioGpuScanout { resource_id });
}
#[cfg(feature = "gfxstream")]
#[cfg(feature = "backend-gfxstream")]
RutabagaComponentType::Gfxstream => {
if resource_id == 0 {
self.scanouts[scanout_idx] = None;
@ -811,7 +811,7 @@ impl VirtioGpu for RutabagaVirtioGpu {
})?;
}
#[cfg(feature = "gfxstream")]
#[cfg(feature = "backend-gfxstream")]
RutabagaComponentType::Gfxstream => {
// Gfxstream expects image memory transfer (read + send)
let resource_size = resource.calculate_size().map_err(|e| {
@ -1096,7 +1096,7 @@ impl VirtioGpu for RutabagaVirtioGpu {
#[cfg(test)]
mod tests {
#[cfg(feature = "gfxstream")]
#[cfg(feature = "backend-gfxstream")]
use std::env::set_var;
use std::{
os::unix::net::UnixStream,
@ -1148,7 +1148,7 @@ mod tests {
GpuMode::VirglRenderer,
Some(GpuCapset::VIRGL | GpuCapset::VIRGL2),
),
#[cfg(feature = "gfxstream")]
#[cfg(feature = "backend-gfxstream")]
RutabagaComponentType::Gfxstream => {
(GpuMode::Gfxstream, Some(GpuCapset::GFXSTREAM_GLES))
}
@ -1349,7 +1349,7 @@ mod tests {
assert_matches!(result, Err(ErrUnspec));
}
#[cfg(feature = "gfxstream")]
#[cfg(feature = "backend-gfxstream")]
#[test]
fn test_set_scanout_with_gfxstream_backend() {
set_var("EGL_PLATFORM", "surfaceless"); // no X/Wayland/GBM needed