Skip to content

Commit

Permalink
vhost-user-backend: set event_idx boolean at set_features
Browse files Browse the repository at this point in the history
A frontend can skip the call to set_vring_base, assuming the ring will
be initialized at 0.  If that frontend acknowledge EVENT_IDX vring and
VhostUserHandler backend will never know they need to use event idx.

Move the features configuration of the vring and the backend to set_features method.

Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
  • Loading branch information
eugpermar authored and stefano-garzarella committed May 14, 2024
1 parent bd6bf13 commit 043d0d8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
1 change: 1 addition & 0 deletions vhost-user-backend/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
### Added

### Changed
- [[#240]](https://github.com/rust-vmm/vhost/pull/240) Move the set of event_idx property from set_vring_base callback to set_features one

### Fixed

Expand Down
9 changes: 5 additions & 4 deletions vhost-user-backend/src/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,11 @@ where
}
}

let event_idx: bool = (self.acked_features & (1 << VIRTIO_RING_F_EVENT_IDX)) != 0;
for vring in self.vrings.iter_mut() {
vring.set_queue_event_idx(event_idx);
}
self.backend.set_event_idx(event_idx);
self.backend.acked_features(self.acked_features);

Ok(())
Expand Down Expand Up @@ -398,11 +403,7 @@ where
.get(index as usize)
.ok_or_else(|| VhostUserError::InvalidParam)?;

let event_idx: bool = (self.acked_features & (1 << VIRTIO_RING_F_EVENT_IDX)) != 0;

vring.set_queue_next_avail(base as u16);
vring.set_queue_event_idx(event_idx);
self.backend.set_event_idx(event_idx);

Ok(())
}
Expand Down

0 comments on commit 043d0d8

Please sign in to comment.