From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:60799) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R3kAP-0006v3-Qc for qemu-devel@nongnu.org; Wed, 14 Sep 2011 03:45:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1R3kAK-00036r-A3 for qemu-devel@nongnu.org; Wed, 14 Sep 2011 03:45:57 -0400 Received: from mail-fx0-f45.google.com ([209.85.161.45]:39826) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R3kAK-00036U-2b for qemu-devel@nongnu.org; Wed, 14 Sep 2011 03:45:52 -0400 Received: by fxh13 with SMTP id 13so1432807fxh.4 for ; Wed, 14 Sep 2011 00:45:50 -0700 (PDT) From: Sasha Levin In-Reply-To: <1315078543-28522-1-git-send-email-levinsasha928@gmail.com> References: <1315078543-28522-1-git-send-email-levinsasha928@gmail.com> Content-Type: text/plain; charset="us-ascii" Date: Wed, 14 Sep 2011 10:45:22 +0300 Message-ID: <1315986322.3744.11.camel@lappy> Mime-Version: 1.0 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: qemu-devel@nongnu.org Cc: Anthony Liguori Ping? 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; > } > -- Sasha.