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.
Sometimes, user don't want to boot from some devices. This patch changes seabios to boot only from selected devices.
If user choose first boot device from menu, then seabios will try all the devices, even some of them are not selected.
Signed-off-by: Amos Kong akong@redhat.com --- Resend for CCing seabios maillist. --- src/boot.c | 13 ++++++++----- 1 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/src/boot.c b/src/boot.c index 3ca7960..ee810ac 100644 --- a/src/boot.c +++ b/src/boot.c @@ -424,6 +424,10 @@ interactive_bootmenu(void) maxmenu++; printf("%d. %s\n", maxmenu , strtcpy(desc, pos->description, ARRAY_SIZE(desc))); + /* If user chooses first boot device from menu, we will treat + all the devices as selected. */ + if (pos->priority == DEFAULT_PRIO) + pos->priority = DEFAULT_PRIO - 1; pos = pos->next; }
@@ -490,7 +494,10 @@ boot_prep(void)
// Map drives and populate BEV list struct bootentry_s *pos = BootList; - while (pos) { + + /* The priority of un-selected device is not changed, + we only boot from user selected devices. */ + while (pos && pos->priority != DEFAULT_PRIO) { switch (pos->type) { case IPL_TYPE_BCV: call_bcv(pos->vector.seg, pos->vector.offset); @@ -513,10 +520,6 @@ boot_prep(void) } pos = pos->next; } - - // If nothing added a floppy/hd boot - add it manually. - add_bev(IPL_TYPE_FLOPPY, 0); - add_bev(IPL_TYPE_HARDDISK, 0); }
On 12/19/12 08:24, 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.
Sometimes, user don't want to boot from some devices. This patch changes seabios to boot only from selected devices.
I think (i.e. I didn't test) the patch breaks booting if the user didn't explicitly specify a boot device.
cheers, Gerd
On Wed, Dec 19, 2012 at 08:38:13AM +0100, Gerd Hoffmann wrote:
On 12/19/12 08:24, 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.
Sometimes, user don't want to boot from some devices. This patch changes seabios to boot only from selected devices.
I think (i.e. I didn't test) the patch breaks booting if the user didn't explicitly specify a boot device.
Hi Gerd,
| #define DEFAULT_PRIO 9999
If we don't select some devices, their priority will always be 9999
| static int DefaultFloppyPrio = 101; | static int DefaultCDPrio = 102; | static int DefaultHDPrio = 103; | static int DefaultBEVPrio = 104;
The priority of selected devices will be changed to above values first, the priority might be re-changed.
However, we can judge if device is selected or not by checking if the priority is 9999.
. Boot guest without qemu boot option, guest will try to boot from network/hd/floppy/cdrom.
. If seabios ignores the order parameter of qemu, guest will also try to boot from network/hd/floppy/cdrom.
On Wed, Dec 19, 2012 at 03:24:45PM +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.
Sometimes, user don't want to boot from some devices. This patch changes
And sometimes he want. The patch changes behaviour unconditionally. New behaviour should be user selectable. Something line -boot order=strict on qemu command line.
seabios to boot only from selected devices.
If user choose first boot device from menu, then seabios will try all the devices, even some of them are not selected.
Signed-off-by: Amos Kong akong@redhat.com
Resend for CCing seabios maillist.
src/boot.c | 13 ++++++++----- 1 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/src/boot.c b/src/boot.c index 3ca7960..ee810ac 100644 --- a/src/boot.c +++ b/src/boot.c @@ -424,6 +424,10 @@ interactive_bootmenu(void) maxmenu++; printf("%d. %s\n", maxmenu , strtcpy(desc, pos->description, ARRAY_SIZE(desc)));
/* If user chooses first boot device from menu, we will treat
all the devices as selected. */
if (pos->priority == DEFAULT_PRIO)
}pos->priority = DEFAULT_PRIO - 1; pos = pos->next;
@@ -490,7 +494,10 @@ boot_prep(void)
// Map drives and populate BEV list struct bootentry_s *pos = BootList;
- while (pos) {
- /* The priority of un-selected device is not changed,
we only boot from user selected devices. */
- while (pos && pos->priority != DEFAULT_PRIO) { switch (pos->type) { case IPL_TYPE_BCV: call_bcv(pos->vector.seg, pos->vector.offset);
@@ -513,10 +520,6 @@ boot_prep(void) } pos = pos->next; }
- // If nothing added a floppy/hd boot - add it manually.
- add_bev(IPL_TYPE_FLOPPY, 0);
- add_bev(IPL_TYPE_HARDDISK, 0);
}
-- 1.7.1
-- Gleb.
On Wed, Dec 19, 2012 at 11:32:08AM +0200, Gleb Natapov wrote:
On Wed, Dec 19, 2012 at 03:24:45PM +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.
Sometimes, user don't want to boot from some devices. This patch changes
Hi Gleb,
And sometimes he want. The patch changes behaviour unconditionally. New behaviour should be user selectable. Something line -boot order=strict on qemu command line.
Sometimes, user don't know which devices are in boot list of seabios, so they could not disable them through qemu cmdline.
I didn't describe the purpose clearly. Currently we can assign boot order by "-boot order=...", if fails to boot from all devices in order parameters, other devices in seabios's boot table will also be tried.
The exact request should be "only boot from selected devices".
I agree to make it configurable. eg: qemu -boot order=nd,strict=on,menu=on strick: on (only boot from selected devices) strick: off (will try to boot from all devices in seabios' boot table) default strick should be 'off' as current behavior.
Thanks, Amos
seabios to boot only from selected devices.
If user choose first boot device from menu, then seabios will try all the devices, even some of them are not selected.
Signed-off-by: Amos Kong akong@redhat.com
Resend for CCing seabios maillist.
src/boot.c | 13 ++++++++----- 1 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/src/boot.c b/src/boot.c index 3ca7960..ee810ac 100644 --- a/src/boot.c +++ b/src/boot.c @@ -424,6 +424,10 @@ interactive_bootmenu(void) maxmenu++; printf("%d. %s\n", maxmenu , strtcpy(desc, pos->description, ARRAY_SIZE(desc)));
/* If user chooses first boot device from menu, we will treat
all the devices as selected. */
if (pos->priority == DEFAULT_PRIO)
}pos->priority = DEFAULT_PRIO - 1; pos = pos->next;
@@ -490,7 +494,10 @@ boot_prep(void)
// Map drives and populate BEV list struct bootentry_s *pos = BootList;
- while (pos) {
- /* The priority of un-selected device is not changed,
we only boot from user selected devices. */
- while (pos && pos->priority != DEFAULT_PRIO) { switch (pos->type) { case IPL_TYPE_BCV: call_bcv(pos->vector.seg, pos->vector.offset);
@@ -513,10 +520,6 @@ boot_prep(void) } pos = pos->next; }
- // If nothing added a floppy/hd boot - add it manually.
- add_bev(IPL_TYPE_FLOPPY, 0);
- add_bev(IPL_TYPE_HARDDISK, 0);
On Tue, Dec 25, 2012 at 11:58:08AM +0800, Amos Kong wrote:
On Wed, Dec 19, 2012 at 11:32:08AM +0200, Gleb Natapov wrote:
On Wed, Dec 19, 2012 at 03:24:45PM +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.
Sometimes, user don't want to boot from some devices. This patch changes
Hi Gleb,
And sometimes he want. The patch changes behaviour unconditionally. New behaviour should be user selectable. Something line -boot order=strict on qemu command line.
Sometimes, user don't know which devices are in boot list of seabios, so they could not disable them through qemu cmdline.
This is not what I suggested though. And currently we do not have a way to remove one device from the boot process. This is separate issue and requires separate patch.
I didn't describe the purpose clearly. Currently we can assign boot order by "-boot order=...", if fails to boot from all devices in order parameters, other devices in seabios's boot table will also be tried.
order= is an old style. Use bootindex instead.
The exact request should be "only boot from selected devices".
You described the purpose clearly first time. This is how I understood it :)
I agree to make it configurable. eg: qemu -boot order=nd,strict=on,menu=on strick: on (only boot from selected devices) strick: off (will try to boot from all devices in seabios' boot table) default strick should be 'off' as current behavior.
Yes, this is my suggestion.
Thanks, Amos
seabios to boot only from selected devices.
If user choose first boot device from menu, then seabios will try all the devices, even some of them are not selected.
Signed-off-by: Amos Kong akong@redhat.com
Resend for CCing seabios maillist.
src/boot.c | 13 ++++++++----- 1 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/src/boot.c b/src/boot.c index 3ca7960..ee810ac 100644 --- a/src/boot.c +++ b/src/boot.c @@ -424,6 +424,10 @@ interactive_bootmenu(void) maxmenu++; printf("%d. %s\n", maxmenu , strtcpy(desc, pos->description, ARRAY_SIZE(desc)));
/* If user chooses first boot device from menu, we will treat
all the devices as selected. */
if (pos->priority == DEFAULT_PRIO)
}pos->priority = DEFAULT_PRIO - 1; pos = pos->next;
@@ -490,7 +494,10 @@ boot_prep(void)
// Map drives and populate BEV list struct bootentry_s *pos = BootList;
- while (pos) {
- /* The priority of un-selected device is not changed,
we only boot from user selected devices. */
- while (pos && pos->priority != DEFAULT_PRIO) { switch (pos->type) { case IPL_TYPE_BCV: call_bcv(pos->vector.seg, pos->vector.offset);
@@ -513,10 +520,6 @@ boot_prep(void) } pos = pos->next; }
- // If nothing added a floppy/hd boot - add it manually.
- add_bev(IPL_TYPE_FLOPPY, 0);
- add_bev(IPL_TYPE_HARDDISK, 0);
-- Gleb.
On Tue, Dec 25, 2012 at 08:37:07AM +0200, Gleb Natapov wrote:
On Tue, Dec 25, 2012 at 11:58:08AM +0800, Amos Kong wrote:
On Wed, Dec 19, 2012 at 11:32:08AM +0200, Gleb Natapov wrote:
On Wed, Dec 19, 2012 at 03:24:45PM +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.
Sometimes, user don't want to boot from some devices. This patch changes
Hi Gleb,
And sometimes he want. The patch changes behaviour unconditionally. New behaviour should be user selectable. Something line -boot order=strict on qemu command line.
Sometimes, user don't know which devices are in boot list of seabios, so they could not disable them through qemu cmdline.
Hi Gleb, Kevin
This is not what I suggested though. And currently we do not have a way to remove one device from the boot process. This is separate issue and requires separate patch.
issue 1: add a qemu parameter to tell seabios don't boot from unselected device issue 2: add the ability to seabios to ignore unselected device
right?
I didn't describe the purpose clearly. Currently we can assign boot order by "-boot order=...", if fails to boot from all devices in order parameters, other devices in seabios's boot table will also be tried.
order= is an old style. Use bootindex instead.
(I'm trying to describe the old/new principles, correct me if sth is wrong, thanks)
+ Old style: order=...
There are two registers in Bochs/qemu's CMOS map, which are used for boot sequence. (number of boot devices <= 3) ------------------------------------------------------- 0x38 S eltorito boot sequence + boot signature check bits 0 floppy boot signature check (1: disabled, 0: enabled) 7-4 boot drive #3 (0: unused, 1: fd, 2: hd, 3:cd, else: fd)
0x3d S eltorito boot sequence (see above) bits 3-0 boot drive #1 7-4 boot drive #2
==> set order in qemu: hw/pc.c: set_boot_dev(ISADevice *s, const char *boot_device, ..) { ... rtc_set_memory(s, 0x3d, (bds[1] << 4) | bds[0]); rtc_set_memory(s, 0x38, (bds[2] << 4) | (fd_bootchk ? 0x0 : 0x1)); }
==> process order in seabios: seabios/src/boot.c: boot_setup(): u32 bootorder = (inb_cmos(CMOS_BIOS_BOOTFLAG2) | ((inb_cmos(CMOS_BIOS_BOOTFLAG1) & 0xf0) << 4)); DefaultFloppyPrio = DefaultCDPrio = DefaultHDPrio = DefaultBEVPrio = DEFAULT_PRIO;
^^^ device priority will be set to 9999 before processing int i; for (i=101; i<104; i++) { u32 val = bootorder & 0x0f; bootorder >>= 4; switch (val) { case 1: DefaultFloppyPrio = i; break; case 2: DefaultHDPrio = i; break; case 3: DefaultCDPrio = i; break; case 4: DefaultBEVPrio = i; break;
^^^ if one device is selected in cmos register, its priority will be set to 10*, the priority of un-selected devices are still 9999. } }
+ New style: bootindex a bootorder string which contains the descriptions of boot devices. (eg. /pci@i0cf8/ethernet@3/ethernet-phy@0\n...) it's loaded through 'bootorder' file in rom by seabios. So 'selected' device can be found in this string. seabios will use the table index as the priority of selected devices.
Seabios uses boot_add_{floppy,floppy,hd,bcv,cd,cbfs} to add devices to boot entry list. the priority will be processed at this point by: defPrio(prio, Default...Prio)
'prio' is got when init the device, two conditions: -1: unselected index of bootorder table: selected in bootorder rom file.
So after processing, priority of unselected devices will be re-set to 9999.
Based on this, we can judge if device is selected or not by checking if priority is 9999. The only problem should be legacy FD/HD.
However, it's better to add a flag ('selected') in struct bev_s. If qemu tells seabios to ignore unselected devices, we can ignore them in do_boot().
// Determine next boot method and attempt a boot using it. static void do_boot(int seq_nr) { .... // Boot the given BEV type. struct bev_s *ie = &BEV[seq_nr]; if (!ie->selected) boot_fail(); ...
The exact request should be "only boot from selected devices".
You described the purpose clearly first time. This is how I understood it :)
I agree to make it configurable. eg: qemu -boot order=nd,strict=on,menu=on strick: on (only boot from selected devices) strick: off (will try to boot from all devices in seabios' boot table) default strick should be 'off' as current behavior.
Yes, this is my suggestion.
Thanks, Amos
seabios to boot only from selected devices.
If user choose first boot device from menu, then seabios will try all the devices, even some of them are not selected.
Hi Kevin,
The BIOS Boot Specification (BBS) is quite complex and your patch changes SeaBIOS' behavior in subtle ways that I'm not convinced is safe. (For example, by not always adding an FD/HD entry it may no longer be possible to boot from a legacy option rom which emulates an FD.)
Yes, not easy as my solution.
Instead of altering the core algorithm for this feature, a different approach would be to add a new "boot device" (eg, IPL_TYPE_HALT) that is only registered if found in the bootorder file and just calls boot_fail() when attempted.
But how to know if device is seleted or not? Bios processes the bootorder complexly. But I find the priority is a clew.
Thanks, Amos
That way users get the default
behaviour unless they explicitly request a halt in boot at a given priority.
-Kevin
Signed-off-by: Amos Kong akong@redhat.com
Resend for CCing seabios maillist.
src/boot.c | 13 ++++++++----- 1 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/src/boot.c b/src/boot.c index 3ca7960..ee810ac 100644 --- a/src/boot.c +++ b/src/boot.c @@ -424,6 +424,10 @@ interactive_bootmenu(void) maxmenu++; printf("%d. %s\n", maxmenu , strtcpy(desc, pos->description, ARRAY_SIZE(desc)));
/* If user chooses first boot device from menu, we will treat
all the devices as selected. */
if (pos->priority == DEFAULT_PRIO)
}pos->priority = DEFAULT_PRIO - 1; pos = pos->next;
@@ -490,7 +494,10 @@ boot_prep(void)
// Map drives and populate BEV list struct bootentry_s *pos = BootList;
- while (pos) {
- /* The priority of un-selected device is not changed,
we only boot from user selected devices. */
- while (pos && pos->priority != DEFAULT_PRIO) { switch (pos->type) { case IPL_TYPE_BCV: call_bcv(pos->vector.seg, pos->vector.offset);
@@ -513,10 +520,6 @@ boot_prep(void) } pos = pos->next; }
- // If nothing added a floppy/hd boot - add it manually.
- add_bev(IPL_TYPE_FLOPPY, 0);
- add_bev(IPL_TYPE_HARDDISK, 0);
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.
Signed-off-by: Amos Kong akong@redhat.com --- src/boot.c | 31 ++++++++++++++++++++++++------- 1 files changed, 24 insertions(+), 7 deletions(-)
diff --git a/src/boot.c b/src/boot.c index c67cc7f..99ac791 100644 --- a/src/boot.c +++ b/src/boot.c @@ -92,6 +92,7 @@ find_prio(const char *glob) int i; for (i = 0; i < BootorderCount; i++) if (glob_prefix(glob, Bootorder[i])) + // device exists in the Bootorder list loaded from rom file return i+1; return -1; } @@ -249,12 +250,14 @@ boot_setup(void) CheckFloppySig = 0; u32 bootorder = (inb_cmos(CMOS_BIOS_BOOTFLAG2) | ((inb_cmos(CMOS_BIOS_BOOTFLAG1) & 0xf0) << 4)); + // reset device priority to default DEFAULT_PRIO(9999) DefaultFloppyPrio = DefaultCDPrio = DefaultHDPrio = DefaultBEVPrio = DEFAULT_PRIO; int i; for (i=101; i<104; i++) { u32 val = bootorder & 0x0f; bootorder >>= 4; + // priority of devices selected in bootorder will be changed switch (val) { case 1: DefaultFloppyPrio = i; break; case 2: DefaultHDPrio = i; break; @@ -280,6 +283,7 @@ struct bootentry_s { struct drive_s *drive; }; int priority; + int selected; const char *description; struct bootentry_s *next; }; @@ -304,6 +308,9 @@ bootentry_add(int type, int prio, u32 data, const char *desc) } be->type = type; be->priority = prio; + // set 'selected' flag according to the priority + if (prio != DEFAULT_PRIO) + be->selected = 1; be->data = data; be->description = desc ?: "?"; dprintf(3, "Registering bootable: %s (type:%d prio:%d data:%x)\n" @@ -332,6 +339,8 @@ bootentry_add(int type, int prio, u32 data, const char *desc) }
// Return the given priority if it's set - defaultprio otherwise. +// This function is called by boot_add_*(), it will only pass +// DEFAULT_PRIO(9999) for unselected devices as the boot-entry priority. static inline int defPrio(int priority, int defaultprio) { return (priority < 0) ? defaultprio : priority; } @@ -454,13 +463,14 @@ interactive_bootmenu(void) struct bev_s { int type; u32 vector; + int selected; }; static struct bev_s BEV[20]; static int BEVCount; static int HaveHDBoot, HaveFDBoot;
static void -add_bev(int type, u32 vector) +add_bev(int type, u32 vector, int selected) { if (type == IPL_TYPE_HARDDISK && HaveHDBoot++) return; @@ -471,6 +481,7 @@ add_bev(int type, u32 vector) struct bev_s *bev = &BEV[BEVCount++]; bev->type = type; bev->vector = vector; + bev->selected = selected; }
// Prepare for boot - show menu and run bcvs. @@ -494,29 +505,29 @@ boot_prep(void) switch (pos->type) { case IPL_TYPE_BCV: call_bcv(pos->vector.seg, pos->vector.offset); - add_bev(IPL_TYPE_HARDDISK, 0); + add_bev(IPL_TYPE_HARDDISK, 0, pos->selected); break; case IPL_TYPE_FLOPPY: map_floppy_drive(pos->drive); - add_bev(IPL_TYPE_FLOPPY, 0); + add_bev(IPL_TYPE_FLOPPY, 0, pos->selected); break; case IPL_TYPE_HARDDISK: map_hd_drive(pos->drive); - add_bev(IPL_TYPE_HARDDISK, 0); + add_bev(IPL_TYPE_HARDDISK, 0, pos->selected); break; case IPL_TYPE_CDROM: map_cd_drive(pos->drive); // NO BREAK default: - add_bev(pos->type, pos->data); + add_bev(pos->type, pos->data, pos->selected); break; } pos = pos->next; }
// If nothing added a floppy/hd boot - add it manually. - add_bev(IPL_TYPE_FLOPPY, 0); - add_bev(IPL_TYPE_HARDDISK, 0); + add_bev(IPL_TYPE_FLOPPY, 0, 0); + add_bev(IPL_TYPE_HARDDISK, 0, 0); }
@@ -654,6 +665,12 @@ do_boot(int seq_nr)
// Boot the given BEV type. struct bev_s *ie = &BEV[seq_nr]; + + int strict = romfile_loadint("etc/boot-strict", 0); + // do strict boot, only boot from user selected devices + if (strict && !ie->selected) + boot_fail(); + switch (ie->type) { case IPL_TYPE_FLOPPY: printf("Booting from Floppy...\n");
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
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
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
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. This patch added a new type, qemu can add "HALT" at the end of bootindex string, then seabios will halt booting after trying to boot from selected devices.
Signed-off-by: Kevin O'Connor kevin@koconnor.net Signed-off-by: Amos Kong akong@redhat.com --- v3: add a new type to halt booting (Kevin) ___ src/boot.c | 9 +++++++++ 1 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/src/boot.c b/src/boot.c index c67cc7f..eea2354 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,11 @@ 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 +678,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
On 12/19/2012 11:32 AM, Gleb Natapov wrote:
On Wed, Dec 19, 2012 at 03:24:45PM +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.
Sometimes, user don't want to boot from some devices. This patch changes
And sometimes he want. The patch changes behaviour unconditionally. New behaviour should be user selectable. Something line -boot order=strict on qemu command line.
Another option would be to add a "terminator" symbol, say "T" (I couldn't find a good terminator), so that order=ndT, would mean strict "nd".
Ronen.
seabios to boot only from selected devices.
If user choose first boot device from menu, then seabios will try all the devices, even some of them are not selected.
Signed-off-by: Amos Kong akong@redhat.com
Resend for CCing seabios maillist.
src/boot.c | 13 ++++++++----- 1 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/src/boot.c b/src/boot.c index 3ca7960..ee810ac 100644 --- a/src/boot.c +++ b/src/boot.c @@ -424,6 +424,10 @@ interactive_bootmenu(void) maxmenu++; printf("%d. %s\n", maxmenu , strtcpy(desc, pos->description, ARRAY_SIZE(desc)));
/* If user chooses first boot device from menu, we will treat
all the devices as selected. */
if (pos->priority == DEFAULT_PRIO)
pos->priority = DEFAULT_PRIO - 1; pos = pos->next; }
@@ -490,7 +494,10 @@ boot_prep(void)
// Map drives and populate BEV list struct bootentry_s *pos = BootList;
- while (pos) {
- /* The priority of un-selected device is not changed,
we only boot from user selected devices. */
- while (pos && pos->priority != DEFAULT_PRIO) { switch (pos->type) { case IPL_TYPE_BCV: call_bcv(pos->vector.seg, pos->vector.offset);
@@ -513,10 +520,6 @@ boot_prep(void) } pos = pos->next; }
- // If nothing added a floppy/hd boot - add it manually.
- add_bev(IPL_TYPE_FLOPPY, 0);
- add_bev(IPL_TYPE_HARDDISK, 0); }
-- 1.7.1
-- Gleb.
On Tue, Dec 25, 2012 at 05:59:04PM +0200, Ronen Hod wrote:
On 12/19/2012 11:32 AM, Gleb Natapov wrote:
On Wed, Dec 19, 2012 at 03:24:45PM +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.
Sometimes, user don't want to boot from some devices. This patch changes
And sometimes he want. The patch changes behaviour unconditionally. New behaviour should be user selectable. Something line -boot order=strict on qemu command line.
Another option would be to add a "terminator" symbol, say "T" (I couldn't find a good terminator), so that order=ndT, would mean strict "nd".
Not very helpful if the order is specified with bootindex like it should.
Ronen.
seabios to boot only from selected devices.
If user choose first boot device from menu, then seabios will try all the devices, even some of them are not selected.
Signed-off-by: Amos Kong akong@redhat.com
Resend for CCing seabios maillist.
src/boot.c | 13 ++++++++----- 1 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/src/boot.c b/src/boot.c index 3ca7960..ee810ac 100644 --- a/src/boot.c +++ b/src/boot.c @@ -424,6 +424,10 @@ interactive_bootmenu(void) maxmenu++; printf("%d. %s\n", maxmenu , strtcpy(desc, pos->description, ARRAY_SIZE(desc)));
/* If user chooses first boot device from menu, we will treat
all the devices as selected. */
if (pos->priority == DEFAULT_PRIO)
}pos->priority = DEFAULT_PRIO - 1; pos = pos->next;
@@ -490,7 +494,10 @@ boot_prep(void) // Map drives and populate BEV list struct bootentry_s *pos = BootList;
- while (pos) {
- /* The priority of un-selected device is not changed,
we only boot from user selected devices. */
- while (pos && pos->priority != DEFAULT_PRIO) { switch (pos->type) { case IPL_TYPE_BCV: call_bcv(pos->vector.seg, pos->vector.offset);
@@ -513,10 +520,6 @@ boot_prep(void) } pos = pos->next; }
- // If nothing added a floppy/hd boot - add it manually.
- add_bev(IPL_TYPE_FLOPPY, 0);
- add_bev(IPL_TYPE_HARDDISK, 0);
}
1.7.1
-- Gleb.
-- Gleb.
On Wed, Dec 19, 2012 at 03:24:45PM +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.
Sometimes, user don't want to boot from some devices. This patch changes seabios to boot only from selected devices.
If user choose first boot device from menu, then seabios will try all the devices, even some of them are not selected.
The BIOS Boot Specification (BBS) is quite complex and your patch changes SeaBIOS' behavior in subtle ways that I'm not convinced is safe. (For example, by not always adding an FD/HD entry it may no longer be possible to boot from a legacy option rom which emulates an FD.)
Instead of altering the core algorithm for this feature, a different approach would be to add a new "boot device" (eg, IPL_TYPE_HALT) that is only registered if found in the bootorder file and just calls boot_fail() when attempted. That way users get the default behaviour unless they explicitly request a halt in boot at a given priority.
-Kevin