From c6d9aa996e86db33e66c411153de3425527fb24f Mon Sep 17 00:00:00 2001 From: Shad L. Lords Date: Mon, 26 Oct 2009 22:20:13 -0600 Subject: [PATCH] Pick correct kernel --- bootloaderInfo.py | 29 ++++++++++++++++++++++++++++- 1 files changed, 28 insertions(+), 1 deletions(-) diff --git a/bootloaderInfo.py b/bootloaderInfo.py index 3668ee8..36aa6ae 100644 --- a/bootloaderInfo.py +++ b/bootloaderInfo.py @@ -732,10 +732,37 @@ class x86BootloaderInfo(bootloaderInfo): f.write("# initrd %sinitrd-version.img\n" % (cfPath)) f.write("#boot=/dev/%s\n" % (grubTarget)) + import isys + nthreads = isys.acpicpus() + if nthreads == 0: + # this should probably be table driven or something... + ncpus = isys.smpAvailable() or 1 + nthreads = isys.htavailable() or 1 + ncores = isys.coresavailable() + + if ncpus == 1: # machines that have one socket + nthreads = nthreads; + else: # machines with more than one socket + nthreads = (int(nthreads / ncores) or 1) * ncpus + + xenkernel = 0 + if os.path.exists("/proc/xen/capabilities"): + xenkernel = 1 + # get the default image to boot... we have to walk and find it # since grub indexes by where it is in the config file if defaultDev == rootDev: - default = 0 + for kernel in range(0, len(kernelList)): + default=kernel + version=kernelList[kernel][2] + if version.find('xen') >= 0: + if xenkernel: + break + elif version.find('smp') >= 0: + if not xenkernel and nthreads > 1: + break + else: + break else: # if the default isn't linux, it's the first thing in the # chain list -- 1.5.5.6