qemu-block
[Top][All Lists]
Advanced

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

Re: [Qemu-block] [PATCH v5 21/38] block: Add blk_insert_bs()


From: Kevin Wolf
Subject: Re: [Qemu-block] [PATCH v5 21/38] block: Add blk_insert_bs()
Date: Tue, 22 Sep 2015 16:42:29 +0200
User-agent: Mutt/1.5.21 (2010-09-15)

Am 18.09.2015 um 17:22 hat Max Reitz geschrieben:
> This function associates the given BlockDriverState with the given
> BlockBackend.
> 
> Signed-off-by: Max Reitz <address@hidden>
> Reviewed-by: Eric Blake <address@hidden>
> Reviewed-by: Alberto Garcia <address@hidden>
> ---
>  block/block-backend.c          | 16 ++++++++++++++++
>  include/sysemu/block-backend.h |  1 +
>  2 files changed, 17 insertions(+)
> 
> diff --git a/block/block-backend.c b/block/block-backend.c
> index 33145f8..652385e 100644
> --- a/block/block-backend.c
> +++ b/block/block-backend.c
> @@ -314,6 +314,22 @@ void blk_hide_on_behalf_of_hmp_drive_del(BlockBackend 
> *blk)
>  }
>  
>  /*
> + * Associates a new BlockDriverState with @blk.
> + */
> +void blk_insert_bs(BlockBackend *blk, BlockDriverState *bs)
> +{
> +    if (bs->blk == blk) {
> +        return;
> +    }
> +
> +    assert(!blk->bs);
> +    assert(!bs->blk);

Why is it useful to allow reconnecting a BDS to a BB it's already
connected to? I would have expected that we can assert that this is not
the case.

> +    bdrv_ref(bs);
> +    blk->bs = bs;
> +    bs->blk = blk;
> +}

My series to remove bdrv_swap() introduces a blk_set_bs() function,
which looks suspiciously similar to this one, except that it allows
passing a BB that already had a BDS (it gets unrefed then) and that I
don't assert that the BDS isn't attached to a BB yet (I should do that).

Do you think that's similar enough to have only one function?

Kevin



reply via email to

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