From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48334) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YGCnV-0007SP-JY for qemu-devel@nongnu.org; Tue, 27 Jan 2015 15:31:42 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YGCnS-0001K7-FG for qemu-devel@nongnu.org; Tue, 27 Jan 2015 15:31:41 -0500 Received: from mx1.redhat.com ([209.132.183.28]:34756) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YGCnS-0001Jv-7l for qemu-devel@nongnu.org; Tue, 27 Jan 2015 15:31:38 -0500 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t0RKVZlh028342 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Tue, 27 Jan 2015 15:31:37 -0500 From: Max Reitz Date: Tue, 27 Jan 2015 14:45:47 -0500 Message-Id: <1422387983-32153-15-git-send-email-mreitz@redhat.com> In-Reply-To: <1422387983-32153-1-git-send-email-mreitz@redhat.com> References: <1422387983-32153-1-git-send-email-mreitz@redhat.com> Subject: [Qemu-devel] [PATCH RESEND 14/50] block: Make some BB functions fall back to BBRS List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Kevin Wolf , Fam Zheng , Jeff Cody , Markus Armbruster , Max Reitz , Stefan Hajnoczi , John Snow If there is no BDS tree attached to a BlockBackend, functions that can do so should fall back to the BlockBackendRootState structure (which are blk_is_read_only() and blk_get_flags(), because the read-only status and the "open flags" are part of the BBRS). Signed-off-by: Max Reitz --- block/block-backend.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/block/block-backend.c b/block/block-backend.c index 7be03ee..62be370 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -829,7 +829,11 @@ void blk_error_action(BlockBackend *blk, BlockErrorAction action, int blk_is_read_only(BlockBackend *blk) { - return bdrv_is_read_only(blk->bs); + if (blk->bs) { + return bdrv_is_read_only(blk->bs); + } else { + return blk->root_state.read_only; + } } int blk_is_sg(BlockBackend *blk) @@ -874,7 +878,11 @@ void blk_eject(BlockBackend *blk, bool eject_flag) int blk_get_flags(BlockBackend *blk) { - return bdrv_get_flags(blk->bs); + if (blk->bs) { + return bdrv_get_flags(blk->bs); + } else { + return blk->root_state.open_flags; + } } void blk_set_guest_block_size(BlockBackend *blk, int align) -- 2.1.0