vm-virtio, vhost_user_{fs,block,backend}: Move EVENT_IDX handling

Move the method that is used to decide whether the guest should be
signalled into the Queue implementation from vm-virtio. This removes
duplicated code between vhost_user_backend and the vm-virtio block
implementation.

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
Rob Bradford
2020-05-20 10:40:54 +01:00
committed by Sebastien Boeuf
parent 8ae7a38da5
commit a813b57f59
5 changed files with 44 additions and 57 deletions

View File

@@ -153,8 +153,9 @@ impl VhostUserBlkThread {
}
if self.event_idx {
if let Some(used_idx) = vring.mut_queue().add_used(mem, head.index, len) {
if vring.needs_notification(&mem, Wrapping(used_idx)) {
let queue = vring.mut_queue();
if let Some(used_idx) = queue.add_used(mem, head.index, len) {
if queue.needs_notification(&mem, Wrapping(used_idx)) {
debug!("signalling queue");
vring.signal_used_queue().unwrap();
} else {