From: Zhang Xiantao <[EMAIL PROTECTED]>

Add the existence check before reading the image.

Signed-off-by: Zhang Xiantao <[EMAIL PROTECTED]>
Signed-off-by: Avi Kivity <[EMAIL PROTECTED]>

diff --git a/qemu/hw/ipf.c b/qemu/hw/ipf.c
index 7ef37d3..100722a 100644
--- a/qemu/hw/ipf.c
+++ b/qemu/hw/ipf.c
@@ -419,7 +419,8 @@ static void ipf_init1(ram_addr_t ram_size, int vga_ram_size,
                image = read_image(buf, &image_size );
                if (NULL == image || !image_size) {
                        fprintf(stderr, "Error when reading Guest Firmware!\n");
-                       return ;
+                       fprintf(stderr, "Please check Guest firmware at %s\n", 
buf);
+                       exit(1);
                }
                fw_image_start = fw_start + GFW_SIZE - image_size;
 
diff --git a/qemu/target-ia64/firmware.c b/qemu/target-ia64/firmware.c
index 51650c8..b8259e0 100644
--- a/qemu/target-ia64/firmware.c
+++ b/qemu/target-ia64/firmware.c
@@ -22,6 +22,10 @@
 #include <string.h>
 #include <stdlib.h>
 #include <zlib.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+
 #include "cpu.h"
 
 #include "firmware.h"
@@ -514,16 +518,17 @@ char *read_image(const char *filename, unsigned long 
*size)
     if ( (filename == NULL) || (size == NULL) )
         return NULL;
 
-    if ( (kernel_fd = open(filename, O_RDONLY)) < 0 )
+    kernel_fd = open(filename, O_RDONLY);
+    if (kernel_fd < 0)
     {
-        Hob_Output("Could not open kernel image");
-        goto out;
+        Hob_Output("Could not open kernel image\n");
+        goto out_1;
     }
 
     if ( (kernel_gfd = gzdopen(kernel_fd, "rb")) == NULL )
     {
-        Hob_Output("Could not allocate decompression state for state file");
-        goto out;
+        Hob_Output("Could not allocate decompression state for state file\n");
+        goto out_1;
     }
 
     *size = 0;
@@ -577,6 +582,9 @@ char *read_image(const char *filename, unsigned long *size)
     else if ( kernel_fd >= 0 )
         close(kernel_fd);
     return image;
+
+out_1:
+    return NULL;
 }
 
 /*
diff --git a/qemu/target-ia64/firmware.h b/qemu/target-ia64/firmware.h
index 1c4e534..dde8b2d 100644
--- a/qemu/target-ia64/firmware.h
+++ b/qemu/target-ia64/firmware.h
@@ -36,7 +36,7 @@
 #define HOB_OFFSET              (GFW_HOB_START-GFW_START)
 
 #define Hob_Output(s) \
-    fprintf(stderr, strcat("HOB:",s))
+    fprintf(stderr, s)
 
 extern int kvm_ia64_build_hob(unsigned long memsize,
             unsigned long vcpus, uint8_t* fw_start);

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
kvm-commits mailing list
kvm-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-commits

Reply via email to