From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38149) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YGCDv-0004ML-5z for qemu-devel@nongnu.org; Tue, 27 Jan 2015 14:54:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YGCDo-0004uf-7a for qemu-devel@nongnu.org; Tue, 27 Jan 2015 14:54:54 -0500 Received: from mx1.redhat.com ([209.132.183.28]:51993) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YGCDo-0004uZ-1S for qemu-devel@nongnu.org; Tue, 27 Jan 2015 14:54:48 -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 t0RJsl5m015081 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Tue, 27 Jan 2015 14:54:47 -0500 From: Max Reitz Date: Tue, 27 Jan 2015 14:45:50 -0500 Message-Id: <1422387983-32153-18-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 17/50] block: Respect empty BB in bdrv_lookup_bs() 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 blk_by_name() may return a BlockBackend for which blk_bs() returns NULL. In this case, an error should be returned (instead of just returning NULL without modifying *errp). Signed-off-by: Max Reitz --- block.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/block.c b/block.c index 9a0a510..b7e631c 100644 --- a/block.c +++ b/block.c @@ -3718,6 +3718,11 @@ BlockDriverState *bdrv_lookup_bs(const char *device, blk = blk_by_name(device); if (blk) { + if (!blk_bs(blk)) { + error_set(errp, QERR_DEVICE_HAS_NO_MEDIUM, device); + return NULL; + } + return blk_bs(blk); } } -- 2.1.0