aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJim Fehlig <jfehlig@novell.com>2011-01-18 17:23:24 +0000
committerJim Fehlig <jfehlig@novell.com>2011-01-18 17:23:24 +0000
commit891436a0e8a8377fc2c4c60686fef5021c22f017 (patch)
tree008020ec4669db89aa9b5bd90cfb9f956278abb0
parent94182843973828ec589e2efc9b65ec013c6caf58 (diff)
downloadxen-891436a0e8a8377fc2c4c60686fef5021c22f017.tar.gz
xen-891436a0e8a8377fc2c4c60686fef5021c22f017.tar.bz2
xen-891436a0e8a8377fc2c4c60686fef5021c22f017.zip
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>
-rw-r--r--tools/python/xen/util/blkif.py13
-rw-r--r--tools/python/xen/xend/XendDomainInfo.py17
2 files changed, 21 insertions, 9 deletions
diff --git a/tools/python/xen/util/blkif.py b/tools/python/xen/util/blkif.py
index 3fc54e79cd..4bbae308af 100644
--- a/tools/python/xen/util/blkif.py
+++ b/tools/python/xen/util/blkif.py
@@ -66,8 +66,8 @@ def blkdev_segment(name):
'type' : 'Disk' }
return val
-def _parse_uname(uname):
- fn = taptype = None
+def parse_uname(uname):
+ fn = typ = taptype = None
if uname.find(":") != -1:
(typ, fn) = uname.split(":", 1)
@@ -76,15 +76,18 @@ def _parse_uname(uname):
if typ in ("tap", "tap2"):
(taptype, fn) = fn.split(":", 1)
- return (fn, taptype)
+ if taptype in ("tapdisk", "ioemu"):
+ (taptype, fn) = fn.split(":", 1)
+ return (fn, (typ,taptype))
+
def blkdev_uname_to_file(uname):
"""Take a blkdev uname and return the corresponding filename."""
- return _parse_uname(uname)[0]
+ return parse_uname(uname)[0]
def blkdev_uname_to_taptype(uname):
"""Take a blkdev uname and return the blktap type."""
- return _parse_uname(uname)[1]
+ return parse_uname(uname)[1]
def mount_mode(name):
mode = None
diff --git a/tools/python/xen/xend/XendDomainInfo.py b/tools/python/xen/xend/XendDomainInfo.py
index 89403be7d6..d5e92be7f5 100644
--- a/tools/python/xen/xend/XendDomainInfo.py
+++ b/tools/python/xen/xend/XendDomainInfo.py
@@ -38,7 +38,7 @@ from types import StringTypes
import xen.lowlevel.xc
from xen.util import asserts, auxbin, mkdir
-from xen.util.blkif import blkdev_uname_to_file, blkdev_uname_to_taptype
+from xen.util.blkif import parse_uname
import xen.util.xsm.xsm as security
from xen.util import xsconstants
from xen.util import mkdir
@@ -3248,9 +3248,18 @@ class XendDomainInfo:
devtype = devinfo[0]
disk = devinfo[1]['uname']
- fn = blkdev_uname_to_file(disk)
- taptype = blkdev_uname_to_taptype(disk)
- mounted = devtype in ['tap', 'tap2'] and taptype != 'aio' and taptype != 'sync' and not os.stat(fn).st_rdev
+ (fn, types) = parse_uname(disk)
+ def _shouldMount(types):
+ if types[0] in ('file', 'phy'):
+ return False
+ if types[0] in ('tap', 'tap2'):
+ if types[1] in ('aio', 'sync'):
+ return False
+ else:
+ return True
+ return os.access('/etc/xen/scripts/block-%s' % types[0], os.X_OK)
+
+ mounted = _shouldMount(types)
mounted_vbd_uuid = 0
if mounted:
# This is a file, not a device. pygrub can cope with a