|
From: | Max Reitz |
Subject: | Re: [Qemu-devel] [PATCH RESEND 16/50] block: Prepare remaining BB functions for NULL BDS |
Date: | Tue, 27 Jan 2015 16:39:29 -0500 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 |
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 <address@hidden> --- 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 <address@hidden>
[Prev in Thread] | Current Thread | [Next in Thread] |