* [PATCH] Qemu : Add the check before reading guest firmware
@ 2008-01-03 9:32 Zhang, Xiantao
[not found] ` <42DFA526FC41B1429CE7279EF83C6BDCBB7B7A-wq7ZOvIWXbMAbVU2wMM1CrfspsVTdybXVpNB7YpNyf8@public.gmane.org>
0 siblings, 1 reply; 2+ messages in thread
From: Zhang, Xiantao @ 2008-01-03 9:32 UTC (permalink / raw)
To: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f; +Cc: Avi Kivity
[-- Attachment #1: Type: text/plain, Size: 2897 bytes --]
>From 1099b09bcdde9a80c5b0383cd063af6ad9ca18e5 Mon Sep 17 00:00:00 2001
From: Zhang Xiantao <xiantao.zhang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Date: Thu, 3 Jan 2008 17:22:36 +0800
Subject: [PATCH] kvm: qemu : Add check for guest firmware.
Add the existence check before reading the image.
Signed-off-by: Zhang Xiantao <xiantao.zhang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
---
qemu/hw/ipf.c | 3 ++-
qemu/target-ia64/firmware.c | 18 +++++++++++++-----
qemu/target-ia64/firmware.h | 2 +-
3 files changed, 16 insertions(+), 7 deletions(-)
diff --git a/qemu/hw/ipf.c b/qemu/hw/ipf.c
index d8e1184..eb4cac3 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..edabd70 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);
--
1.5.2
[-- Attachment #2: 0002-kvm-qemu-Add-check-for-guest-firmware.patch --]
[-- Type: application/octet-stream, Size: 2740 bytes --]
From 1099b09bcdde9a80c5b0383cd063af6ad9ca18e5 Mon Sep 17 00:00:00 2001
From: Zhang Xiantao <xiantao.zhang@intel.com>
Date: Thu, 3 Jan 2008 17:22:36 +0800
Subject: [PATCH] kvm: qemu : Add check for guest firmware.
Add the existence check before reading the image.
Signed-off-by: Zhang Xiantao <xiantao.zhang@intel.com>
---
qemu/hw/ipf.c | 3 ++-
qemu/target-ia64/firmware.c | 18 +++++++++++++-----
qemu/target-ia64/firmware.h | 2 +-
3 files changed, 16 insertions(+), 7 deletions(-)
diff --git a/qemu/hw/ipf.c b/qemu/hw/ipf.c
index d8e1184..eb4cac3 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..edabd70 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);
--
1.5.2
[-- Attachment #3: Type: text/plain, Size: 228 bytes --]
-------------------------------------------------------------------------
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/
[-- Attachment #4: Type: text/plain, Size: 186 bytes --]
_______________________________________________
kvm-devel mailing list
kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/kvm-devel
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] Qemu : Add the check before reading guest firmware
[not found] ` <42DFA526FC41B1429CE7279EF83C6BDCBB7B7A-wq7ZOvIWXbMAbVU2wMM1CrfspsVTdybXVpNB7YpNyf8@public.gmane.org>
@ 2008-01-03 15:42 ` Avi Kivity
0 siblings, 0 replies; 2+ messages in thread
From: Avi Kivity @ 2008-01-03 15:42 UTC (permalink / raw)
To: Zhang, Xiantao; +Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f
Zhang, Xiantao wrote:
> >From 1099b09bcdde9a80c5b0383cd063af6ad9ca18e5 Mon Sep 17 00:00:00 2001
> From: Zhang Xiantao <xiantao.zhang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
> Date: Thu, 3 Jan 2008 17:22:36 +0800
> Subject: [PATCH] kvm: qemu : Add check for guest firmware.
>
> Add the existence check before reading the image.
>
Applied, thanks.
--
error compiling committee.c: too many arguments to function
-------------------------------------------------------------------------
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/
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2008-01-03 15:42 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-01-03 9:32 [PATCH] Qemu : Add the check before reading guest firmware Zhang, Xiantao
[not found] ` <42DFA526FC41B1429CE7279EF83C6BDCBB7B7A-wq7ZOvIWXbMAbVU2wMM1CrfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2008-01-03 15:42 ` Avi Kivity
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox