Index: xen-3.0.4-testing/tools/python/xen/xend/XendBootloader.py =================================================================== --- xen-3.0.4-testing.orig/tools/python/xen/xend/XendBootloader.py +++ xen-3.0.4-testing/tools/python/xen/xend/XendBootloader.py @@ -14,6 +14,7 @@ import os, select, errno, stat import random +import re import shlex from xen.xend import sxp @@ -57,6 +58,8 @@ def bootloader(blexec, disk, quiet = Fal args.append("-q") if dryrun: args.append("--dryrun") + if kernel_args: + args.append("--args=%s" % kernel_args) args.append("--output=%s" % fifo) if blargs: args.extend(shlex.split(blargs)) @@ -97,3 +100,26 @@ def bootloader(blexec, disk, quiet = Fal pin.input_eof() blcfg = pin.val return blcfg + +def bootfilter(bootloader, bootloader_args, vdisk): + """Is this virtual disk ok to boot from?""" + if vdisk.endswith(':disk'): + vdisk = vdisk[:-5] # temporary work-around for bug 237414 + if bootloader.endswith('domUloader.py'): + for arg in bootloader_args.split(): + if arg.startswith('--entry='): + m = re.match(r'^([hsx]v?d[a-z])[0-9]*:[^,]*(,[^,]*)?$', arg[8:]) + if m: + return vdisk == m.group(1) or vdisk == m.group(2) + return True + +def bootselector(bootloader, bootloader_args, disks): + """Returns the desired disk to boot from. + @param disks List of (pdev, vdev, ...) tuples. + """ + if bootloader.endswith('domUloader.py'): + for disk in disks: + if bootfilter(bootloader, bootloader_args, disk[1]): + return disk + return disks[0] + Index: xen-3.0.4-testing/tools/python/xen/xend/XendDomainInfo.py =================================================================== --- xen-3.0.4-testing.orig/tools/python/xen/xend/XendDomainInfo.py +++ xen-3.0.4-testing/tools/python/xen/xend/XendDomainInfo.py @@ -41,7 +41,7 @@ from xen.xend import balloon, sxp, uuid, from xen.xend import XendRoot, XendNode, XendConfig from xen.xend.XendConfig import scrub_password -from xen.xend.XendBootloader import bootloader +from xen.xend.XendBootloader import bootloader, bootfilter from xen.xend.XendError import XendError, VmError from xen.xend.XendDevices import XendDevices from xen.xend.xenstore.xstransact import xstransact, complete @@ -1556,13 +1556,17 @@ class XendDomainInfo: if not devtype or not devinfo or devtype not in ('vbd', 'tap'): continue disk = None + vdisk = None for param in devinfo: if param[0] == 'uname': disk = param[1] - break + elif param[0] == 'dev': + vdisk = param[1] if disk is None: continue + if not bootfilter(blexec, bootloader_args, vdisk): + continue fn = blkdev_uname_to_file(disk) mounted = devtype == 'tap' and not os.stat(fn).st_rdev if mounted: Index: xen-3.0.4-testing/tools/python/xen/xm/create.py =================================================================== --- xen-3.0.4-testing.orig/tools/python/xen/xm/create.py +++ xen-3.0.4-testing/tools/python/xen/xm/create.py @@ -29,7 +29,7 @@ import xmlrpclib from xen.xend import sxp from xen.xend import PrettyPrint import xen.xend.XendClient -from xen.xend.XendBootloader import bootloader +from xen.xend.XendBootloader import bootloader, bootselector from xen.util import blkif from xen.util import security @@ -710,16 +710,18 @@ def run_bootloader(vals, config_image): err("Bootloader '%s' isn't executable" % vals.bootloader) if len(vals.disk) < 1: err("No disks configured and boot loader requested") - (uname, dev, mode, backend) = vals.disk[0] - file = blkif.blkdev_uname_to_file(uname) if vals.bootentry: warn("The bootentry option is deprecated. Use bootargs and pass " "--entry= directly.") vals.bootargs = "--entry=%s" %(vals.bootentry,) + bootdisk = bootselector(vals.bootloader, vals.bootargs, vals.disk) + uname = bootdisk[0] + file = blkif.blkdev_uname_to_file(uname) return bootloader(vals.bootloader, file, not vals.console_autoconnect, - vals.bootargs, config_image) + vals.bootargs, + kernel_args = sxp.child_value(config_image, 'args')) def make_config(vals): """Create the domain configuration.