From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:43225) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tbxjl-000246-Ez for qemu-devel@nongnu.org; Fri, 23 Nov 2012 13:12:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Tbxjj-0001Wq-As for qemu-devel@nongnu.org; Fri, 23 Nov 2012 13:12:25 -0500 From: Markus Armbruster Date: Fri, 23 Nov 2012 19:12:17 +0100 Message-Id: <1353694338-13162-2-git-send-email-armbru@redhat.com> In-Reply-To: <1353694338-13162-1-git-send-email-armbru@redhat.com> References: <1353694338-13162-1-git-send-email-armbru@redhat.com> Subject: [Qemu-devel] [PATCH 1/2] pc_sysfw: Check for qemu_find_file() failure List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: qemu-trivial@nongnu.org, jordan.l.justen@intel.com 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 --- hw/pc_sysfw.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/hw/pc_sysfw.c b/hw/pc_sysfw.c index 9d7c5f4..066c4fe 100644 --- a/hw/pc_sysfw.c +++ b/hw/pc_sysfw.c @@ -84,6 +84,11 @@ 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: %s", + bios_name, strerror(errno)); + exit(1); + } opts = drive_add(IF_PFLASH, -1, filename, "readonly=on"); -- 1.7.11.7