[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 2/7] virtio: Add queue interface to restore avail ind
From: |
Michael S. Tsirkin |
Subject: |
[Qemu-devel] [PULL 2/7] virtio: Add queue interface to restore avail index from vring used index |
Date: |
Fri, 1 Dec 2017 19:08:43 +0200 |
From: Maxime Coquelin <address@hidden>
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 <address@hidden>
Reviewed-by: Michael S. Tsirkin <address@hidden>
Signed-off-by: Michael S. Tsirkin <address@hidden>
---
include/hw/virtio/virtio.h | 1 +
hw/virtio/virtio.c | 10 ++++++++++
2 files changed, 11 insertions(+)
diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h
index 5abada6..098bdaa 100644
--- a/include/hw/virtio/virtio.h
+++ b/include/hw/virtio/virtio.h
@@ -272,6 +272,7 @@ hwaddr virtio_queue_get_avail_size(VirtIODevice *vdev, int
n);
hwaddr virtio_queue_get_used_size(VirtIODevice *vdev, int n);
uint16_t virtio_queue_get_last_avail_idx(VirtIODevice *vdev, int n);
void virtio_queue_set_last_avail_idx(VirtIODevice *vdev, int n, uint16_t idx);
+void virtio_queue_restore_last_avail_idx(VirtIODevice *vdev, int n);
void virtio_queue_invalidate_signalled_used(VirtIODevice *vdev, int n);
void virtio_queue_update_used_idx(VirtIODevice *vdev, int n);
VirtQueue *virtio_get_queue(VirtIODevice *vdev, int n);
diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
index ea532dc..703e672 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();
--
MST
- [Qemu-devel] [PULL 0/7] pc, pci, virtio: fixes for rc3, Michael S. Tsirkin, 2017/12/01
- [Qemu-devel] [PULL 1/7] i386/msi: Correct mask of destination ID in MSI address, Michael S. Tsirkin, 2017/12/01
- [Qemu-devel] [PULL 2/7] virtio: Add queue interface to restore avail index from vring used index,
Michael S. Tsirkin <=
- [Qemu-devel] [PULL 3/7] vhost: restore avail index from vring used index on disconnection, Michael S. Tsirkin, 2017/12/01
- [Qemu-devel] [PULL 4/7] dump-guest-memory.py: fix No symbol "vmcoreinfo_find", Michael S. Tsirkin, 2017/12/01
- [Qemu-devel] [PULL 5/7] vhost: fix error check in vhost_verify_ring_mappings(), Michael S. Tsirkin, 2017/12/01
- [Qemu-devel] [PULL 6/7] virtio: check VirtQueue Vring object is set, Michael S. Tsirkin, 2017/12/01
- [Qemu-devel] [PULL 7/7] pc: fix crash on attempted cpu unplug, Michael S. Tsirkin, 2017/12/01
- Re: [Qemu-devel] [PULL 0/7] pc, pci, virtio: fixes for rc3, Peter Maydell, 2017/12/01
- Re: [Qemu-devel] [PULL 0/7] pc, pci, virtio: fixes for rc3, Michael S. Tsirkin, 2017/12/02
- Re: [Qemu-devel] [PULL 0/7] pc, pci, virtio: fixes for rc3, Peter Maydell, 2017/12/04
- Re: [Qemu-devel] [PULL 0/7] pc, pci, virtio: fixes for rc3, Peter Maydell, 2017/12/04
- Re: [Qemu-devel] [PULL 0/7] pc, pci, virtio: fixes for rc3, Michael S. Tsirkin, 2017/12/04