From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56258) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YqeKm-00022p-LW for qemu-devel@nongnu.org; Fri, 08 May 2015 05:12:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YqeKl-0004Vy-Ej for qemu-devel@nongnu.org; Fri, 08 May 2015 05:12:40 -0400 From: Wen Congyang Date: Fri, 8 May 2015 17:15:59 +0800 Message-ID: <1431076567-30371-8-git-send-email-wency@cn.fujitsu.com> In-Reply-To: <1431076567-30371-1-git-send-email-wency@cn.fujitsu.com> References: <1431076567-30371-1-git-send-email-wency@cn.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain Subject: [Qemu-devel] [PATCH COLO v4 07/15] Add new block driver interface to connect/disconnect the remote target List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu devel , Fam Zheng , Max Reitz , Paolo Bonzini Cc: Kevin Wolf , qemu block , Lai Jiangshan , Jiang Yunhong , Dong Eddie , "Dr. David Alan Gilbert" , Gonglei , Stefan Hajnoczi , Yang Hongyang , zhanghailiang In some cases, we want to connect/disconnect the remote target when we need, not in bdrv_open()/bdrv_close(). Signed-off-by: Wen Congyang Signed-off-by: zhanghailiang Signed-off-by: Gonglei --- block.c | 24 ++++++++++++++++++++++++ include/block/block.h | 3 +++ include/block/block_int.h | 3 +++ 3 files changed, 30 insertions(+) diff --git a/block.c b/block.c index 15d21da..050f919 100644 --- a/block.c +++ b/block.c @@ -4189,3 +4189,27 @@ BlockAcctStats *bdrv_get_stats(BlockDriverState *bs) { return &bs->stats; } + +void bdrv_connect(BlockDriverState *bs, Error **errp) +{ + BlockDriver *drv = bs->drv; + + if (drv && drv->bdrv_connect) { + drv->bdrv_connect(bs, errp); + } else if (bs->file) { + bdrv_connect(bs->file, errp); + } else { + error_setg(errp, "this feature or command is not currently supported"); + } +} + +void bdrv_disconnect(BlockDriverState *bs) +{ + BlockDriver *drv = bs->drv; + + if (drv && drv->bdrv_disconnect) { + drv->bdrv_disconnect(bs); + } else if (bs->file) { + bdrv_disconnect(bs->file); + } +} diff --git a/include/block/block.h b/include/block/block.h index 006c941..e479a34 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -592,4 +592,7 @@ void bdrv_flush_io_queue(BlockDriverState *bs); BlockAcctStats *bdrv_get_stats(BlockDriverState *bs); +void bdrv_connect(BlockDriverState *bs, Error **errp); +void bdrv_disconnect(BlockDriverState *bs); + #endif diff --git a/include/block/block_int.h b/include/block/block_int.h index 49ca826..da29fa7 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -290,6 +290,9 @@ struct BlockDriver { */ int (*bdrv_probe_geometry)(BlockDriverState *bs, HDGeometry *geo); + void (*bdrv_connect)(BlockDriverState *bs, Error **errp); + void (*bdrv_disconnect)(BlockDriverState *bs); + QLIST_ENTRY(BlockDriver) list; }; -- 2.1.0