From patchwork Thu Jun 18 08:49:12 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wen Congyang X-Patchwork-Id: 486147 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 79C0C140187 for ; Thu, 18 Jun 2015 18:46:43 +1000 (AEST) Received: from localhost ([::1]:50962 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z5VT7-00062B-M9 for incoming@patchwork.ozlabs.org; Thu, 18 Jun 2015 04:46:41 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55931) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z5VSK-0004pl-Kv for qemu-devel@nongnu.org; Thu, 18 Jun 2015 04:45:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z5VSH-00046s-3c for qemu-devel@nongnu.org; Thu, 18 Jun 2015 04:45:52 -0400 Received: from [59.151.112.132] (port=31174 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z5VSF-0003kZ-Fs; Thu, 18 Jun 2015 04:45:48 -0400 X-IronPort-AV: E=Sophos;i="5.13,625,1427731200"; d="scan'208";a="97256922" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 18 Jun 2015 16:49:42 +0800 Received: from G08CNEXCHPEKD02.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t5I8huV5019715; Thu, 18 Jun 2015 16:43:56 +0800 Received: from G08FNSTD140052.g08.fujitsu.local (10.167.226.52) by G08CNEXCHPEKD02.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.181.6; Thu, 18 Jun 2015 16:45:31 +0800 From: Wen Congyang To: qemu devel , Fam Zheng , Max Reitz , Paolo Bonzini Date: Thu, 18 Jun 2015 16:49:12 +0800 Message-ID: <1434617361-17778-8-git-send-email-wency@cn.fujitsu.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1434617361-17778-1-git-send-email-wency@cn.fujitsu.com> References: <1434617361-17778-1-git-send-email-wency@cn.fujitsu.com> MIME-Version: 1.0 X-Originating-IP: [10.167.226.52] X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Cc: Kevin Wolf , qemu block , Lai Jiangshan , Jiang Yunhong , Dong Eddie , "Dr. David Alan Gilbert" , Gonglei , Stefan Hajnoczi , Yang Hongyang , zhanghailiang Subject: [Qemu-devel] [PATCH COLO-Block v6 07/16] Add new block driver interface to connect/disconnect the remote target X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 0b41af4..59071d4 100644 --- a/block.c +++ b/block.c @@ -4400,3 +4400,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 7cdb569..2c2a0cc 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -606,4 +606,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 87fe89a..a3e5372 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; };