vm-virtio: Add set_protocol_features in vhost-user-net

While implement vhost-user-net backend with Tap interface, it keeps
failed to enable the tx vring, since there is a checking in
slave_req_handler.rs to require acked_protocol_features to be setup
as a pre-requirement, which is filled by set_protocol_features call.
Add this call in vhost-user-net device implementation to address the issue.

Signed-off-by: Cathy Zhang <cathy.zhang@intel.com>
This commit is contained in:
Cathy Zhang 2019-09-24 07:39:41 +08:00 committed by Sebastien Boeuf
parent 9ff42060e0
commit d724511a91

View File

@ -19,7 +19,7 @@ use super::super::{ActivateError, ActivateResult, Queue, VirtioDevice, VirtioDev
use super::handler::*;
use super::vu_common_ctrl::*;
use super::{Error, Result};
use vhost_rs::vhost_user::message::VhostUserVirtioFeatures;
use vhost_rs::vhost_user::message::{VhostUserProtocolFeatures, VhostUserVirtioFeatures};
use vhost_rs::vhost_user::{Master, VhostUserMaster, VhostUserMasterReqHandler};
use vhost_rs::VhostBackend;
use virtio_bindings::bindings::virtio_net;
@ -82,9 +82,13 @@ impl Net {
let mut acked_features = 0;
if avail_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);
}