Remove gpu-socket feature

Remove conditional compilation because when multiple crates
that are in thesame workspace set different features,
cargo feature unification already defeats the purpose of
the `gpu-socket` feature flag since cargo merges all the
feature flags specified by dependent crates into a single
set when compiling shared dependencies. for reference see:
[feature-unification](https://doc.rust-lang.org/cargo/reference/features.html#feature-unification)

Fixes: #265

Signed-off-by: Dorinda Bassey <dbassey@redhat.com>
This commit is contained in:
Dorinda Bassey 2024-10-18 17:15:38 +02:00 committed by Stefano Garzarella
parent 071216060f
commit 64cc75a8ab
9 changed files with 8 additions and 31 deletions

View file

@ -22,7 +22,7 @@
},
{
"test_name": "unittests-gnu-all-with-xen",
"command": "cargo test --workspace --no-default-features --features test-utils,vhost-vsock,vhost-kern,vhost-vdpa,vhost-net,vhost-user,vhost-user-frontend,gpu-socket,vhost-user-backend,xen",
"command": "cargo test --workspace --no-default-features --features test-utils,vhost-vsock,vhost-kern,vhost-vdpa,vhost-net,vhost-user,vhost-user-frontend,vhost-user-backend,xen",
"platform": [
"x86_64",
"aarch64"
@ -30,7 +30,7 @@
},
{
"test_name": "unittests-gnu-all-without-xen",
"command": "cargo test --workspace --no-default-features --features test-utils,vhost-vsock,vhost-kern,vhost-vdpa,vhost-net,vhost-user,vhost-user-frontend,gpu-socket,vhost-user-backend,postcopy",
"command": "cargo test --workspace --no-default-features --features test-utils,vhost-vsock,vhost-kern,vhost-vdpa,vhost-net,vhost-user,vhost-user-frontend,vhost-user-backend,postcopy",
"platform": [
"x86_64",
"aarch64"
@ -38,7 +38,7 @@
},
{
"test_name": "unittests-musl-all-with-xen",
"command": "cargo test --workspace --target {target_platform}-unknown-linux-musl --no-default-features --features test-utils,vhost-vsock,vhost-kern,vhost-vdpa,vhost-net,vhost-user,vhost-user-frontend,gpu-socket,vhost-user-backend,xen",
"command": "cargo test --workspace --target {target_platform}-unknown-linux-musl --no-default-features --features test-utils,vhost-vsock,vhost-kern,vhost-vdpa,vhost-net,vhost-user,vhost-user-frontend,vhost-user-backend,xen",
"platform": [
"x86_64",
"aarch64"
@ -46,7 +46,7 @@
},
{
"test_name": "unittests-musl-all-without-xen",
"command": "cargo test --workspace --target {target_platform}-unknown-linux-musl --no-default-features --features test-utils,vhost-vsock,vhost-kern,vhost-vdpa,vhost-net,vhost-user,vhost-user-frontend,gpu-socket,vhost-user-backend,postcopy",
"command": "cargo test --workspace --target {target_platform}-unknown-linux-musl --no-default-features --features test-utils,vhost-vsock,vhost-kern,vhost-vdpa,vhost-net,vhost-user,vhost-user-frontend,vhost-user-backend,postcopy",
"platform": [
"x86_64",
"aarch64"
@ -54,7 +54,7 @@
},
{
"test_name": "clippy-all-with-xen",
"command": "cargo clippy --workspace --bins --examples --benches --all-targets --no-default-features --features test-utils,vhost-vsock,vhost-kern,vhost-vdpa,vhost-net,vhost-user,vhost-user-frontend,gpu-socket,vhost-user-backend,xen -- -D warnings -D clippy::undocumented_unsafe_blocks",
"command": "cargo clippy --workspace --bins --examples --benches --all-targets --no-default-features --features test-utils,vhost-vsock,vhost-kern,vhost-vdpa,vhost-net,vhost-user,vhost-user-frontend,vhost-user-backend,xen -- -D warnings -D clippy::undocumented_unsafe_blocks",
"platform": [
"x86_64",
"aarch64"
@ -62,7 +62,7 @@
},
{
"test_name": "clippy-all-without-xen",
"command": "cargo clippy --workspace --bins --examples --benches --all-targets --no-default-features --features test-utils,vhost-vsock,vhost-kern,vhost-vdpa,vhost-net,vhost-user,vhost-user-frontend,gpu-socket,vhost-user-backend,postcopy -- -D warnings -D clippy::undocumented_unsafe_blocks",
"command": "cargo clippy --workspace --bins --examples --benches --all-targets --no-default-features --features test-utils,vhost-vsock,vhost-kern,vhost-vdpa,vhost-net,vhost-user,vhost-user-frontend,vhost-user-backend,postcopy -- -D warnings -D clippy::undocumented_unsafe_blocks",
"platform": [
"x86_64",
"aarch64"
@ -70,7 +70,7 @@
},
{
"test_name": "check-warnings-all-with-xen",
"command": "RUSTFLAGS=\"-D warnings\" cargo check --all-targets --workspace --no-default-features --features test-utils,vhost-vsock,vhost-kern,vhost-vdpa,vhost-net,vhost-user,vhost-user-frontend,gpu-socket,vhost-user-backend,xen",
"command": "RUSTFLAGS=\"-D warnings\" cargo check --all-targets --workspace --no-default-features --features test-utils,vhost-vsock,vhost-kern,vhost-vdpa,vhost-net,vhost-user,vhost-user-frontend,vhost-user-backend,xen",
"platform": [
"x86_64",
"aarch64"
@ -78,7 +78,7 @@
},
{
"test_name": "check-warnings-all-without-xen",
"command": "RUSTFLAGS=\"-D warnings\" cargo check --all-targets --workspace --no-default-features --features test-utils,vhost-vsock,vhost-kern,vhost-vdpa,vhost-net,vhost-user,vhost-user-frontend,gpu-socket,vhost-user-backend,postcopy",
"command": "RUSTFLAGS=\"-D warnings\" cargo check --all-targets --workspace --no-default-features --features test-utils,vhost-vsock,vhost-kern,vhost-vdpa,vhost-net,vhost-user,vhost-user-frontend,vhost-user-backend,postcopy",
"platform": [
"x86_64",
"aarch64"

View file

@ -11,7 +11,6 @@ license = "Apache-2.0"
[features]
xen = ["vm-memory/xen", "vhost/xen"]
postcopy = ["vhost/postcopy", "userfaultfd"]
gpu-socket = ["vhost/gpu-socket"]
[dependencies]
libc = "0.2.39"

View file

@ -31,7 +31,6 @@ use vm_memory::bitmap::Bitmap;
use vmm_sys_util::epoll::EventSet;
use vmm_sys_util::eventfd::EventFd;
#[cfg(feature = "gpu-socket")]
use vhost::vhost_user::GpuBackend;
use super::vring::VringT;
@ -87,7 +86,6 @@ pub trait VhostUserBackend: Send + Sync {
/// function.
fn set_backend_req_fd(&self, _backend: Backend) {}
#[cfg(feature = "gpu-socket")]
/// Set handler for communicating with the frontend by the gpu specific backend communication
/// channel.
///
@ -205,7 +203,6 @@ pub trait VhostUserBackendMut: Send + Sync {
/// function.
fn set_backend_req_fd(&mut self, _backend: Backend) {}
#[cfg(feature = "gpu-socket")]
/// Set handler for communicating with the frontend by the gpu specific backend communication
/// channel.
///
@ -318,7 +315,6 @@ impl<T: VhostUserBackend> VhostUserBackend for Arc<T> {
self.deref().set_backend_req_fd(backend)
}
#[cfg(feature = "gpu-socket")]
fn set_gpu_socket(&self, gpu_backend: GpuBackend) {
self.deref().set_gpu_socket(gpu_backend)
}
@ -400,7 +396,6 @@ impl<T: VhostUserBackendMut> VhostUserBackend for Mutex<T> {
self.lock().unwrap().set_backend_req_fd(backend)
}
#[cfg(feature = "gpu-socket")]
fn set_gpu_socket(&self, gpu_backend: GpuBackend) {
self.lock().unwrap().set_gpu_socket(gpu_backend)
}
@ -485,7 +480,6 @@ impl<T: VhostUserBackendMut> VhostUserBackend for RwLock<T> {
self.write().unwrap().set_backend_req_fd(backend)
}
#[cfg(feature = "gpu-socket")]
fn set_gpu_socket(&self, gpu_backend: GpuBackend) {
self.write().unwrap().set_gpu_socket(gpu_backend)
}
@ -610,7 +604,6 @@ pub mod tests {
fn set_backend_req_fd(&mut self, _backend: Backend) {}
#[cfg(feature = "gpu-socket")]
fn set_gpu_socket(&mut self, _gpu_backend: GpuBackend) {}
fn queues_per_thread(&self) -> Vec<u64> {

View file

@ -21,7 +21,6 @@ use vhost::vhost_user::message::{
VhostUserMemoryRegion, VhostUserProtocolFeatures, VhostUserSingleMemoryRegion,
VhostUserVirtioFeatures, VhostUserVringAddrFlags, VhostUserVringState,
};
#[cfg(feature = "gpu-socket")]
use vhost::vhost_user::GpuBackend;
use vhost::vhost_user::{
Backend, Error as VhostUserError, Result as VhostUserResult, VhostUserBackendReqHandlerMut,
@ -556,7 +555,6 @@ where
self.backend.set_backend_req_fd(backend);
}
#[cfg(feature = "gpu-socket")]
fn set_gpu_socket(&mut self, gpu_backend: GpuBackend) {
self.backend.set_gpu_socket(gpu_backend);
}

View file

@ -10,7 +10,6 @@ use std::thread;
use vhost::vhost_user::message::{
VhostUserConfigFlags, VhostUserHeaderFlag, VhostUserInflight, VhostUserProtocolFeatures,
};
#[cfg(feature = "gpu-socket")]
use vhost::vhost_user::GpuBackend;
use vhost::vhost_user::{Backend, Frontend, Listener, VhostUserFrontend};
use vhost::{VhostBackend, VhostUserMemoryRegionInfo, VringConfigData};
@ -79,7 +78,6 @@ impl VhostUserBackendMut for MockVhostBackend {
Ok(())
}
#[cfg(feature = "gpu-socket")]
fn set_gpu_socket(&mut self, _gpu_backend: GpuBackend) {}
fn update_memory(&mut self, atomic_mem: GuestMemoryAtomic<GuestMemoryMmap>) -> Result<()> {

View file

@ -23,7 +23,6 @@ vhost-net = ["vhost-kern"]
vhost-user = []
vhost-user-frontend = ["vhost-user"]
vhost-user-backend = ["vhost-user"]
gpu-socket = ["vhost-user"]
xen = ["vm-memory/xen"]
postcopy = []

View file

@ -12,7 +12,6 @@ use vm_memory::ByteValued;
use super::backend_req::Backend;
use super::connection::Endpoint;
#[cfg(feature = "gpu-socket")]
use super::gpu_backend_req::GpuBackend;
use super::message::*;
use super::{take_single_file, Error, Result};
@ -67,7 +66,6 @@ pub trait VhostUserBackendReqHandler {
fn get_config(&self, offset: u32, size: u32, flags: VhostUserConfigFlags) -> Result<Vec<u8>>;
fn set_config(&self, offset: u32, buf: &[u8], flags: VhostUserConfigFlags) -> Result<()>;
fn set_backend_req_fd(&self, _backend: Backend) {}
#[cfg(feature = "gpu-socket")]
fn set_gpu_socket(&self, gpu_backend: GpuBackend);
fn get_inflight_fd(&self, inflight: &VhostUserInflight) -> Result<(VhostUserInflight, File)>;
fn set_inflight_fd(&self, inflight: &VhostUserInflight, file: File) -> Result<()>;
@ -128,7 +126,6 @@ pub trait VhostUserBackendReqHandlerMut {
) -> Result<Vec<u8>>;
fn set_config(&mut self, offset: u32, buf: &[u8], flags: VhostUserConfigFlags) -> Result<()>;
fn set_backend_req_fd(&mut self, _backend: Backend) {}
#[cfg(feature = "gpu-socket")]
fn set_gpu_socket(&mut self, _gpu_backend: GpuBackend);
fn get_inflight_fd(
&mut self,
@ -241,7 +238,6 @@ impl<T: VhostUserBackendReqHandlerMut> VhostUserBackendReqHandler for Mutex<T> {
self.lock().unwrap().set_backend_req_fd(backend)
}
#[cfg(feature = "gpu-socket")]
fn set_gpu_socket(&self, gpu_backend: GpuBackend) {
self.lock().unwrap().set_gpu_socket(gpu_backend);
}
@ -571,7 +567,6 @@ impl<S: VhostUserBackendReqHandler> BackendReqHandler<S> {
let res = self.backend.set_inflight_fd(&msg, file);
self.send_ack_message(&hdr, res)?;
}
#[cfg(feature = "gpu-socket")]
Ok(FrontendReq::GPU_SET_SOCKET) => {
let res = self.set_gpu_socket(files);
self.send_ack_message(&hdr, res)?;
@ -812,7 +807,6 @@ impl<S: VhostUserBackendReqHandler> BackendReqHandler<S> {
Ok(())
}
#[cfg(feature = "gpu-socket")]
fn set_gpu_socket(&mut self, files: Option<Vec<File>>) -> Result<()> {
let file = take_single_file(files).ok_or(Error::InvalidMessage)?;
// SAFETY: Safe because we have ownership of the files that were

View file

@ -259,7 +259,6 @@ impl VhostUserBackendReqHandlerMut for DummyBackendReqHandler {
Ok(())
}
#[cfg(feature = "gpu-socket")]
fn set_gpu_socket(&mut self, _gpu_backend: GpuBackend) {}
fn get_inflight_fd(

View file

@ -52,11 +52,8 @@ pub use self::backend_req_handler::{
mod backend_req;
#[cfg(feature = "vhost-user-backend")]
pub use self::backend_req::Backend;
#[cfg(feature = "gpu-socket")]
mod gpu_backend_req;
#[cfg(feature = "gpu-socket")]
pub mod gpu_message;
#[cfg(feature = "gpu-socket")]
pub use self::gpu_backend_req::GpuBackend;
/// Errors for vhost-user operations