qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH 2/5] block: add helper function to determine if


From: Benoît Canet
Subject: Re: [Qemu-devel] [PATCH 2/5] block: add helper function to determine if a BDS is in a chain
Date: Thu, 15 May 2014 13:48:08 +0200
User-agent: Mutt/1.5.23 (2014-03-12)

The Wednesday 14 May 2014 à 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.
> 
> If either argument is NULL, it will also return false.
> 
> Signed-off-by: Jeff Cody <address@hidden>
> ---
>  block.c               | 9 +++++++++
>  include/block/block.h | 1 +
>  2 files changed, 10 insertions(+)
> 
> 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 *device,
>      return NULL;
>  }
>  
> +bool bdrv_is_in_chain(BlockDriverState *top, BlockDriverState *base)
> +{
> +    while (top && top != base) {
> +        top = top->backing_hd;
> +    }
> +
> +    return top != 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);
> -- 
> 1.8.3.1
> 
Reviewed-by: Benoit Canet <address@hidden>



reply via email to

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