aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorKeir Fraser <keir.fraser@citrix.com>2009-01-29 16:39:56 +0000
committerKeir Fraser <keir.fraser@citrix.com>2009-01-29 16:39:56 +0000
commit597edba986d2516dfa478f5c4ec34325da49283b (patch)
tree85d32434f6df09113b6ddd6ec4e0b02eae168f10 /tools
parentaab43dddfe36e154b674bd3de6a54e0d63629a91 (diff)
downloadxen-597edba986d2516dfa478f5c4ec34325da49283b.tar.gz
xen-597edba986d2516dfa478f5c4ec34325da49283b.tar.bz2
xen-597edba986d2516dfa478f5c4ec34325da49283b.zip
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>
Diffstat (limited to 'tools')
-rw-r--r--tools/python/xen/xend/server/blkif.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/tools/python/xen/xend/server/blkif.py b/tools/python/xen/xend/server/blkif.py
index fdbdd04cf8..7c4cb8b6bb 100644
--- a/tools/python/xen/xend/server/blkif.py
+++ b/tools/python/xen/xend/server/blkif.py
@@ -18,6 +18,7 @@
import re
import string
+import os
from xen.util import blkif
import xen.util.xsm.xsm as security
@@ -35,6 +36,13 @@ class BlkifController(DevController):
"""
DevController.__init__(self, vm)
+ def _isValidProtocol(self, protocol):
+ if protocol in ('phy', 'file', 'tap'):
+ return True
+
+ return os.access('/etc/xen/scripts/block-%s' % protocol, os.X_OK)
+
+
def getDeviceDetails(self, config):
"""@see DevController.getDeviceDetails"""
uname = config.get('uname', '')
@@ -56,10 +64,8 @@ class BlkifController(DevController):
else:
try:
(typ, params) = string.split(uname, ':', 1)
- if typ not in ('phy', 'file', 'tap'):
- raise VmError(
- 'Block device must have "phy", "file" or "tap" '
- 'specified to type')
+ if not self._isValidProtocol(typ):
+ raise VmError('Block device type "%s" is invalid.' % typ)
except ValueError:
raise VmError(
'Block device must have physical details specified')