Skip to content

Commit 958cdec

Browse files
germagstefano-garzarella
authored andcommitted
get_vring_base should not reset the queue
The spec specifies that on receiving `GET_VRING_BASE` the backend should stop the vring, but not that it must be reset. This is intended for `VHOST_USER_RESET_DEVICE`, also in this case the spec makes a difference between stopping and disabling the ring. The spec also doesn't forbid to send `VHOST_USER_SET_VRING_ENABLE` to enable the vring after receiving `GET_VRING_BASE` or sending more `GET_VRING_BASE` messages, which would always respond 0. Moreover, qemu doesn't reset the vring either. Signed-off-by: German Maglione <[email protected]>
1 parent 29a7f8c commit 958cdec

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

crates/vhost-user-backend/src/handler.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -367,12 +367,14 @@ where
367367
if index as usize >= self.num_queues {
368368
return Err(VhostUserError::InvalidParam);
369369
}
370+
370371
// Quote from vhost-user specification:
371372
// Client must start ring upon receiving a kick (that is, detecting
372373
// that file descriptor is readable) on the descriptor specified by
373374
// VHOST_USER_SET_VRING_KICK, and stop ring upon receiving
374375
// VHOST_USER_GET_VRING_BASE.
375376
self.vrings[index as usize].set_queue_ready(false);
377+
376378
if let Some(fd) = self.vrings[index as usize].get_ref().get_kick() {
377379
for (thread_index, queues_mask) in self.queues_per_thread.iter().enumerate() {
378380
let shifted_queues_mask = queues_mask >> index;
@@ -391,14 +393,6 @@ where
391393
self.vrings[index as usize].set_kick(None);
392394
self.vrings[index as usize].set_call(None);
393395

394-
// Strictly speaking, we should do this upon receiving the first kick,
395-
// but it's actually easier to just do it here so we're ready in case
396-
// the vring gets re-initialized by the guest.
397-
self.vrings[index as usize]
398-
.get_mut()
399-
.get_queue_mut()
400-
.reset();
401-
402396
Ok(VhostUserVringState::new(index, u32::from(next_avail)))
403397
}
404398

0 commit comments

Comments
 (0)