debuggers.hg
changeset 19666:23f9857f642f
tools: get rid of hardcoded config dirs
Remove *all* hardcoded "/etc/xen" strings in python code.
Additionally, it removes pygrub_path from osdep.py. Its use has been
replaced with auxbin.pathTo("pygrub").
Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
Remove *all* hardcoded "/etc/xen" strings in python code.
Additionally, it removes pygrub_path from osdep.py. Its use has been
replaced with auxbin.pathTo("pygrub").
Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
line diff
1.1 --- a/config/StdGNU.mk Wed May 20 15:13:36 2009 +0100 1.2 +++ b/config/StdGNU.mk Wed May 20 15:27:30 2009 +0100 1.3 @@ -40,6 +40,14 @@ SBINDIR = $(PREFIX)/sbin 1.4 PRIVATE_PREFIX = $(LIBDIR)/xen 1.5 PRIVATE_BINDIR = $(PRIVATE_PREFIX)/bin 1.6 1.7 +ifeq ($(PREFIX),/usr) 1.8 +CONFIG_DIR = /etc 1.9 +else 1.10 +CONFIG_DIR = $(PREFIX)/etc 1.11 +endif 1.12 +XEN_CONFIG_DIR = $(CONFIG_DIR)/xen 1.13 +XEN_SCRIPT_DIR = $(XEN_CONFIG_DIR)/scripts 1.14 + 1.15 SOCKET_LIBS = 1.16 CURSES_LIBS = -lncurses 1.17 PTHREAD_LIBS = -lpthread
2.1 --- a/config/SunOS.mk Wed May 20 15:13:36 2009 +0100 2.2 +++ b/config/SunOS.mk Wed May 20 15:27:30 2009 +0100 2.3 @@ -34,6 +34,14 @@ SBINDIR = $(PREFIX)/sbin 2.4 PRIVATE_PREFIX = $(LIBDIR)/xen 2.5 PRIVATE_BINDIR = $(PRIVATE_PREFIX)/bin 2.6 2.7 +ifeq ($(PREFIX),/usr) 2.8 +CONFIG_DIR = /etc 2.9 +else 2.10 +CONFIG_DIR = $(PREFIX)/etc 2.11 +endif 2.12 +XEN_CONFIG_DIR = $(CONFIG_DIR)/xen 2.13 +XEN_SCRIPT_DIR = $(PRIVATE_PREFIX)/scripts 2.14 + 2.15 SunOS_LIBDIR = /usr/sfw/lib 2.16 SunOS_LIBDIR_x86_64 = /usr/sfw/lib/amd64 2.17
3.1 --- a/tools/Makefile Wed May 20 15:13:36 2009 +0100 3.2 +++ b/tools/Makefile Wed May 20 15:27:30 2009 +0100 3.3 @@ -94,7 +94,9 @@ ioemu-dir-find: 3.4 set -e; \ 3.5 $(absolutify_xen_root); \ 3.6 PREFIX=$(PREFIX); \ 3.7 + XEN_SCRIPT_DIR=$(XEN_SCRIPT_DIR); \ 3.8 export PREFIX; \ 3.9 + export XEN_SCRIPT_DIR; \ 3.10 cd ioemu-dir; \ 3.11 ./xen-setup $(IOEMU_CONFIGURE_CROSS) 3.12
4.1 --- a/tools/Rules.mk Wed May 20 15:13:36 2009 +0100 4.2 +++ b/tools/Rules.mk Wed May 20 15:27:30 2009 +0100 4.3 @@ -8,10 +8,6 @@ include $(XEN_ROOT)/Config.mk 4.4 export _INSTALL := $(INSTALL) 4.5 INSTALL = $(XEN_ROOT)/tools/cross-install 4.6 4.7 -CONFIG_DIR = /etc 4.8 -XEN_CONFIG_DIR = $(CONFIG_DIR)/xen 4.9 -XEN_SCRIPT_DIR = $(XEN_CONFIG_DIR)/scripts 4.10 - 4.11 XEN_INCLUDE = $(XEN_ROOT)/tools/include 4.12 XEN_XC = $(XEN_ROOT)/tools/python/xen/lowlevel/xc 4.13 XEN_LIBXC = $(XEN_ROOT)/tools/libxc
5.1 --- a/tools/python/Makefile Wed May 20 15:13:36 2009 +0100 5.2 +++ b/tools/python/Makefile Wed May 20 15:27:30 2009 +0100 5.3 @@ -23,6 +23,8 @@ genpath: 5.4 echo "LIBEXEC=\"$(LIBEXEC)\"" >> ${xenpath} 5.5 echo "LIBDIR=\"$(LIBDIR)\"" >> ${xenpath} 5.6 echo "PRIVATE_BINDIR=\"$(PRIVATE_BINDIR)\"" >> ${xenpath} 5.7 + echo "XEN_CONFIG_DIR=\"$(XEN_CONFIG_DIR)\"" >> ${xenpath} 5.8 + echo "XEN_SCRIPT_DIR=\"$(XEN_SCRIPT_DIR)\"" >> ${xenpath} 5.9 5.10 buildpy: genpath 5.11 CC="$(CC)" CFLAGS="$(CFLAGS)" $(PYTHON) setup.py build
6.1 --- a/tools/python/xen/util/auxbin.py Wed May 20 15:13:36 2009 +0100 6.2 +++ b/tools/python/xen/util/auxbin.py Wed May 20 15:27:30 2009 +0100 6.3 @@ -20,6 +20,7 @@ import os 6.4 import os.path 6.5 import sys 6.6 from xen.util.path import SBINDIR,BINDIR,LIBEXEC,LIBDIR,PRIVATE_BINDIR 6.7 +from xen.util.path import XEN_CONFIG_DIR, XEN_SCRIPT_DIR 6.8 6.9 def execute(exe, args = None): 6.10 exepath = pathTo(exe) 6.11 @@ -45,3 +46,9 @@ def path(): 6.12 6.13 def libpath(): 6.14 return LIBDIR 6.15 + 6.16 +def xen_configdir(): 6.17 + return XEN_CONFIG_DIR 6.18 + 6.19 +def scripts_dir(): 6.20 + return XEN_SCRIPT_DIR
7.1 --- a/tools/python/xen/util/xsm/acm/acm.py Wed May 20 15:13:36 2009 +0100 7.2 +++ b/tools/python/xen/util/xsm/acm/acm.py Wed May 20 15:27:30 2009 +0100 7.3 @@ -31,11 +31,11 @@ from xen.xend import XendConstants 7.4 from xen.xend import XendOptions 7.5 from xen.xend.XendLogging import log 7.6 from xen.xend.XendError import VmError 7.7 -from xen.util import dictio, xsconstants 7.8 +from xen.util import dictio, xsconstants, auxbin 7.9 from xen.xend.XendConstants import * 7.10 7.11 #global directories and tools for security management 7.12 -install_policy_dir_prefix = "/etc/xen/acm-security/policies" 7.13 +install_policy_dir_prefix = auxbin.xen_configdir() + "/acm-security/policies" 7.14 security_dir_prefix = XendOptions.instance().get_xend_security_path() 7.15 policy_dir_prefix = security_dir_prefix + "/policies" 7.16 res_label_filename = policy_dir_prefix + "/resource_labels"
8.1 --- a/tools/python/xen/xend/XendConstants.py Wed May 20 15:13:36 2009 +0100 8.2 +++ b/tools/python/xen/xend/XendConstants.py Wed May 20 15:27:30 2009 +0100 8.3 @@ -16,6 +16,7 @@ 8.4 #============================================================================ 8.5 8.6 from xen.xend.XendAPIConstants import * 8.7 +from xen.util import auxbin 8.8 8.9 # 8.10 # Shutdown codes and reasons. 8.11 @@ -129,7 +130,7 @@ DEV_MIGRATE_STEP3 = 3 8.12 # VTPM-related constants 8.13 # 8.14 8.15 -VTPM_DELETE_SCRIPT = '/etc/xen/scripts/vtpm-delete' 8.16 +VTPM_DELETE_SCRIPT = auxbin.scripts_dir() + '/vtpm-delete' 8.17 8.18 # 8.19 # Xenstore Constants
9.1 --- a/tools/python/xen/xend/XendDomainInfo.py Wed May 20 15:13:36 2009 +0100 9.2 +++ b/tools/python/xen/xend/XendDomainInfo.py Wed May 20 15:27:30 2009 +0100 9.3 @@ -34,12 +34,12 @@ import traceback 9.4 from types import StringTypes 9.5 9.6 import xen.lowlevel.xc 9.7 -from xen.util import asserts 9.8 +from xen.util import asserts, auxbin 9.9 from xen.util.blkif import blkdev_uname_to_file, blkdev_uname_to_taptype 9.10 import xen.util.xsm.xsm as security 9.11 from xen.util import xsconstants 9.12 9.13 -from xen.xend import balloon, sxp, uuid, image, arch, osdep 9.14 +from xen.xend import balloon, sxp, uuid, image, arch 9.15 from xen.xend import XendOptions, XendNode, XendConfig 9.16 9.17 from xen.xend.XendConfig import scrub_password 9.18 @@ -2914,7 +2914,7 @@ class XendDomainInfo: 9.19 else: 9.20 # Boot using bootloader 9.21 if not blexec or blexec == 'pygrub': 9.22 - blexec = osdep.pygrub_path 9.23 + blexec = auxbin.pathTo('pygrub') 9.24 9.25 blcfg = None 9.26 disks = [x for x in self.info['vbd_refs']
10.1 --- a/tools/python/xen/xend/XendOptions.py Wed May 20 15:13:36 2009 +0100 10.2 +++ b/tools/python/xen/xend/XendOptions.py Wed May 20 15:27:30 2009 +0100 10.3 @@ -32,6 +32,7 @@ import sys 10.4 10.5 from xen.xend import sxp, osdep, XendLogging 10.6 from xen.xend.XendError import XendError 10.7 +from xen.util import auxbin 10.8 10.9 if os.uname()[0] == 'SunOS': 10.10 from xen.lowlevel import scf 10.11 @@ -40,10 +41,10 @@ class XendOptions: 10.12 """Configuration options.""" 10.13 10.14 """Where network control scripts live.""" 10.15 - network_script_dir = osdep.scripts_dir 10.16 + network_script_dir = auxbin.scripts_dir() 10.17 10.18 """Where block control scripts live.""" 10.19 - block_script_dir = osdep.scripts_dir 10.20 + block_script_dir = auxbin.scripts_dir() 10.21 10.22 """Default path to the log file. """ 10.23 logfile_default = "/var/log/xen/xend.log" 10.24 @@ -115,7 +116,7 @@ class XendOptions: 10.25 xend_vnc_tls = 0 10.26 10.27 """x509 certificate directory for QEMU VNC server""" 10.28 - xend_vnc_x509_cert_dir = "/etc/xen/vnc" 10.29 + xend_vnc_x509_cert_dir = auxbin.xen_configdir() + "/vnc" 10.30 10.31 """Verify incoming client x509 certs""" 10.32 xend_vnc_x509_verify = 0 10.33 @@ -355,7 +356,7 @@ class XendOptions: 10.34 s = self.get_config_string('resource-label-change-script') 10.35 if s: 10.36 result = s.split(" ") 10.37 - result[0] = os.path.join(osdep.scripts_dir, result[0]) 10.38 + result[0] = os.path.join(auxbin.scripts_dir(), result[0]) 10.39 return result 10.40 else: 10.41 return None 10.42 @@ -386,7 +387,7 @@ class XendOptions: 10.43 class XendOptionsFile(XendOptions): 10.44 10.45 """Default path to the config file.""" 10.46 - config_default = "/etc/xen/xend-config.sxp" 10.47 + config_default = auxbin.xen_configdir() + "/xend-config.sxp" 10.48 10.49 """Environment variable used to override config_default.""" 10.50 config_var = "XEND_CONFIG"
11.1 --- a/tools/python/xen/xend/XendPIF.py Wed May 20 15:13:36 2009 +0100 11.2 +++ b/tools/python/xen/xend/XendPIF.py Wed May 20 15:27:30 2009 +0100 11.3 @@ -25,6 +25,7 @@ from xen.xend.XendBase import XendBase 11.4 from xen.xend.XendPIFMetrics import XendPIFMetrics 11.5 from xen.xend.XendError import * 11.6 from xen.xend import Vifctl 11.7 +from xen.util import auxbin 11.8 11.9 log = logging.getLogger("xend.XendPIF") 11.10 log.setLevel(logging.TRACE)
12.1 --- a/tools/python/xen/xend/osdep.py Wed May 20 15:13:36 2009 +0100 12.2 +++ b/tools/python/xen/xend/osdep.py Wed May 20 15:27:30 2009 +0100 12.3 @@ -20,21 +20,12 @@ 12.4 import os 12.5 import commands 12.6 12.7 -_scripts_dir = { 12.8 - "Linux": "/etc/xen/scripts", 12.9 - "SunOS": "/usr/lib/xen/scripts", 12.10 -} 12.11 - 12.12 _xend_autorestart = { 12.13 "NetBSD": True, 12.14 "Linux": True, 12.15 "SunOS": False, 12.16 } 12.17 12.18 -_pygrub_path = { 12.19 - "SunOS": "/usr/lib/xen/bin/pygrub" 12.20 -} 12.21 - 12.22 _vif_script = { 12.23 "SunOS": "vif-vnic" 12.24 } 12.25 @@ -221,9 +212,7 @@ def _solaris_postfork(ct, abandon=False) 12.26 def _get(var, default=None): 12.27 return var.get(os.uname()[0], default) 12.28 12.29 -scripts_dir = _get(_scripts_dir, "/etc/xen/scripts") 12.30 xend_autorestart = _get(_xend_autorestart) 12.31 -pygrub_path = _get(_pygrub_path, "/usr/bin/pygrub") 12.32 vif_script = _get(_vif_script, "vif-bridge") 12.33 lookup_balloon_stat = _get(_balloon_stat, _linux_balloon_stat) 12.34 get_cpuinfo = _get(_get_cpuinfo, _linux_get_cpuinfo)
13.1 --- a/tools/python/xen/xend/server/blkif.py Wed May 20 15:13:36 2009 +0100 13.2 +++ b/tools/python/xen/xend/server/blkif.py Wed May 20 15:27:30 2009 +0100 13.3 @@ -24,7 +24,7 @@ from xen.util import blkif 13.4 import xen.util.xsm.xsm as security 13.5 from xen.xend.XendError import VmError 13.6 from xen.xend.server.DevController import DevController 13.7 -from xen.util import xsconstants 13.8 +from xen.util import xsconstants, auxbin 13.9 13.10 class BlkifController(DevController): 13.11 """Block device interface controller. Handles all block devices 13.12 @@ -40,7 +40,7 @@ class BlkifController(DevController): 13.13 if protocol in ('phy', 'file', 'tap'): 13.14 return True 13.15 13.16 - return os.access('/etc/xen/scripts/block-%s' % protocol, os.X_OK) 13.17 + return os.access(auxbin.scripts_dir() + '/block-%s' % protocol, os.X_OK) 13.18 13.19 13.20 def getDeviceDetails(self, config):
14.1 --- a/tools/python/xen/xend/server/pciquirk.py Wed May 20 15:13:36 2009 +0100 14.2 +++ b/tools/python/xen/xend/server/pciquirk.py Wed May 20 15:27:30 2009 +0100 14.3 @@ -3,10 +3,11 @@ from xen.xend.XendError import XendError 14.4 import sys 14.5 import os.path 14.6 from xen.xend.sxp import * 14.7 +from xen.util import auxbin 14.8 14.9 QUIRK_SYSFS_NODE = "/sys/bus/pci/drivers/pciback/quirks" 14.10 -QUIRK_CONFIG_FILE = "/etc/xen/xend-pci-quirks.sxp" 14.11 -PERMISSIVE_CONFIG_FILE = "/etc/xen/xend-pci-permissive.sxp" 14.12 +QUIRK_CONFIG_FILE = auxbin.xen_configdir() + "/xend-pci-quirks.sxp" 14.13 +PERMISSIVE_CONFIG_FILE = auxbin.xen_configdir() + "/xend-pci-permissive.sxp" 14.14 PERMISSIVE_SYSFS_NODE = "/sys/bus/pci/drivers/pciback/permissive" 14.15 14.16 class PCIQuirk:
15.1 --- a/tools/python/xen/xm/addlabel.py Wed May 20 15:13:36 2009 +0100 15.2 +++ b/tools/python/xen/xm/addlabel.py Wed May 20 15:27:30 2009 +0100 15.3 @@ -24,7 +24,7 @@ import sys 15.4 15.5 import xen.util.xsm.xsm as security 15.6 from xen.xm.opts import OptionError 15.7 -from xen.util import xsconstants 15.8 +from xen.util import xsconstants, auxbin 15.9 from xen.xm import main as xm_main 15.10 from xen.xm.main import server 15.11 15.12 @@ -221,7 +221,7 @@ def main(argv): 15.13 if argv[2].lower() == "dom": 15.14 configfile = argv[3] 15.15 if configfile[0] != '/': 15.16 - for prefix in [os.path.realpath(os.path.curdir), "/etc/xen"]: 15.17 + for prefix in [os.path.realpath(os.path.curdir), auxbin.xen_configdir()]: 15.18 configfile = prefix + "/" + configfile 15.19 if os.path.isfile(configfile): 15.20 break
16.1 --- a/tools/python/xen/xm/create.py Wed May 20 15:13:36 2009 +0100 16.2 +++ b/tools/python/xen/xm/create.py Wed May 20 15:27:30 2009 +0100 16.3 @@ -29,7 +29,6 @@ import xmlrpclib 16.4 16.5 from xen.xend import sxp 16.6 from xen.xend import PrettyPrint as SXPPrettyPrint 16.7 -from xen.xend import osdep 16.8 import xen.xend.XendClient 16.9 from xen.xend.XendBootloader import bootloader 16.10 from xen.xend.XendConstants import * 16.11 @@ -38,7 +37,7 @@ from xen.util import blkif 16.12 from xen.util import vscsi_util 16.13 import xen.util.xsm.xsm as security 16.14 from xen.xm.main import serverType, SERVER_XEN_API, get_single_vm 16.15 -from xen.util import utils 16.16 +from xen.util import utils, auxbin 16.17 16.18 from xen.xm.opts import * 16.19 16.20 @@ -72,7 +71,7 @@ gopts.opt('quiet', short='q', 16.21 use="Quiet.") 16.22 16.23 gopts.opt('path', val='PATH', 16.24 - fn=set_value, default='.:/etc/xen', 16.25 + fn=set_value, default='.:' + auxbin.xen_configdir(), 16.26 use="Search path for configuration scripts. " 16.27 "The value of PATH is a colon-separated directory list.") 16.28 16.29 @@ -981,7 +980,7 @@ def make_config(vals): 16.30 config_image = configure_image(vals) 16.31 if vals.bootloader: 16.32 if vals.bootloader == "pygrub": 16.33 - vals.bootloader = osdep.pygrub_path 16.34 + vals.bootloader = auxbin.pathTo(vals.bootloader) 16.35 16.36 config.append(['bootloader', vals.bootloader]) 16.37 if vals.bootargs:
17.1 --- a/tools/python/xen/xm/getlabel.py Wed May 20 15:13:36 2009 +0100 17.2 +++ b/tools/python/xen/xm/getlabel.py Wed May 20 15:27:30 2009 +0100 17.3 @@ -20,7 +20,7 @@ 17.4 """ 17.5 import sys, os, re 17.6 import xen.util.xsm.xsm as security 17.7 -from xen.util import xsconstants 17.8 +from xen.util import xsconstants, auxbin 17.9 from xen.xm.opts import OptionError 17.10 from xen.xm import main as xm_main 17.11 from xen.xm.main import server 17.12 @@ -59,7 +59,7 @@ def get_domain_label(configfile): 17.13 if configfile[0] == '/': 17.14 fd = open(configfile, "rb") 17.15 else: 17.16 - for prefix in [".", "/etc/xen"]: 17.17 + for prefix in [".", auxbin.xen_configdir() ]: 17.18 abs_file = prefix + "/" + configfile 17.19 if os.path.isfile(abs_file): 17.20 fd = open(abs_file, "rb")
18.1 --- a/tools/python/xen/xm/main.py Wed May 20 15:13:36 2009 +0100 18.2 +++ b/tools/python/xen/xm/main.py Wed May 20 15:27:30 2009 +0100 18.3 @@ -55,6 +55,7 @@ from xen.util.xmlrpcclient import Server 18.4 import xen.util.xsm.xsm as security 18.5 from xen.util.xsm.xsm import XSMError 18.6 from xen.util.acmpolicy import ACM_LABEL_UNLABELED_DISPLAY 18.7 +from xen.util import auxbin 18.8 18.9 import XenAPI 18.10 18.11 @@ -72,7 +73,7 @@ if not hasattr(getopt, 'gnu_getopt'): 18.12 getopt.gnu_getopt = getopt.getopt 18.13 18.14 XM_CONFIG_FILE_ENVVAR = 'XM_CONFIG_FILE' 18.15 -XM_CONFIG_FILE_DEFAULT = '/etc/xen/xm-config.xml' 18.16 +XM_CONFIG_FILE_DEFAULT = auxbin.xen_configdir + '/xm-config.xml' 18.17 18.18 # Supported types of server 18.19 SERVER_LEGACY_XMLRPC = 'LegacyXMLRPC'
19.1 --- a/tools/python/xen/xm/rmlabel.py Wed May 20 15:13:36 2009 +0100 19.2 +++ b/tools/python/xen/xm/rmlabel.py Wed May 20 15:27:30 2009 +0100 19.3 @@ -22,7 +22,7 @@ import os 19.4 import re 19.5 import sys 19.6 import xen.util.xsm.xsm as security 19.7 -from xen.util import xsconstants 19.8 +from xen.util import xsconstants, auxbin 19.9 from xen.util.acmpolicy import ACM_LABEL_UNLABELED 19.10 from xen.xm.opts import OptionError 19.11 from xen.xm import main as xm_main 19.12 @@ -81,7 +81,7 @@ def rm_domain_label(configfile): 19.13 fil = configfile 19.14 fd = open(fil, "rb") 19.15 else: 19.16 - for prefix in [".", "/etc/xen"]: 19.17 + for prefix in [".", auxbin.xen_configdir() ]: 19.18 fil = prefix + "/" + configfile 19.19 if os.path.isfile(fil): 19.20 fd = open(fil, "rb")
20.1 --- a/tools/python/xen/xm/tests/test_create.py Wed May 20 15:13:36 2009 +0100 20.2 +++ b/tools/python/xen/xm/tests/test_create.py Wed May 20 15:27:30 2009 +0100 20.3 @@ -8,6 +8,7 @@ import xen.xend.XendOptions 20.4 xen.xend.XendOptions.XendOptions.config_default = '/dev/null' 20.5 20.6 import xen.xm.create 20.7 +from xen.util import auxbin 20.8 20.9 20.10 class test_create(unittest.TestCase): 20.11 @@ -48,7 +49,7 @@ class test_create(unittest.TestCase): 20.12 'boot' : 'c', 20.13 'dhcp' : 'off', 20.14 'interface' : 'eth0', 20.15 - 'path' : '.:/etc/xen', 20.16 + 'path' : '.:' + auxbin.xen_configdir(), 20.17 'builder' : 'linux', 20.18 'nics' : -1, 20.19 'vncunused' : 1, 20.20 @@ -99,7 +100,7 @@ on_crash = 'destroy' 20.21 'boot' : 'c', 20.22 'dhcp' : 'off', 20.23 'interface' : 'eth0', 20.24 - 'path' : '.:/etc/xen', 20.25 + 'path' : '.:' + auxbin.xen_configdir(), 20.26 'builder' : 'linux', 20.27 20.28 'vncunused' : 1, 20.29 @@ -138,7 +139,7 @@ cpu_weight = 0.75 20.30 'boot' : 'c', 20.31 'dhcp' : 'off', 20.32 'interface' : 'eth0', 20.33 - 'path' : '.:/etc/xen', 20.34 + 'path' : '.:' + auxbin.xen_configdir(), 20.35 'builder' : 'linux', 20.36 'nics' : -1, 20.37 20.38 @@ -195,7 +196,7 @@ ne2000=0 20.39 'boot' : 'c', 20.40 'dhcp' : 'off', 20.41 'interface' : 'eth0', 20.42 - 'path' : '.:/etc/xen', 20.43 + 'path' : '.:' + auxbin.xen_configdir(), 20.44 20.45 'xauthority' : xen.xm.create.get_xauthority(), 20.46 })