don't boot from un-selected devices
PATCH 1/1 don't boot from un-selected devices
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.
--- src/boot.c | 13 ++++++++----- 1 files changed, 8 insertions(+), 5 deletions(-)
src/boot.c +8 -5
@@ -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 ); }
Signature · 1 line
1.7.1
PATCH RESEND 1/1 don't boot from un-selected devices
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.
---
Resend for CCing seabios maillist.
--- src/boot.c | 13 ++++++++----- 1 files changed, 8 insertions(+), 5 deletions(-)
src/boot.c +8 -5
@@ -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 ); }
Signature · 1 line
1.7.1
Quoted 4 lines · Amos Kong
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.
Quoted 8 lines
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
Quoted 8 lines · Gerd Hoffmann
Quoted 7 lines · Amos Kong
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 ...
Quoted 8 lines
Quoted 5 lines
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.
Signature · 1 line
Amos.
Quoted 11 lines · Amos Kong
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.
Quoted 52 lines
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 <[email protected]>---
Resend for CCing seabios maillist.--- src/boot.c | 13 ++++++++----- 1 files changed, 8 insertions(+), 5 deletions(-)src/boot.c +8
-5@@ -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 ); }Signature · 1 line
1.7.1
--
Gleb.
Quoted 7 lines · Amos Kong
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 ...
Quoted 8 lines
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
Quoted 5 lines · Gleb Natapov
Quoted 4 lines · Amos Kong
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.
Quoted 7 lines
Quoted 7 lines
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,
Quoted 3 lines
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
Quoted 47 lines
Quoted 47 lines
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 <[email protected]>---
Resend for CCing seabios maillist.--- src/boot.c | 13 ++++++++----- 1 files changed, 8 insertions(+), 5 deletions(-)src/boot.c +8
-5@@ -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 );
Quoted 14 lines · Amos Kong
Quoted 5 lines · Gleb Natapov
Quoted 4 lines · Amos Kong
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.
Quoted 7 lines
Quoted 7 lines
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
Quoted 9 lines
Hi Gleb,
Quoted 3 lines
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.
Quoted 3 lines
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.
Quoted 2 lines
The exact request should be "only boot from selected devices".
You described the purpose clearly first time. This is how I understood it :)
Quoted 7 lines
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.
Quoted 41 lines
Thanks, Amos
Quoted 39 lines
Quoted 39 lines
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 <[email protected]>---
Resend for CCing seabios maillist.--- src/boot.c | 13 ++++++++----- 1 files changed, 8 insertions(+), 5 deletions(-)src/boot.c +8
-1@@ -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);
Quoted 8 lines
Quoted 8 lines
src/boot.c boot_prep(void) · line 519
Quoted 8 lines
src/boot.c +0
-4@@ -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.
Quoted 15 lines · Gleb Natapov
Quoted 14 lines · Amos Kong
Quoted 12 lines · Gleb Natapov
Quoted 11 lines · Amos Kong
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
Quoted 8 lines
Quoted 8 lines
Hi Gleb,
Quoted 3 lines
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
Quoted 3 lines
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?
Quoted 4 lines
Quoted 3 lines
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();
...Quoted 5 lines
Quoted 1 line
The exact request should be "only boot from selected devices".
You described the purpose clearly first time. This is how I understood it :)
Quoted 1 line
Quoted 15 lines
Quoted 6 lines
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.
Quoted 7 lines
Thanks, Amos
Quoted 5 lines
Quoted 4 lines
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,
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
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.
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
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 callsboot_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
Quoted 48 lines
That way users get the default
Quoted 47 lines
Quoted 47 lines
behaviour
unless they explicitly request a halt in boot at a given priority.-Kevin
Quoted 42 lines
Signed-off-by Amos Kong <[email protected]>---
Resend for CCing seabios maillist.--- src/boot.c | 13 ++++++++----- 1 files changed, 8 insertions(+), 5 deletions(-)src/boot.c +8
-5@@ -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 );
Quoted 8 lines · Gleb Natapov
Quoted 7 lines · Amos Kong
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 ...
Quoted 7 lines
Quoted 4 lines
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.
Quoted 56 lines
Quoted 53 lines
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 <[email protected]>---
Resend for CCing seabios maillist.--- src/boot.c | 13 ++++++++----- 1 files changed, 8 insertions(+), 5 deletions(-)src/boot.c +8
-5@@ -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 ); }Signature · 1 line
1.7.1--
Gleb.
Quoted 12 lines · Ronen Hod
Quoted 11 lines · Gleb Natapov
Quoted 10 lines · Amos Kong
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.
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
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.
Quoted 54 lines
Ronen.
Quoted 52 lines
Quoted 49 lines
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 <[email protected]>---
Resend for CCing seabios maillist.--- src/boot.c | 13 ++++++++----- 1 files changed, 8 insertions(+), 5 deletions(-)src/boot.c +8
-5@@ -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 ); }Signature · 1 line
1.7.1--
Gleb.
--
Gleb.
PATCH v2 1/1 boot: support strict boot and make it configurable
In reply to Amos KongCurrent 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.
--- src/boot.c | 31 ++++++++++++++++++++++++------- 1 files changed, 24 insertions(+), 7 deletions(-)
src/boot.c +24 -7
@@ -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" );
Signature · 1 line
1.7.1
Re: [Qemu-devel] [SeaBIOS PATCH v2] boot: support strict boot and make it configurable
Quoted 14 lines · Amos Kong
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.
Quoted 6 lines
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 structbootentry_sand structbev_sto 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
src/boot.c +8 -0
@@ -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 0xf0static 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
Re: [Qemu-devel] [SeaBIOS PATCH v2] boot: support strict boot and make it configurable
Quoted 19 lines · Kevin O'Connor
Quoted 18 lines · Amos Kong
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 structbootentry_sand structbev_sto make it clearer.
Quoted 6 lines
Quoted 2 lines
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
Quoted 36 lines
(quoted diff) +0
-1-Kevinsrc/boot.c +8
-0@@ -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 0xf0static 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
PATCH v3 1/1 boot: add a new type to halt booting
In reply to Kevin O'ConnorCurrent 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.
---
v3: add a new type to halt booting (Kevin)
___
src/boot.c | 9 +++++++++ 1 files changed, 9 insertions(+), 0 deletions(-)
src/boot.c +9 -0
@@ -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 0xf0static 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
Signature · 1 line
1.7.1
Re: [Qemu-devel] [SeaBIOS PATCH v2] boot: support strict boot and make it configurable
In reply to Amos KongQuoted 5 lines · Amos Kong
Quoted 4 lines · Kevin O'Connor
Quoted 3 lines · Amos Kong
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.
[...]
Quoted 9 lines
Quoted 3 lines
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_addunselected 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