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-devel

[Xen-devel] [RFC] bootloader improvements - pygrub-kernel-config

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [RFC] bootloader improvements - pygrub-kernel-config
From: John Levon <levon@xxxxxxxxxxxxxxxxx>
Date: Thu, 9 Nov 2006 19:22:40 +0000
Delivery-date: Thu, 09 Nov 2006 11:23:08 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
In-reply-to: <20061109192017.GA16487@xxxxxxxxxxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <20061109192017.GA16487@xxxxxxxxxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mutt/1.5.9i
# HG changeset patch
# User john.levon@xxxxxxx
# Date 1163095800 28800
# Node ID 0da173ee886e13bd4116c7d085cd4a4704ffe279
# Parent  7c80aaffe16f5e4037d10660d262ed7b22894b01
Split out bootloader-derived parameters separately from config-file-specified
ones. This allows a config file to still specify kernel/ramdisk, even if a
bootloader is being used.

Signed-off-by: John Levon <john.levon@xxxxxxx>

diff --git a/tools/pygrub/src/pygrub b/tools/pygrub/src/pygrub
--- a/tools/pygrub/src/pygrub
+++ b/tools/pygrub/src/pygrub
@@ -514,17 +514,17 @@ if __name__ == "__main__":
     fs = fsimage.open(file, offset)
 
     kernel = fs.open_file(img.kernel[1],).read()
-    (tfd, fn) = tempfile.mkstemp(prefix="vmlinuz.", dir="/var/lib/xen")
+    (tfd, fn) = tempfile.mkstemp(prefix="boot_kernel.", dir="/var/lib/xen")
     os.write(tfd, kernel)
     os.close(tfd)
-    sxp = "linux (kernel %s)" %(fn,)
+    sxp = "linux (boot_kernel %s)" %(fn,)
 
     if img.initrd:
         initrd = fs.open_file(img.initrd[1],).read()
-        (tfd, fn) = tempfile.mkstemp(prefix="initrd.", dir="/var/lib/xen")
+        (tfd, fn) = tempfile.mkstemp(prefix="boot_ramdisk.", 
dir="/var/lib/xen")
         os.write(tfd, initrd)
         os.close(tfd)
-        sxp += "(ramdisk %s)" %(fn,)
+        sxp += "(boot_ramdisk %s)" %(fn,)
     else:
         initrd = None
     sxp += "(args '%s')" %(img.args,)
diff --git a/tools/python/xen/xend/image.py b/tools/python/xen/xend/image.py
--- a/tools/python/xen/xend/image.py
+++ b/tools/python/xen/xend/image.py
@@ -70,7 +70,9 @@ class ImageHandler:
         self.vm = vm
 
         self.kernel = None
+        self.boot_kernel = None
         self.ramdisk = None
+        self.boot_ramdisk = None
         self.cmdline = None
 
         self.configure(imageConfig, deviceConfig)
@@ -82,6 +84,14 @@ class ImageHandler:
             return sxp.child_value(imageConfig, name, default)
 
         self.kernel = get_cfg("kernel")
+        self.ramdisk = get_cfg("ramdisk", '')
+        self.boot_kernel = get_cfg("boot_kernel")
+        if not self.boot_kernel:
+            self.boot_kernel = self.kernel
+        self.boot_ramdisk = get_cfg("boot_ramdisk")
+        if not self.boot_ramdisk:
+            self.boot_ramdisk = self.ramdisk
+
         self.cmdline = ""
         ip = get_cfg("ip")
         if ip:
@@ -92,7 +102,7 @@ class ImageHandler:
         args = get_cfg("args")
         if args:
             self.cmdline += " " + args
-        self.ramdisk = get_cfg("ramdisk", '')
+
         
         self.vm.storeVm(("image/ostype", self.ostype),
                         ("image/kernel", self.kernel),
@@ -101,8 +111,8 @@ class ImageHandler:
 
 
     def cleanupBootloading(self):
-        self.unlink(self.kernel)
-        self.unlink(self.ramdisk)
+        self.unlink(self.boot_kernel)
+        self.unlink(self.boot_ramdisk)
 
 
     def unlink(self, f):
@@ -125,10 +135,11 @@ class ImageHandler:
         """
         # Set params and call buildDomain().
 
-        if not os.path.isfile(self.kernel):
-            raise VmError('Kernel image does not exist: %s' % self.kernel)
-        if self.ramdisk and not os.path.isfile(self.ramdisk):
-            raise VmError('Kernel ramdisk does not exist: %s' % self.ramdisk)
+        if not os.path.isfile(self.boot_kernel):
+            raise VmError('Kernel image does not exist: %s' % self.boot_kernel)
+        if self.boot_ramdisk and not os.path.isfile(self.boot_ramdisk):
+            raise VmError('Kernel ramdisk does not exist: %s' %
+                          self.boot_ramdisk)
         if len(self.cmdline) >= MAX_GUEST_CMDLINE:
             log.warning('kernel cmdline too long, domain %d',
                         self.vm.getDomid())
@@ -193,21 +204,21 @@ class LinuxImageHandler(ImageHandler):
 
         log.debug("domid          = %d", self.vm.getDomid())
         log.debug("memsize        = %d", mem_mb)
-        log.debug("image          = %s", self.kernel)
+        log.debug("image          = %s", self.boot_kernel)
         log.debug("store_evtchn   = %d", store_evtchn)
         log.debug("console_evtchn = %d", console_evtchn)
         log.debug("cmdline        = %s", self.cmdline)
-        log.debug("ramdisk        = %s", self.ramdisk)
+        log.debug("ramdisk        = %s", self.boot_ramdisk)
         log.debug("vcpus          = %d", self.vm.getVCpuCount())
         log.debug("features       = %s", self.vm.getFeatures())
 
         return xc.linux_build(domid          = self.vm.getDomid(),
                               memsize        = mem_mb,
-                              image          = self.kernel,
+                              image          = self.boot_kernel,
                               store_evtchn   = store_evtchn,
                               console_evtchn = console_evtchn,
                               cmdline        = self.cmdline,
-                              ramdisk        = self.ramdisk,
+                              ramdisk        = self.boot_ramdisk,
                               features       = self.vm.getFeatures())
 
 class PPC_LinuxImageHandler(LinuxImageHandler):
@@ -226,11 +237,11 @@ class PPC_LinuxImageHandler(LinuxImageHa
 
         log.debug("domid          = %d", self.vm.getDomid())
         log.debug("memsize        = %d", mem_mb)
-        log.debug("image          = %s", self.kernel)
+        log.debug("image          = %s", self.boot_kernel)
         log.debug("store_evtchn   = %d", store_evtchn)
         log.debug("console_evtchn = %d", console_evtchn)
         log.debug("cmdline        = %s", self.cmdline)
-        log.debug("ramdisk        = %s", self.ramdisk)
+        log.debug("ramdisk        = %s", self.boot_ramdisk)
         log.debug("vcpus          = %d", self.vm.getVCpuCount())
         log.debug("features       = %s", self.vm.getFeatures())
 
@@ -238,11 +249,11 @@ class PPC_LinuxImageHandler(LinuxImageHa
 
         return xc.linux_build(domid          = self.vm.getDomid(),
                               memsize        = mem_mb,
-                              image          = self.kernel,
+                              image          = self.boot_kernel,
                               store_evtchn   = store_evtchn,
                               console_evtchn = console_evtchn,
                               cmdline        = self.cmdline,
-                              ramdisk        = self.ramdisk,
+                              ramdisk        = self.boot_ramdisk,
                               features       = self.vm.getFeatures(),
                               arch_args      = devtree.to_bin())
 
@@ -287,7 +298,7 @@ class HVMImageHandler(ImageHandler):
         mem_mb = self.getRequiredInitialReservation() / 1024
 
         log.debug("domid          = %d", self.vm.getDomid())
-        log.debug("image          = %s", self.kernel)
+        log.debug("image          = %s", self.boot_kernel)
         log.debug("store_evtchn   = %d", store_evtchn)
         log.debug("memsize        = %d", mem_mb)
         log.debug("vcpus          = %d", self.vm.getVCpuCount())
@@ -297,7 +308,7 @@ class HVMImageHandler(ImageHandler):
         self.register_shutdown_watch()
 
         return xc.hvm_build(domid          = self.vm.getDomid(),
-                            image          = self.kernel,
+                            image          = self.boot_kernel,
                             store_evtchn   = store_evtchn,
                             memsize        = mem_mb,
                             vcpus          = self.vm.getVCpuCount(),

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