[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] pc_init: Fail on bad kernel

From: Anthony Liguori
Subject: Re: [Qemu-devel] [PATCH] pc_init: Fail on bad kernel
Date: Wed, 14 Sep 2011 07:54:32 -0500
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv: Gecko/20110516 Lightning/1.0b2 Thunderbird/3.1.10

On 09/14/2011 02:45 AM, Sasha Levin wrote:

I replied on 9/9 with comments.


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<address@hidden>
Signed-off-by: Sasha Levin<address@hidden>
  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)) {
+        } else {
+            fprintf(stderr, "qemu: could not load kernel '%s': %s\n",
+                   kernel_filename, strerror(errno));
+           exit(1);
+        }
        protocol = 0;

reply via email to

[Prev in Thread] Current Thread [Next in Thread]