virtio-devices: vhost_user: Set NEED_REPLY when REPLY_ACK is supported

Now that vhost crate allows the caller to set the header flags, we can
set NEED_REPLY whenever the REPLY_ACK protocol feature is supported from
both ends.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
Sebastien Boeuf 2021-06-04 16:17:48 +02:00
parent 2c576ab312
commit 3c0f06c09c
2 changed files with 15 additions and 5 deletions

2
Cargo.lock generated
View File

@ -1111,7 +1111,7 @@ dependencies = [
[[package]]
name = "vhost"
version = "0.1.0"
source = "git+https://github.com/rust-vmm/vhost?branch=master#a8ff939161d41fc2f449b80e461d013c1e19f666"
source = "git+https://github.com/rust-vmm/vhost?branch=master#e294ed66fcc12e033957f20034ae5fef5bb9eeac"
dependencies = [
"bitflags",
"libc",

View File

@ -14,7 +14,7 @@ use std::thread::sleep;
use std::time::{Duration, Instant};
use std::vec::Vec;
use vhost::vhost_user::message::{
VhostUserInflight, VhostUserProtocolFeatures, VhostUserVirtioFeatures,
VhostUserHeaderFlag, VhostUserInflight, VhostUserProtocolFeatures, VhostUserVirtioFeatures,
};
use vhost::vhost_user::{Master, MasterReqHandler, VhostUserMaster, VhostUserMasterReqHandler};
use vhost::{VhostBackend, VhostUserMemoryRegionInfo, VringConfigData};
@ -95,12 +95,18 @@ pub fn negotiate_features_vhost_user(
vu.set_protocol_features(acked_protocol_features)
.map_err(Error::VhostUserSetProtocolFeatures)?;
acked_protocol_features.bits()
acked_protocol_features
} else {
0
VhostUserProtocolFeatures::empty()
};
Ok((acked_features, acked_protocol_features))
if avail_protocol_features.contains(VhostUserProtocolFeatures::REPLY_ACK)
&& acked_protocol_features.contains(VhostUserProtocolFeatures::REPLY_ACK)
{
vu.set_hdr_flags(VhostUserHeaderFlag::NEED_REPLY);
}
Ok((acked_features, acked_protocol_features.bits()))
}
#[allow(clippy::too_many_arguments)]
@ -230,6 +236,10 @@ pub fn reinitialize_vhost_user<S: VhostUserMasterReqHandler>(
{
vu.set_protocol_features(acked_protocol_features)
.map_err(Error::VhostUserSetProtocolFeatures)?;
if acked_protocol_features.contains(VhostUserProtocolFeatures::REPLY_ACK) {
vu.set_hdr_flags(VhostUserHeaderFlag::NEED_REPLY);
}
}
}