From 8c2a9a75eca9cf89a085674180cf2b18e8eeba7b Mon Sep 17 00:00:00 2001 From: Cathy Zhang Date: Tue, 3 Sep 2019 16:26:01 +0800 Subject: [PATCH] vm-virtio: Update backend feature set for vhost-user-net Regarding vhost-user-net, there are features in avail_features and acked_features, like VIRTIO_NET_F_MAC which is required by driver and device to transfer mac address through config space, but not needed by backend, like ovs+dpdk, so it's necessary to adjust backend_features based on acked_features before calling set_features() API. This fix is to record backend_features in vhost-user-net to avoid requesting it twice. Signed-off-by: Cathy Zhang --- vm-virtio/src/vhost_user/net.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/vm-virtio/src/vhost_user/net.rs b/vm-virtio/src/vhost_user/net.rs index 014006620..21823349e 100644 --- a/vm-virtio/src/vhost_user/net.rs +++ b/vm-virtio/src/vhost_user/net.rs @@ -33,6 +33,7 @@ pub struct Net { kill_evt: EventFd, avail_features: u64, acked_features: u64, + backend_features: u64, config_space: Vec, queue_sizes: Vec, } @@ -79,7 +80,7 @@ impl<'a> Net { .map_err(Error::VhostUserSetFeatures)?; let mut acked_features = 0; - if backend_features & VhostUserVirtioFeatures::PROTOCOL_FEATURES.bits() != 0 { + if avail_features & VhostUserVirtioFeatures::PROTOCOL_FEATURES.bits() != 0 { acked_features |= VhostUserVirtioFeatures::PROTOCOL_FEATURES.bits(); vhost_user_net .get_protocol_features() @@ -106,6 +107,7 @@ impl<'a> Net { kill_evt, avail_features, acked_features, + backend_features, config_space, queue_sizes: vec![vu_cfg.queue_size; vu_cfg.num_queues], }) @@ -201,7 +203,7 @@ impl VirtioDevice for Net { &mem.read().unwrap(), queues, queue_evts, - self.acked_features, + self.acked_features & self.backend_features, ) .map_err(ActivateError::VhostUserNetSetup)?;