qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v2 7/9] block: Avoid bs->blk in bdrv_next()


From: Max Reitz
Subject: Re: [Qemu-devel] [PATCH v2 7/9] block: Avoid bs->blk in bdrv_next()
Date: Fri, 6 May 2016 14:54:47 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.0

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 <address@hidden>
> ---
>  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 <address@hidden>

[...]

> @@ -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

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]