From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LUH86-0002lw-HF for qemu-devel@nongnu.org; Tue, 03 Feb 2009 03:59:38 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LUH85-0002kG-HB for qemu-devel@nongnu.org; Tue, 03 Feb 2009 03:59:37 -0500 Received: from [199.232.76.173] (port=59630 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LUH85-0002k5-BY for qemu-devel@nongnu.org; Tue, 03 Feb 2009 03:59:37 -0500 Received: from mr01.hansenet.de ([213.191.74.10]:39431) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1LUH84-0002nc-RV for qemu-devel@nongnu.org; Tue, 03 Feb 2009 03:59:37 -0500 Received: from exactcode.de (85.183.32.143) by mr01.hansenet.de (7.3.132) id 4967D255002A11D1 for qemu-devel@nongnu.org; Tue, 3 Feb 2009 09:59:36 +0100 Received: from [192.168.2.173] (helo=[192.168.2.173]) by exactcode.de with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.54) id 1LUH83-0000WQ-C0 for qemu-devel@nongnu.org; Tue, 03 Feb 2009 08:59:35 +0000 Message-ID: <49880773.5000203@exactcode.de> Date: Tue, 03 Feb 2009 09:59:31 +0100 From: =?ISO-8859-1?Q?Ren=E9_Rebe?= MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: Quoted-Printable Subject: [Qemu-devel] [PATCH] fix loading tiny kernels Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Further testing / polishing the multi-boot kernel loading support I found the existing code fails to load unusual small kernels, less than 8192=20 bytes - for example the example multi-boot kernel shipped within GRUB that compiles to just 7121 bytes on my system. Signed-off-by: Ren=E9 Rebe --- hw/pc.c (revision 6501) +++ hw/pc.c (working copy) @@ -554,7 +989,7 @@ /* load the kernel header */ f =3D fopen(kernel_filename, "rb"); if (!f || !(kernel_size =3D get_file_size(f)) || - fread(header, 1, 1024, f) !=3D 1024) { + fread(header, 1, MIN(8192, kernel_size), f) !=3D MIN(8192,=20 kernel_size)) { fprintf(stderr, "qemu: could not load kernel '%s'\n", kernel_filename); exit(1); --=20 Ren=E9 Rebe - ExactCODE GmbH - Europe, Germany, Berlin http://exactcode.de | http://t2-project.org | http://rene.rebe.name