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 <robert.bradford@intel.com>
This commit is contained in:
Rob Bradford 2020-05-20 15:59:08 +01:00 committed by Samuel Ortiz
parent 9d88ba7afb
commit b94d9a30d3

View File

@ -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<S: VhostUserBackend> VhostUserSlaveReqHandler for VhostUserHandler<S> {
vring.write().unwrap().enabled = vring_enabled;
}
self.backend
.write()
.unwrap()
.acked_features(self.acked_features);
Ok(())
}