@@ -692,18 +692,18 @@ void vhost_svq_stop(VhostShadowVirtqueue *svq)
/* Send all pending used descriptors to guest */
vhost_svq_flush(svq, false);
- while (!QTAILQ_EMPTY(&svq->desc_state_avail)) {
+ while (!QTAILQ_EMPTY(&svq->desc_state_avail)
+ || svq->next_guest_avail_elem) {
SVQDescState *s = QTAILQ_FIRST(&svq->desc_state_avail);
g_autofree VirtQueueElement *elem = NULL;
- elem = g_steal_pointer(&s->elem);
- virtqueue_detach_element(svq->vq, elem, 0);
- QTAILQ_REMOVE(&svq->desc_state_avail, s, entry);
- }
-
- next_avail_elem = g_steal_pointer(&svq->next_guest_avail_elem);
- if (next_avail_elem) {
- virtqueue_detach_element(svq->vq, next_avail_elem, 0);
+ elem = g_steal_pointer(s ? &s->elem : &svq->next_guest_avail_elem);
+ if (elem) {
+ virtqueue_detach_element(svq->vq, elem, 0);
+ }
+ if (s) {
+ QTAILQ_REMOVE(&svq->desc_state_avail, s, entry);
+ }
}
svq->vq = NULL;
g_free(svq->desc_next);
We need to perform the same actions for the two. Signed-off-by: Eugenio PĂ©rez <eperezma@redhat.com> --- hw/virtio/vhost-shadow-virtqueue.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)