From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NnFay-00060M-AS for qemu-devel@nongnu.org; Thu, 04 Mar 2010 13:16:24 -0500 Received: from [199.232.76.173] (port=55214 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NnFax-0005zC-EU for qemu-devel@nongnu.org; Thu, 04 Mar 2010 13:16:23 -0500 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1NnFav-0000SV-S3 for qemu-devel@nongnu.org; Thu, 04 Mar 2010 13:16:23 -0500 Received: from e6.ny.us.ibm.com ([32.97.182.146]:56154) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1NnFav-0000S8-9C for qemu-devel@nongnu.org; Thu, 04 Mar 2010 13:16:21 -0500 Received: from d01relay07.pok.ibm.com (d01relay07.pok.ibm.com [9.56.227.147]) by e6.ny.us.ibm.com (8.14.3/8.13.1) with ESMTP id o24ID9vs013913 for ; Thu, 4 Mar 2010 13:13:09 -0500 Received: from d01av04.pok.ibm.com (d01av04.pok.ibm.com [9.56.224.64]) by d01relay07.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id o24IGCK72080780 for ; Thu, 4 Mar 2010 13:16:13 -0500 Received: from d01av04.pok.ibm.com (loopback [127.0.0.1]) by d01av04.pok.ibm.com (8.14.3/8.13.1/NCO v10.0 AVout) with ESMTP id o24IGCgh024507 for ; Thu, 4 Mar 2010 13:16:12 -0500 Message-ID: <4B8FF8EA.8040306@linux.vnet.ibm.com> Date: Thu, 04 Mar 2010 10:16:10 -0800 From: jvrao MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH] Check for invalid initrd file References: <201003041432.24973.mohan@in.ibm.com> In-Reply-To: <201003041432.24973.mohan@in.ibm.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "M. Mohan Kumar" Cc: qemu-devel@nongnu.org M. Mohan Kumar wrote: > From c5dca54f67ec6aac16c6c5e09958417b2b3ee5a1 Mon Sep 17 00:00:00 2001 > From: M. Mohan Kumar > Date: Thu, 4 Mar 2010 14:23:07 +0530 > Subject: [PATCH] Check for invalid initrd file > > When qemu is invoked with an invalid initrd file, it crashes. Following > patch prints a error message and exits if an invalid initrd is specified. > > Signed-off-by: M. Mohan Kumar > --- > hw/pc.c | 6 ++++++ > 1 files changed, 6 insertions(+), 0 deletions(-) > > diff --git a/hw/pc.c b/hw/pc.c > index 4f6a522..551c901 100644 > --- a/hw/pc.c > +++ b/hw/pc.c > @@ -669,6 +669,12 @@ static void load_linux(void *fw_cfg, > } > > initrd_size = get_image_size(initrd_filename); > + if (initrd_size < 0) { > + fprintf(stderr, "qemu: initrd %s does not exist\n", > + initrd_filename); > + exit(1); Looks good...but you may want to check the formatting. Also do we know for sure that the file not being there is the only reason for failure? How about making the error statement more generic like.. "Error reading %S" Thanks, JV > + } > + > initrd_addr = (initrd_max-initrd_size) & ~4095; > > initrd_data = qemu_malloc(initrd_size);