From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42859) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wz1Qa-0005uF-7Q for qemu-devel@nongnu.org; Mon, 23 Jun 2014 06:24:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Wz1QR-0007ed-6X for qemu-devel@nongnu.org; Mon, 23 Jun 2014 06:24:44 -0400 Received: from lputeaux-656-01-25-125.w80-12.abo.wanadoo.fr ([80.12.84.125]:51910 helo=paradis.irqsave.net) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wz1QR-0007eY-0t for qemu-devel@nongnu.org; Mon, 23 Jun 2014 06:24:35 -0400 Date: Mon, 23 Jun 2014 12:24:32 +0200 From: =?iso-8859-1?Q?Beno=EEt?= Canet Message-ID: <20140623102432.GA24725@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 v6 for 2.1 02/10] 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 Tuesday 17 Jun 2014 =E0 17:53:50 (-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 > Reviewed-by: Benoit Canet > Reviewed-by: Eric Blake > Signed-off-by: Jeff Cody > --- > block.c | 11 +++++++++++ > include/block/block.h | 1 + > 2 files changed, 12 insertions(+) >=20 > diff --git a/block.c b/block.c > index da32bb0..280a167 100644 > --- a/block.c > +++ b/block.c > @@ -3819,6 +3819,17 @@ BlockDriverState *bdrv_lookup_bs(const char *dev= ice, > return NULL; > } > =20 > +/* If 'base' is in the same chain as 'top', return true. Otherwise, > + * return false. If either argument is NULL, return false. */ > +bool bdrv_chain_contains(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 f15b99b..c60bd52 100644 > --- a/include/block/block.h > +++ b/include/block/block.h > @@ -403,6 +403,7 @@ BlockDeviceInfoList *bdrv_named_nodes_list(void); > BlockDriverState *bdrv_lookup_bs(const char *device, > const char *node_name, > Error **errp); > +bool bdrv_chain_contains(BlockDriverState *top, BlockDriverState *base= ); > BlockDriverState *bdrv_next(BlockDriverState *bs); > void bdrv_iterate(void (*it)(void *opaque, BlockDriverState *bs), > void *opaque); > --=20 > 1.9.3 >=20 >=20 I know I rev by this patch but it now appears we will probably need to ex= tend this function to work with multiple children BDS. Jeff do you prefer to take care of this in this series or should I rework= it later in my quorum maintainance series ? Best regards Beno=EEt