[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-block] [PATCH 11/16] block-backend: Add blk_set_bs()
From: |
Max Reitz |
Subject: |
Re: [Qemu-block] [PATCH 11/16] block-backend: Add blk_set_bs() |
Date: |
Wed, 23 Sep 2015 17:46:04 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 |
On 17.09.2015 15:48, Kevin Wolf wrote:
> It allows changing the BlockDriverState that a BlockBackend points to.
>
> Signed-off-by: Kevin Wolf <address@hidden>
> ---
> block/block-backend.c | 16 ++++++++++++++++
> include/block/block_int.h | 2 ++
> 2 files changed, 18 insertions(+)
>
> diff --git a/block/block-backend.c b/block/block-backend.c
> index c2e8732..a2afcff 100644
> --- a/block/block-backend.c
> +++ b/block/block-backend.c
> @@ -239,6 +239,22 @@ BlockDriverState *blk_bs(BlockBackend *blk)
> }
>
> /*
> + * Changes the BlockDriverState attached to @blk
> + */
> +void blk_set_bs(BlockBackend *blk, BlockDriverState *bs)
> +{
> + bdrv_ref(bs);
> +
> + if (blk->bs) {
> + blk->bs->blk = NULL;
> + bdrv_unref(blk->bs);
> + }
> +
> + blk->bs = bs;
> + bs->blk = blk;
> +}
> +
> +/*
As discussed in the BlockBackend and media thread, you should probably
assert(bs->blk == NULL), and I'd rather have this implemented as
blk_remove_bs(blk); blk_insert_bs(blk, bs);, but that's probably
something that won't happen until I do so myself.
Max
> * Return @blk's DriveInfo if any, else null.
> */
> DriveInfo *blk_legacy_dinfo(BlockBackend *blk)
> diff --git a/include/block/block_int.h b/include/block/block_int.h
> index 4598101..cfcae52 100644
> --- a/include/block/block_int.h
> +++ b/include/block/block_int.h
> @@ -659,6 +659,8 @@ void backup_start(BlockDriverState *bs, BlockDriverState
> *target,
> BlockCompletionFunc *cb, void *opaque,
> Error **errp);
>
> +void blk_set_bs(BlockBackend *blk, BlockDriverState *bs);
> +
> void blk_dev_change_media_cb(BlockBackend *blk, bool load);
> bool blk_dev_has_removable_media(BlockBackend *blk);
> void blk_dev_eject_request(BlockBackend *blk, bool force);
>
signature.asc
Description: OpenPGP digital signature
[Qemu-block] [PATCH 14/16] blockjob: Store device name at job creation, Kevin Wolf, 2015/09/17
[Qemu-block] [PATCH 12/16] block: Introduce parents list, Kevin Wolf, 2015/09/17