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

Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
This commit is contained in:
Keir Fraser committed 2009-06-23 11:23:27 +01:00
1 parent d1abeffc81
commit dcf18dfcc4
7 files changed
+63 -21

No files matched your search

+12 -10
View File
@@ -13,19 +13,20 @@ POTFILE := $(PODIR)/xen-xm.pot
I18NSRCFILES = $(shell find xen/xm/ -name '*.py')
CATALOGS = $(patsubst %,xen/xm/messages/%.mo,$(LINGUAS))
NLSDIR = $(SHAREDIR)/locale
xenpath = "xen/util/path.py"
XENPATH = "xen/util/path.py"
.PHONY: build buildpy genpath
genpath:
rm -f ${xenpath}
echo "SBINDIR=\"$(SBINDIR)\"" >> ${xenpath}
echo "BINDIR=\"$(BINDIR)\"" >> ${xenpath}
echo "LIBEXEC=\"$(LIBEXEC)\"" >> ${xenpath}
echo "LIBDIR=\"$(LIBDIR)\"" >> ${xenpath}
echo "SHAREDIR=\"$(SHAREDIR)\"" >> ${xenpath}
echo "PRIVATE_BINDIR=\"$(PRIVATE_BINDIR)\"" >> ${xenpath}
echo "XEN_CONFIG_DIR=\"$(XEN_CONFIG_DIR)\"" >> ${xenpath}
echo "XEN_SCRIPT_DIR=\"$(XEN_SCRIPT_DIR)\"" >> ${xenpath}
rm -f $(XENPATH)
echo "SBINDIR=\"$(SBINDIR)\"" >> $(XENPATH)
echo "BINDIR=\"$(BINDIR)\"" >> $(XENPATH)
echo "LIBEXEC=\"$(LIBEXEC)\"" >> $(XENPATH)
echo "LIBDIR=\"$(LIBDIR)\"" >> $(XENPATH)
echo "SHAREDIR=\"$(SHAREDIR)\"" >> $(XENPATH)
echo "PRIVATE_BINDIR=\"$(PRIVATE_BINDIR)\"" >> $(XENPATH)
echo "XENFIRMWAREDIR=\"$(XENFIRMWAREDIR)\"" >> $(XENPATH)
echo "XEN_CONFIG_DIR=\"$(XEN_CONFIG_DIR)\"" >> $(XENPATH)
echo "XEN_SCRIPT_DIR=\"$(XEN_SCRIPT_DIR)\"" >> $(XENPATH)
buildpy: genpath
CC="$(CC)" CFLAGS="$(CFLAGS)" $(PYTHON) setup.py build
@@ -91,6 +92,7 @@ test:
.PHONY: clean
clean:
rm -f $(XENPATH)
rm -rf build *.pyc *.pyo *.o *.a *~ $(CATALOGS) xen/util/auxbin.pyc
rm -f $(DEPS)
+2 -3
View File
@@ -19,8 +19,7 @@
import os
import os.path
import sys
from xen.util.path import SBINDIR,BINDIR,LIBEXEC,LIBDIR,PRIVATE_BINDIR
from xen.util.path import XEN_CONFIG_DIR, XEN_SCRIPT_DIR
from xen.util.path import *
def execute(exe, args = None):
exepath = pathTo(exe)
@@ -33,7 +32,7 @@ def execute(exe, args = None):
print exepath, ": ", exn
sys.exit(1)
SEARCHDIRS = [ BINDIR, SBINDIR, LIBEXEC, PRIVATE_BINDIR ]
SEARCHDIRS = [ BINDIR, SBINDIR, LIBEXEC, PRIVATE_BINDIR, XENFIRMWAREDIR ]
def pathTo(exebin):
for dir in SEARCHDIRS:
exe = os.path.join(dir, exebin)
+15 -4
View File
@@ -16,6 +16,7 @@
#============================================================================
import logging
import os
import re
import time
import types
@@ -39,7 +40,7 @@ from xen.util.blkif import blkdev_name_to_number, blkdev_uname_to_file
from xen.util.pci import pci_opts_list_from_sxp, pci_convert_sxp_to_dict
from xen.xend.XendSXPDev import dev_dict_to_sxp
from xen.util import xsconstants
import xen.util.auxbin
from xen.util import auxbin
log = logging.getLogger("xend.XendConfig")
log.setLevel(logging.WARN)
@@ -460,7 +461,11 @@ class XendConfig(dict):
if self.is_hvm() or self.has_rfb():
if 'device_model' not in self['platform']:
self['platform']['device_model'] = xen.util.auxbin.pathTo("qemu-dm")
self['platform']['device_model'] = auxbin.pathTo("qemu-dm")
# device_model may be set to 'qemu-dm' or 'stubdom-dm' w/o a path
if os.path.dirname(self['platform']['device_model']) != "":
self['platform']['device_model'] = \
auxbin.pathTo(self['platform']['device_model'])
if self.is_hvm():
if 'timer_mode' not in self['platform']:
@@ -478,11 +483,17 @@ class XendConfig(dict):
if 'loader' not in self['platform']:
# Old configs may have hvmloader set as PV_kernel param
if self.has_key('PV_kernel') and self['PV_kernel'] != '':
if self['PV_kernel'] == 'hvmloader':
self['PV_kernel'] = auxbin.pathTo("hvmloader")
self['platform']['loader'] = self['PV_kernel']
self['PV_kernel'] = ''
else:
self['platform']['loader'] = "/usr/lib/xen/boot/hvmloader"
self['platform']['loader'] = auxbin.pathTo("hvmloader")
log.debug("Loader is %s" % str(self['platform']['loader']))
elif self['platform']['loader'] == 'hvmloader':
self['platform']['loader'] = auxbin.pathTo("hvmloader")
if not os.path.exists(self['platform']['loader']):
raise VmError("kernel '%s' not found" % str(self['platform']['loader']))
# Compatibility hack, can go away soon.
if 'soundhw' not in self['platform'] and \
@@ -1550,7 +1561,7 @@ class XendConfig(dict):
# is invoked for pvfb services
if 'device_model' not in target['platform']:
target['platform']['device_model'] = \
xen.util.auxbin.pathTo("qemu-dm")
auxbin.pathTo("qemu-dm")
# Finally, if we are a pvfb, we need to make a vkbd
# as well that is not really exposed to Xen API
+31 -3
View File
@@ -653,11 +653,39 @@ def configure_image(vals):
return None
config_image = [ vals.builder ]
if vals.kernel:
config_image.append([ 'kernel', os.path.abspath(vals.kernel) ])
if os.path.dirname(vals.kernel) != "" and os.path.exists(vals.kernel):
config_image.append([ 'kernel', vals.kernel ])
elif vals.kernel == 'hvmloader':
# Keep hvmloader w/o a path and let xend find it.
# This allows guest migration to a Dom0 having different
# xen install pathes.
config_image.append([ 'kernel', vals.kernel ])
elif os.path.exists(os.path.abspath(vals.kernel))
# Keep old behaviour, if path is valid.
config_image.append([ 'kernel', os.path.abspath(vals.kernel) ])
else:
raise ValueError('Cannot find kernel "%s"' % vals.kernel)
if vals.ramdisk:
config_image.append([ 'ramdisk', os.path.abspath(vals.ramdisk) ])
if os.path.dirname(vals.ramdisk) != "" and os.path.exists(vals.ramdisk):
config_image.append([ 'ramdisk', vals.ramdisk ])
elif os.path.exists(os.path.abspath(vals.ramdisk)):
# Keep old behaviour, if path is valid.
config_image.append([ 'ramdisk', os.path.abspath(vals.ramdisk) ])
else:
raise ValueError('Cannot find ramdisk "%s"' % vals.ramdisk)
if vals.loader:
config_image.append([ 'loader', os.path.abspath(vals.loader) ])
if os.path.dirname(vals.loader) != "" and os.path.exists(vals.loader):
config_image.append([ 'loader', vals.loader ])
elif vals.loader == 'hvmloader':
# Keep hvmloader w/o a path and let xend find it.
# This allows guest migration to a Dom0 having different
# xen install pathes.
config_image.append([ 'loader', vals.loader ])
elif os.path.exists(os.path.abspath(vals.loader)):
# Keep old behaviour, if path is valid.
config_image.append([ 'loader', os.path.abspath(vals.loader) ])
else:
raise ValueError('Cannot find loader "%s"' % vals.loader)
if vals.cmdline_ip:
cmdline_ip = strip('ip=', vals.cmdline_ip)
config_image.append(['ip', cmdline_ip])
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.