Am 23.09.2015 um 17:46 hat Max Reitz geschrieben: > On 17.09.2015 15:48, Kevin Wolf wrote: > > It allows changing the BlockDriverState that a BlockBackend points to. > > > > Signed-off-by: Kevin Wolf <kw...@redhat.com> > > --- > > 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),
Yes, my current branch has this already. > 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. Let's see which series hits master first. If yours is first, I'll happily change this patch to make use of the new functions; otherwise, you get to rebase. Kevin
pgpjd2n8sLmt8.pgp
Description: PGP signature