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 <cathy.zhang@intel.com>
This commit is contained in:
Cathy Zhang 2019-09-03 16:26:01 +08:00 committed by Sebastien Boeuf
parent b8622b5c69
commit 8c2a9a75ec

View File

@ -33,6 +33,7 @@ pub struct Net {
kill_evt: EventFd,
avail_features: u64,
acked_features: u64,
backend_features: u64,
config_space: Vec<u8>,
queue_sizes: Vec<u16>,
}
@ -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)?;