diff mbox

[SeaBIOS,v2] boot: support strict boot and make it configurable

Message ID 20130109040042.GC26614@morn.localdomain
State New
Headers show

Commit Message

Kevin O'Connor Jan. 9, 2013, 4 a.m. UTC
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

Comments

Amos Kong Jan. 9, 2013, 5:03 a.m. UTC | #1
On Tue, Jan 08, 2013 at 11:00:42PM -0500, Kevin O'Connor wrote:
> 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).

Thanks for your patch. It's good. I thought you suggest me to add a
new type, and bootentry_add unselected devices to HALT type.

I did a simple test, patch works. I will re-post this patch and change
qemu code to use this new type.

Amos
 
> -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
Kevin O'Connor Jan. 12, 2013, 10:01 p.m. UTC | #2
On Wed, Jan 09, 2013 at 01:03:37PM +0800, Amos Kong wrote:
> On Tue, Jan 08, 2013 at 11:00:42PM -0500, Kevin O'Connor wrote:
> > 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.
[...]
> > 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).
> 
> Thanks for your patch. It's good. I thought you suggest me to add a
> new type, and bootentry_add unselected devices to HALT type.
> 
> I did a simple test, patch works. I will re-post this patch and change
> qemu code to use this new type.

Thanks.  I committed my patch.

-Kevin
diff mbox

Patch

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