From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:39959) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UO6F9-0002B6-W2 for qemu-devel@nongnu.org; Fri, 05 Apr 2013 08:59:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UO6F7-0004u4-DS for qemu-devel@nongnu.org; Fri, 05 Apr 2013 08:59:47 -0400 Date: Fri, 5 Apr 2013 14:59:41 +0200 From: Stefan Hajnoczi Message-ID: <20130405125941.GD15818@stefanha-thinkpad.redhat.com> References: <1364779317-3963-1-git-send-email-lig.fnst@cn.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1364779317-3963-1-git-send-email-lig.fnst@cn.fujitsu.com> Subject: Re: [Qemu-devel] [PATCH v2] hw/i386/pc: reject to boot a wrong header magic kernel List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: liguang Cc: qemu-trivial@nongnu.org, qemu-devel@nongnu.org On Mon, Apr 01, 2013 at 09:21:57AM +0800, liguang wrote: > if head magic is missing or wrong unexpectedly, we'd > better to reject booting. > e.g. > I make a mistake to boot a vmlinuz for MIPS(which > I think it's for x86) like this: > qemu-system-x86_64 -kernel vmlinuz -initrd demord > then qemu report: > "qemu: linux kernel too old to load a ram disk" > that's misleading. > > Signed-off-by: liguang > --- > hw/i386/pc.c | 3 +++ > 1 files changed, 3 insertions(+), 0 deletions(-) > > diff --git a/hw/i386/pc.c b/hw/i386/pc.c > index b1e06fa..bfbb5fe 100644 > --- a/hw/i386/pc.c > +++ b/hw/i386/pc.c > @@ -683,6 +683,9 @@ static void load_linux(void *fw_cfg, > if (load_multiboot(fw_cfg, f, kernel_filename, initrd_filename, > kernel_cmdline, kernel_size, header)) { > return; > + } else { > + fprintf(stderr, "not a valid multiboot image!\n"); > + exit(1); > } > protocol = 0; The point of protocol = 0 is to support old Linux kernels. If we exit when probing load_multiboot() fails then QEMU will no longer load old Linux kernels! I suggest just: fprintf(stderr, "warning: not a valid multiboot or modern kernel image\n"); Stefan