From patchwork Tue Jul 7 08:42:59 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wen Congyang X-Patchwork-Id: 492084 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 5184F1402BE for ; Tue, 7 Jul 2015 18:40:27 +1000 (AEST) Received: from localhost ([::1]:55716 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZCOQT-00070B-IR for incoming@patchwork.ozlabs.org; Tue, 07 Jul 2015 04:40:25 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41237) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZCOQ2-0006HA-Au for qemu-devel@nongnu.org; Tue, 07 Jul 2015 04:39:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZCOPz-000230-4Y for qemu-devel@nongnu.org; Tue, 07 Jul 2015 04:39:58 -0400 Received: from [59.151.112.132] (port=62005 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZCOPx-0001Wo-3Y; Tue, 07 Jul 2015 04:39:54 -0400 X-IronPort-AV: E=Sophos;i="5.13,665,1427731200"; d="scan'208";a="98163928" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 07 Jul 2015 16:43:21 +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 t678bjhM010419; Tue, 7 Jul 2015 16:37:45 +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; Tue, 7 Jul 2015 16:39:27 +0800 From: Wen Congyang To: qemu devel , Fam Zheng , Max Reitz , Paolo Bonzini , Stefan Hajnoczi Date: Tue, 7 Jul 2015 16:42:59 +0800 Message-ID: <1436258596-1253-2-git-send-email-wency@cn.fujitsu.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1436258596-1253-1-git-send-email-wency@cn.fujitsu.com> References: <1436258596-1253-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 , Jiang Yunhong , Dong Eddie , "Dr. David Alan Gilbert" , "Michael R. Hines" , Gonglei , Yang Hongyang , zhanghailiang Subject: [Qemu-devel] [PATCH COLO-BLOCK v8 01/18] Add new block driver interface to add/delete a BDS's child 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 take a quorum child offline, and take another child online. Signed-off-by: Wen Congyang Signed-off-by: zhanghailiang Signed-off-by: Gonglei --- block.c | 39 +++++++++++++++++++++++++++++++++++++++ include/block/block.h | 4 ++++ include/block/block_int.h | 5 +++++ 3 files changed, 48 insertions(+) diff --git a/block.c b/block.c index 7e130cc..2cbc4f9 100644 --- a/block.c +++ b/block.c @@ -4195,3 +4195,42 @@ BlockAcctStats *bdrv_get_stats(BlockDriverState *bs) { return &bs->stats; } + +/* + * Hot add/remove a BDS's child. So the user can take a child offline when + * it is broken and take a new child online + */ +void bdrv_add_child(BlockDriverState *bs, QDict *options, Error **errp) +{ + + if (!bs->drv || !bs->drv->bdrv_add_child) { + error_setg(errp, "this feature or command is not currently supported"); + return; + } + + bs->drv->bdrv_add_child(bs, options, errp); +} + +void bdrv_del_child(BlockDriverState *bs, BlockDriverState *child_bs, + Error **errp) +{ + BdrvChild *child; + + if (!bs->drv || !bs->drv->bdrv_del_child) { + error_setg(errp, "this feature or command is not currently supported"); + return; + } + + QLIST_FOREACH(child, &bs->children, next) { + if (child->bs == child_bs) { + break; + } + } + + if (!child) { + error_setg(errp, "Invalid child"); + return; + } + + bs->drv->bdrv_del_child(bs, child_bs, errp); +} diff --git a/include/block/block.h b/include/block/block.h index 06e4137..29d3363 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -609,4 +609,8 @@ void bdrv_flush_io_queue(BlockDriverState *bs); BlockAcctStats *bdrv_get_stats(BlockDriverState *bs); +void bdrv_add_child(BlockDriverState *bs, QDict *options, Error **errp); +void bdrv_del_child(BlockDriverState *bs, BlockDriverState *child, + Error **errp); + #endif diff --git a/include/block/block_int.h b/include/block/block_int.h index 8996baf..6fddea4 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -288,6 +288,11 @@ struct BlockDriver { */ int (*bdrv_probe_geometry)(BlockDriverState *bs, HDGeometry *geo); + void (*bdrv_add_child)(BlockDriverState *bs, QDict *options, + Error **errp); + void (*bdrv_del_child)(BlockDriverState *bs, BlockDriverState *child, + Error **errp); + QLIST_ENTRY(BlockDriver) list; };