Received: from eggs.gnu.org ([2001:4830:134:3::10]:57056) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZeOmK-0006Fp-PG for qemu-devel@nongnu.org; Tue, 22 Sep 2015 10:42:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZeOmI-0005XE-2d for qemu-devel@nongnu.org; Tue, 22 Sep 2015 10:42:44 -0400 Date: Tue, 22 Sep 2015 16:42:29 +0200 From: Kevin Wolf Message-ID: <20150922144229.GG3999@noname.str.redhat.com> References: <1442589793-7105-1-git-send-email-mreitz@redhat.com> <1442589793-7105-22-git-send-email-mreitz@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1442589793-7105-22-git-send-email-mreitz@redhat.com> Subject: Re: [Qemu-devel] [PATCH v5 21/38] block: Add blk_insert_bs() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Max Reitz Cc: Alberto Garcia , qemu-block@nongnu.org, John Snow , qemu-devel@nongnu.org, Markus Armbruster , Stefan Hajnoczi 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 > Reviewed-by: Eric Blake > Reviewed-by: Alberto Garcia > --- > 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