Reset the Queue on GET_VRING_BASE

According to the vhost-user specs, we should start the vring upon
receiving the first kick, and stop it when we receive GET_VRING_BASE.

Strictly speaking, we should reset the underlying Queue on the first
kick, but it's actually easier to simply do that in GET_VRING_BASE and
be ready in case the guest re-initializes the vring.

Signed-off-by: Sergio Lopez <slp@redhat.com>
This commit is contained in:
Sergio Lopez 2021-09-13 13:45:03 +02:00 committed by Jiang Liu
parent 4feeb77a20
commit 17131359eb

View file

@ -396,6 +396,14 @@ where
self.vrings[index as usize].set_kick(None);
self.vrings[index as usize].set_call(None);
// Strictly speaking, we should do this upon receiving the first kick,
// but it's actually easier to just do it here so we're ready in case
// the vring gets re-initialized by the guest.
self.vrings[index as usize]
.get_mut()
.get_queue_mut()
.reset();
let next_avail = self.vrings[index as usize].queue_next_avail();
Ok(VhostUserVringState::new(index, u32::from(next_avail)))