Skip to content

Commit 1ce5280

Browse files
vireshksameo
authored andcommitted
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 <[email protected]>
1 parent 8783a8d commit 1ce5280

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

crates/vhost/src/backend.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ use std::sync::RwLock;
1717
use vm_memory::{bitmap::Bitmap, Address, GuestMemoryRegion, GuestRegionMmap};
1818
use vmm_sys_util::eventfd::EventFd;
1919

20+
#[cfg(feature = "vhost-user")]
2021
use super::vhost_user::message::{VhostUserMemoryRegion, VhostUserSingleMemoryRegion};
2122
use super::{Error, Result};
2223

@@ -106,6 +107,7 @@ impl VhostUserMemoryRegionInfo {
106107
}
107108

108109
/// Creates VhostUserMemoryRegion from Self.
110+
#[cfg(feature = "vhost-user")]
109111
pub fn to_region(&self) -> VhostUserMemoryRegion {
110112
#[cfg(not(feature = "xen"))]
111113
return VhostUserMemoryRegion::new(
@@ -127,6 +129,7 @@ impl VhostUserMemoryRegionInfo {
127129
}
128130

129131
/// Creates VhostUserSingleMemoryRegion from Self.
132+
#[cfg(feature = "vhost-user")]
130133
pub fn to_single_region(&self) -> VhostUserSingleMemoryRegion {
131134
VhostUserSingleMemoryRegion::new(
132135
self.guest_phys_addr,

0 commit comments

Comments
 (0)