Received: from eggs.gnu.org ([2001:4830:134:3::10]:48313) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ayfIA-0006AX-Gf for qemu-devel@nongnu.org; Fri, 06 May 2016 08:55:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ayfHy-0002UI-J0 for qemu-devel@nongnu.org; Fri, 06 May 2016 08:55:33 -0400 References: <1461763231-17598-1-git-send-email-kwolf@redhat.com> <1461763231-17598-8-git-send-email-kwolf@redhat.com> From: Max Reitz Message-ID: <784e60a4-5840-5cdc-4368-638afcac9918@redhat.com> Date: Fri, 6 May 2016 14:54:47 +0200 MIME-Version: 1.0 In-Reply-To: <1461763231-17598-8-git-send-email-kwolf@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="sg38w4JvMlWM6SxbC2ulQhIv4a5bhx5hl" Subject: Re: [Qemu-devel] [PATCH v2 7/9] block: Avoid bs->blk in bdrv_next() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kevin Wolf , qemu-block@nongnu.org Cc: jcody@redhat.com, armbru@redhat.com, eblake@redhat.com, qemu-devel@nongnu.org This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --sg38w4JvMlWM6SxbC2ulQhIv4a5bhx5hl Content-Type: multipart/mixed; boundary="cD8LjhqkDTfWgpKD9CPLrkKSnTduFn6DS" From: Max Reitz To: Kevin Wolf , qemu-block@nongnu.org Cc: jcody@redhat.com, armbru@redhat.com, eblake@redhat.com, qemu-devel@nongnu.org Message-ID: <784e60a4-5840-5cdc-4368-638afcac9918@redhat.com> Subject: Re: [PATCH v2 7/9] block: Avoid bs->blk in bdrv_next() References: <1461763231-17598-1-git-send-email-kwolf@redhat.com> <1461763231-17598-8-git-send-email-kwolf@redhat.com> In-Reply-To: <1461763231-17598-8-git-send-email-kwolf@redhat.com> --cD8LjhqkDTfWgpKD9CPLrkKSnTduFn6DS Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: quoted-printable On 27.04.2016 15:20, Kevin Wolf wrote: > We need to introduce a separate BdrvNextIterator struct that can keep > more state than just the current BDS in order to avoid using the bs->bl= k > pointer. >=20 > Signed-off-by: Kevin Wolf > --- > block.c | 34 ++++++-------------- > block/block-backend.c | 72 +++++++++++++++++++++++++++++-----= -------- > block/io.c | 13 ++++---- > block/snapshot.c | 30 +++++++++++------- > blockdev.c | 3 +- > include/block/block.h | 3 +- > include/sysemu/block-backend.h | 1 - > migration/block.c | 4 ++- > monitor.c | 6 ++-- > qmp.c | 5 ++- > 10 files changed, 99 insertions(+), 72 deletions(-) Reviewed-by: Max Reitz [...] > @@ -394,21 +417,26 @@ BlockDriverState *blk_bs(BlockBackend *blk) > return blk->root ? blk->root->bs : NULL; > } > =20 > -/* > - * Returns true if @bs has an associated BlockBackend. > - */ > -bool bdrv_has_blk(BlockDriverState *bs) > +static BlockBackend *bdrv_first_blk(BlockDriverState *bs) > { > BdrvChild *child; > QLIST_FOREACH(child, &bs->parents, next_parent) { > if (child->role =3D=3D &child_root) { > assert(bs->blk); > - return true; > + return child->opaque; > } > } > =20 > assert(!bs->blk); > - return false; > + return NULL; > +} > + > +/* > + * Returns true if @bs has an associated BlockBackend. > + */ > +bool bdrv_has_blk(BlockDriverState *bs) > +{ > + return bdrv_first_blk(bs) !=3D NULL; > } Not sure whether I'm supposed to, but I find this pretty clever. Nice. Max --cD8LjhqkDTfWgpKD9CPLrkKSnTduFn6DS-- --sg38w4JvMlWM6SxbC2ulQhIv4a5bhx5hl Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBCAAGBQJXLJQXAAoJEDuxQgLoOKytSmMH/iCkoJBQq89wbg54Q9Tl5LGL IEF9jZdUyMQIBjgNRh7jdaXqBQkwF7/rXpa/xhIkyBdEf2CiOHnUIm7xTHnFRwRR j1YvOXzuMC+O0JEinhR7WNFofmcq9hGZlyms/vfxdh8KD2xpWuDXjUd9hhC7lRwr cKbQGC28L7Hhi7v6egxiWcSHG2x0/kKEVCzfb7OQ+Rs7ZX5M5ns/VLQGItvxIcNg TFgUvR4QthwfkyQaJFAElUlR3rscpnAKbG65FWN+2HoHIhWEgUFeDqfV2p46MlgB gmQCeXB/SesL7GYwU9mkDxzlyBXYXurhvgMg564RnaJHaqvqCb1c/rlt8gNTItw= =jlx3 -----END PGP SIGNATURE----- --sg38w4JvMlWM6SxbC2ulQhIv4a5bhx5hl--