diff options
author | kfraser@localhost.localdomain <kfraser@localhost.localdomain> | 2007-08-31 14:11:15 +0100 |
---|---|---|
committer | kfraser@localhost.localdomain <kfraser@localhost.localdomain> | 2007-08-31 14:11:15 +0100 |
commit | 9ef62339785c1afac5bb46b59e6f37e7ccf1dcc7 (patch) | |
tree | 1797719f2674c4cc361c610863951ff9e74598aa /tools | |
parent | c40696b705c6e8885e7a171afd97b4d55c5f7e9d (diff) | |
download | xen-9ef62339785c1afac5bb46b59e6f37e7ccf1dcc7.tar.gz xen-9ef62339785c1afac5bb46b59e6f37e7ccf1dcc7.tar.bz2 xen-9ef62339785c1afac5bb46b59e6f37e7ccf1dcc7.zip |
xend: Add blktap disk type check
Print the following error when you give a wrong disk type to xm commands:
# xm create /xen/vm1.conf disk='tap:xxx:/xen/root-vm1.img,hda1,w'
Using config file "/xen/vm1.conf".
Error: tap:xxx not a valid disk type
# xm block-attach vm2 tap:yyy:/xen/second.img hdb1 w
Error: tap:yyy not a valid disk type
Usage: xm block-attach <Domain> <BackDev> <FrontDev> <Mode>
[BackDomain]
Signed-off-by: Masaki Kanno <kanno.masaki@jp.fujitsu.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/python/xen/xend/XendConfig.py | 6 | ||||
-rw-r--r-- | tools/python/xen/xend/server/BlktapController.py | 8 |
2 files changed, 14 insertions, 0 deletions
diff --git a/tools/python/xen/xend/XendConfig.py b/tools/python/xen/xend/XendConfig.py index 2d69c2487f..6db58f52d9 100644 --- a/tools/python/xen/xend/XendConfig.py +++ b/tools/python/xen/xend/XendConfig.py @@ -28,6 +28,7 @@ from xen.xend.XendError import VmError from xen.xend.XendDevices import XendDevices from xen.xend.PrettyPrint import prettyprintstring from xen.xend.XendConstants import DOM_STATE_HALTED +from xen.xend.server.BlktapController import blktap_disk_types from xen.xend.server.netif import randomMAC from xen.util.blkif import blkdev_name_to_number from xen.util import xsconstants @@ -1084,6 +1085,11 @@ class XendConfig(dict): else: dev_info['driver'] = 'paravirtualised' + if dev_type == 'tap': + if dev_info['uname'].split(':')[1] not in blktap_disk_types: + raise XendConfigError("tap:%s not a valid disk type" % + dev_info['uname'].split(':')[1]) + if dev_type == 'vif': if not dev_info.get('mac'): dev_info['mac'] = randomMAC() diff --git a/tools/python/xen/xend/server/BlktapController.py b/tools/python/xen/xend/server/BlktapController.py index 420a4bdbe6..3226e81011 100644 --- a/tools/python/xen/xend/server/BlktapController.py +++ b/tools/python/xen/xend/server/BlktapController.py @@ -7,6 +7,14 @@ from xen.xend.XendLogging import log phantomDev = 0; phantomId = 0; +blktap_disk_types = [ + 'aio', + 'sync', + 'vmdk', + 'ram', + 'qcow' + ] + class BlktapController(BlkifController): def __init__(self, vm): BlkifController.__init__(self, vm) |