From patchwork Fri Jan 4 13:55:45 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Hajnoczi X-Patchwork-Id: 209459 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 874C62C0084 for ; Sat, 5 Jan 2013 00:56:37 +1100 (EST) Received: from localhost ([::1]:32956 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tr7lD-00020j-Mb for incoming@patchwork.ozlabs.org; Fri, 04 Jan 2013 08:56:35 -0500 Received: from eggs.gnu.org ([208.118.235.92]:40793) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tr7kt-0001h1-AZ for qemu-devel@nongnu.org; Fri, 04 Jan 2013 08:56:18 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Tr7kl-0007QO-8g for qemu-devel@nongnu.org; Fri, 04 Jan 2013 08:56:15 -0500 Received: from mx1.redhat.com ([209.132.183.28]:24796) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tr7kl-0007QE-1V for qemu-devel@nongnu.org; Fri, 04 Jan 2013 08:56:07 -0500 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r04Du6HX024988 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 4 Jan 2013 08:56:06 -0500 Received: from localhost (ovpn-112-35.ams2.redhat.com [10.36.112.35]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r04Du5il000405; Fri, 4 Jan 2013 08:56:05 -0500 From: Stefan Hajnoczi To: Date: Fri, 4 Jan 2013 14:55:45 +0100 Message-Id: <1357307750-1966-2-git-send-email-stefanha@redhat.com> In-Reply-To: <1357307750-1966-1-git-send-email-stefanha@redhat.com> References: <1357307750-1966-1-git-send-email-stefanha@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Anthony Liguori , Markus Armbruster , Stefan Hajnoczi Subject: [Qemu-devel] [PATCH 1/6] pc_sysfw: Check for qemu_find_file() failure X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Markus Armbruster pc_fw_add_pflash_drv() ignores qemu_find_file() failure, and happily creates a drive without a medium. When pc_system_flash_init() asks for its size, bdrv_getlength() fails with -ENOMEDIUM, which isn't checked either. It fails relatively cleanly only because -ENOMEDIUM isn't a multiple of 4096: $ qemu-system-x86_64 -S -vnc :0 -bios nonexistant qemu: PC system firmware (pflash) must be a multiple of 0x1000 [Exit 1 ] Fix by handling the qemu_find_file() failure. Signed-off-by: Markus Armbruster Signed-off-by: Stefan Hajnoczi --- hw/pc_sysfw.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hw/pc_sysfw.c b/hw/pc_sysfw.c index 87e1fa9..7567593 100644 --- a/hw/pc_sysfw.c +++ b/hw/pc_sysfw.c @@ -84,6 +84,10 @@ static void pc_fw_add_pflash_drv(void) bios_name = BIOS_FILENAME; } filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name); + if (!filename) { + error_report("Can't open BIOS image %s", bios_name); + exit(1); + } opts = drive_add(IF_PFLASH, -1, filename, "readonly=on");