From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36471) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zk0Z8-00012G-KT for qemu-devel@nongnu.org; Wed, 07 Oct 2015 22:04:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zk0Z6-0003BL-Sm for qemu-devel@nongnu.org; Wed, 07 Oct 2015 22:04:18 -0400 References: <1442907862-21376-1-git-send-email-wency@cn.fujitsu.com> <1442907862-21376-2-git-send-email-wency@cn.fujitsu.com> <20151007190010.GO2710@work-vm> From: Wen Congyang Message-ID: <5615CEFF.6060401@cn.fujitsu.com> Date: Thu, 8 Oct 2015 10:03:43 +0800 MIME-Version: 1.0 In-Reply-To: <20151007190010.GO2710@work-vm> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v5 1/4] Add new block driver interface to add/delete a BDS's child List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Dr. David Alan Gilbert" Cc: Kevin Wolf , Alberto Garcia , zhanghailiang , qemu block , Jiang Yunhong , Dong Eddie , qemu devel , Markus Armbruster , Gonglei , Stefan Hajnoczi , Yang Hongyang On 10/08/2015 03:00 AM, Dr. David Alan Gilbert wrote: > * Wen Congyang (wency@cn.fujitsu.com) wrote: >> In some cases, we want to take a quorum child offline, and take >> another child online. > > Hi, > Have you checked the output of 'info block' after adding/deleting a child? > I'm using one of your older worlds (from a few months ago) and I found I had > to add a > > bdrv_refresh_filename(bs); > > to get the output of 'info block' to show the new child. > I don't see it in this version. Max sent a patch series to drop BDS.filename, so I don't call bdrv_refresh_filename() here. If the BDS is not the top BDS, 'info block' still shows the wrong child. Thanks Wen Congyang > > Dave > > >> >> Signed-off-by: Wen Congyang >> Signed-off-by: zhanghailiang >> Signed-off-by: Gonglei >> Reviewed-by: Eric Blake >> --- >> block.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++ >> include/block/block.h | 5 +++++ >> include/block/block_int.h | 5 +++++ >> 3 files changed, 60 insertions(+) >> >> diff --git a/block.c b/block.c >> index e815d73..1b25e43 100644 >> --- a/block.c >> +++ b/block.c >> @@ -4265,3 +4265,53 @@ 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 *parent_bs, BlockDriverState *child_bs, >> + Error **errp) >> +{ >> + >> + if (!parent_bs->drv || !parent_bs->drv->bdrv_add_child) { >> + error_setg(errp, "The BDS %s doesn't support adding a child", >> + bdrv_get_device_or_node_name(parent_bs)); >> + return; >> + } >> + >> + if (!QLIST_EMPTY(&child_bs->parents)) { >> + error_setg(errp, "The BDS %s already has parent", >> + child_bs->node_name); >> + return; >> + } >> + >> + parent_bs->drv->bdrv_add_child(parent_bs, child_bs, errp); >> +} >> + >> +void bdrv_del_child(BlockDriverState *parent_bs, BlockDriverState *child_bs, >> + Error **errp) >> +{ >> + BdrvChild *child; >> + >> + if (!parent_bs->drv || !parent_bs->drv->bdrv_del_child) { >> + error_setg(errp, "The BDS %s doesn't support removing a child", >> + bdrv_get_device_or_node_name(parent_bs)); >> + return; >> + } >> + >> + QLIST_FOREACH(child, &parent_bs->children, next) { >> + if (child->bs == child_bs) { >> + break; >> + } >> + } >> + >> + if (!child) { >> + error_setg(errp, "BDS %s is not a child of %s", >> + bdrv_get_device_or_node_name(child_bs), >> + bdrv_get_device_or_node_name(parent_bs)); >> + return; >> + } >> + >> + parent_bs->drv->bdrv_del_child(parent_bs, child_bs, errp); >> +} >> diff --git a/include/block/block.h b/include/block/block.h >> index ef67353..665c56f 100644 >> --- a/include/block/block.h >> +++ b/include/block/block.h >> @@ -616,4 +616,9 @@ void bdrv_flush_io_queue(BlockDriverState *bs); >> >> BlockAcctStats *bdrv_get_stats(BlockDriverState *bs); >> >> +void bdrv_add_child(BlockDriverState *parent, BlockDriverState *child, >> + Error **errp); >> +void bdrv_del_child(BlockDriverState *parent, BlockDriverState *child, >> + Error **errp); >> + >> #endif >> diff --git a/include/block/block_int.h b/include/block/block_int.h >> index 2f2c47b..64cbc55 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 *parent, BlockDriverState *child, >> + Error **errp); >> + void (*bdrv_del_child)(BlockDriverState *parent, BlockDriverState *child, >> + Error **errp); >> + >> QLIST_ENTRY(BlockDriver) list; >> }; >> >> -- >> 2.4.3 >> > -- > Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK > . >