From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48042) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1axtoJ-0001zH-5B for qemu-devel@nongnu.org; Wed, 04 May 2016 06:13:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1axtny-0006c0-Dv for qemu-devel@nongnu.org; Wed, 04 May 2016 06:13:33 -0400 Date: Wed, 4 May 2016 12:12:42 +0200 From: Kevin Wolf Message-ID: <20160504101242.GC14972@noname.str.redhat.com> References: <1461030177-29144-1-git-send-email-famz@redhat.com> <1461030177-29144-3-git-send-email-famz@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1461030177-29144-3-git-send-email-famz@redhat.com> Subject: Re: [Qemu-devel] [PATCH 2/2] block: Inactivate all children List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Fam Zheng Cc: qemu-devel@nongnu.org, Max Reitz , qemu-block@nongnu.org Am 19.04.2016 um 03:42 hat Fam Zheng geschrieben: > Currently we only inactivate the top BDS. Actually bdrv_inactivate > should be the opposite of bdrv_invalidate_cache. > > Recurse into the whole subtree instead. > > Signed-off-by: Fam Zheng Did you actually test this? I would expect that bs->drv->bdrv_inactivate() fails now (as in assertion failure) if it has anything to flush to the image because bs->file has already be inactivated before. I think children need to be inactived after their parents. Nodes with multiple parents could actually become even more interesting... Kevin > block.c | 8 ++++++++ > 1 file changed, 8 insertions(+) > > diff --git a/block.c b/block.c > index fa8b38f..9a84ed1 100644 > --- a/block.c > +++ b/block.c > @@ -3260,8 +3260,16 @@ void bdrv_invalidate_cache_all(Error **errp) > > static int bdrv_inactivate(BlockDriverState *bs) > { > + BdrvChild *child; > int ret; > > + QLIST_FOREACH(child, &bs->children, next) { > + ret = bdrv_inactivate(child->bs); > + if (ret < 0) { > + return ret; > + } > + } > + > if (bs->drv->bdrv_inactivate) { > ret = bs->drv->bdrv_inactivate(bs); > if (ret < 0) { > -- > 2.8.0 >