From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35376) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZkVys-0005tY-9r for qemu-devel@nongnu.org; Fri, 09 Oct 2015 07:36:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZkVyr-0001Yy-G1 for qemu-devel@nongnu.org; Fri, 09 Oct 2015 07:36:58 -0400 Date: Fri, 9 Oct 2015 13:36:48 +0200 From: Kevin Wolf Message-ID: <20151009113648.GD3956@noname.redhat.com> References: <1443705214-9304-1-git-send-email-kwolf@redhat.com> <1443705214-9304-8-git-send-email-kwolf@redhat.com> <20151009013900.GA19149@ad.nay.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20151009013900.GA19149@ad.nay.redhat.com> Subject: Re: [Qemu-devel] [PATCH v2 07/16] block: Convert bs->backing_hd to BdrvChild List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Fam Zheng Cc: berto@igalia.com, qemu-block@nongnu.org, armbru@redhat.com, jcody@redhat.com, qemu-devel@nongnu.org, mreitz@redhat.com, stefanha@redhat.com Am 09.10.2015 um 03:39 hat Fam Zheng geschrieben: > On Thu, 10/01 15:13, Kevin Wolf wrote: > > This is the final step in converting all of the BlockDriverState > > pointers that block drivers use to BdrvChild. > > > > After this patch, bs->children contains the full list of child nodes > > that are referenced by a given BDS, and these children are only > > referenced through BdrvChild, so that updating the pointer in there is > > enough for changing edges in the graph. > > > > Signed-off-by: Kevin Wolf > > @@ -2366,11 +2365,20 @@ int bdrv_change_backing_file(BlockDriverState *bs, > > BlockDriverState *bdrv_find_overlay(BlockDriverState *active, > > BlockDriverState *bs) > > { > > - while (active && bs != active->backing_hd) { > > - active = active->backing_hd; > > + while (active) { > > + if (active->backing) { > > + if (bs == active->backing->bs) { > > + return active; > > + } > > + active = active->backing->bs; > > + } else if (bs == NULL) { > > + return active; > > + } else { > > + return NULL; > > + } > > Why not just > > while (active && bs != backing_bs(active)) { > active = backing_bs(active); > } > > return active; > > ? Because backing_bs() didn't exist yet when I converted this function. Thanks for noticing, I'll change it into the simpler version. Kevin