@@ -48,6 +48,7 @@ struct vdev_info {
4848
4949static const struct vhost_vring_file no_backend = { .fd = -1 },
5050 backend = { .fd = 1 };
51+ static const struct vhost_vring_state null_state = {};
5152
5253bool vq_notify (struct virtqueue * vq )
5354{
@@ -173,14 +174,19 @@ static void run_test(struct vdev_info *dev, struct vq_info *vq,
173174 unsigned len ;
174175 long long spurious = 0 ;
175176 const bool random_batch = batch == RANDOM_BATCH ;
177+
176178 r = ioctl (dev -> control , VHOST_TEST_RUN , & test );
177179 assert (r >= 0 );
180+ if (!reset_n ) {
181+ next_reset = INT_MAX ;
182+ }
183+
178184 for (;;) {
179185 virtqueue_disable_cb (vq -> vq );
180186 completed_before = completed ;
181187 started_before = started ;
182188 do {
183- const bool reset = reset_n && completed > next_reset ;
189+ const bool reset = completed > next_reset ;
184190 if (random_batch )
185191 batch = (random () % vq -> vring .num ) + 1 ;
186192
@@ -223,10 +229,24 @@ static void run_test(struct vdev_info *dev, struct vq_info *vq,
223229 }
224230
225231 if (reset ) {
232+ struct vhost_vring_state s = { .index = 0 };
233+
234+ vq_reset (vq , vq -> vring .num , & dev -> vdev );
235+
236+ r = ioctl (dev -> control , VHOST_GET_VRING_BASE ,
237+ & s );
238+ assert (!r );
239+
240+ s .num = 0 ;
241+ r = ioctl (dev -> control , VHOST_SET_VRING_BASE ,
242+ & null_state );
243+ assert (!r );
244+
226245 r = ioctl (dev -> control , VHOST_TEST_SET_BACKEND ,
227246 & backend );
228247 assert (!r );
229248
249+ started = completed ;
230250 while (completed > next_reset )
231251 next_reset += completed ;
232252 }
@@ -248,7 +268,9 @@ static void run_test(struct vdev_info *dev, struct vq_info *vq,
248268 test = 0 ;
249269 r = ioctl (dev -> control , VHOST_TEST_RUN , & test );
250270 assert (r >= 0 );
251- fprintf (stderr , "spurious wakeups: 0x%llx\n" , spurious );
271+ fprintf (stderr ,
272+ "spurious wakeups: 0x%llx started=0x%lx completed=0x%lx\n" ,
273+ spurious , started , completed );
252274}
253275
254276const char optstring [] = "h" ;
0 commit comments