From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33629) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wku8V-0007IB-Cs for qemu-devel@nongnu.org; Thu, 15 May 2014 07:47:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Wku8M-0004VL-HC for qemu-devel@nongnu.org; Thu, 15 May 2014 07:47:43 -0400 Received: from lputeaux-656-01-25-125.w80-12.abo.wanadoo.fr ([80.12.84.125]:37599 helo=paradis.irqsave.net) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wku8M-0004VH-Bl for qemu-devel@nongnu.org; Thu, 15 May 2014 07:47:34 -0400 Date: Thu, 15 May 2014 13:48:08 +0200 From: =?iso-8859-1?Q?Beno=EEt?= Canet Message-ID: <20140515114808.GE2812@irqsave.net> References: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH 2/5] block: add helper function to determine if a BDS is in a chain List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Jeff Cody Cc: kwolf@redhat.com, benoit.canet@irqsave.net, pkrempa@redhat.com, famz@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com The Wednesday 14 May 2014 =E0 23:20:16 (-0400), Jeff Cody wrote : > This is a small helper function, to determine if 'base' is in the > chain of BlockDriverState 'top'. It returns true if it is in the chain= , > and false otherwise. >=20 > If either argument is NULL, it will also return false. >=20 > Signed-off-by: Jeff Cody > --- > block.c | 9 +++++++++ > include/block/block.h | 1 + > 2 files changed, 10 insertions(+) >=20 > diff --git a/block.c b/block.c > index 81945d3..c4f77c2 100644 > --- a/block.c > +++ b/block.c > @@ -3734,6 +3734,15 @@ BlockDriverState *bdrv_lookup_bs(const char *dev= ice, > return NULL; > } > =20 > +bool bdrv_is_in_chain(BlockDriverState *top, BlockDriverState *base) > +{ > + while (top && top !=3D base) { > + top =3D top->backing_hd; > + } > + > + return top !=3D NULL; > +} > + > BlockDriverState *bdrv_next(BlockDriverState *bs) > { > if (!bs) { > diff --git a/include/block/block.h b/include/block/block.h > index 1b119aa..283a6f3 100644 > --- a/include/block/block.h > +++ b/include/block/block.h > @@ -381,6 +381,7 @@ BlockDeviceInfoList *bdrv_named_nodes_list(void); > BlockDriverState *bdrv_lookup_bs(const char *device, > const char *node_name, > Error **errp); > +bool bdrv_is_in_chain(BlockDriverState *top, BlockDriverState *base); > BlockDriverState *bdrv_next(BlockDriverState *bs); > void bdrv_iterate(void (*it)(void *opaque, BlockDriverState *bs), > void *opaque); > --=20 > 1.8.3.1 >=20 Reviewed-by: Benoit Canet