ia64/xen-unstable

changeset 19813:b55070edb185

tools: don't require hardcoded firmware path in guest config file

Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
author Keir Fraser <keir.fraser@citrix.com>
date Tue Jun 23 11:23:27 2009 +0100 (2009-06-23)
parents d9b988c65ebf
children 20c0df018786
files config/StdGNU.mk config/SunOS.mk tools/firmware/Makefile tools/python/Makefile tools/python/xen/util/auxbin.py tools/python/xen/xend/XendConfig.py tools/python/xen/xm/create.py
line diff
     1.1 --- a/config/StdGNU.mk	Tue Jun 23 11:22:08 2009 +0100
     1.2 +++ b/config/StdGNU.mk	Tue Jun 23 11:23:27 2009 +0100
     1.3 @@ -36,6 +36,7 @@ MANDIR = $(SHAREDIR)/man
     1.4  MAN1DIR = $(MANDIR)/man1
     1.5  MAN8DIR = $(MANDIR)/man8
     1.6  SBINDIR = $(PREFIX)/sbin
     1.7 +XENFIRMWAREDIR = $(LIBDIR_x86_32)/xen/boot
     1.8  
     1.9  PRIVATE_PREFIX = $(LIBDIR)/xen
    1.10  PRIVATE_BINDIR = $(PRIVATE_PREFIX)/bin
     2.1 --- a/config/SunOS.mk	Tue Jun 23 11:22:08 2009 +0100
     2.2 +++ b/config/SunOS.mk	Tue Jun 23 11:23:27 2009 +0100
     2.3 @@ -30,6 +30,7 @@ MANDIR = $(PREFIX)/share/man
     2.4  MAN1DIR = $(MANDIR)/man1
     2.5  MAN8DIR = $(MANDIR)/man8
     2.6  SBINDIR = $(PREFIX)/sbin
     2.7 +XENFIRMWAREDIR = $(LIBDIR)/xen/boot
     2.8  
     2.9  PRIVATE_PREFIX = $(LIBDIR)/xen
    2.10  PRIVATE_BINDIR = $(PRIVATE_PREFIX)/bin
     3.1 --- a/tools/firmware/Makefile	Tue Jun 23 11:22:08 2009 +0100
     3.2 +++ b/tools/firmware/Makefile	Tue Jun 23 11:23:27 2009 +0100
     3.3 @@ -3,7 +3,7 @@ include $(XEN_ROOT)/tools/Rules.mk
     3.4  
     3.5  # hvmloader is a 32-bit protected mode binary.
     3.6  TARGET      := hvmloader/hvmloader
     3.7 -INST_DIR := $(DESTDIR)$(LIBDIR_x86_32)/xen/boot
     3.8 +INST_DIR := $(DESTDIR)$(XENFIRMWAREDIR)
     3.9  
    3.10  SUBDIRS :=
    3.11  SUBDIRS += rombios
     4.1 --- a/tools/python/Makefile	Tue Jun 23 11:22:08 2009 +0100
     4.2 +++ b/tools/python/Makefile	Tue Jun 23 11:23:27 2009 +0100
     4.3 @@ -13,19 +13,20 @@ POTFILE := $(PODIR)/xen-xm.pot
     4.4  I18NSRCFILES = $(shell find xen/xm/ -name '*.py')
     4.5  CATALOGS = $(patsubst %,xen/xm/messages/%.mo,$(LINGUAS))
     4.6  NLSDIR = $(SHAREDIR)/locale
     4.7 -xenpath = "xen/util/path.py"
     4.8 +XENPATH = "xen/util/path.py"
     4.9    
    4.10  .PHONY: build buildpy genpath
    4.11  genpath:
    4.12 -	rm -f ${xenpath}
    4.13 -	echo "SBINDIR=\"$(SBINDIR)\"" >> ${xenpath}
    4.14 -	echo "BINDIR=\"$(BINDIR)\"" >> ${xenpath}
    4.15 -	echo "LIBEXEC=\"$(LIBEXEC)\"" >> ${xenpath}
    4.16 -	echo "LIBDIR=\"$(LIBDIR)\"" >> ${xenpath}
    4.17 -	echo "SHAREDIR=\"$(SHAREDIR)\"" >> ${xenpath}
    4.18 -	echo "PRIVATE_BINDIR=\"$(PRIVATE_BINDIR)\"" >> ${xenpath}
    4.19 -	echo "XEN_CONFIG_DIR=\"$(XEN_CONFIG_DIR)\"" >> ${xenpath}
    4.20 -	echo "XEN_SCRIPT_DIR=\"$(XEN_SCRIPT_DIR)\"" >> ${xenpath}
    4.21 +	rm -f $(XENPATH)
    4.22 +	echo "SBINDIR=\"$(SBINDIR)\"" >> $(XENPATH)
    4.23 +	echo "BINDIR=\"$(BINDIR)\"" >> $(XENPATH)
    4.24 +	echo "LIBEXEC=\"$(LIBEXEC)\"" >> $(XENPATH)
    4.25 +	echo "LIBDIR=\"$(LIBDIR)\"" >> $(XENPATH)
    4.26 +	echo "SHAREDIR=\"$(SHAREDIR)\"" >> $(XENPATH)
    4.27 +	echo "PRIVATE_BINDIR=\"$(PRIVATE_BINDIR)\"" >> $(XENPATH)
    4.28 +	echo "XENFIRMWAREDIR=\"$(XENFIRMWAREDIR)\"" >> $(XENPATH)
    4.29 +	echo "XEN_CONFIG_DIR=\"$(XEN_CONFIG_DIR)\"" >> $(XENPATH)
    4.30 +	echo "XEN_SCRIPT_DIR=\"$(XEN_SCRIPT_DIR)\"" >> $(XENPATH)
    4.31  
    4.32  buildpy: genpath 
    4.33  	CC="$(CC)" CFLAGS="$(CFLAGS)" $(PYTHON) setup.py build
    4.34 @@ -91,6 +92,7 @@ test:
    4.35  
    4.36  .PHONY: clean
    4.37  clean:
    4.38 +	rm -f $(XENPATH)
    4.39  	rm -rf build *.pyc *.pyo *.o *.a *~ $(CATALOGS) xen/util/auxbin.pyc
    4.40  	rm -f $(DEPS)
    4.41  
     5.1 --- a/tools/python/xen/util/auxbin.py	Tue Jun 23 11:22:08 2009 +0100
     5.2 +++ b/tools/python/xen/util/auxbin.py	Tue Jun 23 11:23:27 2009 +0100
     5.3 @@ -19,8 +19,7 @@
     5.4  import os
     5.5  import os.path
     5.6  import sys
     5.7 -from xen.util.path import SBINDIR,BINDIR,LIBEXEC,LIBDIR,PRIVATE_BINDIR
     5.8 -from xen.util.path import XEN_CONFIG_DIR, XEN_SCRIPT_DIR
     5.9 +from xen.util.path import *
    5.10  
    5.11  def execute(exe, args = None):
    5.12      exepath = pathTo(exe)
    5.13 @@ -33,7 +32,7 @@ def execute(exe, args = None):
    5.14          print exepath, ": ", exn
    5.15          sys.exit(1)
    5.16  
    5.17 -SEARCHDIRS = [ BINDIR, SBINDIR, LIBEXEC, PRIVATE_BINDIR ]
    5.18 +SEARCHDIRS = [ BINDIR, SBINDIR, LIBEXEC, PRIVATE_BINDIR, XENFIRMWAREDIR ]
    5.19  def pathTo(exebin):
    5.20      for dir in SEARCHDIRS:
    5.21          exe = os.path.join(dir, exebin)
     6.1 --- a/tools/python/xen/xend/XendConfig.py	Tue Jun 23 11:22:08 2009 +0100
     6.2 +++ b/tools/python/xen/xend/XendConfig.py	Tue Jun 23 11:23:27 2009 +0100
     6.3 @@ -16,6 +16,7 @@
     6.4  #============================================================================
     6.5  
     6.6  import logging
     6.7 +import os
     6.8  import re
     6.9  import time
    6.10  import types
    6.11 @@ -39,7 +40,7 @@ from xen.util.blkif import blkdev_name_t
    6.12  from xen.util.pci import pci_opts_list_from_sxp, pci_convert_sxp_to_dict
    6.13  from xen.xend.XendSXPDev import dev_dict_to_sxp
    6.14  from xen.util import xsconstants
    6.15 -import xen.util.auxbin
    6.16 +from xen.util import auxbin
    6.17  
    6.18  log = logging.getLogger("xend.XendConfig")
    6.19  log.setLevel(logging.WARN)
    6.20 @@ -460,7 +461,11 @@ class XendConfig(dict):
    6.21  
    6.22          if self.is_hvm() or self.has_rfb():
    6.23              if 'device_model' not in self['platform']:
    6.24 -                self['platform']['device_model'] = xen.util.auxbin.pathTo("qemu-dm")
    6.25 +                self['platform']['device_model'] = auxbin.pathTo("qemu-dm")
    6.26 +            # device_model may be set to 'qemu-dm' or 'stubdom-dm' w/o a path
    6.27 +            if os.path.dirname(self['platform']['device_model']) != "":
    6.28 +                self['platform']['device_model'] = \
    6.29 +                    auxbin.pathTo(self['platform']['device_model'])
    6.30  
    6.31          if self.is_hvm():
    6.32              if 'timer_mode' not in self['platform']:
    6.33 @@ -478,11 +483,17 @@ class XendConfig(dict):
    6.34              if 'loader' not in self['platform']:
    6.35                  # Old configs may have hvmloader set as PV_kernel param
    6.36                  if self.has_key('PV_kernel') and self['PV_kernel'] != '':
    6.37 +                    if self['PV_kernel'] == 'hvmloader':
    6.38 +                        self['PV_kernel'] = auxbin.pathTo("hvmloader")
    6.39                      self['platform']['loader'] = self['PV_kernel']
    6.40                      self['PV_kernel'] = ''
    6.41                  else:
    6.42 -                    self['platform']['loader'] = "/usr/lib/xen/boot/hvmloader"
    6.43 +                    self['platform']['loader'] = auxbin.pathTo("hvmloader")
    6.44                  log.debug("Loader is %s" % str(self['platform']['loader']))
    6.45 +            elif self['platform']['loader'] == 'hvmloader':
    6.46 +                self['platform']['loader'] = auxbin.pathTo("hvmloader")
    6.47 +            if not os.path.exists(self['platform']['loader']):
    6.48 +                raise VmError("kernel '%s' not found" % str(self['platform']['loader']))
    6.49  
    6.50              # Compatibility hack, can go away soon.
    6.51              if 'soundhw' not in self['platform'] and \
    6.52 @@ -1550,7 +1561,7 @@ class XendConfig(dict):
    6.53                      # is invoked for pvfb services
    6.54                      if 'device_model' not in target['platform']:
    6.55                          target['platform']['device_model'] = \
    6.56 -                            xen.util.auxbin.pathTo("qemu-dm")
    6.57 +                            auxbin.pathTo("qemu-dm")
    6.58  
    6.59                      # Finally, if we are a pvfb, we need to make a vkbd
    6.60                      # as well that is not really exposed to Xen API
     7.1 --- a/tools/python/xen/xm/create.py	Tue Jun 23 11:22:08 2009 +0100
     7.2 +++ b/tools/python/xen/xm/create.py	Tue Jun 23 11:23:27 2009 +0100
     7.3 @@ -653,11 +653,39 @@ def configure_image(vals):
     7.4          return None
     7.5      config_image = [ vals.builder ]
     7.6      if vals.kernel:
     7.7 -        config_image.append([ 'kernel', os.path.abspath(vals.kernel) ])
     7.8 +        if os.path.dirname(vals.kernel) != "" and os.path.exists(vals.kernel):
     7.9 +            config_image.append([ 'kernel', vals.kernel ])
    7.10 +        elif vals.kernel == 'hvmloader':
    7.11 +            # Keep hvmloader w/o a path and let xend find it.
    7.12 +            # This allows guest migration to a Dom0 having different
    7.13 +            # xen install pathes.
    7.14 +            config_image.append([ 'kernel', vals.kernel ])
    7.15 +        elif os.path.exists(os.path.abspath(vals.kernel))
    7.16 +            # Keep old behaviour, if path is valid.
    7.17 +            config_image.append([ 'kernel', os.path.abspath(vals.kernel) ])
    7.18 +        else:
    7.19 +            raise ValueError('Cannot find kernel "%s"' % vals.kernel)
    7.20      if vals.ramdisk:
    7.21 -        config_image.append([ 'ramdisk', os.path.abspath(vals.ramdisk) ])
    7.22 +        if os.path.dirname(vals.ramdisk) != "" and os.path.exists(vals.ramdisk):
    7.23 +            config_image.append([ 'ramdisk', vals.ramdisk ])
    7.24 +        elif os.path.exists(os.path.abspath(vals.ramdisk)):
    7.25 +            # Keep old behaviour, if path is valid.
    7.26 +            config_image.append([ 'ramdisk', os.path.abspath(vals.ramdisk) ])
    7.27 +        else:
    7.28 +            raise ValueError('Cannot find ramdisk "%s"' % vals.ramdisk)
    7.29      if vals.loader:
    7.30 -        config_image.append([ 'loader', os.path.abspath(vals.loader) ])
    7.31 +        if os.path.dirname(vals.loader) != "" and os.path.exists(vals.loader):
    7.32 +            config_image.append([ 'loader', vals.loader ])
    7.33 +        elif vals.loader == 'hvmloader':
    7.34 +            # Keep hvmloader w/o a path and let xend find it.
    7.35 +            # This allows guest migration to a Dom0 having different
    7.36 +            # xen install pathes.
    7.37 +            config_image.append([ 'loader', vals.loader ])
    7.38 +        elif os.path.exists(os.path.abspath(vals.loader)):
    7.39 +            # Keep old behaviour, if path is valid.
    7.40 +            config_image.append([ 'loader', os.path.abspath(vals.loader) ])
    7.41 +        else:
    7.42 +            raise ValueError('Cannot find loader "%s"' % vals.loader)
    7.43      if vals.cmdline_ip:
    7.44          cmdline_ip = strip('ip=', vals.cmdline_ip)
    7.45          config_image.append(['ip', cmdline_ip])