From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35638) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YGDrC-0006II-TJ for qemu-devel@nongnu.org; Tue, 27 Jan 2015 16:39:35 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YGDr9-0000in-NH for qemu-devel@nongnu.org; Tue, 27 Jan 2015 16:39:34 -0500 Received: from mx1.redhat.com ([209.132.183.28]:50067) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YGDr9-0000ij-Dx for qemu-devel@nongnu.org; Tue, 27 Jan 2015 16:39:31 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t0RLdU6v027598 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Tue, 27 Jan 2015 16:39:31 -0500 Message-ID: <54C80591.7030503@redhat.com> Date: Tue, 27 Jan 2015 16:39:29 -0500 From: Max Reitz MIME-Version: 1.0 References: <1422387983-32153-1-git-send-email-mreitz@redhat.com> <1422387983-32153-17-git-send-email-mreitz@redhat.com> <54C804C6.4040409@redhat.com> In-Reply-To: <54C804C6.4040409@redhat.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH RESEND 16/50] block: Prepare remaining BB functions for NULL BDS 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-27 at 16:36, Eric Blake wrote: > On 01/27/2015 12:45 PM, Max Reitz wrote: >> There are several BlockBackend functions which, in theory, cannot fail. >> This patch makes them cope with the BlockDriverState pointer being NULL >> by making them fall back to some default action like ignoring the value >> in setters and returning the default in getters. >> >> Signed-off-by: Max Reitz >> --- >> block/block-backend.c | 70 ++++++++++++++++++++++++++++++++++++++++----------- >> 1 file changed, 55 insertions(+), 15 deletions(-) >> >> @@ -926,22 +944,32 @@ void *blk_blockalign(BlockBackend *blk, size_t size) >> >> bool blk_op_is_blocked(BlockBackend *blk, BlockOpType op, Error **errp) >> { >> + if (!blk->bs) { >> + return false; >> + } >> + >> return bdrv_op_is_blocked(blk->bs, op, errp); >> } > I don't know if this is correct - maybe a no-medium drive should block > actions like commit by default? Somehow I don't think they should be blocked. For instance, commit will fail the instant you actually try to commit something (that is, read some data or access the backing hierarchy). Generally, I think we don't need to block operations on an empty BlockBackend due to the fact that any operation will fail anyway. Max > If my design question gets answered satisfactorily that you went with > the right default, then > > Reviewed-by: Eric Blake >