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 <mre...@redhat.com> > Reviewed-by: Eric Blake <ebl...@redhat.com> > Reviewed-by: Alberto Garcia <be...@igalia.com> > --- > 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