From b94d9a30d3597355b5a63209b355a52b003a5b21 Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Wed, 20 May 2020 15:59:08 +0100 Subject: [PATCH] vhost_user_backend: Allow backends to know features that can be used Previous to adding a a trait method to inform the backends of the acked features backends can use features than the guest has not enabled which could lead to unpredictable results. Signed-off-by: Rob Bradford --- vhost_user_backend/src/lib.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/vhost_user_backend/src/lib.rs b/vhost_user_backend/src/lib.rs index fb2d6fcc5..6de50798d 100644 --- a/vhost_user_backend/src/lib.rs +++ b/vhost_user_backend/src/lib.rs @@ -64,9 +64,12 @@ pub trait VhostUserBackend: Send + Sync + 'static { /// Depth of each queue. fn max_queue_size(&self) -> usize; - /// Virtio features. + /// Available virtio features. fn features(&self) -> u64; + /// Acked virtio features. + fn acked_features(&mut self, _features: u64) {} + /// Virtio protocol features. fn protocol_features(&self) -> VhostUserProtocolFeatures; @@ -577,6 +580,11 @@ impl VhostUserSlaveReqHandler for VhostUserHandler { vring.write().unwrap().enabled = vring_enabled; } + self.backend + .write() + .unwrap() + .acked_features(self.acked_features); + Ok(()) }