qemu-block
[Top][All Lists]
Advanced

[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: Kevin Wolf
Subject: Re: [Qemu-block] [PATCH 11/16] block-backend: Add blk_set_bs()
Date: Wed, 23 Sep 2015 17:51:37 +0200
User-agent: Mutt/1.5.21 (2010-09-15)

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 <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),

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

Attachment: pgpz0bUz43GnL.pgp
Description: PGP signature


reply via email to

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