vring->callfd_idx = ~0;
}
if (vring->errfd != -1)
- close (vring->errfd);
+ {
+ close (vring->errfd);
+ vring->errfd = -1;
+ }
vhost_user_vring_init (vui, qid);
}
goto close_socket;
}
- /* Spec says: Client must [...] stop ring upon receiving VHOST_USER_GET_VRING_BASE. */
- vhost_user_vring_close (vui, msg.state.index);
-
+ /*
+ * Copy last_avail_idx from the vring before closing it because
+ * closing the vring also initializes the vring last_avail_idx
+ */
msg.state.num = vui->vrings[msg.state.index].last_avail_idx;
msg.flags |= 4;
msg.size = sizeof (msg.state);
+
+ /* Spec says: Client must [...] stop ring upon receiving VHOST_USER_GET_VRING_BASE. */
+ vhost_user_vring_close (vui, msg.state.index);
break;
case VHOST_USER_NONE: