diff --git a/vhost-user-backend/tests/vhost-user-server.rs b/vhost-user-backend/tests/vhost-user-server.rs index 70b3cc5..e371299 100644 --- a/vhost-user-backend/tests/vhost-user-server.rs +++ b/vhost-user-backend/tests/vhost-user-server.rs @@ -59,7 +59,8 @@ impl VhostUserBackendMut for MockVhostBackend { } fn protocol_features(&self) -> VhostUserProtocolFeatures { - VhostUserProtocolFeatures::all() + // Exclude REPLY_ACK to test that it is automatically added. + VhostUserProtocolFeatures::all() - VhostUserProtocolFeatures::REPLY_ACK } fn reset_device(&mut self) { diff --git a/vhost/CHANGELOG.md b/vhost/CHANGELOG.md index dbbb0c1..ead2f47 100644 --- a/vhost/CHANGELOG.md +++ b/vhost/CHANGELOG.md @@ -5,6 +5,10 @@ - [[#268]](https://github.com/rust-vmm/vhost/pull/268) Add support for `VHOST_USER_GET_SHARED_OBJECT` ### Changed +- [[#290]](https://github.com/rust-vmm/vhost/pull/290) Backends now + always support `VHOST_USER_PROTOCOL_F_REPLY_ACK`, without the + `VhostUserBackendReqHandler` implementation having to include it in + the features returned from `get_protocol_features`. ### Deprecated diff --git a/vhost/src/vhost_user/backend_req_handler.rs b/vhost/src/vhost_user/backend_req_handler.rs index 409073c..d74b045 100644 --- a/vhost/src/vhost_user/backend_req_handler.rs +++ b/vhost/src/vhost_user/backend_req_handler.rs @@ -327,7 +327,6 @@ pub struct BackendReqHandler { virtio_features: u64, acked_virtio_features: u64, - protocol_features: VhostUserProtocolFeatures, acked_protocol_features: u64, // sending ack for messages without payload @@ -347,7 +346,6 @@ impl BackendReqHandler { backend, virtio_features: 0, acked_virtio_features: 0, - protocol_features: VhostUserProtocolFeatures::empty(), acked_protocol_features: 0, reply_ack_enabled: false, error: None, @@ -512,7 +510,9 @@ impl BackendReqHandler { } Ok(FrontendReq::GET_PROTOCOL_FEATURES) => { self.check_request_size(&hdr, size, 0)?; - let features = self.backend.get_protocol_features()?; + // REPLY_ACK is implemented entirely by this library, so it's always supported. + let features = + self.backend.get_protocol_features()? | VhostUserProtocolFeatures::REPLY_ACK; // Enable the `XEN_MMAP` protocol feature for backends if xen feature is enabled. #[cfg(feature = "xen")] @@ -520,7 +520,6 @@ impl BackendReqHandler { let msg = VhostUserU64::new(features.bits()); self.send_reply_message(&hdr, &msg)?; - self.protocol_features = features; self.update_reply_ack_flag(); } Ok(FrontendReq::SET_PROTOCOL_FEATURES) => { @@ -952,7 +951,6 @@ impl BackendReqHandler { let pflag = VhostUserProtocolFeatures::REPLY_ACK; self.reply_ack_enabled = (self.virtio_features & vflag) != 0 - && self.protocol_features.contains(pflag) && (self.acked_protocol_features & pflag.bits()) != 0; }