Based on cloud-hypervisor/vhost c3a835b55dc56aa0de04a9c0695368a6403e8e93.
vhost_user: Add missing protocol features
The spec recently introduced some new protocol features, which we need to be listed if we don't want to run into any issue when getting the list of supported features from the backend.
devices/src/virtio/vhost_user/net.rs | 10 +++++++--- vhost_rs/src/vhost_user/message.rs | 11 +++++++++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/devices/src/virtio/vhost_user/net.rs b/devices/src/virtio/vhost_user/net.rs index 4d222d22..f2a3d79c 100644 --- a/devices/src/virtio/vhost_user/net.rs +++ b/devices/src/virtio/vhost_user/net.rs @@ -20,8 +20,8 @@ use super::handler::*; use super::vu_common_ctrl::*; use super::{Error, Result}; use crate::{pci::MsixConfig, virtio::Interrupt}; -use vhost_rs::vhost_user::message::VhostUserVirtioFeatures; -use vhost_rs::vhost_user::{Master, VhostUserMaster}; +use vhost_rs::vhost_user::message::{VhostUserProtocolFeatures, VhostUserVirtioFeatures}; +use vhost_rs::vhost_user::{Master, VhostUserMaster, VhostUserMasterReqHandler}; use vhost_rs::VhostBackend; use virtio_bindings::virtio_net; use virtio_bindings::virtio_ring; @@ -78,9 +78,13 @@ impl<'a> Net { let mut acked_features = 0; if backend_features & VhostUserVirtioFeatures::PROTOCOL_FEATURES.bits() != 0 { acked_features |= VhostUserVirtioFeatures::PROTOCOL_FEATURES.bits(); - vhost_user_net + let mut protocol_features = vhost_user_net .get_protocol_features() .map_err(Error::VhostUserGetProtocolFeatures)?; + protocol_features &= VhostUserProtocolFeatures::MQ; + vhost_user_net + .set_protocol_features(protocol_features) + .map_err(Error::VhostUserSetProtocolFeatures); } else { return Err(Error::VhostUserProtocolNotSupport); } diff --git a/vhost_rs/src/vhost_user/message.rs b/vhost_rs/src/vhost_user/message.rs index 834397f4..b3ed27a5 100644 --- a/vhost_rs/src/vhost_user/message.rs +++ b/vhost_rs/src/vhost_user/message.rs @@ -346,6 +346,17 @@ bitflags! { const SLAVE_SEND_FD = 0x0000_0400; /// Allow the slave to register a host notifier. const HOST_NOTIFIER = 0x0000_0800; + /// Support inflight shmfd. + const INFLIGHT_SHMFD = 0x0000_1000; + /// Support resetting the device. + const RESET_DEVICE = 0x0000_2000; + /// Support inband notifications. + const INBAND_NOTIFICATIONS = 0x0000_4000; + /// Support configuring memory slots. + const CONFIGURE_MEM_SLOTS = 0x0000_8000; + /// Support reporting status. + const STATUS = 0x0001_0000; + } } -- 2.31.0