From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41280) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UnQcs-0001ZT-Ck for qemu-devel@nongnu.org; Fri, 14 Jun 2013 05:49:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UnQcl-0000dc-Fx for qemu-devel@nongnu.org; Fri, 14 Jun 2013 05:48:58 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41108) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UnQcl-0000dQ-6c for qemu-devel@nongnu.org; Fri, 14 Jun 2013 05:48:51 -0400 From: Stefan Hajnoczi Date: Fri, 14 Jun 2013 11:48:24 +0200 Message-Id: <1371203313-26490-5-git-send-email-stefanha@redhat.com> In-Reply-To: <1371203313-26490-1-git-send-email-stefanha@redhat.com> References: <1371203313-26490-1-git-send-email-stefanha@redhat.com> Subject: [Qemu-devel] [RFC 04/13] virtio-blk: implement BlockDevOps->drain_threads_cb() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Kevin Wolf , Paolo Bonzini , Anthony Liguori , Ping Fan Liu , Stefan Hajnoczi 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 --- hw/block/virtio-blk.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c index cf12469..f9c2b79 100644 --- a/hw/block/virtio-blk.c +++ b/hw/block/virtio-blk.c @@ -618,8 +618,20 @@ 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) { + 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