]> git.proxmox.com Git - qemu.git/commitdiff
pc_sysfw: Check for qemu_find_file() failure
authorMarkus Armbruster <armbru@redhat.com>
Wed, 5 Dec 2012 14:28:05 +0000 (15:28 +0100)
committerStefan Hajnoczi <stefanha@redhat.com>
Fri, 4 Jan 2013 13:38:04 +0000 (14:38 +0100)
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 <armbru@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
hw/pc_sysfw.c

index 87e1fa961b52ea69bf1e6d2fb418c320f3262dfe..7567593a63e8031da3ff77ac7bec25dd799aefae 100644 (file)
@@ -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");