[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
- [Qemu-block] [PATCH v5 16/38] block: Move I/O status and error actions into BB, (continued)
- [Qemu-block] [PATCH v5 20/38] block: Prepare remaining BB functions for NULL BDS, Max Reitz, 2015/09/18
- [Qemu-block] [PATCH v5 21/38] block: Add blk_insert_bs(), Max Reitz, 2015/09/18
- Re: [Qemu-block] [PATCH v5 21/38] block: Add blk_insert_bs(),
Kevin Wolf <=
- [Qemu-block] [PATCH v5 22/38] block: Prepare for NULL BDS, Max Reitz, 2015/09/18
- [Qemu-block] [PATCH v5 23/38] blockdev: Do not create BDS for empty drive, Max Reitz, 2015/09/18
- [Qemu-block] [PATCH v5 24/38] blockdev: Pull out blockdev option extraction, Max Reitz, 2015/09/18
- [Qemu-block] [PATCH v5 26/38] block: Add blk_remove_bs(), Max Reitz, 2015/09/18
- [Qemu-block] [PATCH v5 25/38] blockdev: Allow more options for BB-less BDS tree, Max Reitz, 2015/09/18
- [Qemu-block] [PATCH v5 27/38] blockdev: Add blockdev-open-tray, Max Reitz, 2015/09/18
- [Qemu-block] [PATCH v5 28/38] blockdev: Add blockdev-close-tray, Max Reitz, 2015/09/18
- [Qemu-block] [PATCH v5 29/38] blockdev: Add blockdev-remove-medium, Max Reitz, 2015/09/18