Craig Johnston
2008-Jan-29 17:34 UTC
[syslinux] Conditional kernel selection based on CPUID/DMI info
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
H. Peter Anvin
2008-Jan-29 20:05 UTC
[syslinux] Conditional kernel selection based on CPUID/DMI info
Craig Johnston wrote:> > 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? :) >I think we can consider a pattern-substitution module to be the beginning of a scripting language. We should probably have it collect information from as many sources as possible (CPUID, ...) On the other hand, a fullblown scripting language probably would be easy enough -- it's not really any different than what you're doing above. It's just a matter of having the time to do it... -hpa
Seemingly Similar Threads
- Automatically choose between 32-bit and 64-bit kernel
- default64 patch?
- [PATCH] virt-what.in: Added VMware virt detection using cpuid in wrapper script
- [PATCH] virt-what.in: Added VMware virt detection using cpuid in wrapper script
- Syslinux Digest, Vol 67, Issue 10