Skip to content

Commit 997c053

Browse files
committed
vhost-user-backend: Add vhost-user bitmap trait bounds
Any bitmap used in the vhost-user backend must implement the BitmapReplace trait, which provides the functionality to replace the internal bitmap in runtime. This internal bitmap is required because in the vm-memory crate the bitmap is expected to exist at the time of creating the memory regions, and in the case of vhost-user the bitmap is added at runtime, also it could be replaced at a later time. In addition, the vhost user protocol does not specify whether the previous bitmap is still active after replying to the VHOST_USER_SET_LOG_BASE message, so we must be sure that the in-flight requests are using the new bitmap after the message reply. Signed-off-by: German Maglione <[email protected]>
1 parent e37d9c9 commit 997c053

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

vhost-user-backend/src/handler.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ use std::os::unix::io::AsRawFd;
1212
use std::sync::Arc;
1313
use std::thread;
1414

15+
use crate::bitmap::BitmapReplace;
1516
#[cfg(feature = "postcopy")]
1617
use userfaultfd::{Uffd, UffdBuilder};
1718
use vhost::vhost_user::message::{
@@ -230,7 +231,7 @@ where
230231

231232
impl<T: VhostUserBackend> VhostUserBackendReqHandlerMut for VhostUserHandler<T>
232233
where
233-
T::Bitmap: NewBitmap + Clone,
234+
T::Bitmap: BitmapReplace + NewBitmap + Clone,
234235
{
235236
fn set_owner(&mut self) -> VhostUserResult<()> {
236237
if self.owned {

vhost-user-backend/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ mod handler;
2929
pub use self::handler::VhostUserHandlerError;
3030

3131
pub mod bitmap;
32+
use crate::bitmap::BitmapReplace;
3233

3334
mod vring;
3435
pub use self::vring::{
@@ -97,7 +98,7 @@ pub struct VhostUserDaemon<T: VhostUserBackend> {
9798
impl<T> VhostUserDaemon<T>
9899
where
99100
T: VhostUserBackend + Clone + 'static,
100-
T::Bitmap: NewBitmap + Clone + Send + Sync,
101+
T::Bitmap: BitmapReplace + NewBitmap + Clone + Send + Sync,
101102
T::Vring: Clone + Send + Sync,
102103
{
103104
/// Create the daemon instance, providing the backend implementation of `VhostUserBackend`.

0 commit comments

Comments
 (0)