From: Christoph Egger <Christoph.Egger@amd.com>
To: xen-devel@lists.xensource.com, Keir Fraser <Keir.Fraser@eu.citrix.com>
Subject: Re: [PATCH] tools: get rid of hardcoded config dirs
Date: Wed, 20 May 2009 12:12:32 +0200 [thread overview]
Message-ID: <200905201212.32848.Christoph.Egger@amd.com> (raw)
In-Reply-To: <200905200953.05427.Christoph.Egger@amd.com>
[-- Attachment #1: Type: text/plain, Size: 806 bytes --]
Hi Keir,
attached is a much improved version of the patch.
It removes *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>
On Wednesday 20 May 2009 09:53:05 Christoph Egger wrote:
> Hi,
>
> attached patch gets rid of hardcoded config dirs.
> Solaris related changes acknowleged by John Levon.
>
> Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
--
---to satisfy European Law for business letters:
Advanced Micro Devices GmbH
Karl-Hammerschmidt-Str. 34, 85609 Dornach b. Muenchen
Geschaeftsfuehrer: Thomas M. McCoy, Giuliano Meroni
Sitz: Dornach, Gemeinde Aschheim, Landkreis Muenchen
Registergericht Muenchen, HRB Nr. 43632
[-- Attachment #2: xen_configdir.diff --]
[-- Type: text/x-diff, Size: 17615 bytes --]
diff -r e0221531d0e5 tools/Makefile
--- a/tools/Makefile Tue May 19 14:17:56 2009 +0100
+++ b/tools/Makefile Wed May 20 11:55:57 2009 +0200
@@ -93,8 +96,7 @@ ioemu-dir-find:
fi
set -e; \
$(absolutify_xen_root); \
- PREFIX=$(PREFIX); \
- export PREFIX; \
+ $(buildmakevars2shellvars); \
cd ioemu-dir; \
./xen-setup $(IOEMU_CONFIGURE_CROSS)
diff -r e0221531d0e5 tools/Rules.mk
--- a/tools/Rules.mk Tue May 19 14:17:56 2009 +0100
+++ b/tools/Rules.mk Wed May 20 11:55:57 2009 +0200
@@ -8,10 +8,6 @@ include $(XEN_ROOT)/Config.mk
export _INSTALL := $(INSTALL)
INSTALL = $(XEN_ROOT)/tools/cross-install
-CONFIG_DIR = /etc
-XEN_CONFIG_DIR = $(CONFIG_DIR)/xen
-XEN_SCRIPT_DIR = $(XEN_CONFIG_DIR)/scripts
-
XEN_INCLUDE = $(XEN_ROOT)/tools/include
XEN_XC = $(XEN_ROOT)/tools/python/xen/lowlevel/xc
XEN_LIBXC = $(XEN_ROOT)/tools/libxc
diff -r e0221531d0e5 tools/python/Makefile
--- a/tools/python/Makefile Tue May 19 14:17:56 2009 +0100
+++ b/tools/python/Makefile Wed May 20 11:55:57 2009 +0200
@@ -23,6 +23,8 @@ genpath:
echo "LIBEXEC=\"$(LIBEXEC)\"" >> ${xenpath}
echo "LIBDIR=\"$(LIBDIR)\"" >> ${xenpath}
echo "PRIVATE_BINDIR=\"$(PRIVATE_BINDIR)\"" >> ${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
diff -r e0221531d0e5 tools/python/xen/util/auxbin.py
--- a/tools/python/xen/util/auxbin.py Tue May 19 14:17:56 2009 +0100
+++ b/tools/python/xen/util/auxbin.py Wed May 20 11:55:57 2009 +0200
@@ -20,6 +20,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
def execute(exe, args = None):
exepath = pathTo(exe)
@@ -45,3 +46,9 @@ def path():
def libpath():
return LIBDIR
+
+def xen_configdir():
+ return XEN_CONFIG_DIR
+
+def scripts_dir():
+ return XEN_SCRIPT_DIR
diff -r e0221531d0e5 tools/python/xen/util/xsm/acm/acm.py
--- a/tools/python/xen/util/xsm/acm/acm.py Tue May 19 14:17:56 2009 +0100
+++ b/tools/python/xen/util/xsm/acm/acm.py Wed May 20 11:55:57 2009 +0200
@@ -31,11 +31,11 @@ from xen.xend import XendConstants
from xen.xend import XendOptions
from xen.xend.XendLogging import log
from xen.xend.XendError import VmError
-from xen.util import dictio, xsconstants
+from xen.util import dictio, xsconstants, auxbin
from xen.xend.XendConstants import *
#global directories and tools for security management
-install_policy_dir_prefix = "/etc/xen/acm-security/policies"
+install_policy_dir_prefix = auxbin.xen_configdir() + "/acm-security/policies"
security_dir_prefix = XendOptions.instance().get_xend_security_path()
policy_dir_prefix = security_dir_prefix + "/policies"
res_label_filename = policy_dir_prefix + "/resource_labels"
diff -r e0221531d0e5 tools/python/xen/xend/XendConstants.py
--- a/tools/python/xen/xend/XendConstants.py Tue May 19 14:17:56 2009 +0100
+++ b/tools/python/xen/xend/XendConstants.py Wed May 20 11:55:57 2009 +0200
@@ -16,6 +16,7 @@
#============================================================================
from xen.xend.XendAPIConstants import *
+from xen.util import auxbin
#
# Shutdown codes and reasons.
@@ -129,7 +130,7 @@ DEV_MIGRATE_STEP3 = 3
# VTPM-related constants
#
-VTPM_DELETE_SCRIPT = '/etc/xen/scripts/vtpm-delete'
+VTPM_DELETE_SCRIPT = auxbin.scripts_dir() + '/vtpm-delete'
#
# Xenstore Constants
diff -r e0221531d0e5 tools/python/xen/xend/XendDomainInfo.py
--- a/tools/python/xen/xend/XendDomainInfo.py Tue May 19 14:17:56 2009 +0100
+++ b/tools/python/xen/xend/XendDomainInfo.py Wed May 20 11:55:57 2009 +0200
@@ -34,12 +34,12 @@ import traceback
from types import StringTypes
import xen.lowlevel.xc
-from xen.util import asserts
+from xen.util import asserts, auxbin
from xen.util.blkif import blkdev_uname_to_file, blkdev_uname_to_taptype
import xen.util.xsm.xsm as security
from xen.util import xsconstants
-from xen.xend import balloon, sxp, uuid, image, arch, osdep
+from xen.xend import balloon, sxp, uuid, image, arch
from xen.xend import XendOptions, XendNode, XendConfig
from xen.xend.XendConfig import scrub_password
@@ -2915,7 +2915,7 @@ class XendDomainInfo:
else:
# Boot using bootloader
if not blexec or blexec == 'pygrub':
- blexec = osdep.pygrub_path
+ blexec = auxbin.pathTo('pygrub')
blcfg = None
disks = [x for x in self.info['vbd_refs']
diff -r e0221531d0e5 tools/python/xen/xend/XendOptions.py
--- a/tools/python/xen/xend/XendOptions.py Tue May 19 14:17:56 2009 +0100
+++ b/tools/python/xen/xend/XendOptions.py Wed May 20 11:55:57 2009 +0200
@@ -32,6 +32,7 @@ import sys
from xen.xend import sxp, osdep, XendLogging
from xen.xend.XendError import XendError
+from xen.util import auxbin
if os.uname()[0] == 'SunOS':
from xen.lowlevel import scf
@@ -40,10 +41,10 @@ class XendOptions:
"""Configuration options."""
"""Where network control scripts live."""
- network_script_dir = osdep.scripts_dir
+ network_script_dir = auxbin.scripts_dir()
"""Where block control scripts live."""
- block_script_dir = osdep.scripts_dir
+ block_script_dir = auxbin.scripts_dir()
"""Default path to the log file. """
logfile_default = "/var/log/xen/xend.log"
@@ -115,7 +116,7 @@ class XendOptions:
xend_vnc_tls = 0
"""x509 certificate directory for QEMU VNC server"""
- xend_vnc_x509_cert_dir = "/etc/xen/vnc"
+ xend_vnc_x509_cert_dir = auxbin.xen_configdir() + "/vnc"
"""Verify incoming client x509 certs"""
xend_vnc_x509_verify = 0
@@ -355,7 +356,7 @@ class XendOptions:
s = self.get_config_string('resource-label-change-script')
if s:
result = s.split(" ")
- result[0] = os.path.join(osdep.scripts_dir, result[0])
+ result[0] = os.path.join(auxbin.scripts_dir(), result[0])
return result
else:
return None
@@ -386,7 +387,7 @@ class XendOptions:
class XendOptionsFile(XendOptions):
"""Default path to the config file."""
- config_default = "/etc/xen/xend-config.sxp"
+ config_default = auxbin.xen_configdir() + "/xend-config.sxp"
"""Environment variable used to override config_default."""
config_var = "XEND_CONFIG"
diff -r e0221531d0e5 tools/python/xen/xend/XendPIF.py
--- a/tools/python/xen/xend/XendPIF.py Tue May 19 14:17:56 2009 +0100
+++ b/tools/python/xen/xend/XendPIF.py Wed May 20 11:55:57 2009 +0200
@@ -25,6 +25,7 @@ from xen.xend.XendBase import XendBase
from xen.xend.XendPIFMetrics import XendPIFMetrics
from xen.xend.XendError import *
from xen.xend import Vifctl
+from xen.util import auxbin
log = logging.getLogger("xend.XendPIF")
log.setLevel(logging.TRACE)
diff -r e0221531d0e5 tools/python/xen/xend/osdep.py
--- a/tools/python/xen/xend/osdep.py Tue May 19 14:17:56 2009 +0100
+++ b/tools/python/xen/xend/osdep.py Wed May 20 11:55:57 2009 +0200
@@ -20,21 +20,12 @@
import os
import commands
-_scripts_dir = {
- "Linux": "/etc/xen/scripts",
- "SunOS": "/usr/lib/xen/scripts",
-}
-
_xend_autorestart = {
"NetBSD": True,
"Linux": True,
"SunOS": False,
}
-_pygrub_path = {
- "SunOS": "/usr/lib/xen/bin/pygrub"
-}
-
_vif_script = {
"SunOS": "vif-vnic"
}
@@ -221,9 +250,7 @@ _get_postfork = {
def _get(var, default=None):
return var.get(os.uname()[0], default)
-scripts_dir = _get(_scripts_dir, "/etc/xen/scripts")
xend_autorestart = _get(_xend_autorestart)
-pygrub_path = _get(_pygrub_path, "/usr/bin/pygrub")
vif_script = _get(_vif_script, "vif-bridge")
lookup_balloon_stat = _get(_balloon_stat, _linux_balloon_stat)
get_cpuinfo = _get(_get_cpuinfo, _linux_get_cpuinfo)
diff -r e0221531d0e5 tools/python/xen/xend/server/blkif.py
--- a/tools/python/xen/xend/server/blkif.py Tue May 19 14:17:56 2009 +0100
+++ b/tools/python/xen/xend/server/blkif.py Wed May 20 11:55:57 2009 +0200
@@ -24,7 +24,7 @@ from xen.util import blkif
import xen.util.xsm.xsm as security
from xen.xend.XendError import VmError
from xen.xend.server.DevController import DevController
-from xen.util import xsconstants
+from xen.util import xsconstants, auxbin
class BlkifController(DevController):
"""Block device interface controller. Handles all block devices
@@ -40,7 +40,7 @@ class BlkifController(DevController):
if protocol in ('phy', 'file', 'tap'):
return True
- return os.access('/etc/xen/scripts/block-%s' % protocol, os.X_OK)
+ return os.access(auxbin.scripts_dir() + '/block-%s' % protocol, os.X_OK)
def getDeviceDetails(self, config):
diff -r e0221531d0e5 tools/python/xen/xend/server/pciquirk.py
--- a/tools/python/xen/xend/server/pciquirk.py Tue May 19 14:17:56 2009 +0100
+++ b/tools/python/xen/xend/server/pciquirk.py Wed May 20 11:55:57 2009 +0200
@@ -3,10 +3,11 @@ from xen.xend.XendError import XendError
import sys
import os.path
from xen.xend.sxp import *
+from xen.util import auxbin
QUIRK_SYSFS_NODE = "/sys/bus/pci/drivers/pciback/quirks"
-QUIRK_CONFIG_FILE = "/etc/xen/xend-pci-quirks.sxp"
-PERMISSIVE_CONFIG_FILE = "/etc/xen/xend-pci-permissive.sxp"
+QUIRK_CONFIG_FILE = auxbin.xen_configdir() + "/xend-pci-quirks.sxp"
+PERMISSIVE_CONFIG_FILE = auxbin.xen_configdir() + "/xend-pci-permissive.sxp"
PERMISSIVE_SYSFS_NODE = "/sys/bus/pci/drivers/pciback/permissive"
class PCIQuirk:
diff -r e0221531d0e5 tools/python/xen/xm/addlabel.py
--- a/tools/python/xen/xm/addlabel.py Tue May 19 14:17:56 2009 +0100
+++ b/tools/python/xen/xm/addlabel.py Wed May 20 11:55:57 2009 +0200
@@ -24,7 +24,7 @@ import sys
import xen.util.xsm.xsm as security
from xen.xm.opts import OptionError
-from xen.util import xsconstants
+from xen.util import xsconstants, auxbin
from xen.xm import main as xm_main
from xen.xm.main import server
@@ -221,7 +221,7 @@ def main(argv):
if argv[2].lower() == "dom":
configfile = argv[3]
if configfile[0] != '/':
- for prefix in [os.path.realpath(os.path.curdir), "/etc/xen"]:
+ for prefix in [os.path.realpath(os.path.curdir), auxbin.xen_configdir()]:
configfile = prefix + "/" + configfile
if os.path.isfile(configfile):
break
diff -r e0221531d0e5 tools/python/xen/xm/create.py
--- a/tools/python/xen/xm/create.py Tue May 19 14:17:56 2009 +0100
+++ b/tools/python/xen/xm/create.py Wed May 20 11:55:57 2009 +0200
@@ -29,7 +29,6 @@ import xmlrpclib
from xen.xend import sxp
from xen.xend import PrettyPrint as SXPPrettyPrint
-from xen.xend import osdep
import xen.xend.XendClient
from xen.xend.XendBootloader import bootloader
from xen.xend.XendConstants import *
@@ -38,7 +37,7 @@ from xen.util import blkif
from xen.util import vscsi_util
import xen.util.xsm.xsm as security
from xen.xm.main import serverType, SERVER_XEN_API, get_single_vm
-from xen.util import utils
+from xen.util import utils, auxbin
from xen.xm.opts import *
@@ -72,7 +71,7 @@ gopts.opt('quiet', short='q',
use="Quiet.")
gopts.opt('path', val='PATH',
- fn=set_value, default='.:/etc/xen',
+ fn=set_value, default='.:' + auxbin.xen_configdir(),
use="Search path for configuration scripts. "
"The value of PATH is a colon-separated directory list.")
@@ -981,7 +980,7 @@ def make_config(vals):
config_image = configure_image(vals)
if vals.bootloader:
if vals.bootloader == "pygrub":
- vals.bootloader = osdep.pygrub_path
+ vals.bootloader = auxbin.pathTo(vals.bootloader)
config.append(['bootloader', vals.bootloader])
if vals.bootargs:
diff -r e0221531d0e5 tools/python/xen/xm/getlabel.py
--- a/tools/python/xen/xm/getlabel.py Tue May 19 14:17:56 2009 +0100
+++ b/tools/python/xen/xm/getlabel.py Wed May 20 11:55:57 2009 +0200
@@ -20,7 +20,7 @@
"""
import sys, os, re
import xen.util.xsm.xsm as security
-from xen.util import xsconstants
+from xen.util import xsconstants, auxbin
from xen.xm.opts import OptionError
from xen.xm import main as xm_main
from xen.xm.main import server
@@ -59,7 +59,7 @@ def get_domain_label(configfile):
if configfile[0] == '/':
fd = open(configfile, "rb")
else:
- for prefix in [".", "/etc/xen"]:
+ for prefix in [".", auxbin.xen_configdir() ]:
abs_file = prefix + "/" + configfile
if os.path.isfile(abs_file):
fd = open(abs_file, "rb")
diff -r e0221531d0e5 tools/python/xen/xm/main.py
--- a/tools/python/xen/xm/main.py Tue May 19 14:17:56 2009 +0100
+++ b/tools/python/xen/xm/main.py Wed May 20 11:55:57 2009 +0200
@@ -55,6 +55,7 @@ from xen.util.xmlrpcclient import Server
import xen.util.xsm.xsm as security
from xen.util.xsm.xsm import XSMError
from xen.util.acmpolicy import ACM_LABEL_UNLABELED_DISPLAY
+from xen.util import auxbin
import XenAPI
@@ -72,7 +73,7 @@ if not hasattr(getopt, 'gnu_getopt'):
getopt.gnu_getopt = getopt.getopt
XM_CONFIG_FILE_ENVVAR = 'XM_CONFIG_FILE'
-XM_CONFIG_FILE_DEFAULT = '/etc/xen/xm-config.xml'
+XM_CONFIG_FILE_DEFAULT = auxbin.xen_configdir + '/xm-config.xml'
# Supported types of server
SERVER_LEGACY_XMLRPC = 'LegacyXMLRPC'
diff -r e0221531d0e5 tools/python/xen/xm/rmlabel.py
--- a/tools/python/xen/xm/rmlabel.py Tue May 19 14:17:56 2009 +0100
+++ b/tools/python/xen/xm/rmlabel.py Wed May 20 11:55:57 2009 +0200
@@ -22,7 +22,7 @@ import os
import re
import sys
import xen.util.xsm.xsm as security
-from xen.util import xsconstants
+from xen.util import xsconstants, auxbin
from xen.util.acmpolicy import ACM_LABEL_UNLABELED
from xen.xm.opts import OptionError
from xen.xm import main as xm_main
@@ -81,7 +81,7 @@ def rm_domain_label(configfile):
fil = configfile
fd = open(fil, "rb")
else:
- for prefix in [".", "/etc/xen"]:
+ for prefix in [".", auxbin.xen_configdir() ]:
fil = prefix + "/" + configfile
if os.path.isfile(fil):
fd = open(fil, "rb")
diff -r e0221531d0e5 tools/python/xen/xm/tests/test_create.py
--- a/tools/python/xen/xm/tests/test_create.py Tue May 19 14:17:56 2009 +0100
+++ b/tools/python/xen/xm/tests/test_create.py Wed May 20 11:55:57 2009 +0200
@@ -8,6 +8,7 @@ import xen.xend.XendOptions
xen.xend.XendOptions.XendOptions.config_default = '/dev/null'
import xen.xm.create
+from xen.util import auxbin
class test_create(unittest.TestCase):
@@ -48,7 +49,7 @@ class test_create(unittest.TestCase):
'boot' : 'c',
'dhcp' : 'off',
'interface' : 'eth0',
- 'path' : '.:/etc/xen',
+ 'path' : '.:' + auxbin.xen_configdir(),
'builder' : 'linux',
'nics' : -1,
'vncunused' : 1,
@@ -99,7 +100,7 @@ on_crash = 'destroy'
'boot' : 'c',
'dhcp' : 'off',
'interface' : 'eth0',
- 'path' : '.:/etc/xen',
+ 'path' : '.:' + auxbin.xen_configdir(),
'builder' : 'linux',
'vncunused' : 1,
@@ -138,7 +139,7 @@ cpu_weight = 0.75
'boot' : 'c',
'dhcp' : 'off',
'interface' : 'eth0',
- 'path' : '.:/etc/xen',
+ 'path' : '.:' + auxbin.xen_configdir(),
'builder' : 'linux',
'nics' : -1,
@@ -195,7 +196,7 @@ ne2000=0
'boot' : 'c',
'dhcp' : 'off',
'interface' : 'eth0',
- 'path' : '.:/etc/xen',
+ 'path' : '.:' + auxbin.xen_configdir(),
'xauthority' : xen.xm.create.get_xauthority(),
})
diff -r e0221531d0e5 Config.mk
--- a/Config.mk Tue May 19 14:17:56 2009 +0100
+++ b/Config.mk Wed May 20 12:05:18 2009 +0200
@@ -87,6 +87,13 @@ define absolutify_xen_root
export XEN_ROOT
endef
+define buildmakevars2shellvars
+ PREFIX="$(PREFIX)"; \
+ XEN_SCRIPT_DIR="$(XEN_SCRIPT_DIR)"; \
+ export PREFIX; \
+ export XEN_SCRIPT_DIR
+endef
+
ifeq ($(debug),y)
CFLAGS += -g
endif
diff -r e0221531d0e5 config/StdGNU.mk
--- a/config/StdGNU.mk Tue May 19 14:17:56 2009 +0100
+++ b/config/StdGNU.mk Wed May 20 12:05:18 2009 +0200
@@ -40,6 +40,14 @@ SBINDIR = $(PREFIX)/sbin
PRIVATE_PREFIX = $(LIBDIR)/xen
PRIVATE_BINDIR = $(PRIVATE_PREFIX)/bin
+ifeq ($(PREFIX),/usr)
+CONFIG_DIR = /etc
+else
+CONFIG_DIR = $(PREFIX)/etc
+endif
+XEN_CONFIG_DIR = $(CONFIG_DIR)/xen
+XEN_SCRIPT_DIR = $(XEN_CONFIG_DIR)/scripts
+
SOCKET_LIBS =
CURSES_LIBS = -lncurses
PTHREAD_LIBS = -lpthread
diff -r e0221531d0e5 config/SunOS.mk
--- a/config/SunOS.mk Tue May 19 14:17:56 2009 +0100
+++ b/config/SunOS.mk Wed May 20 12:05:18 2009 +0200
@@ -34,6 +34,14 @@ SBINDIR = $(PREFIX)/sbin
PRIVATE_PREFIX = $(LIBDIR)/xen
PRIVATE_BINDIR = $(PRIVATE_PREFIX)/bin
+ifeq ($(PREFIX),/usr)
+CONFIG_DIR = /etc
+else
+CONFIG_DIR = $(PREFIX)/etc
+endif
+XEN_CONFIG_DIR = $(CONFIG_DIR)/xen
+XEN_SCRIPT_DIR = $(PRIVATE_PREFIX)/scripts
+
SunOS_LIBDIR = /usr/sfw/lib
SunOS_LIBDIR_x86_64 = /usr/sfw/lib/amd64
[-- Attachment #3: Type: text/plain, Size: 138 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
prev parent reply other threads:[~2009-05-20 10:12 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-05-20 7:53 [PATCH] tools: get rid of hardcoded config dirs Christoph Egger
2009-05-20 10:12 ` Christoph Egger [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200905201212.32848.Christoph.Egger@amd.com \
--to=christoph.egger@amd.com \
--cc=Keir.Fraser@eu.citrix.com \
--cc=xen-devel@lists.xensource.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.