From patchwork Fri Oct 23 17:00:54 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 535090 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 91D2C140DAE for ; Sat, 24 Oct 2015 04:06:22 +1100 (AEDT) Received: from localhost ([::1]:39931 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZpfnI-000715-Hb for incoming@patchwork.ozlabs.org; Fri, 23 Oct 2015 13:06:20 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54692) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zpfis-0007H4-0k for qemu-devel@nongnu.org; Fri, 23 Oct 2015 13:01:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zpfir-0006d5-9R for qemu-devel@nongnu.org; Fri, 23 Oct 2015 13:01:45 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39999) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zpfio-0006cH-3u; Fri, 23 Oct 2015 13:01:42 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id BA9A4AA7; Fri, 23 Oct 2015 17:01:41 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-127.ams2.redhat.com [10.36.116.127]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t9NH1RSG019423; Fri, 23 Oct 2015 13:01:39 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Fri, 23 Oct 2015 19:00:54 +0200 Message-Id: <1445619684-18216-8-git-send-email-kwolf@redhat.com> In-Reply-To: <1445619684-18216-1-git-send-email-kwolf@redhat.com> References: <1445619684-18216-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org Subject: [Qemu-devel] [PULL 07/37] block: Make bdrv_is_inserted() recursive 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 From: Max Reitz If bdrv_is_inserted() is called on the top level BDS, it should make sure all nodes in the BDS tree are actually inserted. Signed-off-by: Max Reitz Reviewed-by: Eric Blake Reviewed-by: Kevin Wolf Signed-off-by: Kevin Wolf --- block.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/block.c b/block.c index bdd3338..bb8c067 100644 --- a/block.c +++ b/block.c @@ -3143,14 +3143,20 @@ void bdrv_invalidate_cache_all(Error **errp) bool bdrv_is_inserted(BlockDriverState *bs) { BlockDriver *drv = bs->drv; + BdrvChild *child; if (!drv) { return false; } - if (!drv->bdrv_is_inserted) { - return true; + if (drv->bdrv_is_inserted) { + return drv->bdrv_is_inserted(bs); } - return drv->bdrv_is_inserted(bs); + QLIST_FOREACH(child, &bs->children, next) { + if (!bdrv_is_inserted(child->bs)) { + return false; + } + } + return true; } /**