debuggers.hg

changeset 21173:5bc70100b514

pygrub: fix 64b Solaris PV guest boot on 32b Linux dom0 & 64b Xen

Signed-off-by: Mark Johnson <mark.r.johnson@oracle.com>
author Keir Fraser <keir.fraser@citrix.com>
date Mon Apr 12 07:21:44 2010 +0100 (2010-04-12)
parents aae7cb2f1841
children b5f9c6274d91
files tools/pygrub/src/pygrub
line diff
     1.1 --- a/tools/pygrub/src/pygrub	Fri Apr 09 08:54:25 2010 +0100
     1.2 +++ b/tools/pygrub/src/pygrub	Mon Apr 12 07:21:44 2010 +0100
     1.3 @@ -17,6 +17,7 @@ import os, sys, string, struct, tempfile
     1.4  import copy
     1.5  import logging
     1.6  import platform
     1.7 +import xen.lowlevel.xc
     1.8  
     1.9  import curses, _curses, curses.wrapper, curses.textpad, curses.ascii
    1.10  import getopt
    1.11 @@ -573,27 +574,28 @@ def run_grub(file, entry, fs, arg):
    1.12  
    1.13      return grubcfg
    1.14  
    1.15 +def supports64bitPVguest():
    1.16 +    xc = xen.lowlevel.xc.xc()
    1.17 +    caps = xc.xeninfo()['xen_caps'].split(" ")
    1.18 +    for cap in caps:
    1.19 +        if cap == "xen-3.0-x86_64":
    1.20 +            return True
    1.21 +    return False
    1.22 +
    1.23  # If nothing has been specified, look for a Solaris domU. If found, perform the
    1.24  # necessary tweaks.
    1.25  def sniff_solaris(fs, cfg):
    1.26      if not fs.file_exists("/platform/i86xpv/kernel/unix"):
    1.27          return cfg
    1.28 -    
    1.29 -    # darned python
    1.30 -    longmode = (sys.maxint != 2147483647L)
    1.31 -    if not longmode:
    1.32 -        longmode = os.uname()[4] == "x86_64"
    1.33 -    if not longmode:
    1.34 -        if (os.access("/usr/bin/isainfo", os.R_OK) and
    1.35 -            os.popen("/usr/bin/isainfo -b").read() == "64\n"):
    1.36 -            longmode = True
    1.37  
    1.38      if not cfg["kernel"]:
    1.39 -        cfg["kernel"] = "/platform/i86xpv/kernel/unix"
    1.40 -        cfg["ramdisk"] = "/platform/i86pc/boot_archive"
    1.41 -        if longmode:
    1.42 +        if supports64bitPVguest() and \
    1.43 +          fs.file_exists("/platform/i86xpv/kernel/amd64/unix"):
    1.44              cfg["kernel"] = "/platform/i86xpv/kernel/amd64/unix"
    1.45              cfg["ramdisk"] = "/platform/i86pc/amd64/boot_archive"
    1.46 +        else:
    1.47 +            cfg["kernel"] = "/platform/i86xpv/kernel/unix"
    1.48 +            cfg["ramdisk"] = "/platform/i86pc/boot_archive"
    1.49  
    1.50      # Unpleasant. Typically we'll have 'root=foo -k' or 'root=foo /kernel -k',
    1.51      # and we need to maintain Xen properties (root= and ip=) and the kernel