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->blk > pointer. > > Signed-off-by: Kevin Wolf <[email protected]> > --- > 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 <[email protected]> [...] > @@ -394,21 +417,26 @@ BlockDriverState *blk_bs(BlockBackend *blk) > return blk->root ? blk->root->bs : NULL; > } > > -/* > - * 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 == &child_root) { > assert(bs->blk); > - return true; > + return child->opaque; > } > } > > 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) != NULL; > } Not sure whether I'm supposed to, but I find this pretty clever. Nice. Max
signature.asc
Description: OpenPGP digital signature
