All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christoph Egger <Christoph.Egger@amd.com>
To: xen-devel@lists.xensource.com
Cc: Ian Jackson <Ian.Jackson@eu.citrix.com>
Subject: Re: [PATCH] tools: don't require hardcoded path in guest config file
Date: Mon, 22 Jun 2009 15:01:34 +0200	[thread overview]
Message-ID: <200906221501.34973.Christoph.Egger@amd.com> (raw)
In-Reply-To: <19003.43994.710809.744259@mariner.uk.xensource.com>

[-- Attachment #1: Type: text/plain, Size: 1758 bytes --]

On Friday 19 June 2009 17:16:42 Ian Jackson wrote:
> Christoph Egger writes ("[Xen-devel] [PATCH] tools: don't require hardcoded 
path in guest config file"):
> > Attached patch allows xen tools to no longer require the hardcoded path's
> > to hvmloader, qemu-dm and stubdom-dm in the guest config files.
>
> In general I think this is a great idea.
> I just have some detailed quibbles.

Attached is a new version. Fixes your quibbles below.
I hope you like it.

> > +            if not os.path.exists(self['platform']['device_model']):
> > +                self['platform']['device_model'] = \
> > +                    auxbin.pathTo(self['platform']['device_model'])
>
> I think it would be better just to look for a slash in the specified
> value, and always prepend the path.  Otherwise you end up checking for
> the file in xend's cwd which is pretty strange behaviour.
>
> Treating all /-less values as paths in the expected installation
> directory is more sensible.
>
> > +                    # XXX basename works around a bug somewhere in the 
guest
> > +                    # config file parser which prepends cwd to the kernel
> > +                    # w/o checking if the result is valid if no absolute
> > +                    # path is specified 
>
> Surely it would be better to fix the guest config file parser!

Done.

> > +                    if os.path.basename(self['PV_kernel']) 
==  'hvmloader':
>
> That workaround is a pretty hideous hack.


Christoph

-- 
---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_firmwaredir.diff --]
[-- Type: text/x-diff, Size: 9102 bytes --]

diff -r 703ced548925 config/StdGNU.mk
--- a/config/StdGNU.mk	Fri Jun 19 08:45:55 2009 +0100
+++ b/config/StdGNU.mk	Mon Jun 22 14:59:12 2009 +0200
@@ -36,6 +36,7 @@ MANDIR = $(SHAREDIR)/man
 MAN1DIR = $(MANDIR)/man1
 MAN8DIR = $(MANDIR)/man8
 SBINDIR = $(PREFIX)/sbin
+XENFIRMWAREDIR = $(LIBDIR_x86_32)/xen/boot
 
 PRIVATE_PREFIX = $(LIBDIR)/xen
 PRIVATE_BINDIR = $(PRIVATE_PREFIX)/bin
diff -r 703ced548925 config/SunOS.mk
--- a/config/SunOS.mk	Fri Jun 19 08:45:55 2009 +0100
+++ b/config/SunOS.mk	Mon Jun 22 14:59:12 2009 +0200
@@ -30,6 +30,7 @@ MANDIR = $(PREFIX)/share/man
 MAN1DIR = $(MANDIR)/man1
 MAN8DIR = $(MANDIR)/man8
 SBINDIR = $(PREFIX)/sbin
+XENFIRMWAREDIR = $(LIBDIR)/xen/boot
 
 PRIVATE_PREFIX = $(LIBDIR)/xen
 PRIVATE_BINDIR = $(PRIVATE_PREFIX)/bin
diff -r 703ced548925 tools/firmware/Makefile
--- a/tools/firmware/Makefile	Fri Jun 19 08:45:55 2009 +0100
+++ b/tools/firmware/Makefile	Mon Jun 22 14:59:12 2009 +0200
@@ -3,7 +3,7 @@ include $(XEN_ROOT)/tools/Rules.mk
 
 # hvmloader is a 32-bit protected mode binary.
 TARGET      := hvmloader/hvmloader
-INST_DIR := $(DESTDIR)$(LIBDIR_x86_32)/xen/boot
+INST_DIR := $(DESTDIR)$(XENFIRMWAREDIR)
 
 SUBDIRS :=
 SUBDIRS += rombios
diff -r 703ced548925 tools/python/Makefile
--- a/tools/python/Makefile	Fri Jun 19 08:45:55 2009 +0100
+++ b/tools/python/Makefile	Mon Jun 22 14:59:12 2009 +0200
@@ -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)
 
diff -r 703ced548925 tools/python/xen/util/auxbin.py
--- a/tools/python/xen/util/auxbin.py	Fri Jun 19 08:45:55 2009 +0100
+++ b/tools/python/xen/util/auxbin.py	Mon Jun 22 14:59:12 2009 +0200
@@ -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)
diff -r 703ced548925 tools/python/xen/xend/XendConfig.py
--- a/tools/python/xen/xend/XendConfig.py	Fri Jun 19 08:45:55 2009 +0100
+++ b/tools/python/xen/xend/XendConfig.py	Mon Jun 22 14:59:12 2009 +0200
@@ -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_t
 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 \
@@ -1549,7 +1560,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
diff -r 703ced548925 tools/python/xen/xm/create.py
--- a/tools/python/xen/xm/create.py	Fri Jun 19 08:45:55 2009 +0100
+++ b/tools/python/xen/xm/create.py	Mon Jun 22 14:59:12 2009 +0200
@@ -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])

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

      parent reply	other threads:[~2009-06-22 13:01 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-19 14:33 [PATCH] tools: don't require hardcoded path in guest config file Christoph Egger
2009-06-19 15:16 ` Ian Jackson
2009-06-19 15:32   ` Christoph Egger
2009-06-22 13:01   ` 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=200906221501.34973.Christoph.Egger@amd.com \
    --to=christoph.egger@amd.com \
    --cc=Ian.Jackson@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.