From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37092) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YGVxI-0008JP-VK for qemu-devel@nongnu.org; Wed, 28 Jan 2015 11:59:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YGVxG-0002wO-7V for qemu-devel@nongnu.org; Wed, 28 Jan 2015 11:59:04 -0500 Received: from mx1.redhat.com ([209.132.183.28]:46185) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YGVxF-0002wC-Vb for qemu-devel@nongnu.org; Wed, 28 Jan 2015 11:59:02 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t0SGx02U016329 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Wed, 28 Jan 2015 11:59:01 -0500 Message-ID: <54C91552.6070803@redhat.com> Date: Wed, 28 Jan 2015 11:58:58 -0500 From: Max Reitz MIME-Version: 1.0 References: <1422387983-32153-1-git-send-email-mreitz@redhat.com> <1422387983-32153-32-git-send-email-mreitz@redhat.com> <54C913DB.3060505@redhat.com> In-Reply-To: <54C913DB.3060505@redhat.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH RESEND 31/50] block: Add blk_insert_bs() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake , qemu-devel@nongnu.org Cc: Kevin Wolf , Fam Zheng , Jeff Cody , Markus Armbruster , Stefan Hajnoczi , John Snow On 2015-01-28 at 11:52, Eric Blake wrote: > On 01/27/2015 12:46 PM, Max Reitz wrote: >> This function associates the given BlockDriverState with the given >> BlockBackend. >> >> Signed-off-by: Max Reitz >> --- >> 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 760558f..656ebfc 100644 >> --- a/block/block-backend.c >> +++ b/block/block-backend.c >> @@ -312,6 +312,22 @@ void blk_hide_on_behalf_of_do_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); > I guess this interesting code allows for idempotent use of blk_insert_bs > more than once? What situations require that usage pattern? Well, to be honest, there is no such requirement. I could (probably) have just omitted the condition before the assertion; but I just felt like it would be perfectly valid for this function to be idempotent which is why the condition is there. > At any rate, the new function looks fine. > Reviewed-by: Eric Blake Once again, thank you! Max