[syslinux] Conditional kernel selection based on CPUID/DMI info

Craig Johnston agspoon at gmail.com
Tue Jan 29 09:34:57 PST 2008


I'm network booting various systems via PXE using pxelinux, and I
would like to select a specific kernel and kernel options based on the
type of CPU and/or type of system (PAE, 64bit, vmx, etc.).  I see that
some of this capability is present (e.g. Erwan Velu's nice
cpuid/dmi/pci code), but the infrastructure to make use of this
information in the config file is missing.  It looks like it would be
fairly straight forward to create a custom com32 module to detect
whatever I want, but I don't see an easy way to translate that
information into the mechanism by which my kernel of choice is
selected.  I've seen a patch that makes the 64bit/32bit distinction
and adds a special "default64" target.  This is close, but breaks the
flexibility of the menu system and the user's ability to add
parameters to the command line or select from multiple configurations.

I see at least two possibilities here.  One is to add variables and
conditionals to the configuration file parser (a scripting language
has been proposed), or parameter string substitution.  The former
would be fairly complicated, and that is probably why it hasn't been
implemented.  The latter has some history in a related DHCP patch that
went by a while ago, and is less intrusive (though less flexible).

What do people think of the following for a string substitution method?

DEFAULT linux

LABEL linux
    KERNEL cpuselect.c32
    APPEND ${LM?"x86_64":"i386"}/bzImage-${SMP?"smp":"up"}
initrd=${LM?"x86_64":"i386"}/initrd-${SMP?"smp":"up"} console=ttyS0

LABEL linux-single
    KERNEL cpuselect.c32
     APPEND ${LM?"x86_64":"i386"}/bzImage-${SMP?"smp":"up"}
initrd=${LM?"x86_64":"i386"}/initrd-${SMP?"smp":"up"} console=ttyS0
single

The parameters "LM" and "SMP" are Boolean values that are set in the
cpuselect.c32 module, and select the replacement text ala the C-like
conditional statement.  This is just one of many ways to do something
like this, and it would seem a lot simpler than a full fledged
scripting language (it's all kept inside a module).

Am I reinventing the wheel here, or inventing a square wheel?  :)

Craig




More information about the Syslinux mailing list