Skip to content

Commit b4cca6d

Browse files
eugpermarmstsirkin
authored andcommitted
vdpa_sim: set last_used_idx as last_avail_idx in vdpasim_queue_ready
Starting from an used_idx different than 0 is needed in use cases like virtual machine migration. Not doing so and letting the caller set an avail idx different than 0 causes destination device to try to use old buffers that source driver already recover and are not available anymore. Since vdpa_sim does not support receive inflight descriptors as a destination of a migration, let's set both avail_idx and used_idx the same at vq start. This is how vhost-user works in a VHOST_SET_VRING_BASE call. Although the simple fix is to set last_used_idx at vdpasim_set_vq_state, it would be reset at vdpasim_queue_ready. The last_avail_idx case is fixed with commit 0e84f91 ("vdpa_sim: not reset state in vdpasim_queue_ready"). Since the only option is to make it equal to last_avail_idx, adding the only change needed here. This was discovered and tested live migrating the vdpa_sim_net device. Fixes: 2c53d0f ("vdpasim: vDPA device simulator") Reviewed-by: Stefano Garzarella <[email protected]> Signed-off-by: Eugenio Pérez <[email protected]> Message-Id: <[email protected]> Signed-off-by: Michael S. Tsirkin <[email protected]>
1 parent 5a52215 commit b4cca6d

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

drivers/vdpa/vdpa_sim/vdpa_sim.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,17 @@ static void vdpasim_queue_ready(struct vdpasim *vdpasim, unsigned int idx)
6868
(uintptr_t)vq->device_addr);
6969

7070
vq->vring.last_avail_idx = last_avail_idx;
71+
72+
/*
73+
* Since vdpa_sim does not support receive inflight descriptors as a
74+
* destination of a migration, let's set both avail_idx and used_idx
75+
* the same at vq start. This is how vhost-user works in a
76+
* VHOST_SET_VRING_BASE call.
77+
*
78+
* Although the simple fix is to set last_used_idx at
79+
* vdpasim_set_vq_state, it would be reset at vdpasim_queue_ready.
80+
*/
81+
vq->vring.last_used_idx = last_avail_idx;
7182
vq->vring.notify = vdpasim_vq_notify;
7283
}
7384

0 commit comments

Comments
 (0)