WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] tools: don't require hardcoded firmware p

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] tools: don't require hardcoded firmware path in guest config file
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Tue, 23 Jun 2009 03:45:16 -0700
Delivery-date: Tue, 23 Jun 2009 03:46:24 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1245752607 -3600
# Node ID b55070edb1854060914f4f313d62eb303501887c
# Parent  d9b988c65ebfab24cd61d467bd8a4374419de55e
tools: don't require hardcoded firmware path in guest config file

Signed-off-by: Christoph Egger <Christoph.Egger@xxxxxxx>
---
 config/StdGNU.mk                    |    1 +
 config/SunOS.mk                     |    1 +
 tools/firmware/Makefile             |    2 +-
 tools/python/Makefile               |   22 ++++++++++++----------
 tools/python/xen/util/auxbin.py     |    5 ++---
 tools/python/xen/xend/XendConfig.py |   19 +++++++++++++++----
 tools/python/xen/xm/create.py       |   34 +++++++++++++++++++++++++++++++---
 7 files changed, 63 insertions(+), 21 deletions(-)

diff -r d9b988c65ebf -r b55070edb185 config/StdGNU.mk
--- a/config/StdGNU.mk  Tue Jun 23 11:22:08 2009 +0100
+++ b/config/StdGNU.mk  Tue Jun 23 11:23:27 2009 +0100
@@ -36,6 +36,7 @@ MAN1DIR = $(MANDIR)/man1
 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 d9b988c65ebf -r b55070edb185 config/SunOS.mk
--- a/config/SunOS.mk   Tue Jun 23 11:22:08 2009 +0100
+++ b/config/SunOS.mk   Tue Jun 23 11:23:27 2009 +0100
@@ -30,6 +30,7 @@ MAN1DIR = $(MANDIR)/man1
 MAN1DIR = $(MANDIR)/man1
 MAN8DIR = $(MANDIR)/man8
 SBINDIR = $(PREFIX)/sbin
+XENFIRMWAREDIR = $(LIBDIR)/xen/boot
 
 PRIVATE_PREFIX = $(LIBDIR)/xen
 PRIVATE_BINDIR = $(PRIVATE_PREFIX)/bin
diff -r d9b988c65ebf -r b55070edb185 tools/firmware/Makefile
--- a/tools/firmware/Makefile   Tue Jun 23 11:22:08 2009 +0100
+++ b/tools/firmware/Makefile   Tue Jun 23 11:23:27 2009 +0100
@@ -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 d9b988c65ebf -r b55070edb185 tools/python/Makefile
--- a/tools/python/Makefile     Tue Jun 23 11:22:08 2009 +0100
+++ b/tools/python/Makefile     Tue Jun 23 11:23:27 2009 +0100
@@ -13,19 +13,20 @@ I18NSRCFILES = $(shell find xen/xm/ -nam
 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 d9b988c65ebf -r b55070edb185 tools/python/xen/util/auxbin.py
--- a/tools/python/xen/util/auxbin.py   Tue Jun 23 11:22:08 2009 +0100
+++ b/tools/python/xen/util/auxbin.py   Tue Jun 23 11:23:27 2009 +0100
@@ -19,8 +19,7 @@ import os
 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 d9b988c65ebf -r b55070edb185 tools/python/xen/xend/XendConfig.py
--- a/tools/python/xen/xend/XendConfig.py       Tue Jun 23 11:22:08 2009 +0100
+++ b/tools/python/xen/xend/XendConfig.py       Tue Jun 23 11:23:27 2009 +0100
@@ -16,6 +16,7 @@
 #============================================================================
 
 import logging
+import os
 import re
 import time
 import types
@@ -39,7 +40,7 @@ from xen.util.pci import pci_opts_list_f
 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
diff -r d9b988c65ebf -r b55070edb185 tools/python/xen/xm/create.py
--- a/tools/python/xen/xm/create.py     Tue Jun 23 11:22:08 2009 +0100
+++ b/tools/python/xen/xm/create.py     Tue Jun 23 11:23:27 2009 +0100
@@ -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])

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

<Prev in Thread] Current Thread [Next in Thread>