ia64/xen-unstable

changeset 9885:ef6216b43278

Instead of relying on xm create to always run the bootloader, make sure
we run it if we get into domain creation with a bootloader set but no
image. This could happen if someone creates a domain config via the
XML-RPC or sxp interfaces.

Signed-off-by: Jeremy Katz <katzj@redhat.com>
author kaf24@firebug.cl.cam.ac.uk
date Fri Apr 28 14:11:57 2006 +0100 (2006-04-28)
parents 268e45409ecd
children 73435820f513
files tools/python/xen/xend/XendDomainInfo.py
line diff
     1.1 --- a/tools/python/xen/xend/XendDomainInfo.py	Fri Apr 28 14:10:59 2006 +0100
     1.2 +++ b/tools/python/xen/xend/XendDomainInfo.py	Fri Apr 28 14:11:57 2006 +0100
     1.3 @@ -1234,6 +1234,11 @@ class XendDomainInfo:
     1.4                    self.domid,
     1.5                    self.info['cpu_weight'])
     1.6  
     1.7 +        # if we have a boot loader but no image, then we need to set things
     1.8 +        # up by running the boot loader non-interactively
     1.9 +        if self.infoIsSet('bootloader') and not self.infoIsSet('image'):
    1.10 +            self.configure_bootloader()
    1.11 +
    1.12          if not self.infoIsSet('image'):
    1.13              raise VmError('Missing image in configuration')
    1.14  
    1.15 @@ -1613,23 +1618,25 @@ class XendDomainInfo:
    1.16  
    1.17  
    1.18      def configure_bootloader(self):
    1.19 +        """Run the bootloader if we're configured to do so."""
    1.20          if not self.info['bootloader']:
    1.21              return
    1.22 -        # if we're restarting with a bootloader, we need to run it
    1.23          blcfg = None
    1.24 -        config = self.sxpr()
    1.25 -        # FIXME: this assumes that we want to use the first disk
    1.26 -        for dev in sxp.children(config, "device"):
    1.27 -            disk = sxp.child(dev, "vbd")
    1.28 +        # FIXME: this assumes that we want to use the first disk device
    1.29 +        for (n,c) in self.info['device']:
    1.30 +            if not n or not c or n != "vbd":
    1.31 +                continue
    1.32 +            disk = sxp.child_value(c, "uname")
    1.33              if disk is None:
    1.34                  continue
    1.35 -            fn = blkdev_uname_to_file(sxp.child_value(disk, "uname"))
    1.36 +            fn = blkdev_uname_to_file(disk)
    1.37              blcfg = bootloader(self.info['bootloader'], fn, 1)
    1.38 +            break
    1.39          if blcfg is None:
    1.40              msg = "Had a bootloader specified, but can't find disk"
    1.41              log.error(msg)
    1.42              raise VmError(msg)
    1.43 -        self.info['image'] = sxp.to_string(blcfg)
    1.44 +        self.info['image'] = blcfg
    1.45  
    1.46  
    1.47      def send_sysrq(self, key):