From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45550) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZvigZ-0006FB-Gm for qemu-devel@nongnu.org; Mon, 09 Nov 2015 04:24:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZvigY-0004Hj-MM for qemu-devel@nongnu.org; Mon, 09 Nov 2015 04:24:23 -0500 Sender: Paolo Bonzini References: <1447037808-31886-1-git-send-email-famz@redhat.com> <1447037808-31886-9-git-send-email-famz@redhat.com> From: Paolo Bonzini Message-ID: <5640663E.9020107@redhat.com> Date: Mon, 9 Nov 2015 10:24:14 +0100 MIME-Version: 1.0 In-Reply-To: <1447037808-31886-9-git-send-email-famz@redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v3 8/9] block: Introduce BlockDriver.bdrv_drain callback List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Fam Zheng , qemu-devel@nongnu.org Cc: Kevin Wolf , Ronnie Sahlberg , Peter Lieven , qemu-block@nongnu.org, Stefan Hajnoczi On 09/11/2015 03:56, Fam Zheng wrote: > + if (bs->drv && bs->drv->bdrv_drain) { > + bs->drv->bdrv_drain(bs); > + } > + QLIST_FOREACH(child, &bs->children, next) { > + BlockDriverState *cbs = child->bs; > + if (cbs->drv && cbs->drv->bdrv_drain) { > + cbs->drv->bdrv_drain(bs); > + } > + } I think this is not enough, because the children could have children as well. Perhaps you can do it like bdrv_flush: one function does the call to bdrv_drain and the recursion on children; bdrv_drain calls that one function and then does the "while (busy)" loop. Paolo