qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH] pc_sysfw: old_pc_system_rom_init(): improve error m


From: Luiz Capitulino
Subject: [Qemu-devel] [PATCH] pc_sysfw: old_pc_system_rom_init(): improve error messages
Date: Thu, 28 Jun 2012 13:58:09 -0300

Also say why loading the bios has failed.

Signed-off-by: Luiz Capitulino <address@hidden>
---
 hw/pc_sysfw.c | 27 +++++++++++++++++++--------
 1 file changed, 19 insertions(+), 8 deletions(-)

diff --git a/hw/pc_sysfw.c b/hw/pc_sysfw.c
index b45f0ac..5670651 100644
--- a/hw/pc_sysfw.c
+++ b/hw/pc_sysfw.c
@@ -144,23 +144,28 @@ static void old_pc_system_rom_init(MemoryRegion 
*rom_memory)
         bios_name = BIOS_FILENAME;
     }
     filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
-    if (filename) {
-        bios_size = get_image_size(filename);
-    } else {
-        bios_size = -1;
+    if (!filename) {
+        goto exit_err;
+    }
+
+    bios_size = get_image_size(filename);
+    if (bios_size < 0) {
+        goto exit_err;
     }
-    if (bios_size <= 0 ||
+
+    if (bios_size == 0 ||
         (bios_size % 65536) != 0) {
-        goto bios_error;
+        fprintf(stderr, "qemu: PC BIOS '%s' has bad size (%d bytes)\n",
+                bios_name, bios_size);
+        exit(1);
     }
+
     bios = g_malloc(sizeof(*bios));
     memory_region_init_ram(bios, "pc.bios", bios_size);
     vmstate_register_ram_global(bios);
     memory_region_set_readonly(bios, true);
     ret = rom_add_file_fixed(bios_name, (uint32_t)(-bios_size), -1);
     if (ret != 0) {
-    bios_error:
-        fprintf(stderr, "qemu: could not load PC BIOS '%s'\n", bios_name);
         exit(1);
     }
     if (filename) {
@@ -185,6 +190,12 @@ static void old_pc_system_rom_init(MemoryRegion 
*rom_memory)
     memory_region_add_subregion(rom_memory,
                                 (uint32_t)(-bios_size),
                                 bios);
+    return;
+
+exit_err:
+    fprintf(stderr, "qemu: could not load PC BIOS '%s' (%s)\n", bios_name,
+            strerror(errno));
+    exit(1);
 }
 
 void pc_system_firmware_init(MemoryRegion *rom_memory)
-- 
1.7.10.2.565.gbd578b5




reply via email to

[Prev in Thread] Current Thread [Next in Thread]