From patchwork Thu Jun 25 06:55:10 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wen Congyang X-Patchwork-Id: 488300 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 19F5B1402E8 for ; Thu, 25 Jun 2015 16:51:35 +1000 (AEST) Received: from localhost ([::1]:54180 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z810X-0001PK-CJ for incoming@patchwork.ozlabs.org; Thu, 25 Jun 2015 02:51:33 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36061) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z810F-00018S-Dd for qemu-devel@nongnu.org; Thu, 25 Jun 2015 02:51:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z810C-0006cl-1S for qemu-devel@nongnu.org; Thu, 25 Jun 2015 02:51:15 -0400 Received: from [59.151.112.132] (port=49764 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z810B-0006c0-CI for qemu-devel@nongnu.org; Thu, 25 Jun 2015 02:51:11 -0400 X-IronPort-AV: E=Sophos;i="5.13,665,1427731200"; d="scan'208";a="97735519" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 25 Jun 2015 14:55:11 +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 t5P6nTAc011406; Thu, 25 Jun 2015 14:49:29 +0800 Received: from [10.167.226.52] (10.167.226.52) by G08CNEXCHPEKD02.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server id 14.3.181.6; Thu, 25 Jun 2015 14:51:07 +0800 Message-ID: <558BA5CE.80507@cn.fujitsu.com> Date: Thu, 25 Jun 2015 14:55:10 +0800 From: Wen Congyang User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: qemu-devl , Jeff Cody 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: Fam Zheng , Stefan Hajnoczi Subject: [Qemu-devel] [PATCH] more check for replaced node 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 Signed-off-by: Wen Congyang --- block.c | 5 +++-- block/mirror.c | 3 ++- blockdev.c | 2 +- include/block/block.h | 3 ++- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/block.c b/block.c index 7168575..70ee0f6 100644 --- a/block.c +++ b/block.c @@ -4033,7 +4033,8 @@ bool bdrv_is_first_non_filter(BlockDriverState *candidate) return false; } -BlockDriverState *check_to_replace_node(const char *node_name, Error **errp) +BlockDriverState *check_to_replace_node(BlockDriverState *parent_bs, + const char *node_name, Error **errp) { BlockDriverState *to_replace_bs = bdrv_find_node(node_name); AioContext *aio_context; @@ -4056,7 +4057,7 @@ BlockDriverState *check_to_replace_node(const char *node_name, Error **errp) * Another benefit is that this tests exclude backing files which are * blocked by the backing blockers. */ - if (!bdrv_is_first_non_filter(to_replace_bs)) { + if (!bdrv_recurse_is_first_non_filter(parent_bs, to_replace_bs)) { error_setg(errp, "Only top most non filter can be replaced"); to_replace_bs = NULL; goto out; diff --git a/block/mirror.c b/block/mirror.c index 0d06cc2..f132f35 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -612,7 +612,8 @@ static void mirror_complete(BlockJob *job, Error **errp) if (s->replaces) { AioContext *replace_aio_context; - s->to_replace = check_to_replace_node(s->replaces, &local_err); + s->to_replace = check_to_replace_node(s->common.bs, s->replaces, + &local_err); if (!s->to_replace) { error_propagate(errp, local_err); return; diff --git a/blockdev.c b/blockdev.c index f3a3097..a0e13b0 100644 --- a/blockdev.c +++ b/blockdev.c @@ -2756,7 +2756,7 @@ void qmp_drive_mirror(const char *device, const char *target, goto out; } - to_replace_bs = check_to_replace_node(replaces, &local_err); + to_replace_bs = check_to_replace_node(bs, replaces, &local_err); if (!to_replace_bs) { error_propagate(errp, local_err); diff --git a/include/block/block.h b/include/block/block.h index 07bb724..e0dad54 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -311,7 +311,8 @@ bool bdrv_recurse_is_first_non_filter(BlockDriverState *bs, bool bdrv_is_first_non_filter(BlockDriverState *candidate); /* check if a named node can be replaced when doing drive-mirror */ -BlockDriverState *check_to_replace_node(const char *node_name, Error **errp); +BlockDriverState *check_to_replace_node(BlockDriverState *parent_bs, + const char *node_name, Error **errp); /* async block I/O */ typedef void BlockDriverDirtyHandler(BlockDriverState *bs, int64_t sector,