From: Amos Kong <akong@redhat.com>
To: Gleb Natapov <gleb@redhat.com>
Cc: dallan@redhat.com, alex.williamson@redhat.com,
kevin@koconnor.net, seabios@seabios.org, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [Resend][Seabios PATCH] don't boot from un-selected devices
Date: Tue, 25 Dec 2012 18:37:01 +0800 [thread overview]
Message-ID: <20121225103701.GA6688@t430s.redhat.com> (raw)
In-Reply-To: <20121225063707.GX17584@redhat.com>
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);
next prev parent reply other threads:[~2012-12-25 10:37 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-12-19 7:22 [Qemu-devel] [PATCH] don't boot from un-selected devices Amos Kong
2012-12-19 7:24 ` [Qemu-devel] [Resend][Seabios PATCH] " Amos Kong
2012-12-19 7:38 ` Gerd Hoffmann
2012-12-19 8:12 ` Amos Kong
2012-12-19 9:32 ` Gleb Natapov
2012-12-25 3:58 ` Amos Kong
2012-12-25 6:37 ` Gleb Natapov
2012-12-25 10:37 ` Amos Kong [this message]
2012-12-26 0:55 ` [Qemu-devel] [SeaBIOS PATCH v2] boot: support strict boot and make it configurable Amos Kong
2013-01-09 4:00 ` Kevin O'Connor
2013-01-09 5:03 ` Amos Kong
2013-01-12 22:01 ` Kevin O'Connor
2013-01-09 5:17 ` [Qemu-devel] [SeaBIOS PATCH v3] boot: add a new type to halt booting Amos Kong
2012-12-25 15:59 ` [Qemu-devel] [Resend][Seabios PATCH] don't boot from un-selected devices Ronen Hod
2012-12-25 17:15 ` Gleb Natapov
2012-12-19 16:39 ` Kevin O'Connor
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20121225103701.GA6688@t430s.redhat.com \
--to=akong@redhat.com \
--cc=alex.williamson@redhat.com \
--cc=dallan@redhat.com \
--cc=gleb@redhat.com \
--cc=kevin@koconnor.net \
--cc=qemu-devel@nongnu.org \
--cc=seabios@seabios.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).