From e22f9262ff105241dd64ca65da29cccdf05e89d2 Mon Sep 17 00:00:00 2001 From: Sergio Lopez Date: Wed, 23 Oct 2019 16:24:07 +0200 Subject: [PATCH] Move protocol_features to the backend Extend VhostUserBackend trait with protocol_features(), so device backend implementations can freely define which protocol features they want to support. Signed-off-by: Sergio Lopez --- src/lib.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index fd78671..c74d4c8 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -62,6 +62,9 @@ pub trait VhostUserBackend: Send + Sync + 'static { /// Virtio features. fn features(&self) -> u64; + /// Virtio protocol features. + fn protocol_features(&self) -> VhostUserProtocolFeatures; + /// Update guest memory regions. fn update_memory(&mut self, mem: GuestMemoryMmap) -> result::Result<(), io::Error>; @@ -501,7 +504,7 @@ impl VhostUserSlaveReqHandler for VhostUserHandler { } fn get_protocol_features(&mut self) -> VhostUserResult { - Ok(VhostUserProtocolFeatures::all()) + Ok(self.backend.read().unwrap().protocol_features()) } fn set_protocol_features(&mut self, features: u64) -> VhostUserResult<()> {