qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH v2 03/13] virtio-blk: implement BlockDevOps->drain_t


From: Stefan Hajnoczi
Subject: [Qemu-devel] [PATCH v2 03/13] virtio-blk: implement BlockDevOps->drain_threads_cb()
Date: Mon, 15 Jul 2013 22:42:52 +0800

Drain and stop the dataplane thread when bdrv_drain_all() is called.
Note that the thread will be restarted in virtio_blk_handle_output() the
next time the guest kicks the virtqueue.

Signed-off-by: Stefan Hajnoczi <address@hidden>
---
 hw/block/virtio-blk.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c
index cf12469..f4ad528 100644
--- a/hw/block/virtio-blk.c
+++ b/hw/block/virtio-blk.c
@@ -618,8 +618,24 @@ static void virtio_blk_resize(void *opaque)
     virtio_notify_config(vdev);
 }
 
+static void virtio_blk_drain_threads(void *opaque)
+{
+#ifdef CONFIG_VIRTIO_BLK_DATA_PLANE
+    VirtIOBlock *s = VIRTIO_BLK(opaque);
+
+    if (s->dataplane) {
+        /* Drain I/O and stop thread.  Next time the guest kicks the virtqueue
+         * we restart the thread.  In the meantime the main loop may access the
+         * block device.
+         */
+        virtio_blk_data_plane_stop(s->dataplane);
+    }
+#endif
+}
+
 static const BlockDevOps virtio_block_ops = {
     .resize_cb = virtio_blk_resize,
+    .drain_threads_cb = virtio_blk_drain_threads,
 };
 
 void virtio_blk_set_conf(DeviceState *dev, VirtIOBlkConf *blk)
-- 
1.8.1.4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]