Skip to contentSkip to conversation

Guest boot loader support

PATCH In review Jeremy Katz 6 participants 17 messages Apr 25, 2005 – Apr 29, 2005

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Guest boot loader support

Attached is an updated version of the patch to add boot loader support for guest domains.

Changes from the initial set of patches:
* Per Ian's request, adds an option to specify booting a specific kernel from the host domain (you can specify it either with the title of the boot loader config entry or with the grub 0-based index)
* Reduces some of the code duplication for finding out what the virtual disk to boot off of is
* Improved error handling to use the standard Xen logging and error facilities

At this point, I think that we handle the use cases where a user just wants to have everything specified from within the guest domain, creating a domain with xm create and wanting to be able to interactively select a kernel and asking for a specific entry from the grub.conf to be booted when creating a domain.

Future things (which I think are fine to do after the initial pass is committed) include
* Reworking to use the planned new console infrastructure [1]
* Handling whole disks
* More filesystem support -- the code is generic and has all the hooks, I just haven't delved deep enough into any of the other fs libraries
* Further improvements for the menu interface

Jeremy

[1] And I foolishly told Ian I'd start a discussion about this last week and still haven't. Hopefully tonight.

# This is a BitKeeper generated diff -Nru style patch. #
# ChangeSet
# 2005/04/25 18:25:47-04:00 [email protected]
# Add passing of booting a specific entry by label or by index
#

# tools/python/xen/xm/create.py
#   2005/04/25 18:25:45-04:00 [email protected] +6 -2
#   allow specifying the default entry to boot
# 
# tools/python/xen/xend/XendBootloader.py
#   2005/04/25 18:25:45-04:00 [email protected] +9 -3
#   support passing the default entry to boot
# 
# tools/pygrub/src/pygrub
#   2005/04/25 18:25:45-04:00 [email protected] +35 -20
#   support passing an entry to boot either by label or by index.  also
#   remove some dead code and fix a few minor bugs
# 
# ChangeSet
#   2005/04/14 12:16:27-04:00 [email protected] 
#   Minor fixes based on feedback from Mike Wray
# 
# tools/python/xen/xm/create.py
#   2005/04/14 12:16:25-04:00 [email protected] +2 -3
#   Use method in blkif to do uname -> file conversion
# 
# tools/python/xen/xend/server/blkif.py
#   2005/04/14 12:16:25-04:00 [email protected] +9 -0
#   Add method to convert from a uname to a real file
# 
# tools/python/xen/xend/XendDomainInfo.py
#   2005/04/14 12:16:25-04:00 [email protected] +6 -8
#   Make lack of a disk a fatal error.  Use the method in blkif
#   for going from a disk uname to a filename
# 
# tools/python/xen/xend/XendBootloader.py
#   2005/04/14 12:16:25-04:00 [email protected] +14 -4
#   Improve error handling.  Log errors and raise an error on a problem
#   instead of just printing to stderr and exiting
# 
# ChangeSet
#   2005/04/13 23:02:35-04:00 [email protected] 
#   Add pygrub, a simple boot loader for use to read a boot loader
#   config out of a domU's filesystem and then read kernels out as well.
#   Currently only has support for ext[23] via libext2fs, but it should
#   be easy to add other filesystems.
#   
#   Still needs work to complete the interface and to support full disk
#   images instead of just partitions.
# 
# tools/pygrub/src/pygrub
#   2005/04/13 23:02:33-04:00 [email protected] +255 -0
# 
# tools/pygrub/src/fsys/ext2/test.py
#   2005/04/13 23:02:33-04:00 [email protected] +15 -0
# 
# tools/pygrub/src/fsys/ext2/ext2module.c
#   2005/04/13 23:02:33-04:00 [email protected] +332 -0
# 
# tools/pygrub/src/fsys/ext2/__init__.py
#   2005/04/13 23:02:33-04:00 [email protected] +38 -0
# 
# tools/pygrub/src/fsys/__init__.py
#   2005/04/13 23:02:33-04:00 [email protected] +61 -0
# 
# tools/pygrub/src/GrubConf.py
#   2005/04/13 23:02:33-04:00 [email protected] +229 -0
# 
# tools/pygrub/setup.py
#   2005/04/13 23:02:33-04:00 [email protected] +25 -0
# 
# tools/pygrub/Makefile
#   2005/04/13 23:02:33-04:00 [email protected] +18 -0
# 
# tools/pygrub/src/pygrub
#   2005/04/13 23:02:33-04:00 [email protected] +0 -0
#   BitKeeper file /home/katzj/cvs/xen/xen-pygrub/tools/pygrub/src/pygrub
# 
# tools/pygrub/src/fsys/ext2/test.py
#   2005/04/13 23:02:33-04:00 [email protected] +0 -0
#   BitKeeper file /home/katzj/cvs/xen/xen-pygrub/tools/pygrub/src/fsys/ext2/test.py
# 
# tools/pygrub/src/fsys/ext2/ext2module.c
#   2005/04/13 23:02:33-04:00 [email protected] +0 -0
#   BitKeeper file /home/katzj/cvs/xen/xen-pygrub/tools/pygrub/src/fsys/ext2/ext2module.c
# 
# tools/pygrub/src/fsys/ext2/__init__.py
#   2005/04/13 23:02:33-04:00 [email protected] +0 -0
#   BitKeeper file /home/katzj/cvs/xen/xen-pygrub/tools/pygrub/src/fsys/ext2/__init__.py
# 
# tools/pygrub/src/fsys/__init__.py
#   2005/04/13 23:02:33-04:00 [email protected] +0 -0
#   BitKeeper file /home/katzj/cvs/xen/xen-pygrub/tools/pygrub/src/fsys/__init__.py
# 
# tools/pygrub/src/GrubConf.py
#   2005/04/13 23:02:33-04:00 [email protected] +0 -0
#   BitKeeper file /home/katzj/cvs/xen/xen-pygrub/tools/pygrub/src/GrubConf.py
# 
# tools/pygrub/setup.py
#   2005/04/13 23:02:33-04:00 [email protected] +0 -0
#   BitKeeper file /home/katzj/cvs/xen/xen-pygrub/tools/pygrub/setup.py
# 
# tools/pygrub/Makefile
#   2005/04/13 23:02:33-04:00 [email protected] +0 -0
#   BitKeeper file /home/katzj/cvs/xen/xen-pygrub/tools/pygrub/Makefile
# 
# tools/Makefile
#   2005/04/13 23:02:33-04:00 [email protected] +1 -0
#   Add pygrub subdirectory
# 
# ChangeSet
#   2005/04/13 23:01:42-04:00 [email protected] 
#   Add framework for running a bootloader from within xend and xm. To
#   specify the executable to run, set in your domain config like
#     bootloader="/usr/bin/pygrub"
#   
#   The bootloader will get executed on both domain creation and domain
#   reboot to get the default kernel/initrd specified in the bootloader
#   config for the domain.  If you auto-connect the console on domain
#   creation, then your bootloader will be run in an interactive mode.
# 
# BitKeeper/etc/logging_ok
#   2005/04/13 23:01:42-04:00 [email protected] +1 -0
#   Logging to [email protected] accepted
# 
# tools/python/xen/xend/XendBootloader.py
#   2005/04/13 23:01:37-04:00 [email protected] +79 -0
# 
# tools/python/xen/xm/create.py
#   2005/04/13 23:01:37-04:00 [email protected] +29 -2
#   Run bootloader on domain creation.  If console is being connected,
#   then run in an interactive mode, else just go with the default.
# 
# tools/python/xen/xend/XendDomainInfo.py
#   2005/04/13 23:01:37-04:00 [email protected] +41 -1
#   Add running of a boot loader from xend on domain reboot.  Runs in
#   an uninteractive mode to get the default kernel/initrd for the
#   domain.  Also removes any temporary kernels created by the 
#   bootloader.
# 
# tools/python/xen/xend/XendBootloader.py
#   2005/04/13 23:01:37-04:00 [email protected] +0 -0
#   BitKeeper file /home/katzj/cvs/xen/xen-pygrub/tools/python/xen/xend/XendBootloader.py
# 
diff -Nru a/tools/Makefile b/tools/Makefile
--- a/tools/Makefile	2005-04-25 18:49:05 -04:00
+++ b/tools/Makefile	2005-04-25 18:49:05 -04:00
@@ -11,6 +11,7 @@
 SUBDIRS += xfrd
 SUBDIRS += xcs
 SUBDIRS += ioemu
+SUBDIRS += pygrub

.PHONY: all install clean check check_clean

tools/pygrub/Makefile new file +18 -0
diff -Nru a/tools/pygrub/Makefile b/tools/pygrub/Makefile
@@ -0,0 +1,18 @@
+
+XEN_ROOT = ../..
+include $(XEN_ROOT)/tools/Rules.mk
+
+all: build
+build:
+	CFLAGS="$(CFLAGS)" python setup.py build
+
+ifndef XEN_PYTHON_NATIVE_INSTALL
+install: all
+	CFLAGS="$(CFLAGS)" python setup.py install --home="$(DESTDIR)/usr"
+else
+install: all
+	CFLAGS="$(CFLAGS)" python setup.py install --root="$(DESTDIR)"
+endif
+
+clean:
+	rm -rf build *.pyc *.pyo *.o *.a *~
tools/pygrub/setup.py new file +25 -0
diff -Nru a/tools/pygrub/setup.py b/tools/pygrub/setup.py
@@ -0,0 +1,25 @@
+from distutils.core import setup, Extension
+import os
+
+extra_compile_args  = [ "-fno-strict-aliasing", "-Wall", "-Werror" ]
+
+# in a perfect world, we'd figure out the fsys modules dynamically
+ext2 = Extension("grub.fsys.ext2._pyext2",
+                 extra_compile_args = extra_compile_args,
+                 libraries = ["ext2fs"],
+                 sources = ["src/fsys/ext2/ext2module.c"])
+
+setup(name='pygrub',
+      version='0.1',
+      description='Boot loader that looks a lot like grub for Xen',
+      author='Jeremy Katz',
+      author_email='[email protected]',
+      license='GPL',
+      package_dir={'grub': 'src'},
+      scripts = ["src/pygrub"],
+      packages=['grub',
+                'grub.fsys',
+                'grub.fsys.ext2'],
+      ext_modules = [ext2]
+      )
+               
tools/pygrub/src/GrubConf.py new file +229 -0

229 lines not on this page · raw message

tools/pygrub/src/fsys/__init__.py new file +61 -0

61 lines not on this page · raw message

tools/pygrub/src/fsys/ext2/__init__.py new file +38 -0
diff -Nru a/tools/pygrub/src/fsys/ext2/__init__.py b/tools/pygrub/src/fsys/ext2/__init__.py
@@ -0,0 +1,38 @@
+# Copyright 2005 Red Hat, Inc.
+# Jeremy Katz <[email protected]>
+#
+# This software may be freely redistributed under the terms of the GNU
+# general public license.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+#
+
+from grub.fsys import register_fstype, FileSystemType
+from _pyext2 import *
+
+import os, struct
+
+class Ext2FileSystemType(FileSystemType):
+    def __init__(self):
+        FileSystemType.__init__(self)
+        self.name = "ext2"
+
+    def sniff_magic(self, fn, offset = 0):
+        fd = os.open(fn, os.O_RDONLY)
+        os.lseek(fd, offset, 0)
+        buf = os.read(fd, 2048)
+        
+        if len(buf) > 1082 and \
+               struct.unpack("<H", buf[1080:1082]) == (0xef53,):
+            return True
+        return False
+
+    def open_fs(self, fn, offset = 0):
+        if not self.sniff_magic(fn, offset):
+            raise ValueError, "Not an ext2 filesystem"
+        return Ext2Fs(fn)
+
+register_fstype(Ext2FileSystemType())
+
tools/pygrub/src/fsys/ext2/ext2module.c new file +332 -0

332 lines not on this page · raw message

tools/pygrub/src/fsys/ext2/test.py new file +15 -0
diff -Nru a/tools/pygrub/src/fsys/ext2/test.py b/tools/pygrub/src/fsys/ext2/test.py
@@ -0,0 +1,15 @@
+#!/usr/bin/python
+
+
+import _pyext2
+import struct, os, sys
+
+fs = _pyext2.Ext2Fs("test.img")
+
+f = fs.open_file("/boot/vmlinuz-2.6.11-1.1177_FC4")
+buf = f.read()
+o = open("vmlinuz", "wb+")
+o.write(buf)
+o.close()
+
+f.close()
tools/pygrub/src/pygrub new file +270 -0

270 lines not on this page · raw message

tools/python/xen/xend/XendBootloader.py new file +95 -0

95 lines not on this page · raw message

tools/python/xen/xend/XendDomainInfo.py +40 -2

96 lines not on this page · raw message

tools/python/xen/xend/server/blkif.py +9 -0
diff -Nru a/tools/python/xen/xend/server/blkif.py b/tools/python/xen/xend/server/blkif.py
@@ -96,6 +96,15 @@
                 'type' : 'Disk' }
     return val
 
+def blkdev_uname_to_file(uname):
+    """Take a blkdev uname and return the corresponding filename."""
+    fn = None
+    if uname.find(":") != -1:
+        (typ, fn) = uname.split(":")
+        if typ == "phy" and not fn.startswith("/dev/"):
+            fn = "/dev/%s" %(fn,)
+    return fn
+
 class BlkifBackendController(controller.BackendController):
     """ Handler for the 'back-end' channel to a block device driver domain.
     """
tools/python/xen/xm/create.py +32 -2
diff -Nru a/tools/python/xen/xm/create.py b/tools/python/xen/xm/create.py
@@ -10,6 +10,8 @@
 from xen.xend import sxp
 from xen.xend import PrettyPrint
 from xen.xend.XendClient import server, XendError
+from xen.xend.XendBootloader import bootloader
+from xen.xend.server import blkif
 
 from xen.util import console_client
 
@@ -94,6 +96,14 @@
           fn=set_value, default=None,
           use="Domain name. Must be unique.")
 
+gopts.var('bootloader', val='FILE',
+          fn=set_value, default=None,
+          use="Path to bootloader.")
+
+gopts.var('bootentry', val='NAME',
+          fn=set_value, default=None,
+          use="Entry to boot via boot loader")
+
 gopts.var('kernel', val='FILE',
           fn=set_value, default=None,
           use="Path to kernel image.")
@@ -375,6 +385,21 @@
     config_devs.append(['device_model', device_model])
     config_devs.append(['device_config', device_config])
 
+def run_bootloader(config, vals):
+    if not os.access(vals.bootloader, os.X_OK):
+        print >> sys.stderr, "Bootloader isn't executable"
+        sys.exit(1)
+    if len(vals.disk) < 1:
+        print >> sys.stderr, "No disks configured and boot loader requested"
+        sys.exit(1)
+    (uname, dev, mode, backend) = vals.disk[0]
+    file = blkif.blkdev_uname_to_file(uname)
+
+    blcfg = bootloader(vals.bootloader, file, not vals.console_autoconnect,
+                       vals.vcpus, vals.blentry)
+
+    config.extend(blcfg)
+
 def make_config(vals):
     """Create the domain configuration.
     """
@@ -396,8 +421,11 @@
         config.append(['restart', vals.restart])
     if vals.console:
         config.append(['console', vals.console])
-    
-    configure_image(config, vals)
+
+    if vals.bootloader:
+        run_bootloader(config, vals)
+    else:
+        configure_image(config, vals)
     config_devs = []
     configure_disks(config_devs, vals)
     configure_pci(config_devs, vals)
@@ -405,6 +433,7 @@
     configure_usb(config_devs, vals)
     configure_vmx(config_devs, vals)
     config += config_devs
+
     return config
 
 def preprocess_disk(opts, vals):
@@ -588,6 +617,7 @@
         if not opts.getopt('name') and opts.getopt('defconfig'):
             opts.setopt('name', os.path.basename(opts.getopt('defconfig')))
         config = make_config(opts.vals)
+
     if opts.vals.dryrun:
         PrettyPrint.prettyprint(config)
     else:

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#1 lore raw
Quoted 26 lines · Jeremy Katz

Attached is an updated version of the patch to add boot loader support for guest domains.

Changes from the initial set of patches:
* Per Ian's request, adds an option to specify booting a specific kernel from the host domain (you can specify it either with the title of the boot loader config entry or with the grub 0-based index)
* Reduces some of the code duplication for finding out what the virtual disk to boot off of is
* Improved error handling to use the standard Xen logging and error facilities

At this point, I think that we handle the use cases where a user just wants to have everything specified from within the guest domain, creating a domain with xm create and wanting to be able to interactively select a kernel and asking for a specific entry from the grub.conf to be booted when creating a domain.

Future things (which I think are fine to do after the initial pass is committed) include
* Reworking to use the planned new console infrastructure [1]
* Handling whole disks
* More filesystem support -- the code is generic and has all the hooks, I just haven't delved deep enough into any of the other fs libraries
* Further improvements for the menu interface

Quoted 6 lines

Jeremy

[1] And I foolishly told Ian I'd start a discussion about this last week and still haven't. Hopefully tonight.

Jeremy, I tried it out with the latest xen-unstable got from the homepage and patch with xen-booloader.patch. There are few "hunk". What xen-unstable version are you using?

By the way, did you forget __init__.py in pygrub/src/ ? pygrub is a python package, and looks like we need it. At the moment compilation spit out an error "... __init__.py not found...".

Quick fix:

touch tools/pygrub/src/__init__.py

then no more complain.

regards,
aq

#2 lore raw
Quoted 4 lines · aq
Quoted 3 lines · Jeremy Katz

Attached is an updated version of the patch to add boot loader support for guest domains.

Quoted 9 lines
Quoted 9 lines

Changes from the initial set of patches:
* Per Ian's request, adds an option to specify booting a specific kernel from the host domain (you can specify it either with the title of the boot loader config entry or with the grub 0-based index)
* Reduces some of the code duplication for finding out what the virtual disk to boot off of is
* Improved error handling to use the standard Xen logging and error facilities

Jeremy, I looked at your code, and find few lines like this:

exec("%s = r\"%s\"" %(self.commands[com], arg.strip()))

Looks like you dont need the above "r". Then the code should be:

exec("%s = \"%s\"" %(self.commands[com], arg.strip()))

Here is a small patch (against your patch) to remove those typos.

$ diffstat booloader1.patch
 xen-bootloader2.patch |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
xen-bootloader2.patch renamed from xen-bootloader.patch +2 -2
@@ -147,7 +147,7 @@ diff -Nru a/tools/pygrub/src/GrubConf.py
 +
 +            if self.commands.has_key(com):
 +                if self.commands[com] is not None:
-+                    exec("%s = r\"%s\"" %(self.commands[com], arg.strip()))
++                    exec("%s = \"%s\"" %(self.commands[com], arg.strip()))
 +                else:
 +                    logging.info("Ignored image directive %s" %(com,))
 +            else:
@@ -246,7 +246,7 @@ diff -Nru a/tools/pygrub/src/GrubConf.py
 +
 +            if self.commands.has_key(com):
 +                if self.commands[com] is not None:
-+                    exec("%s = r\"%s\"" %(self.commands[com], arg.strip()))
++                    exec("%s = \"%s\"" %(self.commands[com], arg.strip()))
 +                else:
 +                    logging.info("Ignored directive %s" %(com,))
 +            else:

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#3 lore raw
In reply to aq
Quoted 3 lines · aq

Jeremy, I tried it out with the latest xen-unstable got from the homepage and patch with xen-booloader.patch. There are few "hunk". What xen-unstable version are you using?

Bah, bitkeeper foils me again. Rediffed to current -unstable attached. Thanks for catching that.

Quoted 3 lines

By the way, did you forget __init__.py in pygrub/src/ ? pygrub is a python package, and looks like we need it. At the moment compilation spit out an error "... __init__.py not found...".

It was there at one point... added it as well for this diff.

As for your other comment, the r quoting of the strings is to make sure that the strings are interpreted as raw strings instead of trying to handle escaping which helps in cases where you have "odd" things in your grub.conf.

Jeremy

# This is a BitKeeper generated diff -Nru style patch. #
# ChangeSet
# 2005/04/26 12:46:24-04:00 [email protected]
# Add __init__.py. Noticed by aq <[email protected]>
#

# tools/pygrub/src/__init__.py
#   2005/04/26 12:39:00-04:00 [email protected] +0 -0
# 
# tools/pygrub/src/__init__.py
#   2005/04/26 12:38:59-04:00 [email protected] +0 -0
#   BitKeeper file /home/katzj/cvs/xen/xen-pygrub/tools/pygrub/src/__init__.py
# 
# ChangeSet
#   2005/04/25 18:25:47-04:00 [email protected] 
#   Add passing of booting a specific entry by label or by index
# 
# tools/python/xen/xm/create.py
#   2005/04/25 18:25:45-04:00 [email protected] +6 -2
#   allow specifying the default entry to boot
# 
# tools/python/xen/xend/XendBootloader.py
#   2005/04/25 18:25:45-04:00 [email protected] +9 -3
#   support passing the default entry to boot
# 
# tools/pygrub/src/pygrub
#   2005/04/25 18:25:45-04:00 [email protected] +35 -20
#   support passing an entry to boot either by label or by index.  also
#   remove some dead code and fix a few minor bugs
# 
# ChangeSet
#   2005/04/14 12:16:27-04:00 [email protected] 
#   Minor fixes based on feedback from Mike Wray
# 
# tools/python/xen/xm/create.py
#   2005/04/14 12:16:25-04:00 [email protected] +2 -3
#   Use method in blkif to do uname -> file conversion
# 
# tools/python/xen/xend/server/blkif.py
#   2005/04/14 12:16:25-04:00 [email protected] +9 -0
#   Add method to convert from a uname to a real file
# 
# tools/python/xen/xend/XendDomainInfo.py
#   2005/04/14 12:16:25-04:00 [email protected] +6 -8
#   Make lack of a disk a fatal error.  Use the method in blkif
#   for going from a disk uname to a filename
# 
# tools/python/xen/xend/XendBootloader.py
#   2005/04/14 12:16:25-04:00 [email protected] +14 -4
#   Improve error handling.  Log errors and raise an error on a problem
#   instead of just printing to stderr and exiting
# 
# ChangeSet
#   2005/04/13 23:02:35-04:00 [email protected] 
#   Add pygrub, a simple boot loader for use to read a boot loader
#   config out of a domU's filesystem and then read kernels out as well.
#   Currently only has support for ext[23] via libext2fs, but it should
#   be easy to add other filesystems.
#   
#   Still needs work to complete the interface and to support full disk
#   images instead of just partitions.
# 
# tools/pygrub/src/pygrub
#   2005/04/13 23:02:33-04:00 [email protected] +255 -0
# 
# tools/pygrub/src/fsys/ext2/test.py
#   2005/04/13 23:02:33-04:00 [email protected] +15 -0
# 
# tools/pygrub/src/fsys/ext2/ext2module.c
#   2005/04/13 23:02:33-04:00 [email protected] +332 -0
# 
# tools/pygrub/src/fsys/ext2/__init__.py
#   2005/04/13 23:02:33-04:00 [email protected] +38 -0
# 
# tools/pygrub/src/fsys/__init__.py
#   2005/04/13 23:02:33-04:00 [email protected] +61 -0
# 
# tools/pygrub/src/GrubConf.py
#   2005/04/13 23:02:33-04:00 [email protected] +229 -0
# 
# tools/pygrub/setup.py
#   2005/04/13 23:02:33-04:00 [email protected] +25 -0
# 
# tools/pygrub/Makefile
#   2005/04/13 23:02:33-04:00 [email protected] +18 -0
# 
# tools/pygrub/src/pygrub
#   2005/04/13 23:02:33-04:00 [email protected] +0 -0
#   BitKeeper file /home/katzj/cvs/xen/xen-pygrub/tools/pygrub/src/pygrub
# 
# tools/pygrub/src/fsys/ext2/test.py
#   2005/04/13 23:02:33-04:00 [email protected] +0 -0
#   BitKeeper file /home/katzj/cvs/xen/xen-pygrub/tools/pygrub/src/fsys/ext2/test.py
# 
# tools/pygrub/src/fsys/ext2/ext2module.c
#   2005/04/13 23:02:33-04:00 [email protected] +0 -0
#   BitKeeper file /home/katzj/cvs/xen/xen-pygrub/tools/pygrub/src/fsys/ext2/ext2module.c
# 
# tools/pygrub/src/fsys/ext2/__init__.py
#   2005/04/13 23:02:33-04:00 [email protected] +0 -0
#   BitKeeper file /home/katzj/cvs/xen/xen-pygrub/tools/pygrub/src/fsys/ext2/__init__.py
# 
# tools/pygrub/src/fsys/__init__.py
#   2005/04/13 23:02:33-04:00 [email protected] +0 -0
#   BitKeeper file /home/katzj/cvs/xen/xen-pygrub/tools/pygrub/src/fsys/__init__.py
# 
# tools/pygrub/src/GrubConf.py
#   2005/04/13 23:02:33-04:00 [email protected] +0 -0
#   BitKeeper file /home/katzj/cvs/xen/xen-pygrub/tools/pygrub/src/GrubConf.py
# 
# tools/pygrub/setup.py
#   2005/04/13 23:02:33-04:00 [email protected] +0 -0
#   BitKeeper file /home/katzj/cvs/xen/xen-pygrub/tools/pygrub/setup.py
# 
# tools/pygrub/Makefile
#   2005/04/13 23:02:33-04:00 [email protected] +0 -0
#   BitKeeper file /home/katzj/cvs/xen/xen-pygrub/tools/pygrub/Makefile
# 
# tools/Makefile
#   2005/04/13 23:02:33-04:00 [email protected] +1 -0
#   Add pygrub subdirectory
# 
# ChangeSet
#   2005/04/13 23:01:42-04:00 [email protected] 
#   Add framework for running a bootloader from within xend and xm. To
#   specify the executable to run, set in your domain config like
#     bootloader="/usr/bin/pygrub"
#   
#   The bootloader will get executed on both domain creation and domain
#   reboot to get the default kernel/initrd specified in the bootloader
#   config for the domain.  If you auto-connect the console on domain
#   creation, then your bootloader will be run in an interactive mode.
# 
# BitKeeper/etc/logging_ok
#   2005/04/13 23:01:42-04:00 [email protected] +1 -0
#   Logging to [email protected] accepted
# 
# tools/python/xen/xend/XendBootloader.py
#   2005/04/13 23:01:37-04:00 [email protected] +79 -0
# 
# tools/python/xen/xm/create.py
#   2005/04/13 23:01:37-04:00 [email protected] +29 -2
#   Run bootloader on domain creation.  If console is being connected,
#   then run in an interactive mode, else just go with the default.
# 
# tools/python/xen/xend/XendDomainInfo.py
#   2005/04/13 23:01:37-04:00 [email protected] +41 -1
#   Add running of a boot loader from xend on domain reboot.  Runs in
#   an uninteractive mode to get the default kernel/initrd for the
#   domain.  Also removes any temporary kernels created by the 
#   bootloader.
# 
# tools/python/xen/xend/XendBootloader.py
#   2005/04/13 23:01:37-04:00 [email protected] +0 -0
#   BitKeeper file /home/katzj/cvs/xen/xen-pygrub/tools/python/xen/xend/XendBootloader.py
# 
diff -Nru a/tools/Makefile b/tools/Makefile
--- a/tools/Makefile	2005-04-26 12:54:29 -04:00
+++ b/tools/Makefile	2005-04-26 12:54:29 -04:00
@@ -13,6 +13,7 @@
 ifndef XEN_NO_IOEMU
 SUBDIRS += ioemu
 endif
+SUBDIRS += pygrub

.PHONY: all install clean check check_clean

tools/pygrub/Makefile new file +18 -0
diff -Nru a/tools/pygrub/Makefile b/tools/pygrub/Makefile
@@ -0,0 +1,18 @@
+
+XEN_ROOT = ../..
+include $(XEN_ROOT)/tools/Rules.mk
+
+all: build
+build:
+	CFLAGS="$(CFLAGS)" python setup.py build
+
+ifndef XEN_PYTHON_NATIVE_INSTALL
+install: all
+	CFLAGS="$(CFLAGS)" python setup.py install --home="$(DESTDIR)/usr"
+else
+install: all
+	CFLAGS="$(CFLAGS)" python setup.py install --root="$(DESTDIR)"
+endif
+
+clean:
+	rm -rf build *.pyc *.pyo *.o *.a *~
tools/pygrub/setup.py new file +25 -0
diff -Nru a/tools/pygrub/setup.py b/tools/pygrub/setup.py
@@ -0,0 +1,25 @@
+from distutils.core import setup, Extension
+import os
+
+extra_compile_args  = [ "-fno-strict-aliasing", "-Wall", "-Werror" ]
+
+# in a perfect world, we'd figure out the fsys modules dynamically
+ext2 = Extension("grub.fsys.ext2._pyext2",
+                 extra_compile_args = extra_compile_args,
+                 libraries = ["ext2fs"],
+                 sources = ["src/fsys/ext2/ext2module.c"])
+
+setup(name='pygrub',
+      version='0.1',
+      description='Boot loader that looks a lot like grub for Xen',
+      author='Jeremy Katz',
+      author_email='[email protected]',
+      license='GPL',
+      package_dir={'grub': 'src'},
+      scripts = ["src/pygrub"],
+      packages=['grub',
+                'grub.fsys',
+                'grub.fsys.ext2'],
+      ext_modules = [ext2]
+      )
+               
tools/pygrub/src/GrubConf.py new file +229 -0

229 lines not on this page · raw message

tools/pygrub/src/fsys/__init__.py new file +61 -0

61 lines not on this page · raw message

tools/pygrub/src/fsys/ext2/__init__.py new file +38 -0
diff -Nru a/tools/pygrub/src/fsys/ext2/__init__.py b/tools/pygrub/src/fsys/ext2/__init__.py
@@ -0,0 +1,38 @@
+# Copyright 2005 Red Hat, Inc.
+# Jeremy Katz <[email protected]>
+#
+# This software may be freely redistributed under the terms of the GNU
+# general public license.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+#
+
+from grub.fsys import register_fstype, FileSystemType
+from _pyext2 import *
+
+import os, struct
+
+class Ext2FileSystemType(FileSystemType):
+    def __init__(self):
+        FileSystemType.__init__(self)
+        self.name = "ext2"
+
+    def sniff_magic(self, fn, offset = 0):
+        fd = os.open(fn, os.O_RDONLY)
+        os.lseek(fd, offset, 0)
+        buf = os.read(fd, 2048)
+        
+        if len(buf) > 1082 and \
+               struct.unpack("<H", buf[1080:1082]) == (0xef53,):
+            return True
+        return False
+
+    def open_fs(self, fn, offset = 0):
+        if not self.sniff_magic(fn, offset):
+            raise ValueError, "Not an ext2 filesystem"
+        return Ext2Fs(fn)
+
+register_fstype(Ext2FileSystemType())
+
tools/pygrub/src/fsys/ext2/ext2module.c new file +332 -0

332 lines not on this page · raw message

tools/pygrub/src/fsys/ext2/test.py new file +15 -0
diff -Nru a/tools/pygrub/src/fsys/ext2/test.py b/tools/pygrub/src/fsys/ext2/test.py
@@ -0,0 +1,15 @@
+#!/usr/bin/python
+
+
+import _pyext2
+import struct, os, sys
+
+fs = _pyext2.Ext2Fs("test.img")
+
+f = fs.open_file("/boot/vmlinuz-2.6.11-1.1177_FC4")
+buf = f.read()
+o = open("vmlinuz", "wb+")
+o.write(buf)
+o.close()
+
+f.close()
tools/pygrub/src/pygrub new file +270 -0

270 lines not on this page · raw message

tools/python/xen/xend/XendBootloader.py new file +95 -0

95 lines not on this page · raw message

tools/python/xen/xend/XendDomainInfo.py +40 -2

96 lines not on this page · raw message

tools/python/xen/xend/server/blkif.py +9 -0
diff -Nru a/tools/python/xen/xend/server/blkif.py b/tools/python/xen/xend/server/blkif.py
@@ -96,6 +96,15 @@
                 'type' : 'Disk' }
     return val
 
+def blkdev_uname_to_file(uname):
+    """Take a blkdev uname and return the corresponding filename."""
+    fn = None
+    if uname.find(":") != -1:
+        (typ, fn) = uname.split(":")
+        if typ == "phy" and not fn.startswith("/dev/"):
+            fn = "/dev/%s" %(fn,)
+    return fn
+
 class BlkifBackendController(controller.BackendController):
     """ Handler for the 'back-end' channel to a block device driver domain.
     """
tools/python/xen/xm/create.py +32 -2
diff -Nru a/tools/python/xen/xm/create.py b/tools/python/xen/xm/create.py
@@ -10,6 +10,8 @@
 from xen.xend import sxp
 from xen.xend import PrettyPrint
 from xen.xend.XendClient import server, XendError
+from xen.xend.XendBootloader import bootloader
+from xen.xend.server import blkif
 
 from xen.util import console_client
 
@@ -94,6 +96,14 @@
           fn=set_value, default=None,
           use="Domain name. Must be unique.")
 
+gopts.var('bootloader', val='FILE',
+          fn=set_value, default=None,
+          use="Path to bootloader.")
+
+gopts.var('bootentry', val='NAME',
+          fn=set_value, default=None,
+          use="Entry to boot via boot loader")
+
 gopts.var('kernel', val='FILE',
           fn=set_value, default=None,
           use="Path to kernel image.")
@@ -375,6 +385,21 @@
     config_devs.append(['device_model', device_model])
     config_devs.append(['device_config', device_config])
 
+def run_bootloader(config, vals):
+    if not os.access(vals.bootloader, os.X_OK):
+        print >> sys.stderr, "Bootloader isn't executable"
+        sys.exit(1)
+    if len(vals.disk) < 1:
+        print >> sys.stderr, "No disks configured and boot loader requested"
+        sys.exit(1)
+    (uname, dev, mode, backend) = vals.disk[0]
+    file = blkif.blkdev_uname_to_file(uname)
+
+    blcfg = bootloader(vals.bootloader, file, not vals.console_autoconnect,
+                       vals.vcpus, vals.blentry)
+
+    config.extend(blcfg)
+
 def make_config(vals):
     """Create the domain configuration.
     """
@@ -396,8 +421,11 @@
         config.append(['restart', vals.restart])
     if vals.console:
         config.append(['console', vals.console])
-    
-    configure_image(config, vals)
+
+    if vals.bootloader:
+        run_bootloader(config, vals)
+    else:
+        configure_image(config, vals)
     config_devs = []
     configure_disks(config_devs, vals)
     configure_pci(config_devs, vals)
@@ -405,6 +433,7 @@
     configure_usb(config_devs, vals)
     configure_vmx(config_devs, vals)
     config += config_devs
+
     return config
 
 def preprocess_disk(opts, vals):
@@ -588,6 +617,7 @@
         if not opts.getopt('name') and opts.getopt('defconfig'):
             opts.setopt('name', os.path.basename(opts.getopt('defconfig')))
         config = make_config(opts.vals)
+
     if opts.vals.dryrun:
         PrettyPrint.prettyprint(config)
     else:

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#4 lore raw
Quoted 12 lines · Jeremy Katz
Quoted 3 lines · aq

Jeremy, I tried it out with the latest xen-unstable got from the homepage and patch with xen-booloader.patch. There are few "hunk". What xen-unstable version are you using?

Bah, bitkeeper foils me again. Rediffed to current -unstable attached. Thanks for catching that.

Quoted 3 lines

By the way, did you forget __init__.py in pygrub/src/ ? pygrub is a python package, and looks like we need it. At the moment compilation spit out an error "... __init__.py not found...".

Quoted 6 lines

It was there at one point... added it as well for this diff.

As for your other comment, the r quoting of the strings is to make sure that the strings are interpreted as raw strings instead of trying to handle escaping which helps in cases where you have "odd" things in your grub.conf.

ok, i see the point.

other question: pygrub::get_config(fn) tries to read "/boot/grub/grub.conf". Normally this should be "/boot/grub/menu.lst". I wonder which distro are you working on?

I expect this code will be in -unstable soon, so we can work on the same code base. sending patch would be easier.

thank you,
aq

#5 lore raw
Quoted 5 lines

ok, i see the point.

other question: pygrub::get_config(fn) tries to read "/boot/grub/grub.conf". Normally this should be "/boot/grub/menu.lst". I wonder which distro are you working on?

I'm betting he's using RedHat :-)

My FC3 box has menu.lst as a symlink to grub.conf. Grub seems to be happy with either of these names. Painful experience suggests that if both files are present, then "menu.lst" will "win".

Jeremy: for distros that just have menu.lst, could you search for this too? Perhaps it's worth implementing a grub-style precedence for menu.lst when present and grub.conf if not?

Cheers,
Mark

Quoted 10 lines

I expect this code will be in -unstable soon, so we can work on the same code base. sending patch would be easier.

thank you,
aq

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#6 lore raw
Quoted 9 lines · Mark Williamson
Quoted 5 lines

ok, i see the point.

other question: pygrub::get_config(fn) tries to read "/boot/grub/grub.conf". Normally this should be "/boot/grub/menu.lst". I wonder which distro are you working on?

My FC3 box has menu.lst as a symlink to grub.conf. Grub seems to be happy with either of these names. Painful experience suggests that if both files are present, then "menu.lst" will "win".

GRUB only looks for menu.lst; distros create symlinks because that's a terrible name for a config file. In other words, no code should be opening grub.conf...

Signature · 2 lines
Hollis Blanchard
IBM Linux Technology Center
#7 lore raw
Quoted 3 lines

GRUB only looks for menu.lst; distros create symlinks because that's a terrible name for a config file. In other words, no code should be opening grub.conf...

OK, I've investigated this using my sacrificial FC3 laptop ;-) I'd not fully investigated this before.

Redhat's grub looks for grub.conf and not menu.lst. Standard grub looks for menu.lst.

If the loader is to be flexible for different domU distros, it'd be nice to look for both, in one order or the other.

Cheers,
Mark

#8 lore raw
Quoted 4 lines · Mark Williamson
Quoted 3 lines

GRUB only looks for menu.lst; distros create symlinks because that's a terrible name for a config file. In other words, no code should be opening grub.conf...

Quoted 9 lines

OK, I've investigated this using my sacrificial FC3 laptop ;-) I'd not fully investigated this before.

Redhat's grub looks for grub.conf and not menu.lst. Standard grub looks for menu.lst.

If the loader is to be flexible for different domU distros, it'd be nice to look for both, in one order or the other.

in that case, this patch is better for you, Mark ;-). Please apply this on top of Jeremy's patch.

list of changes:
- make a dummy file tools/pygrub/src/__init__.py
- tools/src/pygrub looks for either /boot/grub/menu.lst or /boot/grub/grub.conf, in that order.

$ diffstat xen-bootloader.aq2.patch 
 __init__.py |    1 +
 pygrub      |   11 +++++++++--
 2 files changed, 10 insertions(+), 2 deletions(-)
tools/pygrub/src/__init__.py +1 -0
diff -Nurp xen-unstable.27.3.org/tools/pygrub/src/__init__.py xen-unstable.27.3/tools/pygrub/src/__init__.py
@@ -0,0 +1 @@
+ 
tools/pygrub/src/pygrub +9 -2
diff -Nurp xen-unstable.27.3.org/tools/pygrub/src/pygrub xen-unstable.27.3/tools/pygrub/src/pygrub
@@ -13,7 +13,7 @@
 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 #
 
-import os, sys, string, struct, tempfile
+import os, os.path, sys, string, struct, tempfile
 import logging
 
 import curses, _curses, curses.wrapper
@@ -97,7 +97,14 @@ def get_config(fn):
             break
 
     if fs is not None:
-        f = fs.open_file("/boot/grub/grub.conf")
+        if os.path.isfile("/boot/grub/menu.lst"):
+            grubfile = "/boot/grub/menu.lst"
+        elif os.path.isfile("/boot/grub/grub.conf"):
+            grubfile = "/boot/grub/grub.conf"
+        else:
+            raise RuntimeError, "we cannot find /boot/grub/{menu.lst,grub.conf} " + \
+                                "in the image provided. halt!"
+        f = fs.open_file(grubfile)
         buf = f.read()
         f.close()
         fs.close()

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#9 lore raw

Thanks for the patch.

I haven't looked at Jeremy's code but won't the os.path.isfile() break when the kernel (and the boot options) are being loaded from within a domain's filesystem, rather than dom0?

Cheers,
Mark

Quoted 28 lines · aq
Quoted 4 lines · Mark Williamson
Quoted 3 lines

GRUB only looks for menu.lst; distros create symlinks because that's a terrible name for a config file. In other words, no code should be opening grub.conf...

Quoted 8 lines

OK, I've investigated this using my sacrificial FC3 laptop ;-) I'd not fully investigated this before.

Redhat's grub looks for grub.conf and not menu.lst. Standard grub looks for menu.lst.

If the loader is to be flexible for different domU distros, it'd be nice to look for both, in one order or the other.

in that case, this patch is better for you, Mark ;-). Please apply this on top of Jeremy's patch.

list of changes:
- make a dummy file tools/pygrub/src/__init__.py
- tools/src/pygrub looks for either /boot/grub/menu.lst or /boot/grub/grub.conf, in that order.

$ diffstat xen-bootloader.aq2.patch
 __init__.py |    1 +
 pygrub      |   11 +++++++++--
 2 files changed, 10 insertions(+), 2 deletions(-)
#10 lore raw
Quoted 5 lines · Mark Williamson

Thanks for the patch.

I haven't looked at Jeremy's code but won't the os.path.isfile() break when the kernel (and the boot options) are being loaded from within a domain's filesystem, rather than dom0?

ah you right here. my bad mistake. so we need another patch for this problem. Perhaps the abstract of filesystem should be extended for this case also. I am working on it.

thank you,
aq

#11 lore raw
In reply to Mark Williamson
Quoted 4 lines · Mark Williamson
Quoted 3 lines

GRUB only looks for menu.lst; distros create symlinks because that's a terrible name for a config file. In other words, no code should be opening grub.conf...

Quoted 8 lines

OK, I've investigated this using my sacrificial FC3 laptop ;-) I'd not fully investigated this before.

Redhat's grub looks for grub.conf and not menu.lst. Standard grub looks for menu.lst.

If the loader is to be flexible for different domU distros, it'd be nice to look for both, in one order or the other.

Yeah, oops... I forgot about that. I've been doing grub.conf so long now that my mind forgets that Okuji didn't want to take the patch for upstream grub at times.

Just checking both is the easy answer and aq has already sent the patch to do so (thanks!)

Jeremy

#12 lore raw
In reply to Hollis Blanchard
Quoted 7 lines · Hollis Blanchard
Quoted 6 lines · Mark Williamson
Quoted 5 lines

ok, i see the point.

other question: pygrub::get_config(fn) tries to read "/boot/grub/grub.conf". Normally this should be "/boot/grub/menu.lst". I wonder which distro are you working on?

Quoted 8 lines
Quoted 3 lines

My FC3 box has menu.lst as a symlink to grub.conf. Grub seems to be happy with either of these names. Painful experience suggests that if both files are present, then "menu.lst" will "win".

GRUB only looks for menu.lst; distros create symlinks because that's a terrible name for a config file. In other words, no code should be opening grub.conf...

ok, so here is a quick patch to fix the "/boot/grub/grub.conf" problem. Please apply this after applying the last Jeremy's patch.

list of changes:
- make a dummy file tools/pygrub/src/__init__.py
- open and parse /boot/grub/menu.lst instead of /boot/grub/grub.conf

$ diffstat xen-bootloader.aq.patch 
 __init__.py |    1 +
 pygrub      |    7 +++++--
 2 files changed, 6 insertions(+), 2 deletions(-)
tools/pygrub/src/__init__.py +1 -0
diff -Nurp xen-unstable.27.3.org/tools/pygrub/src/__init__.py xen-unstable.27.3/tools/pygrub/src/__init__.py
@@ -0,0 +1 @@
+ 
tools/pygrub/src/pygrub +5 -2
diff -Nurp xen-unstable.27.3.org/tools/pygrub/src/pygrub xen-unstable.27.3/tools/pygrub/src/pygrub
@@ -13,7 +13,7 @@
 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 #
 
-import os, sys, string, struct, tempfile
+import os, os.path, sys, string, struct, tempfile
 import logging
 
 import curses, _curses, curses.wrapper
@@ -97,7 +97,10 @@ def get_config(fn):
             break
 
     if fs is not None:
-        f = fs.open_file("/boot/grub/grub.conf")
+        if not os.path.isfile("/boot/grub/menu.lst"):
+            raise RuntimeError, "we cannot find /boot/grub/menu.lst" + \
+                                "in the image provided. halt!"
+        f = fs.open_file("/boot/grub/menu.lst")
         buf = f.read()
         f.close()
         fs.close()

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#13 lore raw
In reply to Jeremy Katz
Quoted 12 lines · Jeremy Katz
Quoted 3 lines · aq

Jeremy, I tried it out with the latest xen-unstable got from the homepage and patch with xen-booloader.patch. There are few "hunk". What xen-unstable version are you using?

Bah, bitkeeper foils me again. Rediffed to current -unstable attached. Thanks for catching that.

Quoted 3 lines

By the way, did you forget __init__.py in pygrub/src/ ? pygrub is a python package, and looks like we need it. At the moment compilation spit out an error "... __init__.py not found...".

Quoted 9 lines

It was there at one point... added it as well for this diff.

As for your other comment, the r quoting of the strings is to make sure that the strings are interpreted as raw strings instead of trying to handle escaping which helps in cases where you have "odd" things in your grub.conf.

Jeremy

I checked the new patch. src/__init__.py is not in yet?

$ diffstat xen-bootloader-2.patch 
 Makefile                          |    1 
 pygrub/Makefile                   |   18 ++
 pygrub/setup.py                   |   25 ++
 pygrub/src/GrubConf.py            |  229 ++++++++++++++++++++++++++
 pygrub/src/fsys/__init__.py       |   61 ++++++
 pygrub/src/fsys/ext2/__init__.py  |   38 ++++
 pygrub/src/fsys/ext2/ext2module.c |  332 ++++++++++++++++++++++++++++++++++++++
 pygrub/src/fsys/ext2/test.py      |   15 +
 pygrub/src/pygrub                 |  270 ++++++++++++++++++++++++++++++
 python/xen/xend/XendBootloader.py |   95 ++++++++++
 python/xen/xend/XendDomainInfo.py |   42 ++++
 python/xen/xend/server/blkif.py   |    9 +
 python/xen/xm/create.py           |   34 +++
 13 files changed, 1165 insertions(+), 4 deletions(-)

when i use diff to produce the patch, if the src/__init__.py is empty, diff would ignore that file, too. so the trick is to create __init__.py with a space inside ;-)

regards,
aq

#14 lore raw
In reply to Jeremy Katz
Quoted 2 lines · Jeremy Katz

Attached is an updated version of the patch to add boot loader support for guest domains.

In relation to this, did anyone consider porting Grub to run inside a domU?

Jacob

#15 lore raw
Quoted 5 lines · Jacob Gorm Hansen
Quoted 2 lines · Jeremy Katz

Attached is an updated version of the patch to add boot loader support for guest domains.

In relation to this, did anyone consider porting Grub to run inside a domU?

While it seems appealing, a large amount of the grub code is device drivers, real mode boot strapping code, etc.

You'd probably get very little useful code from grub in porting it to domU.

Regards,

Quoted 6 lines

Jacob

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

Signature · 4 lines
Anthony Liguori
Linux Technology Center (LTC) - IBM Austin
E-mail: [email protected]
Phone: (512) 838-1208
#16 lore raw
Quoted 4 lines · Anthony Liguori
Quoted 2 lines · Jacob Gorm Hansen

Jeremy Katz wrote:

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

Attached is an updated version of the patch to add boot loader support for guest domains.

In relation to this, did anyone consider porting Grub to run inside a domU?

While it seems appealing, a large amount of the grub code is device drivers, real mode boot strapping code, etc.

The interesting things you would get from Grub would be the filesystem-decoding stuff, the elf decoder, the two-stage loader, and the nice and well-tested config-file parsing, in a format that lots of users already understand. Tftp and bootp/dhcp support could also be nice in some scenarios.

And by having the bootloader in the domU you would get stronger security as well.

Jacob