[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 6/6] load_linux: change kernel header size alloc
From: |
Blue Swirl |
Subject: |
Re: [Qemu-devel] [PATCH 6/6] load_linux: change kernel header size allocation |
Date: |
Mon, 4 Feb 2013 18:26:08 +0000 |
On Mon, Feb 4, 2013 at 2:27 AM, liguang <address@hidden> wrote:
> it's not necessary to alloc 8K bytes for kernel
> header, 0.5K is enough.
>
> Signed-off-by: liguang <address@hidden>
> ---
> hw/pc.c | 10 ++++++----
> 1 files changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/hw/pc.c b/hw/pc.c
> index 0ccd775..b6b236f 100644
> --- a/hw/pc.c
> +++ b/hw/pc.c
> @@ -637,6 +637,9 @@ static long get_file_size(FILE *f)
> return size;
> }
>
> +#define HEADER_SIZE 0x200
> +#define HEADER_SIGNATURE 0x53726448
> +
> static void load_linux(void *fw_cfg,
> const char *kernel_filename,
> const char *initrd_filename,
> @@ -646,7 +649,7 @@ static void load_linux(void *fw_cfg,
> uint16_t protocol;
> int setup_size, kernel_size, initrd_size = 0, cmdline_size;
> uint32_t initrd_max;
> - uint8_t header[8192], *setup, *kernel, *initrd_data;
> + uint8_t header[HEADER_SIZE], *setup, *kernel, *initrd_data;
> hwaddr real_addr, prot_addr, cmdline_addr, initrd_addr = 0;
> FILE *f;
> char *vmode;
> @@ -665,8 +668,7 @@ static void load_linux(void *fw_cfg,
> fprintf(stderr, "can't get size of kernel image file\n");
> exit(1);
> }
> - if (fread(header, 1, MIN(ARRAY_SIZE(header), kernel_size), f) !=
> - MIN(ARRAY_SIZE(header), kernel_size)) {
> + if (fread(header, 1, HEADER_SIZE, f) <= 0) {
> fprintf(stderr, "qemu: could not load kernel '%s': %s\n",
> kernel_filename, strerror(errno));
> exit(1);
> @@ -676,7 +678,7 @@ static void load_linux(void *fw_cfg,
> #if 0
> fprintf(stderr, "header magic: %#x\n", ldl_p(header+0x202));
> #endif
> - if (ldl_p(header+0x202) == 0x53726448)
> + if (ldl_p(header+0x202) == HEADER_SIGNATURE)
Please add braces while touching the line and add spaces around '+'.
Maybe you have not checked the patches with checkpatch.pl?
> protocol = lduw_p(header+0x206);
> else {
> /* This looks like a multiboot kernel. If it is, let's stop
> --
> 1.7.2.5
>
>
- [Qemu-devel] [PATCH 0/6] change acpi numa info format passed from qemu to seabios, liguang, 2013/02/03
- [Qemu-devel] [PATCH 1/6] pc/bios: move common BIOS_CFG_IOPORT into fw_cfg.h, liguang, 2013/02/03
- [Qemu-devel] [PATCH 6/6] load_linux: change kernel header size allocation, liguang, 2013/02/03
- Re: [Qemu-devel] [PATCH 6/6] load_linux: change kernel header size allocation,
Blue Swirl <=
- [Qemu-devel] [PATCH 5/6] load_linux: report open kernel file & its size error, liguang, 2013/02/03
- [Qemu-devel] [PATCH 2/6] pc/numa: refactor bios_init function, liguang, 2013/02/03
- [Qemu-devel] [PATCH 3/6] bitops: change BITS_TO_LONGS, liguang, 2013/02/03
- [Qemu-devel] [PATCH 4/6] pc: format load_linux(), liguang, 2013/02/03
- [Qemu-devel] [seabios][PATCH 2/2] acpi: change numa data format from fw_cfg interface, liguang, 2013/02/03