debuggers.hg

changeset 22825:d1631540bcc4

xend: improve psudeo-bootloader support for external block scripts

Userspace tools support external block scripts (e.g. block-drbd
provided by drbd project). The psuedo-bootloader setup code in
xend has a few limitations wrt external block scripts, which this
patch addresses.

blkif.py: parse_uname() utility function should be able to parse a
disk specifier understood by the rest of the tools.

XendDomainInfo.py: Block devices using external block scripts must
be attached to dom0 before running the psuedo-bootloader.

Signed-off-by: Jim Fehlig <jfehlig@novell.com>
Tested-by: Shriram Rajagopalan <rshriram@gmail.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
author Jim Fehlig <jfehlig@novell.com>
date Tue Jan 18 17:23:24 2011 +0000 (2011-01-18)
parents d2a1e1e12667
children 97ab84aca65c
files tools/python/xen/util/blkif.py tools/python/xen/xend/XendDomainInfo.py
line diff
     1.1 --- a/tools/python/xen/util/blkif.py	Tue Jan 18 17:20:55 2011 +0000
     1.2 +++ b/tools/python/xen/util/blkif.py	Tue Jan 18 17:23:24 2011 +0000
     1.3 @@ -66,8 +66,8 @@ def blkdev_segment(name):
     1.4                  'type'         : 'Disk' }
     1.5      return val
     1.6  
     1.7 -def _parse_uname(uname):
     1.8 -    fn = taptype = None
     1.9 +def parse_uname(uname):
    1.10 +    fn = typ = taptype = None
    1.11      if uname.find(":") != -1:
    1.12          (typ, fn) = uname.split(":", 1)
    1.13  
    1.14 @@ -76,15 +76,18 @@ def _parse_uname(uname):
    1.15                 
    1.16          if typ in ("tap", "tap2"):
    1.17              (taptype, fn) = fn.split(":", 1)
    1.18 -    return (fn, taptype)
    1.19 +            if taptype in ("tapdisk", "ioemu"):
    1.20 +                (taptype, fn) = fn.split(":", 1)
    1.21 +    return (fn, (typ,taptype))
    1.22 +
    1.23  
    1.24  def blkdev_uname_to_file(uname):
    1.25      """Take a blkdev uname and return the corresponding filename."""
    1.26 -    return _parse_uname(uname)[0]
    1.27 +    return parse_uname(uname)[0]
    1.28  
    1.29  def blkdev_uname_to_taptype(uname):
    1.30      """Take a blkdev uname and return the blktap type."""
    1.31 -    return _parse_uname(uname)[1]
    1.32 +    return parse_uname(uname)[1]
    1.33  
    1.34  def mount_mode(name):
    1.35      mode = None
     2.1 --- a/tools/python/xen/xend/XendDomainInfo.py	Tue Jan 18 17:20:55 2011 +0000
     2.2 +++ b/tools/python/xen/xend/XendDomainInfo.py	Tue Jan 18 17:23:24 2011 +0000
     2.3 @@ -38,7 +38,7 @@ from types import StringTypes
     2.4  
     2.5  import xen.lowlevel.xc
     2.6  from xen.util import asserts, auxbin, mkdir
     2.7 -from xen.util.blkif import blkdev_uname_to_file, blkdev_uname_to_taptype
     2.8 +from xen.util.blkif import parse_uname
     2.9  import xen.util.xsm.xsm as security
    2.10  from xen.util import xsconstants
    2.11  from xen.util import mkdir
    2.12 @@ -3248,9 +3248,18 @@ class XendDomainInfo:
    2.13              devtype = devinfo[0]
    2.14              disk = devinfo[1]['uname']
    2.15  
    2.16 -            fn = blkdev_uname_to_file(disk)
    2.17 -            taptype = blkdev_uname_to_taptype(disk)
    2.18 -            mounted = devtype in ['tap', 'tap2'] and taptype != 'aio' and taptype != 'sync' and not os.stat(fn).st_rdev
    2.19 +            (fn, types) = parse_uname(disk)
    2.20 +            def _shouldMount(types):
    2.21 +                if types[0] in ('file', 'phy'):
    2.22 +                    return False
    2.23 +                if types[0] in ('tap', 'tap2'):
    2.24 +                    if types[1] in ('aio', 'sync'):
    2.25 +                        return False
    2.26 +                    else:
    2.27 +                        return True
    2.28 +                return os.access('/etc/xen/scripts/block-%s' % types[0], os.X_OK)
    2.29 +
    2.30 +            mounted = _shouldMount(types)
    2.31              mounted_vbd_uuid = 0
    2.32              if mounted:
    2.33                  # This is a file, not a device.  pygrub can cope with a