From 1ce528041729ee2f39f73223f037f650fc41ef05 Mon Sep 17 00:00:00 2001 From: Viresh Kumar Date: Wed, 5 Jul 2023 15:12:24 +0530 Subject: [PATCH] vhost: Use vhost_user definitions from within #[cfg] block The `vhost-user` feature isn't enabled by default and using it without protection in backend.rs makes the vhost only build fails. Fix it by protecting it with the `#[cfg]` block. Signed-off-by: Viresh Kumar --- crates/vhost/src/backend.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/crates/vhost/src/backend.rs b/crates/vhost/src/backend.rs index 744f821..bd4a83b 100644 --- a/crates/vhost/src/backend.rs +++ b/crates/vhost/src/backend.rs @@ -17,6 +17,7 @@ use std::sync::RwLock; use vm_memory::{bitmap::Bitmap, Address, GuestMemoryRegion, GuestRegionMmap}; use vmm_sys_util::eventfd::EventFd; +#[cfg(feature = "vhost-user")] use super::vhost_user::message::{VhostUserMemoryRegion, VhostUserSingleMemoryRegion}; use super::{Error, Result}; @@ -106,6 +107,7 @@ impl VhostUserMemoryRegionInfo { } /// Creates VhostUserMemoryRegion from Self. + #[cfg(feature = "vhost-user")] pub fn to_region(&self) -> VhostUserMemoryRegion { #[cfg(not(feature = "xen"))] return VhostUserMemoryRegion::new( @@ -127,6 +129,7 @@ impl VhostUserMemoryRegionInfo { } /// Creates VhostUserSingleMemoryRegion from Self. + #[cfg(feature = "vhost-user")] pub fn to_single_region(&self) -> VhostUserSingleMemoryRegion { VhostUserSingleMemoryRegion::new( self.guest_phys_addr,