diff options
author | Maxime Coquelin <maxime.coquelin@redhat.com> | 2017-11-16 19:48:34 +0100 |
---|---|---|
committer | Michael S. Tsirkin <mst@redhat.com> | 2017-12-01 19:05:58 +0200 |
commit | 2d4ba6cc741df15df6fbb4feaa706a02e103083a (patch) | |
tree | 0310d3cc53bb9b9dc9472448155b2442b86f79c6 /hw/virtio | |
parent | 861fec459bb4db69123c3b320e1bad9585cdb524 (diff) |
virtio: Add queue interface to restore avail index from vring used index
In case of backend crash, it is not possible to restore internal
avail index from the backend value as vhost_get_vring_base
callback fails.
This patch provides a new interface to restore internal avail index
from the vring used index, as done by some vhost-user backend on
reconnection.
Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Diffstat (limited to 'hw/virtio')
-rw-r--r-- | hw/virtio/virtio.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index ea532dc35f..703e672f3d 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -2310,6 +2310,16 @@ void virtio_queue_set_last_avail_idx(VirtIODevice *vdev, int n, uint16_t idx) vdev->vq[n].shadow_avail_idx = idx; } +void virtio_queue_restore_last_avail_idx(VirtIODevice *vdev, int n) +{ + rcu_read_lock(); + if (vdev->vq[n].vring.desc) { + vdev->vq[n].last_avail_idx = vring_used_idx(&vdev->vq[n]); + vdev->vq[n].shadow_avail_idx = vdev->vq[n].last_avail_idx; + } + rcu_read_unlock(); +} + void virtio_queue_update_used_idx(VirtIODevice *vdev, int n) { rcu_read_lock(); |