From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:47670) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R3oz7-00016z-Vy for qemu-devel@nongnu.org; Wed, 14 Sep 2011 08:54:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1R3oz6-0008Gf-HI for qemu-devel@nongnu.org; Wed, 14 Sep 2011 08:54:37 -0400 Received: from mail-yw0-f45.google.com ([209.85.213.45]:56564) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R3oz6-0008GG-Ej for qemu-devel@nongnu.org; Wed, 14 Sep 2011 08:54:36 -0400 Received: by ywm39 with SMTP id 39so1581655ywm.4 for ; Wed, 14 Sep 2011 05:54:35 -0700 (PDT) Message-ID: <4E70A408.1040801@codemonkey.ws> Date: Wed, 14 Sep 2011 07:54:32 -0500 From: Anthony Liguori MIME-Version: 1.0 References: <1315078543-28522-1-git-send-email-levinsasha928@gmail.com> <1315986322.3744.11.camel@lappy> In-Reply-To: <1315986322.3744.11.camel@lappy> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] pc_init: Fail on bad kernel List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Sasha Levin Cc: qemu-devel@nongnu.org On 09/14/2011 02:45 AM, Sasha Levin wrote: > Ping? I replied on 9/9 with comments. Regards, Anthony Liguori > > On Sat, 2011-09-03 at 22:35 +0300, Sasha Levin wrote: >> When providing QEMU with a bad '-kernel' parameter, such as a file which >> is not really a kernel, QEMU will attempt to allocate a huge amount of >> memory and fail either with "Failed to allocate memory: Cannot allocate >> memory" or a GLib error: "GLib-ERROR **: gmem.c:170: failed to allocate >> 18446744073709529965 bytes" >> >> This patch handles the case where the magic sig wasn't located in the >> provided kernel, and loading it as multiboot failed as well. >> >> Cc: Anthony Liguori >> Signed-off-by: Sasha Levin >> --- >> hw/pc.c | 8 +++++++- >> 1 files changed, 7 insertions(+), 1 deletions(-) >> >> diff --git a/hw/pc.c b/hw/pc.c >> index 6b3662e..428440b 100644 >> --- a/hw/pc.c >> +++ b/hw/pc.c >> @@ -691,8 +691,14 @@ static void load_linux(void *fw_cfg, >> /* This looks like a multiboot kernel. If it is, let's stop >> treating it like a Linux kernel. */ >> if (load_multiboot(fw_cfg, f, kernel_filename, initrd_filename, >> - kernel_cmdline, kernel_size, header)) >> + kernel_cmdline, kernel_size, header)) { >> return; >> + } else { >> + fprintf(stderr, "qemu: could not load kernel '%s': %s\n", >> + kernel_filename, strerror(errno)); >> + exit(1); >> + } >> + >> protocol = 0; >> } >> >