Received: from eggs.gnu.org ([2001:4830:134:3::10]:60935) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YLk5k-00024a-N9 for qemu-devel@nongnu.org; Wed, 11 Feb 2015 22:05:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YLk5g-00017C-Bl for qemu-devel@nongnu.org; Wed, 11 Feb 2015 22:05:24 -0500 Received: from [59.151.112.132] (port=57794 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YLk5f-00014D-8T for qemu-devel@nongnu.org; Wed, 11 Feb 2015 22:05:20 -0500 From: Wen Congyang Date: Thu, 12 Feb 2015 11:07:08 +0800 Message-ID: <1423710438-14377-5-git-send-email-wency@cn.fujitsu.com> In-Reply-To: <1423710438-14377-1-git-send-email-wency@cn.fujitsu.com> References: <1423710438-14377-1-git-send-email-wency@cn.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain Subject: [Qemu-devel] [RFC PATCH 04/14] Add new block driver interfaces to control disk replication List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu devel , Kevin Wolf , Stefan Hajnoczi , Paolo Bonzini Cc: Lai Jiangshan , Jiang Yunhong , Dong Eddie , "Dr. David Alan Gilbert" , Gonglei , Yang Hongyang , zhanghailiang Signed-off-by: Wen Congyang Signed-off-by: zhanghailiang Signed-off-by: Gonglei --- block.c | 36 ++++++++++++++++++++++++++++++++++++ include/block/block.h | 10 ++++++++++ include/block/block_int.h | 12 ++++++++++++ 3 files changed, 58 insertions(+) diff --git a/block.c b/block.c index 210fd5f..2335af1 100644 --- a/block.c +++ b/block.c @@ -6156,3 +6156,39 @@ BlockAcctStats *bdrv_get_stats(BlockDriverState *bs) { return &bs->stats; } + +int bdrv_start_replication(BlockDriverState *bs, int mode) +{ + BlockDriver *drv = bs->drv; + if (drv && drv->bdrv_start_replication) { + return drv->bdrv_start_replication(bs, mode); + } else if (bs->file) { + return bdrv_start_replication(bs->file, mode); + } + + return -1; +} + +int bdrv_do_checkpoint(BlockDriverState *bs) +{ + BlockDriver *drv = bs->drv; + if (drv && drv->bdrv_do_checkpoint) { + return drv->bdrv_do_checkpoint(bs); + } else if (bs->file) { + return bdrv_do_checkpoint(bs->file); + } + + return -1; +} + +int bdrv_stop_replication(BlockDriverState *bs) +{ + BlockDriver *drv = bs->drv; + if (drv && drv->bdrv_stop_replication) { + return drv->bdrv_stop_replication(bs); + } else if (bs->file) { + return bdrv_stop_replication(bs->file); + } + + return -1; +} diff --git a/include/block/block.h b/include/block/block.h index 321295e..632b9fc 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -557,4 +557,14 @@ void bdrv_flush_io_queue(BlockDriverState *bs); BlockAcctStats *bdrv_get_stats(BlockDriverState *bs); +/* Checkpoint control, called in migration/checkpoint thread */ +enum { + COLO_UNPROTECTED_MODE = 0, + COLO_PRIMARY_MODE, + COLO_SECONDARY_MODE, +}; +int bdrv_start_replication(BlockDriverState *bs, int mode); +int bdrv_do_checkpoint(BlockDriverState *bs); +int bdrv_stop_replication(BlockDriverState *bs); + #endif diff --git a/include/block/block_int.h b/include/block/block_int.h index 7ad1950..603f704 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -273,6 +273,18 @@ struct BlockDriver { void (*bdrv_io_unplug)(BlockDriverState *bs); void (*bdrv_flush_io_queue)(BlockDriverState *bs); + + /* Checkpoint control, called in migration/checkpoint thread */ + int (*bdrv_start_replication)(BlockDriverState *bs, int mode); + /* + * Drop Disk buffer when doing checkpoint. + */ + int (*bdrv_do_checkpoint)(BlockDriverState *bs); + /* After failover, we should flush Disk buffer into secondary disk + * and stop block replication. + */ + int (*bdrv_stop_replication)(BlockDriverState *bs); + QLIST_ENTRY(BlockDriver) list; }; -- 2.1.0