From patchwork Fri Jan 4 13:55:45 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [1/6] pc_sysfw: Check for qemu_find_file() failure Date: Fri, 04 Jan 2013 03:55:45 -0000 From: Stefan Hajnoczi X-Patchwork-Id: 209459 Message-Id: <1357307750-1966-2-git-send-email-stefanha@redhat.com> To: Cc: Anthony Liguori , Markus Armbruster , Stefan Hajnoczi 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");