From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:38662) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TsmqQ-0006M8-5J for qemu-devel@nongnu.org; Tue, 08 Jan 2013 23:00:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TsmqM-0004op-JK for qemu-devel@nongnu.org; Tue, 08 Jan 2013 23:00:50 -0500 Received: from mail-qa0-f44.google.com ([209.85.216.44]:37381) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TsmqM-0004oa-6S for qemu-devel@nongnu.org; Tue, 08 Jan 2013 23:00:46 -0500 Received: by mail-qa0-f44.google.com with SMTP id z4so353158qan.3 for ; Tue, 08 Jan 2013 20:00:45 -0800 (PST) Date: Tue, 8 Jan 2013 23:00:42 -0500 From: Kevin O'Connor Message-ID: <20130109040042.GC26614@morn.localdomain> References: <20121225103701.GA6688@t430s.redhat.com> <1356483340-12962-1-git-send-email-akong@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1356483340-12962-1-git-send-email-akong@redhat.com> Subject: Re: [Qemu-devel] [SeaBIOS PATCH v2] boot: support strict boot and make it configurable List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Amos Kong Cc: alex.williamson@redhat.com, seabios@seabios.org, dallan@redhat.com, qemu-devel@nongnu.org, gleb@redhat.com On Wed, Dec 26, 2012 at 08:55:40AM +0800, Amos Kong wrote: > Current seabios will try to boot from selected devices first, > if they are all failed, seabios will also try to boot from > un-selected devices. > > For example: > @ qemu-kvm -boot order=n,menu=on ... > > Guest will boot from network first, if it's failed, guest will try to > boot from other un-selected devices (floppy, cdrom, disk) one by one. > > We need to make it configurable, seabios user can config it by a rom > file('etc/boot-strict'). 'strict boot' means only boot from user > selected devices. > > I added some comments in this patch to explain why we can judge if > device is selected or not by DEFAULT_PRIO(9999). I also added 'selected' > flag in struct bootentry_s and struct bev_s to make it clearer. > > If this patch is accepted, I will add a boot option (-boot strict=on) > for qemu. I think it would be simpler to use the existing bootorder file instead of introducing a new "boot-strict" file. Something like the below (untested). -Kevin diff --git a/src/boot.c b/src/boot.c index c67cc7f..56843e3 100644 --- a/src/boot.c +++ b/src/boot.c @@ -291,6 +291,7 @@ static struct bootentry_s *BootList; #define IPL_TYPE_CBFS 0x20 #define IPL_TYPE_BEV 0x80 #define IPL_TYPE_BCV 0x81 +#define IPL_TYPE_HALT 0xf0 static void bootentry_add(int type, int prio, u32 data, const char *desc) @@ -488,6 +489,10 @@ boot_prep(void) interactive_bootmenu(); wait_threads(); + int haltprio = find_prio("HALT"); + if (haltprio >= 0) + bootentry_add(IPL_TYPE_HALT, haltprio, 0, "HALT"); + // Map drives and populate BEV list struct bootentry_s *pos = BootList; while (pos) { @@ -672,6 +677,9 @@ do_boot(int seq_nr) case IPL_TYPE_BEV: boot_rom(ie->vector); break; + case IPL_TYPE_HALT: + boot_fail(); + break; } // Boot failed: invoke the boot recovery function