|
|
9bac43 |
From 257d8d98076717288519d312f1690c453bb74776 Mon Sep 17 00:00:00 2001
|
|
|
9bac43 |
From: Maxime Coquelin <maxime.coquelin@redhat.com>
|
|
|
9bac43 |
Date: Tue, 5 Dec 2017 09:28:38 +0100
|
|
|
9bac43 |
Subject: [PATCH 16/21] virtio: Add queue interface to restore avail index from
|
|
|
9bac43 |
vring used index
|
|
|
9bac43 |
MIME-Version: 1.0
|
|
|
9bac43 |
Content-Type: text/plain; charset=UTF-8
|
|
|
9bac43 |
Content-Transfer-Encoding: 8bit
|
|
|
9bac43 |
|
|
|
9bac43 |
RH-Author: Maxime Coquelin <maxime.coquelin@redhat.com>
|
|
|
9bac43 |
Message-id: <20171205092839.17597-2-maxime.coquelin@redhat.com>
|
|
|
9bac43 |
Patchwork-id: 78140
|
|
|
9bac43 |
O-Subject: [RHV7.5 qemu-kvm-rhev PATCH 1/2] virtio: Add queue interface to restore avail index from vring used index
|
|
|
9bac43 |
Bugzilla: 1491909
|
|
|
9bac43 |
RH-Acked-by: wexu@redhat.com
|
|
|
9bac43 |
RH-Acked-by: Marc-André Lureau <marcandre.lureau@redhat.com>
|
|
|
9bac43 |
RH-Acked-by: Michael S. Tsirkin <mst@redhat.com>
|
|
|
9bac43 |
RH-Acked-by: Xiao Wang <jasowang@redhat.com>
|
|
|
9bac43 |
|
|
|
9bac43 |
In case of backend crash, it is not possible to restore internal
|
|
|
9bac43 |
avail index from the backend value as vhost_get_vring_base
|
|
|
9bac43 |
callback fails.
|
|
|
9bac43 |
|
|
|
9bac43 |
This patch provides a new interface to restore internal avail index
|
|
|
9bac43 |
from the vring used index, as done by some vhost-user backend on
|
|
|
9bac43 |
reconnection.
|
|
|
9bac43 |
|
|
|
9bac43 |
Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
|
|
|
9bac43 |
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
|
|
|
9bac43 |
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
|
|
|
9bac43 |
(cherry picked from commit 2d4ba6cc741df15df6fbb4feaa706a02e103083a)
|
|
|
9bac43 |
Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
|
|
|
9bac43 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9bac43 |
---
|
|
|
9bac43 |
hw/virtio/virtio.c | 10 ++++++++++
|
|
|
9bac43 |
include/hw/virtio/virtio.h | 1 +
|
|
|
9bac43 |
2 files changed, 11 insertions(+)
|
|
|
9bac43 |
|
|
|
9bac43 |
diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
|
|
|
9bac43 |
index e7a2bc2..58ecf75 100644
|
|
|
9bac43 |
--- a/hw/virtio/virtio.c
|
|
|
9bac43 |
+++ b/hw/virtio/virtio.c
|
|
|
9bac43 |
@@ -2329,6 +2329,16 @@ void virtio_queue_set_last_avail_idx(VirtIODevice *vdev, int n, uint16_t idx)
|
|
|
9bac43 |
vdev->vq[n].shadow_avail_idx = idx;
|
|
|
9bac43 |
}
|
|
|
9bac43 |
|
|
|
9bac43 |
+void virtio_queue_restore_last_avail_idx(VirtIODevice *vdev, int n)
|
|
|
9bac43 |
+{
|
|
|
9bac43 |
+ rcu_read_lock();
|
|
|
9bac43 |
+ if (vdev->vq[n].vring.desc) {
|
|
|
9bac43 |
+ vdev->vq[n].last_avail_idx = vring_used_idx(&vdev->vq[n]);
|
|
|
9bac43 |
+ vdev->vq[n].shadow_avail_idx = vdev->vq[n].last_avail_idx;
|
|
|
9bac43 |
+ }
|
|
|
9bac43 |
+ rcu_read_unlock();
|
|
|
9bac43 |
+}
|
|
|
9bac43 |
+
|
|
|
9bac43 |
void virtio_queue_update_used_idx(VirtIODevice *vdev, int n)
|
|
|
9bac43 |
{
|
|
|
9bac43 |
rcu_read_lock();
|
|
|
9bac43 |
diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h
|
|
|
9bac43 |
index 5faa359..912310c 100644
|
|
|
9bac43 |
--- a/include/hw/virtio/virtio.h
|
|
|
9bac43 |
+++ b/include/hw/virtio/virtio.h
|
|
|
9bac43 |
@@ -273,6 +273,7 @@ hwaddr virtio_queue_get_avail_size(VirtIODevice *vdev, int n);
|
|
|
9bac43 |
hwaddr virtio_queue_get_used_size(VirtIODevice *vdev, int n);
|
|
|
9bac43 |
uint16_t virtio_queue_get_last_avail_idx(VirtIODevice *vdev, int n);
|
|
|
9bac43 |
void virtio_queue_set_last_avail_idx(VirtIODevice *vdev, int n, uint16_t idx);
|
|
|
9bac43 |
+void virtio_queue_restore_last_avail_idx(VirtIODevice *vdev, int n);
|
|
|
9bac43 |
void virtio_queue_invalidate_signalled_used(VirtIODevice *vdev, int n);
|
|
|
9bac43 |
void virtio_queue_update_used_idx(VirtIODevice *vdev, int n);
|
|
|
9bac43 |
VirtQueue *virtio_get_queue(VirtIODevice *vdev, int n);
|
|
|
9bac43 |
--
|
|
|
9bac43 |
1.8.3.1
|
|
|
9bac43 |
|