[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 03/11] dataplane: sync virtio.c and vring.c virtqueu
From: |
Stefan Hajnoczi |
Subject: |
[Qemu-devel] [PATCH 03/11] dataplane: sync virtio.c and vring.c virtqueue state |
Date: |
Fri, 19 Jul 2013 16:38:44 +0800 |
Load the virtio.c state into vring.c when we start dataplane mode and
vice versa when stopping dataplane mode. This patch makes it possible
to start and stop dataplane any time while the guest is running.
This will eventually allow us to go back to QEMU main loop for
bdrv_drain_all() and live migration. In the meantime, this patch makes
the dataplane lifecycle more robust but should make no visible
difference. It may be useful in the virtio-net dataplane effort.
Signed-off-by: Stefan Hajnoczi <address@hidden>
---
hw/block/dataplane/virtio-blk.c | 2 +-
hw/virtio/dataplane/vring.c | 8 +++++---
include/hw/virtio/dataplane/vring.h | 2 +-
3 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/hw/block/dataplane/virtio-blk.c b/hw/block/dataplane/virtio-blk.c
index 0356665..2faed43 100644
--- a/hw/block/dataplane/virtio-blk.c
+++ b/hw/block/dataplane/virtio-blk.c
@@ -537,7 +537,7 @@ void virtio_blk_data_plane_stop(VirtIOBlockDataPlane *s)
/* Clean up guest notifier (irq) */
k->set_guest_notifiers(qbus->parent, 1, false);
- vring_teardown(&s->vring);
+ vring_teardown(&s->vring, s->vdev, 0);
s->started = false;
s->stopping = false;
}
diff --git a/hw/virtio/dataplane/vring.c b/hw/virtio/dataplane/vring.c
index e0d6e83..82cc151 100644
--- a/hw/virtio/dataplane/vring.c
+++ b/hw/virtio/dataplane/vring.c
@@ -39,8 +39,8 @@ bool vring_setup(Vring *vring, VirtIODevice *vdev, int n)
vring_init(&vring->vr, virtio_queue_get_num(vdev, n), vring_ptr, 4096);
- vring->last_avail_idx = 0;
- vring->last_used_idx = 0;
+ vring->last_avail_idx = virtio_queue_get_last_avail_idx(vdev, n);
+ vring->last_used_idx = vring->vr.used->idx;
vring->signalled_used = 0;
vring->signalled_used_valid = false;
@@ -49,8 +49,10 @@ bool vring_setup(Vring *vring, VirtIODevice *vdev, int n)
return true;
}
-void vring_teardown(Vring *vring)
+void vring_teardown(Vring *vring, VirtIODevice *vdev, int n)
{
+ virtio_queue_set_last_avail_idx(vdev, n, vring->last_avail_idx);
+
hostmem_finalize(&vring->hostmem);
}
diff --git a/include/hw/virtio/dataplane/vring.h
b/include/hw/virtio/dataplane/vring.h
index 9380cb5..c0b69ff 100644
--- a/include/hw/virtio/dataplane/vring.h
+++ b/include/hw/virtio/dataplane/vring.h
@@ -50,7 +50,7 @@ static inline void vring_set_broken(Vring *vring)
}
bool vring_setup(Vring *vring, VirtIODevice *vdev, int n);
-void vring_teardown(Vring *vring);
+void vring_teardown(Vring *vring, VirtIODevice *vdev, int n);
void vring_disable_notification(VirtIODevice *vdev, Vring *vring);
bool vring_enable_notification(VirtIODevice *vdev, Vring *vring);
bool vring_should_notify(VirtIODevice *vdev, Vring *vring);
--
1.8.1.4
- [Qemu-devel] [PULL for-1.6 00/11] Block patches, Stefan Hajnoczi, 2013/07/19
- [Qemu-devel] [PATCH 01/11] gluster: Use pkg-config to configure GlusterFS block driver, Stefan Hajnoczi, 2013/07/19
- [Qemu-devel] [PATCH 02/11] gluster: Add discard support for GlusterFS block driver., Stefan Hajnoczi, 2013/07/19
- [Qemu-devel] [PATCH 03/11] dataplane: sync virtio.c and vring.c virtqueue state,
Stefan Hajnoczi <=
- [Qemu-devel] [PATCH 04/11] QEMUBH: make AioContext's bh re-entrant, Stefan Hajnoczi, 2013/07/19
- [Qemu-devel] [PATCH 05/11] block: fix vvfat error path for enable_write_target, Stefan Hajnoczi, 2013/07/19
- [Qemu-devel] [PATCH 09/11] cpus: Let vm_stop[_force_state]() always flush block devices, Stefan Hajnoczi, 2013/07/19
- [Qemu-devel] [PATCH 08/11] block-migration: efficiently encode zero blocks, Stefan Hajnoczi, 2013/07/19
- [Qemu-devel] [PATCH 10/11] block: fix bdrv_read_unthrottled(), Stefan Hajnoczi, 2013/07/19
- [Qemu-devel] [PATCH 11/11] block/raw: add .bdrv_get_info, Stefan Hajnoczi, 2013/07/19
- [Qemu-devel] [PATCH 07/11] block/raw: add bdrv_co_write_zeroes, Stefan Hajnoczi, 2013/07/19
- [Qemu-devel] [PATCH 06/11] block: add bdrv_write_zeroes(), Stefan Hajnoczi, 2013/07/19