ia64/xen-unstable

changeset 19119:aa89d1afb287

xend: Fix block device type check

Since changeset 17617 the block device protocols are checked to be
either file or phy. This has later been fixed to also include
tap. This is still not a correct check as there can be arbitrary
additional protocols. Before this check was added you could have a
block-xyz hotplug script and xyz would work as a protocol, now it is
refused. An example for this mechanism is the block-nbd script which
is included in the tree.

This patch changes the check to allow file, phy, tap and all protocol
names for which a block-$protocol hotplug script exists. This should
fix the last regressions introduced by the check.

Signed-off-by: Kevin Wolf <kwolf@suse.de>
author Keir Fraser <keir.fraser@citrix.com>
date Thu Jan 29 16:39:56 2009 +0000 (2009-01-29)
parents 259d6ac13704
children e1352667df95
files tools/python/xen/xend/server/blkif.py
line diff
     1.1 --- a/tools/python/xen/xend/server/blkif.py	Thu Jan 29 12:48:33 2009 +0000
     1.2 +++ b/tools/python/xen/xend/server/blkif.py	Thu Jan 29 16:39:56 2009 +0000
     1.3 @@ -18,6 +18,7 @@
     1.4  
     1.5  import re
     1.6  import string
     1.7 +import os
     1.8  
     1.9  from xen.util import blkif
    1.10  import xen.util.xsm.xsm as security
    1.11 @@ -35,6 +36,13 @@ class BlkifController(DevController):
    1.12          """
    1.13          DevController.__init__(self, vm)
    1.14  
    1.15 +    def _isValidProtocol(self, protocol):
    1.16 +        if protocol in ('phy', 'file', 'tap'):
    1.17 +            return True
    1.18 +
    1.19 +        return os.access('/etc/xen/scripts/block-%s' % protocol, os.X_OK)
    1.20 +
    1.21 +
    1.22      def getDeviceDetails(self, config):
    1.23          """@see DevController.getDeviceDetails"""
    1.24          uname = config.get('uname', '')
    1.25 @@ -56,10 +64,8 @@ class BlkifController(DevController):
    1.26          else:
    1.27              try:
    1.28                  (typ, params) = string.split(uname, ':', 1)
    1.29 -                if typ not in ('phy', 'file', 'tap'):
    1.30 -                    raise VmError(
    1.31 -                        'Block device must have "phy", "file" or "tap" '
    1.32 -                        'specified to type')
    1.33 +                if not self._isValidProtocol(typ):
    1.34 +                    raise VmError('Block device type "%s" is invalid.' % typ)
    1.35              except ValueError:
    1.36                  raise VmError(
    1.37                      'Block device must have physical details specified')